1 /* Declarations for GNU's read utmp module.
3 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 2001, 2002, 2003 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* Written by jla; revised by djm */
22 #ifndef __READUTMP_H__
23 # define __READUTMP_H__
25 # include <sys/types.h>
29 /* HPUX 10.20 needs utmp.h, for the definition of e.g., UTMP_FILE. */
33 # define UTMP_STRUCT_NAME utmpx
34 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
35 # define SET_UTMP_ENT setutxent
36 # define GET_UTMP_ENT getutxent
37 # define END_UTMP_ENT endutxent
38 # ifdef HAVE_UTMPXNAME
39 # define UTMP_NAME_FUNCTION utmpxname
43 # if !HAVE_DECL_GETUTENT
44 struct utmp *getutent();
46 # define UTMP_STRUCT_NAME utmp
47 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
48 # define SET_UTMP_ENT setutent
49 # define GET_UTMP_ENT getutent
50 # define END_UTMP_ENT endutent
52 # define UTMP_NAME_FUNCTION utmpname
56 /* Accessor macro for the member named ut_user or ut_name. */
59 # if HAVE_STRUCT_UTMPX_UT_USER
60 # define UT_USER(Utmp) ((Utmp)->ut_user)
62 # if HAVE_STRUCT_UTMPX_UT_NAME
64 # define UT_USER(Utmp) ((Utmp)->ut_name)
69 # if HAVE_STRUCT_UTMP_UT_USER
70 # define UT_USER(Utmp) Utmp->ut_user
72 # if HAVE_STRUCT_UTMP_UT_NAME
74 # define UT_USER(Utmp) Utmp->ut_name
79 # define HAVE_STRUCT_XTMP_UT_EXIT \
80 (HAVE_STRUCT_UTMP_UT_EXIT \
81 || HAVE_STRUCT_UTMPX_UT_EXIT)
83 # define HAVE_STRUCT_XTMP_UT_ID \
84 (HAVE_STRUCT_UTMP_UT_ID \
85 || HAVE_STRUCT_UTMPX_UT_ID)
87 # define HAVE_STRUCT_XTMP_UT_PID \
88 (HAVE_STRUCT_UTMP_UT_PID \
89 || HAVE_STRUCT_UTMPX_UT_PID)
91 # define HAVE_STRUCT_XTMP_UT_TYPE \
92 (HAVE_STRUCT_UTMP_UT_TYPE \
93 || HAVE_STRUCT_UTMPX_UT_TYPE)
95 typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;
98 # ifdef HAVE_SYS_PARAM_H
99 # include <sys/param.h>
107 # if !defined (UTMP_FILE) && defined (_PATH_UTMP)
108 # define UTMP_FILE _PATH_UTMP
111 # if !defined (WTMP_FILE) && defined (_PATH_WTMP)
112 # define WTMP_FILE _PATH_WTMP
115 # ifdef UTMPX_FILE /* Solaris, SysVr4 */
117 # define UTMP_FILE UTMPX_FILE
120 # ifdef WTMPX_FILE /* Solaris, SysVr4 */
122 # define WTMP_FILE WTMPX_FILE
126 # define UTMP_FILE "/etc/utmp"
130 # define WTMP_FILE "/etc/wtmp"
133 char *extract_trimmed_name (const STRUCT_UTMP *ut);
134 int read_utmp (const char *filename, int *n_entries, STRUCT_UTMP **utmp_buf);
136 #endif /* __READUTMP_H__ */