.
[gnulib.git] / lib / readutmp.h
1 /* Declarations for GNU's read utmp module.
2    Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
3
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.
8
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.
13
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.  */
17
18 /* Written by jla; revised by djm */
19
20 #ifndef __READUTMP_H__
21 # define __READUTMP_H__
22
23 # include <stdio.h>
24 # include <sys/types.h>
25
26 # ifdef HAVE_UTMPX_H
27 #  include <utmpx.h>
28 #  define STRUCT_UTMP struct utmpx
29 #  define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
30 # else
31 #  include <utmp.h>
32 #  define STRUCT_UTMP struct utmp
33 #  define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
34 # endif
35
36 # include <time.h>
37 # ifdef HAVE_SYS_PARAM_H
38 #  include <sys/param.h>
39 # endif
40
41 # include <errno.h>
42 # ifndef errno
43 extern int errno;
44 # endif
45
46 # if !defined (UTMP_FILE) && defined (_PATH_UTMP)
47 #  define UTMP_FILE _PATH_UTMP
48 # endif
49
50 # if !defined (WTMP_FILE) && defined (_PATH_WTMP)
51 #  define WTMP_FILE _PATH_WTMP
52 # endif
53
54 # ifdef UTMPX_FILE /* Solaris, SysVr4 */
55 #  undef UTMP_FILE
56 #  define UTMP_FILE UTMPX_FILE
57 # endif
58
59 # ifdef WTMPX_FILE /* Solaris, SysVr4 */
60 #  undef WTMP_FILE
61 #  define WTMP_FILE WTMPX_FILE
62 # endif
63
64 # ifndef UTMP_FILE
65 #  define UTMP_FILE "/etc/utmp"
66 # endif
67
68 # ifndef WTMP_FILE
69 #  define WTMP_FILE "/etc/wtmp"
70 # endif
71
72 extern STRUCT_UTMP * utmp_contents;
73
74 # undef PARAMS
75 # if defined (__STDC__) && __STDC__
76 #  define PARAMS(Args) Args
77 # else
78 #  define PARAMS(Args) ()
79 # endif
80
81 extern char * extract_trimmed_name PARAMS((const STRUCT_UTMP *ut));
82 extern int read_utmp PARAMS((const char *filename));
83
84 #endif /* __READUTMP_H__ */