1 /* Declarations for GNU's read utmp module.
2 Copyright (C) 1992-2000 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>
35 # define UTMP_STRUCT_NAME utmpx
36 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
37 # define SET_UTMP_ENT setutxent
38 # define GET_UTMP_ENT getutxent
39 # define END_UTMP_ENT endutxent
40 # ifdef HAVE_UTMPXNAME
41 # define UTMP_NAME_FUNCTION utmpxname
45 # define UTMP_STRUCT_NAME utmp
46 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
47 # define SET_UTMP_ENT setutent
48 # define GET_UTMP_ENT getutent
49 # define END_UTMP_ENT endutent
51 # define UTMP_NAME_FUNCTION utmpname
55 /* Accessor macro for the member named ut_user or ut_name. */
58 # if HAVE_STRUCT_UTMPX_UT_USER
59 # define UT_USER(Utmp) ((Utmp)->ut_user)
61 # if HAVE_STRUCT_UTMPX_UT_NAME
63 # define UT_USER(Utmp) ((Utmp)->ut_name)
68 # if HAVE_STRUCT_UTMP_UT_USER
69 # define UT_USER(Utmp) Utmp->ut_user
71 # if HAVE_STRUCT_UTMP_UT_NAME
73 # define UT_USER(Utmp) Utmp->ut_name
78 typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;
81 # ifdef HAVE_SYS_PARAM_H
82 # include <sys/param.h>
90 # if !defined (UTMP_FILE) && defined (_PATH_UTMP)
91 # define UTMP_FILE _PATH_UTMP
94 # if !defined (WTMP_FILE) && defined (_PATH_WTMP)
95 # define WTMP_FILE _PATH_WTMP
98 # ifdef UTMPX_FILE /* Solaris, SysVr4 */
100 # define UTMP_FILE UTMPX_FILE
103 # ifdef WTMPX_FILE /* Solaris, SysVr4 */
105 # define WTMP_FILE WTMPX_FILE
109 # define UTMP_FILE "/etc/utmp"
113 # define WTMP_FILE "/etc/wtmp"
117 # if defined (__STDC__) && __STDC__
118 # define PARAMS(Args) Args
120 # define PARAMS(Args) ()
123 extern char *extract_trimmed_name PARAMS ((const STRUCT_UTMP *ut));
124 extern int read_utmp PARAMS ((const char *filename,
125 int *n_entries, STRUCT_UTMP **utmp_buf));
127 #endif /* __READUTMP_H__ */