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)
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__
24 # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
25 # define PARAMS(Args) Args
27 # define PARAMS(Args) ()
31 # include <sys/types.h>
33 /* AIX 4.3.3 has both utmp.h and utmpx.h, but only struct utmp
34 has the ut_exit member. */
35 # if HAVE_UTMPX_H && HAVE_UTMP_H && HAVE_STRUCT_UTMP_UT_EXIT && ! HAVE_STRUCT_UTMPX_UT_EXIT
41 /* HPUX 10.20 needs utmp.h, for the definition of e.g., UTMP_FILE. */
45 # define UTMP_STRUCT_NAME utmpx
46 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
47 # define SET_UTMP_ENT setutxent
48 # define GET_UTMP_ENT getutxent
49 # define END_UTMP_ENT endutxent
50 # ifdef HAVE_UTMPXNAME
51 # define UTMP_NAME_FUNCTION utmpxname
54 # if HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION
55 # define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.e_termination)
57 # if HAVE_STRUCT_UTMPX_UT_EXIT_UT_TERMINATION
58 # define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.ut_termination)
60 # define UT_EXIT_E_TERMINATION(U) 0
64 # if HAVE_STRUCT_UTMPX_UT_EXIT_E_EXIT
65 # define UT_EXIT_E_EXIT(U) ((U)->ut_exit.e_exit)
67 # if HAVE_STRUCT_UTMPX_UT_EXIT_UT_EXIT
68 # define UT_EXIT_E_EXIT(U) ((U)->ut_exit.ut_exit)
70 # define UT_EXIT_E_EXIT(U) 0
76 # if !HAVE_DECL_GETUTENT
77 struct utmp
*getutent();
79 # define UTMP_STRUCT_NAME utmp
80 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
81 # define SET_UTMP_ENT setutent
82 # define GET_UTMP_ENT getutent
83 # define END_UTMP_ENT endutent
85 # define UTMP_NAME_FUNCTION utmpname
88 # if HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION
89 # define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.e_termination)
91 # if HAVE_STRUCT_UTMP_UT_EXIT_UT_TERMINATION
92 # define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.ut_termination)
94 # define UT_EXIT_E_TERMINATION(U) 0
98 # if HAVE_STRUCT_UTMP_UT_EXIT_E_EXIT
99 # define UT_EXIT_E_EXIT(U) ((U)->ut_exit.e_exit)
101 # if HAVE_STRUCT_UTMP_UT_EXIT_UT_EXIT
102 # define UT_EXIT_E_EXIT(U) ((U)->ut_exit.ut_exit)
104 # define UT_EXIT_E_EXIT(U) 0
110 /* Accessor macro for the member named ut_user or ut_name. */
113 # if HAVE_STRUCT_UTMPX_UT_USER
114 # define UT_USER(Utmp) ((Utmp)->ut_user)
116 # if HAVE_STRUCT_UTMPX_UT_NAME
118 # define UT_USER(Utmp) ((Utmp)->ut_name)
123 # if HAVE_STRUCT_UTMP_UT_USER
124 # define UT_USER(Utmp) Utmp->ut_user
126 # if HAVE_STRUCT_UTMP_UT_NAME
128 # define UT_USER(Utmp) Utmp->ut_name
133 # define HAVE_STRUCT_XTMP_UT_EXIT \
134 (HAVE_STRUCT_UTMP_UT_EXIT \
135 || HAVE_STRUCT_UTMPX_UT_EXIT)
137 # define HAVE_STRUCT_XTMP_UT_ID \
138 (HAVE_STRUCT_UTMP_UT_ID \
139 || HAVE_STRUCT_UTMPX_UT_ID)
141 # define HAVE_STRUCT_XTMP_UT_PID \
142 (HAVE_STRUCT_UTMP_UT_PID \
143 || HAVE_STRUCT_UTMPX_UT_PID)
145 # define HAVE_STRUCT_XTMP_UT_TYPE \
146 (HAVE_STRUCT_UTMP_UT_TYPE \
147 || HAVE_STRUCT_UTMPX_UT_TYPE)
149 typedef struct UTMP_STRUCT_NAME STRUCT_UTMP
;
152 # ifdef HAVE_SYS_PARAM_H
153 # include <sys/param.h>
161 # if !defined (UTMP_FILE) && defined (_PATH_UTMP)
162 # define UTMP_FILE _PATH_UTMP
165 # if !defined (WTMP_FILE) && defined (_PATH_WTMP)
166 # define WTMP_FILE _PATH_WTMP
169 # ifdef UTMPX_FILE /* Solaris, SysVr4 */
171 # define UTMP_FILE UTMPX_FILE
174 # ifdef WTMPX_FILE /* Solaris, SysVr4 */
176 # define WTMP_FILE WTMPX_FILE
180 # define UTMP_FILE "/etc/utmp"
184 # define WTMP_FILE "/etc/wtmp"
188 # if defined (__STDC__) && __STDC__
189 # define PARAMS(Args) Args
191 # define PARAMS(Args) ()
194 extern char *extract_trimmed_name
PARAMS ((const STRUCT_UTMP
*ut
));
195 extern int read_utmp
PARAMS ((const char *filename
,
196 int *n_entries
, STRUCT_UTMP
**utmp_buf
));
198 #endif /* __READUTMP_H__ */