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