utmpx.h revision 1.2 1 /* $NetBSD: utmpx.h,v 1.2 2002/02/25 03:19:15 christos 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/socket.h>
42
43 #define _PATH_UTMPX "/var/run/utmpx"
44 #define _PATH_WTMPX "/var/log/wtmpx"
45 #define _PATH_LASTLOGX "/var/log/lastlogx"
46 #define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update"
47
48 #define _UTX_NAMESIZE 32
49 #define _UTX_LINESIZE 32
50 #define _UTX_IDSIZE 4
51 #define _UTX_HOSTSIZE 256
52
53 #ifndef _XOPEN_SOURCE
54 #define UTX_NAMESIZE _UTX_NAMESIZE
55 #define UTX_LINESIZE _UTX_LINESIZE
56 #define UTX_IDSIZE _UTX_IDSIZE
57 #define UTX_HOSTSIZE _UTX_HOSTSIZE
58 #endif
59
60 #define EMPTY 0
61 #define RUN_LVL 1
62 #define BOOT_TIME 2
63 #define OLD_TIME 3
64 #define NEW_TIME 4
65 #define INIT_PROCESS 5
66 #define LOGIN_PROCESS 6
67 #define USER_PROCESS 7
68 #define DEAD_PROCESS 8
69
70 #ifndef _XOPEN_SOURCE
71 #define ACCOUNTING 9
72 #define SIGNATURE 10
73 #endif
74
75 /*
76 * The following structure describes the fields of the utmpx entries
77 * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the
78 * entries are stored in the files, and application should only access
79 * entries using routines described in getutxent(3).
80 */
81 struct utmpx {
82 char ut_name[_UTX_NAMESIZE]; /* login name */
83 char ut_id[_UTX_IDSIZE]; /* inittab id */
84 char ut_line[_UTX_LINESIZE]; /* tty name */
85 char ut_host[_UTX_HOSTSIZE]; /* host name */
86 uint16_t ut_session; /* session id used for windowing */
87 uint16_t ut_type; /* type of this entry */
88 pid_t ut_pid; /* process id creating the entry */
89 struct {
90 uint16_t e_termination; /* process termination signal */
91 uint16_t e_exit; /* process exit status */
92 } ut_exit;
93 struct sockaddr_storage ut_ss; /* address where entry was made from */
94 struct timeval ut_tv; /* time entry was created */
95 uint32_t ut_pad[10]; /* reserved for future use */
96 };
97
98 #ifndef _XOPEN_SOURCE
99 struct lastlogx {
100 struct timespec ll_time; /* time entry was created */
101 char ll_line[_UTX_LINESIZE]; /* tty name */
102 char ll_host[_UTX_HOSTSIZE]; /* host name */
103 struct sockaddr_storage ll_ss; /* address where entry was made from */
104 };
105 #endif /* !_XOPEN_SOURCE */
106
107 __BEGIN_DECLS
108
109 void setutxent(void);
110 void endutxent(void);
111 struct utmpx *getutxent(void);
112 struct utmpx *getutxid(const struct utmpx *);
113 struct utmpx *getutxline(const struct utmpx *);
114 struct utmpx *pututxline(const struct utmpx *);
115
116 #ifndef _XOPEN_SOURCE
117
118 int lastlogxname(const char *);
119 struct lastlogx *getlastlogxuid(uid_t);
120 void updlastlogx(const char *, struct lastlogx *);
121
122 int utmpxname(const char *);
123
124 #endif /* !_XOPEN_SOURCE */
125
126 __END_DECLS
127
128 #endif /* !_UTMPX_H_ */
129