]>
Commit | Line | Data |
---|---|---|
ad3c9f2a A |
1 | /* |
2 | * Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
3d9156a7 A |
23 | /* $NetBSD: utmpx.h,v 1.11 2003/08/26 16:48:32 wiz Exp $ */ |
24 | ||
25 | /*- | |
26 | * Copyright (c) 2002 The NetBSD Foundation, Inc. | |
27 | * All rights reserved. | |
28 | * | |
29 | * This code is derived from software contributed to The NetBSD Foundation | |
30 | * by Christos Zoulas. | |
31 | * | |
32 | * Redistribution and use in source and binary forms, with or without | |
33 | * modification, are permitted provided that the following conditions | |
34 | * are met: | |
35 | * 1. Redistributions of source code must retain the above copyright | |
36 | * notice, this list of conditions and the following disclaimer. | |
37 | * 2. Redistributions in binary form must reproduce the above copyright | |
38 | * notice, this list of conditions and the following disclaimer in the | |
39 | * documentation and/or other materials provided with the distribution. | |
40 | * 3. All advertising materials mentioning features or use of this software | |
41 | * must display the following acknowledgement: | |
42 | * This product includes software developed by the NetBSD | |
43 | * Foundation, Inc. and its contributors. | |
44 | * 4. Neither the name of The NetBSD Foundation nor the names of its | |
45 | * contributors may be used to endorse or promote products derived | |
46 | * from this software without specific prior written permission. | |
47 | * | |
48 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
49 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
50 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
51 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
52 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
53 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
54 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
55 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
56 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
57 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
58 | * POSSIBILITY OF SUCH DAMAGE. | |
59 | */ | |
60 | #ifndef _UTMPX_H_ | |
61 | #define _UTMPX_H_ | |
62 | ||
ad3c9f2a | 63 | #include <_types.h> |
3d9156a7 | 64 | #include <sys/time.h> |
ad3c9f2a A |
65 | #include <sys/cdefs.h> |
66 | #include <Availability.h> | |
6465356a | 67 | #include <sys/_types/_pid_t.h> |
ad3c9f2a A |
68 | |
69 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) | |
6465356a | 70 | #include <sys/_types/_uid_t.h> |
ad3c9f2a | 71 | #endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ |
3d9156a7 A |
72 | |
73 | #define _PATH_UTMPX "/var/run/utmpx" | |
3d9156a7 | 74 | |
ad3c9f2a A |
75 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
76 | #define UTMPX_FILE _PATH_UTMPX | |
77 | #endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ | |
78 | ||
79 | #define _UTX_USERSIZE 256 /* matches MAXLOGNAME */ | |
3d9156a7 A |
80 | #define _UTX_LINESIZE 32 |
81 | #define _UTX_IDSIZE 4 | |
82 | #define _UTX_HOSTSIZE 256 | |
83 | ||
3d9156a7 A |
84 | #define EMPTY 0 |
85 | #define RUN_LVL 1 | |
86 | #define BOOT_TIME 2 | |
87 | #define OLD_TIME 3 | |
88 | #define NEW_TIME 4 | |
89 | #define INIT_PROCESS 5 | |
90 | #define LOGIN_PROCESS 6 | |
91 | #define USER_PROCESS 7 | |
92 | #define DEAD_PROCESS 8 | |
93 | ||
ad3c9f2a | 94 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
3d9156a7 A |
95 | #define ACCOUNTING 9 |
96 | #define SIGNATURE 10 | |
ad3c9f2a A |
97 | #define SHUTDOWN_TIME 11 |
98 | ||
99 | #define UTMPX_AUTOFILL_MASK 0x8000 | |
100 | #define UTMPX_DEAD_IF_CORRESPONDING_MASK 0x4000 | |
101 | ||
102 | /* notify(3) change notification name */ | |
103 | #define UTMPX_CHANGE_NOTIFICATION "com.apple.system.utmpx" | |
104 | #endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ | |
3d9156a7 A |
105 | |
106 | /* | |
107 | * The following structure describes the fields of the utmpx entries | |
ad3c9f2a | 108 | * stored in _PATH_UTMPX. This is not the format the |
3d9156a7 A |
109 | * entries are stored in the files, and application should only access |
110 | * entries using routines described in getutxent(3). | |
111 | */ | |
112 | ||
ad3c9f2a | 113 | #ifdef _UTMPX_COMPAT |
3d9156a7 A |
114 | #define ut_user ut_name |
115 | #define ut_xtime ut_tv.tv_sec | |
ad3c9f2a | 116 | #endif /* _UTMPX_COMPAT */ |
3d9156a7 A |
117 | |
118 | struct utmpx { | |
ad3c9f2a A |
119 | char ut_user[_UTX_USERSIZE]; /* login name */ |
120 | char ut_id[_UTX_IDSIZE]; /* id */ | |
3d9156a7 | 121 | char ut_line[_UTX_LINESIZE]; /* tty name */ |
3d9156a7 | 122 | pid_t ut_pid; /* process id creating the entry */ |
ad3c9f2a | 123 | short ut_type; /* type of this entry */ |
3d9156a7 | 124 | struct timeval ut_tv; /* time entry was created */ |
ad3c9f2a A |
125 | char ut_host[_UTX_HOSTSIZE]; /* host name */ |
126 | __uint32_t ut_pad[16]; /* reserved for future use */ | |
3d9156a7 A |
127 | }; |
128 | ||
ad3c9f2a | 129 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
3d9156a7 A |
130 | struct lastlogx { |
131 | struct timeval ll_tv; /* time entry was created */ | |
132 | char ll_line[_UTX_LINESIZE]; /* tty name */ | |
133 | char ll_host[_UTX_HOSTSIZE]; /* host name */ | |
3d9156a7 | 134 | }; |
ad3c9f2a | 135 | #endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ |
3d9156a7 A |
136 | |
137 | __BEGIN_DECLS | |
138 | ||
ad3c9f2a A |
139 | void endutxent(void); |
140 | ||
141 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) | |
142 | void endutxent_wtmp(void) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); | |
143 | struct lastlogx * | |
144 | getlastlogx(uid_t, struct lastlogx *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); | |
145 | struct lastlogx * | |
146 | getlastlogxbyname(const char*, struct lastlogx *)__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); | |
147 | #ifdef UNIFDEF_LEGACY_UTMP_APIS | |
148 | struct utmp; /* forward reference */ | |
6465356a A |
149 | void getutmp(const struct utmpx *, struct utmp *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_9, __IPHONE_2_0, __IPHONE_7_0); |
150 | void getutmpx(const struct utmp *, struct utmpx *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_9, __IPHONE_2_0, __IPHONE_7_0); | |
ad3c9f2a A |
151 | #endif /* UNIFDEF_LEGACY_UTMP_APIS */ |
152 | #endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ | |
153 | ||
154 | struct utmpx * | |
155 | getutxent(void); | |
156 | ||
157 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) | |
158 | struct utmpx * | |
159 | getutxent_wtmp(void) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); | |
160 | #endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ | |
161 | ||
162 | struct utmpx * | |
163 | getutxid(const struct utmpx *); | |
164 | struct utmpx * | |
165 | getutxline(const struct utmpx *); | |
166 | struct utmpx * | |
167 | pututxline(const struct utmpx *); | |
168 | void setutxent(void); | |
169 | ||
170 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) | |
171 | void setutxent_wtmp(int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); | |
172 | int utmpxname(const char *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); | |
173 | int wtmpxname(const char *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); | |
174 | #endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ | |
3d9156a7 A |
175 | |
176 | __END_DECLS | |
177 | ||
178 | #endif /* !_UTMPX_H_ */ |