* libmisc/utmp.c: Replace HAVE_UTMPX_H by USE_UTMPX.

* libmisc/utmp.c: Removed old comment on HAVE_STRUCT_UTMP_UT_ID
	and UTMPX support.
This commit is contained in:
nekral-guest 2009-04-27 20:06:25 +00:00
parent 13b74243a6
commit 80fd2969c9
2 changed files with 15 additions and 18 deletions

View File

@ -3,6 +3,9 @@
* NEWS, configure.in: Added configure option --enable-utmpx, * NEWS, configure.in: Added configure option --enable-utmpx,
disabled by default. This defines USE_UTMPX, which should be used disabled by default. This defines USE_UTMPX, which should be used
instead of HAVE_UTMPX_H. instead of HAVE_UTMPX_H.
* libmisc/utmp.c: Replace HAVE_UTMPX_H by USE_UTMPX.
* libmisc/utmp.c: Removed old comment on HAVE_STRUCT_UTMP_UT_ID
and UTMPX support.
2009-04-27 Nicolas François <nicolas.francois@centraliens.net> 2009-04-27 Nicolas François <nicolas.francois@centraliens.net>

View File

@ -37,10 +37,7 @@
#include <utmp.h> #include <utmp.h>
// FIXME: disable UTMPX on Linux in configure.in #if USE_UTMPX
// Maybe define an intermediate USE_UTMPX to replace HAVE_UTMPX_H,
// which would be defined if HAVE_UTMPX_H is defined on non-Linux.
#if HAVE_UTMPX_H
#include <utmpx.h> #include <utmpx.h>
#endif #endif
@ -149,7 +146,7 @@ static void updwtmp (const char *filename, const struct utmp *ut)
} }
#endif /* ! HAVE_UPDWTMP */ #endif /* ! HAVE_UPDWTMP */
#ifdef HAVE_UTMPX_H #ifdef USE_UTMPX
#ifndef HAVE_UPDWTMPX #ifndef HAVE_UPDWTMPX
static void updwtmpx (const char *filename, const struct utmpx *utx) static void updwtmpx (const char *filename, const struct utmpx *utx)
{ {
@ -162,7 +159,7 @@ static void updwtmpx (const char *filename, const struct utmpx *utx)
} }
} }
#endif /* ! HAVE_UPDWTMPX */ #endif /* ! HAVE_UPDWTMPX */
#endif /* ! HAVE_UTMPX_H */ #endif /* ! USE_UTMPX */
/* /*
@ -184,9 +181,9 @@ static void updwtmpx (const char *filename, const struct utmpx *utx)
* The returned structure shall be freed by the caller. * The returned structure shall be freed by the caller.
*/ */
/*@only@*/struct utmp *prepare_utmp (const char *name, /*@only@*/struct utmp *prepare_utmp (const char *name,
const char *line, const char *line,
const char *host, const char *host,
/*@null@*/const struct utmp *ut) /*@null@*/const struct utmp *ut)
{ {
struct timeval tv; struct timeval tv;
char *hostname = NULL; char *hostname = NULL;
@ -322,14 +319,14 @@ int setutmp (struct utmp *ut)
return err; return err;
} }
#ifdef HAVE_UTMPX_H #ifdef USE_UTMPX
/* /*
* prepare_utmpx - the UTMPX version for prepare_utmp * prepare_utmpx - the UTMPX version for prepare_utmp
*/ */
/*@only@*/struct utmpx *prepare_utmpx (const char *name, /*@only@*/struct utmpx *prepare_utmpx (const char *name,
const char *line, const char *line,
const char *host, const char *host,
/*@null@*/const struct utmp *ut) /*@null@*/const struct utmp *ut)
{ {
struct timeval tv; struct timeval tv;
char *hostname = NULL; char *hostname = NULL;
@ -366,10 +363,7 @@ int setutmp (struct utmp *ut)
utxent->ut_type = USER_PROCESS; utxent->ut_type = USER_PROCESS;
utxent->ut_pid = getpid (); utxent->ut_pid = getpid ();
strncpy (utxent->ut_line, line, sizeof (utxent->ut_line)); strncpy (utxent->ut_line, line, sizeof (utxent->ut_line));
#ifndef HAVE_STRUCT_UTMP_UT_ID /* existence of ut->ut_id is enforced by configure */
// FIXME: move to configure.in
# error "No support for systems with utmpx and no ut_id field in utmp"
#endif /* !HAVE_STRUCT_UTMP_UT_ID */
if (NULL != ut) { if (NULL != ut) {
strncpy (utxent->ut_id, ut->ut_id, sizeof (utxent->ut_id)); strncpy (utxent->ut_id, ut->ut_id, sizeof (utxent->ut_id));
} else { } else {
@ -457,5 +451,5 @@ int setutmpx (struct utmpx *utx)
return err; return err;
} }
#endif /* HAVE_UTMPX_H */ #endif /* USE_UTMPX */