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