1202188Sed/*-
2202188Sed * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
3202188Sed * All rights reserved.
4202188Sed *
5202188Sed * Redistribution and use in source and binary forms, with or without
6202188Sed * modification, are permitted provided that the following conditions
7202188Sed * are met:
8202188Sed * 1. Redistributions of source code must retain the above copyright
9202188Sed *    notice, this list of conditions and the following disclaimer.
10202188Sed * 2. Redistributions in binary form must reproduce the above copyright
11202188Sed *    notice, this list of conditions and the following disclaimer in the
12202188Sed *    documentation and/or other materials provided with the distribution.
13202188Sed *
14202188Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15202188Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16202188Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17202188Sed * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18202188Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19202188Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20202188Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21202188Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22202188Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23202188Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24202188Sed * SUCH DAMAGE.
25202188Sed *
26202188Sed * $FreeBSD$
27202188Sed */
28202188Sed
29202188Sed#ifndef _UTMPX_H_
30202188Sed#define	_UTMPX_H_
31202188Sed
32202188Sed#include <sys/cdefs.h>
33202188Sed#include <sys/_timeval.h>
34202188Sed#include <sys/_types.h>
35202188Sed
36202188Sed#ifndef _PID_T_DECLARED
37202188Sedtypedef	__pid_t		pid_t;
38202188Sed#define	_PID_T_DECLARED
39202188Sed#endif
40202188Sed
41202188Sedstruct utmpx {
42202188Sed	short		ut_type;	/* Type of entry. */
43202188Sed	struct timeval	ut_tv;		/* Time entry was made. */
44202188Sed	char		ut_id[8];	/* Record identifier. */
45202188Sed	pid_t		ut_pid;		/* Process ID. */
46202188Sed	char		ut_user[32];	/* User login name. */
47202188Sed	char		ut_line[16];	/* Device name. */
48202188Sed#if __BSD_VISIBLE
49202188Sed	char		ut_host[128];	/* Remote hostname. */
50202188Sed#else
51202188Sed	char		__ut_host[128];
52202188Sed#endif
53202188Sed	char		__ut_spare[64];
54202188Sed};
55202188Sed
56202188Sed#define	EMPTY		0	/* No valid user accounting information. */
57202188Sed#define	BOOT_TIME	1	/* Time of system boot. */
58202188Sed#define	OLD_TIME	2	/* Time when system clock changed. */
59202188Sed#define	NEW_TIME	3	/* Time after system clock changed. */
60202188Sed#define	USER_PROCESS	4	/* A process. */
61202188Sed#define	INIT_PROCESS	5	/* A process spawned by the init process. */
62202188Sed#define	LOGIN_PROCESS	6	/* The session leader of a logged-in user. */
63202188Sed#define	DEAD_PROCESS	7	/* A session leader who has exited. */
64202188Sed#if __BSD_VISIBLE
65202188Sed#define	SHUTDOWN_TIME	8	/* Time of system shutdown. */
66202188Sed#endif
67202188Sed
68202188Sed#if __BSD_VISIBLE
69202188Sed#define	UTXDB_ACTIVE	0	/* Active login sessions. */
70202188Sed#define	UTXDB_LASTLOGIN	1	/* Last login sessions. */
71202188Sed#define	UTXDB_LOG	2	/* Log indexed by time. */
72202188Sed#endif
73202188Sed
74202188Sed__BEGIN_DECLS
75202188Sedvoid	endutxent(void);
76202188Sedstruct utmpx *getutxent(void);
77202188Sedstruct utmpx *getutxid(const struct utmpx *);
78202188Sedstruct utmpx *getutxline(const struct utmpx *);
79202188Sedstruct utmpx *pututxline(const struct utmpx *);
80202188Sedvoid	setutxent(void);
81202188Sed
82202188Sed#if __BSD_VISIBLE
83202188Sedstruct utmpx *getutxuser(const char *);
84202188Sedint	setutxdb(int, const char *);
85202188Sed#endif
86202188Sed__END_DECLS
87202188Sed
88202188Sed#endif /* !_UTMPX_H_ */
89