xref: /minix3/include/utmpx.h (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras /*	$NetBSD: utmpx.h,v 1.17 2009/01/11 19:09:29 christos Exp $	 */
2*2fe8fb19SBen Gras 
3*2fe8fb19SBen Gras /*-
4*2fe8fb19SBen Gras  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5*2fe8fb19SBen Gras  * All rights reserved.
6*2fe8fb19SBen Gras  *
7*2fe8fb19SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
8*2fe8fb19SBen Gras  * by Christos Zoulas.
9*2fe8fb19SBen Gras  *
10*2fe8fb19SBen Gras  * Redistribution and use in source and binary forms, with or without
11*2fe8fb19SBen Gras  * modification, are permitted provided that the following conditions
12*2fe8fb19SBen Gras  * are met:
13*2fe8fb19SBen Gras  * 1. Redistributions of source code must retain the above copyright
14*2fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer.
15*2fe8fb19SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
16*2fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer in the
17*2fe8fb19SBen Gras  *    documentation and/or other materials provided with the distribution.
18*2fe8fb19SBen Gras  *
19*2fe8fb19SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*2fe8fb19SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*2fe8fb19SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*2fe8fb19SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*2fe8fb19SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*2fe8fb19SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*2fe8fb19SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*2fe8fb19SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*2fe8fb19SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*2fe8fb19SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*2fe8fb19SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
30*2fe8fb19SBen Gras  */
31*2fe8fb19SBen Gras #ifndef	_UTMPX_H_
32*2fe8fb19SBen Gras #define	_UTMPX_H_
33*2fe8fb19SBen Gras 
34*2fe8fb19SBen Gras #include <sys/cdefs.h>
35*2fe8fb19SBen Gras #include <sys/featuretest.h>
36*2fe8fb19SBen Gras #include <sys/socket.h>
37*2fe8fb19SBen Gras #include <sys/time.h>
38*2fe8fb19SBen Gras 
39*2fe8fb19SBen Gras #define	_PATH_UTMPX		"/var/run/utmpx"
40*2fe8fb19SBen Gras #define	_PATH_WTMPX		"/var/log/wtmpx"
41*2fe8fb19SBen Gras #define	_PATH_LASTLOGX		"/var/log/lastlogx"
42*2fe8fb19SBen Gras #define	_PATH_UTMP_UPDATE	"/usr/libexec/utmp_update"
43*2fe8fb19SBen Gras 
44*2fe8fb19SBen Gras #define _UTX_USERSIZE	32
45*2fe8fb19SBen Gras #define _UTX_LINESIZE	32
46*2fe8fb19SBen Gras #define	_UTX_IDSIZE	4
47*2fe8fb19SBen Gras #define _UTX_HOSTSIZE	256
48*2fe8fb19SBen Gras 
49*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
50*2fe8fb19SBen Gras #define UTX_USERSIZE	_UTX_USERSIZE
51*2fe8fb19SBen Gras #define UTX_LINESIZE	_UTX_LINESIZE
52*2fe8fb19SBen Gras #define	UTX_IDSIZE	_UTX_IDSIZE
53*2fe8fb19SBen Gras #define UTX_HOSTSIZE	_UTX_HOSTSIZE
54*2fe8fb19SBen Gras #endif
55*2fe8fb19SBen Gras 
56*2fe8fb19SBen Gras #define EMPTY		0
57*2fe8fb19SBen Gras #define RUN_LVL		1
58*2fe8fb19SBen Gras #define BOOT_TIME	2
59*2fe8fb19SBen Gras #define OLD_TIME	3
60*2fe8fb19SBen Gras #define NEW_TIME	4
61*2fe8fb19SBen Gras #define INIT_PROCESS	5
62*2fe8fb19SBen Gras #define LOGIN_PROCESS	6
63*2fe8fb19SBen Gras #define USER_PROCESS	7
64*2fe8fb19SBen Gras #define DEAD_PROCESS	8
65*2fe8fb19SBen Gras 
66*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
67*2fe8fb19SBen Gras #define ACCOUNTING	9
68*2fe8fb19SBen Gras #define SIGNATURE	10
69*2fe8fb19SBen Gras #define DOWN_TIME	11
70*2fe8fb19SBen Gras 
71*2fe8fb19SBen Gras /*
72*2fe8fb19SBen Gras  * Strings placed in the ut_line field to indicate special type entries
73*2fe8fb19SBen Gras  */
74*2fe8fb19SBen Gras #define	RUNLVL_MSG	"run-level %c"
75*2fe8fb19SBen Gras #define	BOOT_MSG	"system boot"
76*2fe8fb19SBen Gras #define	OTIME_MSG	"old time"
77*2fe8fb19SBen Gras #define	NTIME_MSG	"new time"
78*2fe8fb19SBen Gras #define	DOWN_MSG	"system down"
79*2fe8fb19SBen Gras #endif
80*2fe8fb19SBen Gras 
81*2fe8fb19SBen Gras /*
82*2fe8fb19SBen Gras  * The following structure describes the fields of the utmpx entries
83*2fe8fb19SBen Gras  * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the
84*2fe8fb19SBen Gras  * entries are stored in the files, and application should only access
85*2fe8fb19SBen Gras  * entries using routines described in getutxent(3).
86*2fe8fb19SBen Gras  */
87*2fe8fb19SBen Gras 
88*2fe8fb19SBen Gras #define ut_user ut_name
89*2fe8fb19SBen Gras #define ut_xtime ut_tv.tv_sec
90*2fe8fb19SBen Gras 
91*2fe8fb19SBen Gras /*
92*2fe8fb19SBen Gras  * This should be:
93*2fe8fb19SBen Gras  * 40 - (sizeof(struct timeval) - sizeof(struct { long s; long u; })))
94*2fe8fb19SBen Gras  * but g++ does not like it, to retain size compatibility with v1.00,
95*2fe8fb19SBen Gras  * so we do it manually.
96*2fe8fb19SBen Gras  */
97*2fe8fb19SBen Gras #ifdef _LP64
98*2fe8fb19SBen Gras #define _UTX_PADSIZE 36
99*2fe8fb19SBen Gras #else
100*2fe8fb19SBen Gras #define _UTX_PADSIZE 40
101*2fe8fb19SBen Gras #endif
102*2fe8fb19SBen Gras 
103*2fe8fb19SBen Gras struct utmpx {
104*2fe8fb19SBen Gras 	char ut_name[_UTX_USERSIZE];	/* login name */
105*2fe8fb19SBen Gras 	char ut_id[_UTX_IDSIZE];	/* inittab id */
106*2fe8fb19SBen Gras 	char ut_line[_UTX_LINESIZE];	/* tty name */
107*2fe8fb19SBen Gras 	char ut_host[_UTX_HOSTSIZE];	/* host name */
108*2fe8fb19SBen Gras 	uint16_t ut_session;		/* session id used for windowing */
109*2fe8fb19SBen Gras 	uint16_t ut_type;		/* type of this entry */
110*2fe8fb19SBen Gras 	pid_t ut_pid;			/* process id creating the entry */
111*2fe8fb19SBen Gras 	struct {
112*2fe8fb19SBen Gras 		uint16_t e_termination;	/* process termination signal */
113*2fe8fb19SBen Gras 		uint16_t e_exit;	/* process exit status */
114*2fe8fb19SBen Gras 	} ut_exit;
115*2fe8fb19SBen Gras 	struct sockaddr_storage ut_ss;	/* address where entry was made from */
116*2fe8fb19SBen Gras 	struct timeval ut_tv;		/* time entry was created */
117*2fe8fb19SBen Gras 	uint8_t ut_pad[_UTX_PADSIZE];	/* reserved for future use */
118*2fe8fb19SBen Gras };
119*2fe8fb19SBen Gras 
120*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
121*2fe8fb19SBen Gras struct lastlogx {
122*2fe8fb19SBen Gras 	struct timeval ll_tv;		/* time entry was created */
123*2fe8fb19SBen Gras 	char ll_line[_UTX_LINESIZE];	/* tty name */
124*2fe8fb19SBen Gras 	char ll_host[_UTX_HOSTSIZE];	/* host name */
125*2fe8fb19SBen Gras 	struct sockaddr_storage ll_ss;	/* address where entry was made from */
126*2fe8fb19SBen Gras };
127*2fe8fb19SBen Gras #endif	/* !_XOPEN_SOURCE */
128*2fe8fb19SBen Gras 
129*2fe8fb19SBen Gras __BEGIN_DECLS
130*2fe8fb19SBen Gras 
131*2fe8fb19SBen Gras void setutxent(void);
132*2fe8fb19SBen Gras void endutxent(void);
133*2fe8fb19SBen Gras 
134*2fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
135*2fe8fb19SBen Gras struct utmpx *getutxent(void) __RENAME(__getutxent50);
136*2fe8fb19SBen Gras struct utmpx *getutxid(const struct utmpx *) __RENAME(__getutxid50);
137*2fe8fb19SBen Gras struct utmpx *getutxline(const struct utmpx *) __RENAME(__getutxline50);
138*2fe8fb19SBen Gras struct utmpx *pututxline(const struct utmpx *) __RENAME(__pututxline50);
139*2fe8fb19SBen Gras #endif
140*2fe8fb19SBen Gras 
141*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
142*2fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
143*2fe8fb19SBen Gras int updwtmpx(const char *, const struct utmpx *) __RENAME(__updwtmpx50);
144*2fe8fb19SBen Gras struct lastlogx *getlastlogx(const char *, uid_t, struct lastlogx *)
145*2fe8fb19SBen Gras     __RENAME(__getlastlogx50);
146*2fe8fb19SBen Gras int updlastlogx(const char *, uid_t, struct lastlogx *)
147*2fe8fb19SBen Gras     __RENAME(__updlastlogx50);
148*2fe8fb19SBen Gras struct utmp;
149*2fe8fb19SBen Gras void getutmp(const struct utmpx *, struct utmp *) __RENAME(__getutmp50);
150*2fe8fb19SBen Gras void getutmpx(const struct utmp *, struct utmpx *) __RENAME(__getutmpx50);
151*2fe8fb19SBen Gras #endif
152*2fe8fb19SBen Gras 
153*2fe8fb19SBen Gras int utmpxname(const char *);
154*2fe8fb19SBen Gras 
155*2fe8fb19SBen Gras #endif /* _NETBSD_SOURCE */
156*2fe8fb19SBen Gras 
157*2fe8fb19SBen Gras __END_DECLS
158*2fe8fb19SBen Gras 
159*2fe8fb19SBen Gras #endif /* !_UTMPX_H_ */
160