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