xref: /titanic_50/usr/src/head/utmp.h (revision 0a1278f26ea4b7c8c0285d4f2d6c5b680904aa01)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 
32 #ifndef _UTMP_H
33 #define	_UTMP_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.5.1.7 */
36 
37 /*
38  * Note:  The getutent(3c) family of interfaces are obsolete.
39  * The getutxent(3c) family provide a superset of this functionality
40  * and should be used in place of getutent(3c).
41  */
42 
43 #include <sys/types.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
50 #define	UTMP_FILE	"/var/adm/utmp"
51 #define	WTMP_FILE	"/var/adm/wtmp"
52 #endif
53 
54 #define	ut_name	ut_user
55 
56 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
57 struct exit_status {
58 	short e_termination;	/* Process termination status */
59 	short e_exit;		/* Process exit status */
60 };
61 #else
62 struct ut_exit_status {
63 	short ut_e_termination;	/* Process termination status */
64 	short ut_e_exit;	/* Process exit status */
65 };
66 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
67 
68 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
69 
70 /*
71  * This data structure describes the utmp entries returned by
72  * the getutent(3c) family of APIs.  It does not (necessarily)
73  * correspond to the contents of the utmp or wtmp files.
74  *
75  * Applications should only interact with this subsystem via
76  * the getutxent(3c) family of APIs, as the getutent(3c) family
77  * are obsolete.
78  */
79 struct utmp {
80 	char ut_user[8];		/* User login name */
81 	char ut_id[4]; 			/* /etc/inittab id(usually line #) */
82 	char ut_line[12];		/* device name (console, lnxx) */
83 	short ut_pid;			/* short for compat. - process id */
84 	short ut_type;			/* type of entry */
85 	struct exit_status ut_exit;	/* The exit status of a process */
86 					/* marked as DEAD_PROCESS. */
87 	time_t ut_time;			/* time entry was made */
88 };
89 
90 #include <sys/types32.h>
91 #include <inttypes.h>
92 
93 /*
94  * This data structure describes the utmp *file* contents using
95  * fixed-width data types.  It should only be used by the implementation.
96  *
97  * Applications should use the getutxent(3c) family of routines to interact
98  * with this database.
99  */
100 
101 struct futmp {
102 	char ut_user[8];		/* User login name */
103 	char ut_id[4];			/* /etc/inittab id */
104 	char ut_line[12];		/* device name (console, lnxx) */
105 	int16_t ut_pid;			/* process id */
106 	int16_t ut_type;		/* type of entry */
107 	struct {
108 		int16_t	e_termination;	/* Process termination status */
109 		int16_t e_exit;		/* Process exit status */
110 	} ut_exit;			/* The exit status of a process */
111 	time32_t ut_time;		/* time entry was made */
112 };
113 
114 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
115 
116 /*	Definitions for ut_type						*/
117 
118 #define	EMPTY		0
119 #define	RUN_LVL		1
120 #define	BOOT_TIME	2
121 #define	OLD_TIME	3
122 #define	NEW_TIME	4
123 #define	INIT_PROCESS	5	/* Process spawned by "init" */
124 #define	LOGIN_PROCESS	6	/* A "getty" process waiting for login */
125 #define	USER_PROCESS	7	/* A user process */
126 #define	DEAD_PROCESS	8
127 
128 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
129 
130 #define	ACCOUNTING	9
131 #define	DOWN_TIME	10
132 
133 #define	UTMAXTYPE	DOWN_TIME	/* Largest legal value of ut_type */
134 
135 /*	Special strings or formats used in the "ut_line" field when	*/
136 /*	accounting for something other than a process.			*/
137 /*	No string for the ut_line field can be more than 11 chars +	*/
138 /*	a NULL in length.						*/
139 
140 #define	RUNLVL_MSG	"run-level %c"
141 #define	BOOT_MSG	"system boot"
142 #define	OTIME_MSG	"old time"
143 #define	NTIME_MSG	"new time"
144 #define	PSRADM_MSG	"%03d  %s"	/* processor on or off */
145 #define	DOWN_MSG	"system down"
146 
147 /*	Define and macro for determing if a normal user wrote the entry */
148 /*	 and marking the utmpx entry as a normal user */
149 #define	NONROOT_USR	2
150 #define	nonuser(ut)	((ut).ut_exit.e_exit == NONROOT_USR ? 1 : 0)
151 #define	setuser(ut)	((ut).ut_exit.e_exit = NONROOT_USR)
152 
153 
154 #if defined(__STDC__)
155 extern void endutent(void);
156 extern struct utmp *getutent(void);
157 extern struct utmp *getutid(const struct utmp *);
158 extern struct utmp *getutline(const struct utmp *);
159 extern struct utmp *pututline(const struct utmp *);
160 extern void setutent(void);
161 extern int utmpname(const char *);
162 #else
163 extern void endutent();
164 extern struct utmp *getutent();
165 extern struct utmp *getutid();
166 extern struct utmp *getutline();
167 extern struct utmp *pututline();
168 extern void setutent();
169 extern int utmpname();
170 #endif
171 
172 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
173 
174 #ifdef	__cplusplus
175 }
176 #endif
177 
178 #endif	/* _UTMP_H */
179