xref: /freebsd-src/include/utmpx.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1a627ac61SEd Schouten /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3e58eb3c4SPedro F. Giffuni  *
4a627ac61SEd Schouten  * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
5a627ac61SEd Schouten  * All rights reserved.
6a627ac61SEd Schouten  *
7a627ac61SEd Schouten  * Redistribution and use in source and binary forms, with or without
8a627ac61SEd Schouten  * modification, are permitted provided that the following conditions
9a627ac61SEd Schouten  * are met:
10a627ac61SEd Schouten  * 1. Redistributions of source code must retain the above copyright
11a627ac61SEd Schouten  *    notice, this list of conditions and the following disclaimer.
12a627ac61SEd Schouten  * 2. Redistributions in binary form must reproduce the above copyright
13a627ac61SEd Schouten  *    notice, this list of conditions and the following disclaimer in the
14a627ac61SEd Schouten  *    documentation and/or other materials provided with the distribution.
15a627ac61SEd Schouten  *
16a627ac61SEd Schouten  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17a627ac61SEd Schouten  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18a627ac61SEd Schouten  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19a627ac61SEd Schouten  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20a627ac61SEd Schouten  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21a627ac61SEd Schouten  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22a627ac61SEd Schouten  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23a627ac61SEd Schouten  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24a627ac61SEd Schouten  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25a627ac61SEd Schouten  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26a627ac61SEd Schouten  * SUCH DAMAGE.
27a627ac61SEd Schouten  */
28a627ac61SEd Schouten 
29a627ac61SEd Schouten #ifndef _UTMPX_H_
30a627ac61SEd Schouten #define	_UTMPX_H_
31a627ac61SEd Schouten 
32a627ac61SEd Schouten #include <sys/cdefs.h>
33a627ac61SEd Schouten #include <sys/_timeval.h>
34a627ac61SEd Schouten #include <sys/_types.h>
35a627ac61SEd Schouten 
36a627ac61SEd Schouten #ifndef _PID_T_DECLARED
37a627ac61SEd Schouten typedef	__pid_t		pid_t;
38a627ac61SEd Schouten #define	_PID_T_DECLARED
39a627ac61SEd Schouten #endif
40a627ac61SEd Schouten 
41a627ac61SEd Schouten struct utmpx {
42a627ac61SEd Schouten 	short		ut_type;	/* Type of entry. */
43a627ac61SEd Schouten 	struct timeval	ut_tv;		/* Time entry was made. */
44a627ac61SEd Schouten 	char		ut_id[8];	/* Record identifier. */
45a627ac61SEd Schouten 	pid_t		ut_pid;		/* Process ID. */
46a627ac61SEd Schouten 	char		ut_user[32];	/* User login name. */
47a627ac61SEd Schouten 	char		ut_line[16];	/* Device name. */
48a627ac61SEd Schouten #if __BSD_VISIBLE
49a627ac61SEd Schouten 	char		ut_host[128];	/* Remote hostname. */
50a627ac61SEd Schouten #else
51a627ac61SEd Schouten 	char		__ut_host[128];
52a627ac61SEd Schouten #endif
53a627ac61SEd Schouten 	char		__ut_spare[64];
54a627ac61SEd Schouten };
55a627ac61SEd Schouten 
56a627ac61SEd Schouten #define	EMPTY		0	/* No valid user accounting information. */
57a627ac61SEd Schouten #define	BOOT_TIME	1	/* Time of system boot. */
58a627ac61SEd Schouten #define	OLD_TIME	2	/* Time when system clock changed. */
59a627ac61SEd Schouten #define	NEW_TIME	3	/* Time after system clock changed. */
60a627ac61SEd Schouten #define	USER_PROCESS	4	/* A process. */
61a627ac61SEd Schouten #define	INIT_PROCESS	5	/* A process spawned by the init process. */
62a627ac61SEd Schouten #define	LOGIN_PROCESS	6	/* The session leader of a logged-in user. */
63a627ac61SEd Schouten #define	DEAD_PROCESS	7	/* A session leader who has exited. */
64a627ac61SEd Schouten #if __BSD_VISIBLE
65a627ac61SEd Schouten #define	SHUTDOWN_TIME	8	/* Time of system shutdown. */
66a627ac61SEd Schouten #endif
67a627ac61SEd Schouten 
68a627ac61SEd Schouten #if __BSD_VISIBLE
69a627ac61SEd Schouten #define	UTXDB_ACTIVE	0	/* Active login sessions. */
70a627ac61SEd Schouten #define	UTXDB_LASTLOGIN	1	/* Last login sessions. */
71a627ac61SEd Schouten #define	UTXDB_LOG	2	/* Log indexed by time. */
72a627ac61SEd Schouten #endif
73a627ac61SEd Schouten 
74a627ac61SEd Schouten __BEGIN_DECLS
75a627ac61SEd Schouten void	endutxent(void);
76a627ac61SEd Schouten struct utmpx *getutxent(void);
77a627ac61SEd Schouten struct utmpx *getutxid(const struct utmpx *);
78a627ac61SEd Schouten struct utmpx *getutxline(const struct utmpx *);
79a627ac61SEd Schouten struct utmpx *pututxline(const struct utmpx *);
80a627ac61SEd Schouten void	setutxent(void);
81a627ac61SEd Schouten 
82a627ac61SEd Schouten #if __BSD_VISIBLE
83a627ac61SEd Schouten struct utmpx *getutxuser(const char *);
84a627ac61SEd Schouten int	setutxdb(int, const char *);
85a627ac61SEd Schouten #endif
86a627ac61SEd Schouten __END_DECLS
87a627ac61SEd Schouten 
88a627ac61SEd Schouten #endif /* !_UTMPX_H_ */
89