2 * Copyright (c) 2005, 2009 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 2004 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
28 #include <sys/param.h>
31 #define UTMP_COMPAT_UTMP0 0x01
32 #define UTMP_COMPAT_UTMP1 0x02
33 #define UTMP_COMPAT_WTMP 0x04
34 #define UTMP_COMPAT_LASTLOG 0x08
35 #endif /* UTMP_COMPAT */
37 #define LASTLOG_FACILITY "com.apple.system.lastlog"
38 #define UTMPX_FACILITY "com.apple.system.utmpx"
40 #define UTMPX_LOCK(x) if (__is_threaded) pthread_mutex_lock(&(x)->utmpx_mutex)
41 #define UTMPX_UNLOCK(x) if (__is_threaded) pthread_mutex_unlock(&(x)->utmpx_mutex)
43 #define __UTX_MAGIC__ { 'u', 't', 'x', 0, 'v', 1, 0, 0 }
45 #define TEST_UTMPX_T(x,y) { \
47 LIBC_ABORT("%s: NULL utmpx_t", (x)); \
48 if (memcmp((y)->magic, __utx_magic__, UTMPX_MAGIC) != 0) \
49 LIBC_ABORT("%s: magic mismatch", (x)); \
52 extern int __is_threaded
;
55 char magic
[UTMPX_MAGIC
];
57 pthread_mutex_t utmpx_mutex
;
60 unsigned int utfile_system
:1; /* are we using _PATH_UTMPX? */
61 unsigned int readonly
:1;
63 extern struct _utmpx __utx__
; /* the default struct _utmpx */
64 extern const char __utx_magic__
[]; /* size of UTMPX_MAGIC */
67 #define __need_struct_timeval32
71 * these structures assume natural alignment so they are the same size
72 * and layout as their 32-bit counterpart
77 char ll_line
[UT_LINESIZE
];
78 char ll_host
[UT_HOSTSIZE
];
82 char ut_line
[UT_LINESIZE
];
83 char ut_name
[UT_NAMESIZE
];
84 char ut_host
[UT_HOSTSIZE
];
87 #endif /* UTMP_COMPAT */
90 char ut_user
[_UTX_USERSIZE
]; /* login name */
91 char ut_id
[_UTX_IDSIZE
]; /* id */
92 char ut_line
[_UTX_LINESIZE
]; /* tty name */
93 pid_t ut_pid
; /* process id creating the entry */
94 short ut_type
; /* type of this entry */
95 struct timeval32 ut_tv
; /* time entry was created */
96 char ut_host
[_UTX_HOSTSIZE
]; /* host name */
97 __uint32_t ut_pad
[16]; /* reserved for future use */
101 void __endutxent(struct _utmpx
*);
102 struct utmpx
*__getutxent(struct _utmpx
*);
103 void __setutxent(struct _utmpx
*);
104 struct utmpx
*__pututxline(struct _utmpx
*, const struct utmpx
*);
105 int __utmpxname(struct _utmpx
*, const char *);
107 void _utmpx32_64(const struct utmpx32
*, struct utmpx
*);
108 void _utmpx64_32(const struct utmpx
*, struct utmpx32
*);
109 #endif /* __LP64__ */
110 void _utmpx_asl(const struct utmpx
*);
111 const struct utmpx
*_utmpx_working_copy(const struct utmpx
*, struct utmpx
*, int);
115 void _getutmp32(const struct utmpx
*, struct utmp32
*);
116 int _utmp_compat(const struct utmpx
*, struct utmp32
*);
117 void _write_lastlog(const struct utmp32
*, const struct utmpx
*);
118 void _write_utmp(const struct utmp32
*, int);
120 int _utmp_compat(const struct utmpx
*, struct utmp
*);
121 void _write_lastlog(const struct utmp
*, const struct utmpx
*);
122 void _write_utmp(const struct utmp
*, int);
123 #endif /* __LP64__ */
124 void _write_utmp_compat(const struct utmpx
*);
126 void _write_wtmp(const struct utmp32
*);
128 void _write_wtmp(const struct utmp
*);
129 #endif /* __LP64__ */
130 #endif /* UTMP_COMPAT */