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