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