1 /* $NetBSD: utmpx.h,v 1.9 2002/07/28 22:48:38 christos Exp $ */ 2 3 /*- 4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Christos Zoulas. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 #ifndef _UTMPX_H_ 39 #define _UTMPX_H_ 40 41 #include <sys/socket.h> 42 #include <sys/time.h> 43 44 #define _PATH_UTMPX "/var/run/utmpx" 45 #define _PATH_WTMPX "/var/log/wtmpx" 46 #define _PATH_LASTLOGX "/var/log/lastlogx" 47 #define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update" 48 49 #define _UTX_USERSIZE 32 50 #define _UTX_LINESIZE 32 51 #define _UTX_IDSIZE 4 52 #define _UTX_HOSTSIZE 256 53 54 #ifndef _XOPEN_SOURCE 55 #define UTX_USERSIZE _UTX_USERSIZE 56 #define UTX_LINESIZE _UTX_LINESIZE 57 #define UTX_IDSIZE _UTX_IDSIZE 58 #define UTX_HOSTSIZE _UTX_HOSTSIZE 59 #endif 60 61 #define EMPTY 0 62 #define RUN_LVL 1 63 #define BOOT_TIME 2 64 #define OLD_TIME 3 65 #define NEW_TIME 4 66 #define INIT_PROCESS 5 67 #define LOGIN_PROCESS 6 68 #define USER_PROCESS 7 69 #define DEAD_PROCESS 8 70 71 #ifndef _XOPEN_SOURCE 72 #define ACCOUNTING 9 73 #define SIGNATURE 10 74 #endif 75 76 /* 77 * The following structure describes the fields of the utmpx entries 78 * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the 79 * entries are stored in the files, and application should only access 80 * entries using routines described in getutxent(3). 81 */ 82 83 #define ut_user ut_name 84 #define ut_xtime ut_tv.tv_sec 85 86 struct utmpx { 87 char ut_name[_UTX_USERSIZE]; /* login name */ 88 char ut_id[_UTX_IDSIZE]; /* inittab id */ 89 char ut_line[_UTX_LINESIZE]; /* tty name */ 90 char ut_host[_UTX_HOSTSIZE]; /* host name */ 91 uint16_t ut_session; /* session id used for windowing */ 92 uint16_t ut_type; /* type of this entry */ 93 pid_t ut_pid; /* process id creating the entry */ 94 struct { 95 uint16_t e_termination; /* process termination signal */ 96 uint16_t e_exit; /* process exit status */ 97 } ut_exit; 98 struct sockaddr_storage ut_ss; /* address where entry was made from */ 99 struct timeval ut_tv; /* time entry was created */ 100 uint32_t ut_pad[10]; /* reserved for future use */ 101 }; 102 103 #ifndef _XOPEN_SOURCE 104 struct lastlogx { 105 struct timeval ll_tv; /* time entry was created */ 106 char ll_line[_UTX_LINESIZE]; /* tty name */ 107 char ll_host[_UTX_HOSTSIZE]; /* host name */ 108 struct sockaddr_storage ll_ss; /* address where entry was made from */ 109 }; 110 #endif /* !_XOPEN_SOURCE */ 111 112 __BEGIN_DECLS 113 114 void setutxent __P((void)); 115 void endutxent __P((void)); 116 struct utmpx *getutxent __P((void)); 117 struct utmpx *getutxid __P((const struct utmpx *)); 118 struct utmpx *getutxline __P((const struct utmpx *)); 119 struct utmpx *pututxline __P((const struct utmpx *)); 120 121 #ifndef _XOPEN_SOURCE 122 int updwtmpx __P((const char *, const struct utmpx *)); 123 int lastlogxname __P((const char *)); 124 struct lastlogx *getlastlogx __P((uid_t, struct lastlogx *)); 125 int updlastlogx __P((const char *, uid_t, struct lastlogx *)); 126 struct utmp; 127 void getutmp __P((const struct utmpx *, struct utmp *)); 128 void getutmpx __P((const struct utmp *, struct utmpx *)); 129 130 int utmpxname __P((const char *)); 131 132 #endif /* !_XOPEN_SOURCE */ 133 134 __END_DECLS 135 136 #endif /* !_UTMPX_H_ */ 137