diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-11-30 21:39:46 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-11-30 21:39:46 +0000 |
commit | fa60e4cb6f9069e5ae9541a99e1995611eceba28 (patch) | |
tree | 4db6577d3eb357e38426d163ff64c566af505ae2 /lib | |
parent | 8f7cca3d72c535282c8bb3f929c73968713298a9 (diff) | |
download | coreutils-fa60e4cb6f9069e5ae9541a99e1995611eceba28.tar.xz |
Don't include <sys/types.h>, <errno.h>,
<sys/param.h>, <time.h>; not needed to establish interface.
Include <stddef.h> instead.
(errno): Remove decl.
(HAVE_STRUCT_XTMP_UT_TYPE): Remove; no longer needed.
(UT_TYPE_EQ, UT_TYPE_NOT_DEFINED, UT_TYPE_BOOT_TIME,
UT_TYPE_USER_PROCESS, IS_USER_PROCESS): New macros.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/readutmp.h | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/readutmp.h b/lib/readutmp.h index 100db19c5..6260b08f3 100644 --- a/lib/readutmp.h +++ b/lib/readutmp.h @@ -22,7 +22,7 @@ #ifndef __READUTMP_H__ # define __READUTMP_H__ -# include <sys/types.h> +# include <stddef.h> /* AIX 4.3.3 has both utmp.h and utmpx.h, but only struct utmp has the ut_exit member. */ @@ -137,24 +137,10 @@ (HAVE_STRUCT_UTMP_UT_PID \ || HAVE_STRUCT_UTMPX_UT_PID) -# define HAVE_STRUCT_XTMP_UT_TYPE \ - (HAVE_STRUCT_UTMP_UT_TYPE \ - || HAVE_STRUCT_UTMPX_UT_TYPE) - typedef struct UTMP_STRUCT_NAME STRUCT_UTMP; enum { UT_USER_SIZE = sizeof UT_USER ((STRUCT_UTMP *) 0) }; -# include <time.h> -# ifdef HAVE_SYS_PARAM_H -# include <sys/param.h> -# endif - -# include <errno.h> -# ifndef errno -extern int errno; -# endif - # if !defined (UTMP_FILE) && defined (_PATH_UTMP) # define UTMP_FILE _PATH_UTMP # endif @@ -181,6 +167,31 @@ extern int errno; # define WTMP_FILE "/etc/wtmp" # endif +# if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE +# define UT_TYPE_EQ(U, V) ((U)->ut_type == (V)) +# define UT_TYPE_NOT_DEFINED 0 +# else +# define UT_TYPE_EQ(U, V) 0 +# define UT_TYPE_NOT_DEFINED 1 +# endif + +# ifdef BOOT_TIME +# define UT_TYPE_BOOT_TIME(U) UT_TYPE_EQ (U, BOOT_TIME) +# else +# define UT_TYPE_BOOT_TIME(U) 0 +# endif + +# ifdef USER_PROCESS +# define UT_TYPE_USER_PROCESS(U) UT_TYPE_EQ (U, USER_PROCESS) +# else +# define UT_TYPE_USER_PROCESS(U) 0 +# endif + +# define IS_USER_PROCESS(U) \ + (UT_USER (U)[0] \ + && (UT_TYPE_USER_PROCESS (U) \ + || (UT_TYPE_NOT_DEFINED && UT_TIME_MEMBER (U) != 0))) + char *extract_trimmed_name (const STRUCT_UTMP *ut); int read_utmp (const char *filename, size_t *n_entries, STRUCT_UTMP **utmp_buf); |