]> git.saurik.com Git - apple/libc.git/blobdiff - gen/utmpx-darwin.h
Libc-1439.100.3.tar.gz
[apple/libc.git] / gen / utmpx-darwin.h
index a15054721b551095b989abb0188874209c389dac..ae4733cc4996ed3e2aa488aa5f7b6ae34e39d10f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2005, 2009 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 #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 LASTLOG_FACILITY       "com.apple.system.lastlog"
 #define UTMPX_FACILITY         "com.apple.system.utmpx"
 
-#define        UTMPX_LOCK      if (__is_threaded) pthread_mutex_lock(&utmpx_mutex)
-#define        UTMPX_UNLOCK    if (__is_threaded) pthread_mutex_unlock(&utmpx_mutex)
+#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 }
 
-extern int utfile_system; /* are we using _PATH_UTMPX? */
-extern int __is_threaded;
-extern pthread_mutex_t utmpx_mutex;
+#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; /* are we using _PATH_UTMPX? */
+       unsigned int readonly      :1;
+};
+extern const char __utx_magic__[]; /* size of UTMPX_MAGIC */
 
 #ifdef __LP64__
-#define __need_struct_timeval32
-#include <_structs.h>
+#include <sys/_types.h>
+#include <sys/_types/_timeval32.h>
 
 /*
  * these structures assume natural alignment so they are the same size
@@ -75,9 +95,13 @@ struct utmpx32 {
 };
 #endif /* __LP64__ */
 
-void _endutxent(void);
-void _setutxent(void);
-struct utmpx *_pututxline(const struct utmpx *);
+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 *);