1 /* 2 * sysutmp.h Compatibility stuff for the different UTMP systems. 3 * 4 * Version: $Id: 13a47b582aa721a8a560e5f9df63eb0975e6f0cb $ 5 */ 6 7 #ifndef SYSUTMP_H_INCLUDED 8 #define SYSUTMP_H_INCLUDED 9 10 RCSIDH(sysutmp_h, "$Id: 13a47b582aa721a8a560e5f9df63eb0975e6f0cb $") 11 12 /* 13 * If we have BOTH utmp.h and utmpx.h, then 14 * we prefer to use utmp.h, but only on systems other than Solaris. 15 */ 16 #if !defined(__sun) && !defined(sgi) && !defined(hpux) 17 # ifdef HAVE_UTMP_H 18 # undef HAVE_UTMPX_H 19 # endif 20 #endif 21 22 #if defined(HAVE_UTMP_H) || defined(HAVE_UTMPX_H) 23 24 /* UTMP stuff. Uses utmpx on svr4 */ 25 #ifdef HAVE_UTMPX_H 26 # include <utmpx.h> 27 # include <sys/fcntl.h> 28 # define utmp utmpx 29 # define UT_NAMESIZE 32 30 # define UT_LINESIZE 32 31 # define UT_HOSTSIZE 257 32 #if defined(hpux) || defined(__FreeBSD__) 33 # define ut_name ut_user 34 #endif 35 #else 36 # include <utmp.h> 37 #endif 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 #ifdef __osf__ 44 # define UT_NAMESIZE 32 45 # define UT_LINESIZE 32 46 # define UT_HOSTSIZE 64 47 #endif 48 49 #ifdef __DragonFly__ 50 # ifndef UTMP_FILE 51 # define UTMP_FILE _PATH_UTMPX 52 # endif 53 #endif 54 55 #if (defined(__FreeBSD__) && !defined(HAVE_UTMPX_H)) || defined(__NetBSD__) || defined(bsdi) || defined(__OpenBSD__) || defined(__APPLE__) 56 # ifndef UTMP_FILE 57 # define UTMP_FILE "/var/run/utmp" 58 # endif 59 # define ut_user ut_name 60 #endif 61 62 /* 63 * Generate definitions for systems which are too broken to 64 * do it themselves. 65 * 66 * Hmm... this means that we can probably get rid of a lot of 67 * the static defines above, as the following lines will generate 68 * the proper defines for any system. 69 */ 70 #ifndef UT_LINESIZE 71 #define UT_LINESIZE sizeof(((struct utmp *) NULL)->ut_line) 72 #endif 73 74 #ifndef UT_NAMESIZE 75 #define UT_NAMESIZE sizeof(((struct utmp *) NULL)->ut_user) 76 #endif 77 78 #ifndef UT_HOSTSIZE 79 #define UT_HOSTSIZE sizeof(((struct utmp *) NULL)->ut_host) 80 #endif 81 82 #else /* HAVE_UTMP_H */ 83 84 /* 85 * No <utmp.h> file - define stuff ourselves (minimally). 86 */ 87 #define UT_LINESIZE 16 88 #define UT_NAMESIZE 16 89 #define UT_HOSTSIZE 16 90 91 #define USER_PROCESS 7 92 #define DEAD_PROCESS 8 93 94 #define UTMP_FILE "/var/run/utmp" 95 #define ut_name ut_user 96 97 struct utmp { 98 short ut_type; 99 int ut_pid; 100 char ut_line[UT_LINESIZE]; 101 char ut_id[4]; 102 long ut_time; 103 char ut_user[UT_NAMESIZE]; 104 char ut_host[UT_HOSTSIZE]; 105 long ut_addr; 106 }; 107 108 #endif /* HAVE_UTMP_H */ 109 110 #ifdef __cplusplus 111 } 112 #endif 113 114 #endif /* SYSUTMP_H_INCLUDED */ 115