#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#ifdef UTMP_COMPAT
#define UTMP_COMPAT_UTMP0 0x01
#define UTMP_COMPAT_UTMP1 0x02
#define UTMP_COMPAT_WTMP 0x04
#define UTMP_COMPAT_LASTLOG 0x08
#endif
#define LASTLOG_FACILITY "com.apple.system.lastlog"
#define UTMPX_FACILITY "com.apple.system.utmpx"
#define UTMPX_LOCK(x) pthread_mutex_lock(&(x)->utmpx_mutex)
#define UTMPX_UNLOCK(x) pthread_mutex_unlock(&(x)->utmpx_mutex)
#define UTMPX_MAGIC 8
#define __UTX_MAGIC__ { 'u', 't', 'x', 0, 'v', 1, 0, 0 }
#define TEST_UTMPX_T(x,y) { \
if (!(y)) \
LIBC_ABORT("%s: NULL utmpx_t", (x)); \
if (memcmp((y)->magic, __utx_magic__, UTMPX_MAGIC) != 0) \
LIBC_ABORT("%s: magic mismatch", (x)); \
}
struct _utmpx {
char magic[UTMPX_MAGIC];
struct utmpx ut;
pthread_mutex_t utmpx_mutex;
char *utfile;
FILE *fp;
unsigned int utfile_system :1;
unsigned int readonly :1;
};
extern const char __utx_magic__[];
#ifdef __LP64__
#include <sys/_types.h>
#include <sys/_types/_timeval32.h>
#ifdef UTMP_COMPAT
struct lastlog32 {
__int32_t ll_time;
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};
struct utmp32 {
char ut_line[UT_LINESIZE];
char ut_name[UT_NAMESIZE];
char ut_host[UT_HOSTSIZE];
__int32_t ut_time;
};
#endif
struct utmpx32 {
char ut_user[_UTX_USERSIZE];
char ut_id[_UTX_IDSIZE];
char ut_line[_UTX_LINESIZE];
pid_t ut_pid;
short ut_type;
struct timeval32 ut_tv;
char ut_host[_UTX_HOSTSIZE];
__uint32_t ut_pad[16];
};
#endif
struct _utmpx *__default_utx(void);
void __endutxent(struct _utmpx *);
struct utmpx *__getutxent(struct _utmpx *);
void __setutxent(struct _utmpx *);
struct utmpx *__pututxline(struct _utmpx *, const struct utmpx *);
int __utmpxname(struct _utmpx *, const char *);
#ifdef __LP64__
void _utmpx32_64(const struct utmpx32 *, struct utmpx *);
void _utmpx64_32(const struct utmpx *, struct utmpx32 *);
#endif
void _utmpx_asl(const struct utmpx *);
const struct utmpx *_utmpx_working_copy(const struct utmpx *, struct utmpx *, int);
#ifdef UTMP_COMPAT
#ifdef __LP64__
void _getutmp32(const struct utmpx *, struct utmp32 *);
int _utmp_compat(const struct utmpx *, struct utmp32 *);
void _write_lastlog(const struct utmp32 *, const struct utmpx *);
void _write_utmp(const struct utmp32 *, int);
#else
int _utmp_compat(const struct utmpx *, struct utmp *);
void _write_lastlog(const struct utmp *, const struct utmpx *);
void _write_utmp(const struct utmp *, int);
#endif
void _write_utmp_compat(const struct utmpx *);
#ifdef __LP64__
void _write_wtmp(const struct utmp32 *);
#else
void _write_wtmp(const struct utmp *);
#endif
#endif