(jm_PREREQ): Add jm_PREREQ_SIG2STR.
[gnulib.git] / lib / readutmp.h
blobb6c74a2e6f0697dcf1b8c8537f4195f497b1a742
1 /* Declarations for GNU's read utmp module.
2 Copyright (C) 1992-2002 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /* Written by jla; revised by djm */
20 #ifndef __READUTMP_H__
21 # define __READUTMP_H__
23 # ifndef PARAMS
24 # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
25 # define PARAMS(Args) Args
26 # else
27 # define PARAMS(Args) ()
28 # endif
29 # endif
31 # include <sys/types.h>
33 # ifdef HAVE_UTMPX_H
34 # ifdef HAVE_UTMP_H
35 /* HPUX 10.20 needs utmp.h, for the definition of e.g., UTMP_FILE. */
36 # include <utmp.h>
37 # endif
38 # include <utmpx.h>
39 # define UTMP_STRUCT_NAME utmpx
40 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
41 # define SET_UTMP_ENT setutxent
42 # define GET_UTMP_ENT getutxent
43 # define END_UTMP_ENT endutxent
44 # ifdef HAVE_UTMPXNAME
45 # define UTMP_NAME_FUNCTION utmpxname
46 # endif
47 # else
48 # include <utmp.h>
49 # if !HAVE_DECL_GETUTENT
50 struct utmp *getutent();
51 # endif
52 # define UTMP_STRUCT_NAME utmp
53 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
54 # define SET_UTMP_ENT setutent
55 # define GET_UTMP_ENT getutent
56 # define END_UTMP_ENT endutent
57 # ifdef HAVE_UTMPNAME
58 # define UTMP_NAME_FUNCTION utmpname
59 # endif
60 # endif
62 /* Accessor macro for the member named ut_user or ut_name. */
63 # ifdef HAVE_UTMPX_H
65 # if HAVE_STRUCT_UTMPX_UT_USER
66 # define UT_USER(Utmp) ((Utmp)->ut_user)
67 # endif
68 # if HAVE_STRUCT_UTMPX_UT_NAME
69 # undef UT_USER
70 # define UT_USER(Utmp) ((Utmp)->ut_name)
71 # endif
73 # else
75 # if HAVE_STRUCT_UTMP_UT_USER
76 # define UT_USER(Utmp) Utmp->ut_user
77 # endif
78 # if HAVE_STRUCT_UTMP_UT_NAME
79 # undef UT_USER
80 # define UT_USER(Utmp) Utmp->ut_name
81 # endif
83 # endif
85 # define HAVE_STRUCT_XTMP_UT_EXIT \
86 (HAVE_STRUCT_UTMP_UT_EXIT \
87 || HAVE_STRUCT_UTMPX_UT_EXIT)
89 # define HAVE_STRUCT_XTMP_UT_ID \
90 (HAVE_STRUCT_UTMP_UT_ID \
91 || HAVE_STRUCT_UTMPX_UT_ID)
93 # define HAVE_STRUCT_XTMP_UT_PID \
94 (HAVE_STRUCT_UTMP_UT_PID \
95 || HAVE_STRUCT_UTMPX_UT_PID)
97 # define HAVE_STRUCT_XTMP_UT_TYPE \
98 (HAVE_STRUCT_UTMP_UT_TYPE \
99 || HAVE_STRUCT_UTMPX_UT_TYPE)
101 typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;
103 # include <time.h>
104 # ifdef HAVE_SYS_PARAM_H
105 # include <sys/param.h>
106 # endif
108 # include <errno.h>
109 # ifndef errno
110 extern int errno;
111 # endif
113 # if !defined (UTMP_FILE) && defined (_PATH_UTMP)
114 # define UTMP_FILE _PATH_UTMP
115 # endif
117 # if !defined (WTMP_FILE) && defined (_PATH_WTMP)
118 # define WTMP_FILE _PATH_WTMP
119 # endif
121 # ifdef UTMPX_FILE /* Solaris, SysVr4 */
122 # undef UTMP_FILE
123 # define UTMP_FILE UTMPX_FILE
124 # endif
126 # ifdef WTMPX_FILE /* Solaris, SysVr4 */
127 # undef WTMP_FILE
128 # define WTMP_FILE WTMPX_FILE
129 # endif
131 # ifndef UTMP_FILE
132 # define UTMP_FILE "/etc/utmp"
133 # endif
135 # ifndef WTMP_FILE
136 # define WTMP_FILE "/etc/wtmp"
137 # endif
139 # undef PARAMS
140 # if defined (__STDC__) && __STDC__
141 # define PARAMS(Args) Args
142 # else
143 # define PARAMS(Args) ()
144 # endif
146 extern char *extract_trimmed_name PARAMS ((const STRUCT_UTMP *ut));
147 extern int read_utmp PARAMS ((const char *filename,
148 int *n_entries, STRUCT_UTMP **utmp_buf));
150 #endif /* __READUTMP_H__ */