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