import from HEAD:
[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 #if !defined(sun) && !defined(sgi) && !defined(hpux)
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 #ifdef hpux
31 #  define ut_name ut_user
32 #endif
33 #else
34 #  include <utmp.h>
35 #endif
36
37 #ifdef __osf__
38 #  define UT_NAMESIZE   32
39 #  define UT_LINESIZE   32
40 #  define UT_HOSTSIZE   64
41 #endif
42
43 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(bsdi) || defined(__OpenBSD__) || defined(__APPLE__)
44 #  ifndef UTMP_FILE
45 #    define UTMP_FILE "/var/run/utmp"
46 #  endif
47 #  define ut_user ut_name
48 #endif
49
50 /*
51  *      Generate definitions for systems which are too broken to
52  *      do it themselves.
53  *
54  *      Hmm... this means that we can probably get rid of a lot of
55  *      the static defines above, as the following lines will generate
56  *      the proper defines for any system.
57  */
58 #ifndef UT_LINESIZE
59 #define UT_LINESIZE sizeof(((struct utmp *) NULL)->ut_line)
60 #endif
61
62 #ifndef UT_NAMESIZE
63 #define UT_NAMESIZE sizeof(((struct utmp *) NULL)->ut_user)
64 #endif
65
66 #ifndef UT_HOSTSIZE
67 #define UT_HOSTSIZE sizeof(((struct utmp *) NULL)->ut_host)
68 #endif
69
70 #else /* HAVE_UTMP_H */
71
72 /*
73  *      No <utmp.h> file - define stuff ourselves (minimally).
74  */
75 #define UT_LINESIZE     16
76 #define UT_NAMESIZE     16
77 #define UT_HOSTSIZE     16
78
79 #define USER_PROCESS    7
80 #define DEAD_PROCESS    8
81
82 #define UTMP_FILE       "/var/run/utmp"
83 #define ut_name         ut_user
84
85 struct utmp {
86         short   ut_type;
87         int     ut_pid;
88         char    ut_line[UT_LINESIZE];
89         char    ut_id[4];
90         long    ut_time;
91         char    ut_user[UT_NAMESIZE];
92         char    ut_host[UT_HOSTSIZE];
93         long    ut_addr;
94 };
95
96 #endif /* HAVE_UTMP_H */
97
98 #endif /* SYSUTMP_H_INCLUDED */