]> git.saurik.com Git - apple/libc.git/blob - include/NetBSD/utmpx.h
Libc-594.9.5.tar.gz
[apple/libc.git] / include / NetBSD / utmpx.h
1 /* $NetBSD: utmpx.h,v 1.11 2003/08/26 16:48:32 wiz 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/cdefs.h>
42 #include <sys/featuretest.h>
43 #include <sys/socket.h>
44 #include <sys/time.h>
45
46 #define _PATH_UTMPX "/var/run/utmpx"
47 #define _PATH_WTMPX "/var/log/wtmpx"
48 #define _PATH_LASTLOGX "/var/log/lastlogx"
49 #define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update"
50
51 #define _UTX_USERSIZE 32
52 #define _UTX_LINESIZE 32
53 #define _UTX_IDSIZE 4
54 #define _UTX_HOSTSIZE 256
55
56 #if defined(_NETBSD_SOURCE)
57 #define UTX_USERSIZE _UTX_USERSIZE
58 #define UTX_LINESIZE _UTX_LINESIZE
59 #define UTX_IDSIZE _UTX_IDSIZE
60 #define UTX_HOSTSIZE _UTX_HOSTSIZE
61 #endif
62
63 #define EMPTY 0
64 #define RUN_LVL 1
65 #define BOOT_TIME 2
66 #define OLD_TIME 3
67 #define NEW_TIME 4
68 #define INIT_PROCESS 5
69 #define LOGIN_PROCESS 6
70 #define USER_PROCESS 7
71 #define DEAD_PROCESS 8
72
73 #if defined(_NETBSD_SOURCE)
74 #define ACCOUNTING 9
75 #define SIGNATURE 10
76 #endif
77
78 /*
79 * The following structure describes the fields of the utmpx entries
80 * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the
81 * entries are stored in the files, and application should only access
82 * entries using routines described in getutxent(3).
83 */
84
85 #define ut_user ut_name
86 #define ut_xtime ut_tv.tv_sec
87
88 struct utmpx {
89 char ut_name[_UTX_USERSIZE]; /* login name */
90 char ut_id[_UTX_IDSIZE]; /* inittab id */
91 char ut_line[_UTX_LINESIZE]; /* tty name */
92 char ut_host[_UTX_HOSTSIZE]; /* host name */
93 uint16_t ut_session; /* session id used for windowing */
94 uint16_t ut_type; /* type of this entry */
95 pid_t ut_pid; /* process id creating the entry */
96 struct {
97 uint16_t e_termination; /* process termination signal */
98 uint16_t e_exit; /* process exit status */
99 } ut_exit;
100 struct sockaddr_storage ut_ss; /* address where entry was made from */
101 struct timeval ut_tv; /* time entry was created */
102 uint32_t ut_pad[10]; /* reserved for future use */
103 };
104
105 #if defined(_NETBSD_SOURCE)
106 struct lastlogx {
107 struct timeval ll_tv; /* time entry was created */
108 char ll_line[_UTX_LINESIZE]; /* tty name */
109 char ll_host[_UTX_HOSTSIZE]; /* host name */
110 struct sockaddr_storage ll_ss; /* address where entry was made from */
111 };
112 #endif /* !_XOPEN_SOURCE */
113
114 __BEGIN_DECLS
115
116 void setutxent __P((void));
117 void endutxent __P((void));
118 struct utmpx *getutxent __P((void));
119 struct utmpx *getutxid __P((const struct utmpx *));
120 struct utmpx *getutxline __P((const struct utmpx *));
121 struct utmpx *pututxline __P((const struct utmpx *));
122
123 #if defined(_NETBSD_SOURCE)
124 int updwtmpx __P((const char *, const struct utmpx *));
125 int lastlogxname __P((const char *));
126 #ifdef __LIBC12_SOURCE__
127 struct lastlogx *getlastlogx __P((uid_t, struct lastlogx *));
128 struct lastlogx *__getlastlogx13 __P((const char *, uid_t, struct lastlogx *));
129 #else
130 struct lastlogx *getlastlogx __P((const char *, uid_t, struct lastlogx *))
131 __RENAME(__getlastlogx13);
132 #endif
133 int updlastlogx __P((const char *, uid_t, struct lastlogx *));
134 struct utmp;
135 void getutmp __P((const struct utmpx *, struct utmp *));
136 void getutmpx __P((const struct utmp *, struct utmpx *));
137
138 int utmpxname __P((const char *));
139
140 #endif /* _NETBSD_SOURCE */
141
142 __END_DECLS
143
144 #endif /* !_UTMPX_H_ */