add copyright/no-warranty comment
[coreutils.git] / lib / readutmp.h
blob7cef30be523c44ceb8f6d4cf2ef78d617312a312
1 /* Declarations for GNU's read utmp module.
2 Copyright (C) 1992-1999 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 # include <utmpx.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 # define UTMP_NAME_FUNCTION utmpxname
41 # else
42 # include <utmp.h>
43 # define UTMP_STRUCT_NAME utmp
44 # define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
45 # define SET_UTMP_ENT setutent
46 # define GET_UTMP_ENT getutent
47 # define END_UTMP_ENT endutent
48 # define UTMP_NAME_FUNCTION utmpname
49 # endif
51 typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;
53 # include <time.h>
54 # ifdef HAVE_SYS_PARAM_H
55 # include <sys/param.h>
56 # endif
58 # include <errno.h>
59 # ifndef errno
60 extern int errno;
61 # endif
63 # if !defined (UTMP_FILE) && defined (_PATH_UTMP)
64 # define UTMP_FILE _PATH_UTMP
65 # endif
67 # if !defined (WTMP_FILE) && defined (_PATH_WTMP)
68 # define WTMP_FILE _PATH_WTMP
69 # endif
71 # ifdef UTMPX_FILE /* Solaris, SysVr4 */
72 # undef UTMP_FILE
73 # define UTMP_FILE UTMPX_FILE
74 # endif
76 # ifdef WTMPX_FILE /* Solaris, SysVr4 */
77 # undef WTMP_FILE
78 # define WTMP_FILE WTMPX_FILE
79 # endif
81 # ifndef UTMP_FILE
82 # define UTMP_FILE "/etc/utmp"
83 # endif
85 # ifndef WTMP_FILE
86 # define WTMP_FILE "/etc/wtmp"
87 # endif
89 # undef PARAMS
90 # if defined (__STDC__) && __STDC__
91 # define PARAMS(Args) Args
92 # else
93 # define PARAMS(Args) ()
94 # endif
96 extern char *extract_trimmed_name PARAMS ((const STRUCT_UTMP *ut));
97 extern int read_utmp PARAMS ((const char *filename,
98 int *n_entries, STRUCT_UTMP **utmp_buf));
100 #endif /* __READUTMP_H__ */