utmpx.h revision 1.10 1 /* $NetBSD: utmpx.h,v 1.10 2003/04/28 23:16:15 bjh21 Exp $ */
2
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38 #ifndef _UTMPX_H_
39 #define _UTMPX_H_
40
41 #include <sys/featuretest.h>
42 #include <sys/socket.h>
43 #include <sys/time.h>
44
45 #define _PATH_UTMPX "/var/run/utmpx"
46 #define _PATH_WTMPX "/var/log/wtmpx"
47 #define _PATH_LASTLOGX "/var/log/lastlogx"
48 #define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update"
49
50 #define _UTX_USERSIZE 32
51 #define _UTX_LINESIZE 32
52 #define _UTX_IDSIZE 4
53 #define _UTX_HOSTSIZE 256
54
55 #if defined(_NETBSD_SOURCE)
56 #define UTX_USERSIZE _UTX_USERSIZE
57 #define UTX_LINESIZE _UTX_LINESIZE
58 #define UTX_IDSIZE _UTX_IDSIZE
59 #define UTX_HOSTSIZE _UTX_HOSTSIZE
60 #endif
61
62 #define EMPTY 0
63 #define RUN_LVL 1
64 #define BOOT_TIME 2
65 #define OLD_TIME 3
66 #define NEW_TIME 4
67 #define INIT_PROCESS 5
68 #define LOGIN_PROCESS 6
69 #define USER_PROCESS 7
70 #define DEAD_PROCESS 8
71
72 #if defined(_NETBSD_SOURCE)
73 #define ACCOUNTING 9
74 #define SIGNATURE 10
75 #endif
76
77 /*
78 * The following structure describes the fields of the utmpx entries
79 * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the
80 * entries are stored in the files, and application should only access
81 * entries using routines described in getutxent(3).
82 */
83
84 #define ut_user ut_name
85 #define ut_xtime ut_tv.tv_sec
86
87 struct utmpx {
88 char ut_name[_UTX_USERSIZE]; /* login name */
89 char ut_id[_UTX_IDSIZE]; /* inittab id */
90 char ut_line[_UTX_LINESIZE]; /* tty name */
91 char ut_host[_UTX_HOSTSIZE]; /* host name */
92 uint16_t ut_session; /* session id used for windowing */
93 uint16_t ut_type; /* type of this entry */
94 pid_t ut_pid; /* process id creating the entry */
95 struct {
96 uint16_t e_termination; /* process termination signal */
97 uint16_t e_exit; /* process exit status */
98 } ut_exit;
99 struct sockaddr_storage ut_ss; /* address where entry was made from */
100 struct timeval ut_tv; /* time entry was created */
101 uint32_t ut_pad[10]; /* reserved for future use */
102 };
103
104 #if defined(_NETBSD_SOURCE)
105 struct lastlogx {
106 struct timeval ll_tv; /* time entry was created */
107 char ll_line[_UTX_LINESIZE]; /* tty name */
108 char ll_host[_UTX_HOSTSIZE]; /* host name */
109 struct sockaddr_storage ll_ss; /* address where entry was made from */
110 };
111 #endif /* !_XOPEN_SOURCE */
112
113 __BEGIN_DECLS
114
115 void setutxent __P((void));
116 void endutxent __P((void));
117 struct utmpx *getutxent __P((void));
118 struct utmpx *getutxid __P((const struct utmpx *));
119 struct utmpx *getutxline __P((const struct utmpx *));
120 struct utmpx *pututxline __P((const struct utmpx *));
121
122 #if defined(_NETBSD_SOURCE)
123 int updwtmpx __P((const char *, const struct utmpx *));
124 int lastlogxname __P((const char *));
125 struct lastlogx *getlastlogx __P((uid_t, struct lastlogx *));
126 int updlastlogx __P((const char *, uid_t, struct lastlogx *));
127 struct utmp;
128 void getutmp __P((const struct utmpx *, struct utmp *));
129 void getutmpx __P((const struct utmp *, struct utmpx *));
130
131 int utmpxname __P((const char *));
132
133 #endif /* _NETBSD_SOURCE */
134
135 __END_DECLS
136
137 #endif /* !_UTMPX_H_ */
138