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