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