s4:heimdal: import lorikeet-heimdal-202201172009 (commit 5a0b45cd723628b3690ea848548b...
[samba.git] / source4 / heimdal / lib / base / baselocl.h
similarity index 62%
rename from source4/heimdal/base/baselocl.h
rename to source4/heimdal/lib/base/baselocl.h
index 901e8606fd97a47565296a9dd32710d1160ec437..7ca6439b33b3bfdea0056199820e6400247be40b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Kungliga Tekniska Högskolan
+ * Copyright (c) 2010 - 2011 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
 
 #include "config.h"
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+#include <roken.h>
+
+#define ISTILDE(x) (x == '~')
+#ifdef _WIN32
+# define ISPATHSEP(x) (x == '/' || x =='\\')
+#else
+# define ISPATHSEP(x) (x == '/')
 #endif
+
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
+#define HEIMDAL_TEXTDOMAIN "heimdal_krb5"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#ifdef LIBINTL
+#include <libintl.h>
+#define N_(x,y) dgettext(HEIMDAL_TEXTDOMAIN, x)
+#else
+#define N_(x,y) (x)
+#define bindtextdomain(package, localedir)
 #endif
 
 #include "heimqueue.h"
 #include <dispatch/dispatch.h>
 #endif
 
-#if defined(__GNUC__) && defined(HAVE___SYNC_ADD_AND_FETCH)
-
-#define heim_base_atomic_inc(x) __sync_add_and_fetch((x), 1)
-#define heim_base_atomic_dec(x) __sync_sub_and_fetch((x), 1)
-#define heim_base_atomic_type  unsigned int
-#define heim_base_atomic_max    UINT_MAX
-
-#define heim_base_exchange_pointer(t,v) __sync_lock_test_and_set((t), (v))
-
-#elif defined(_WIN32)
-
-#define heim_base_atomic_inc(x) InterlockedIncrement(x)
-#define heim_base_atomic_dec(x) InterlockedDecrement(x)
-#define heim_base_atomic_type  LONG
-#define heim_base_atomic_max    MAXLONG
-
-#define heim_base_exchange_pointer(t,v) InterlockedExchangePointer((t),(v))
-
-#else
-
-#define HEIM_BASE_NEED_ATOMIC_MUTEX 1
-extern HEIMDAL_MUTEX _heim_base_mutex;
-
-#define heim_base_atomic_type  unsigned int
-
-static inline heim_base_atomic_type
-heim_base_atomic_inc(heim_base_atomic_type *x)
-{
-    heim_base_atomic_type t;
-    HEIMDAL_MUTEX_lock(&_heim_base_mutex);
-    t = ++(*x);
-    HEIMDAL_MUTEX_unlock(&_heim_base_mutex);
-    return t;
-}
-
-static inline heim_base_atomic_type
-heim_base_atomic_dec(heim_base_atomic_type *x)
-{
-    heim_base_atomic_type t;
-    HEIMDAL_MUTEX_lock(&_heim_base_mutex);
-    t = --(*x);
-    HEIMDAL_MUTEX_unlock(&_heim_base_mutex);
-    return t;
-}
-
-#define heim_base_atomic_max    UINT_MAX
-
-#endif
-
 /* tagged strings/object/XXX */
 #define heim_base_is_tagged(x) (((uintptr_t)(x)) & 0x3)
 
@@ -127,3 +84,15 @@ heim_base_atomic_dec(heim_base_atomic_type *x)
 #define HEIMDAL_NORETURN_ATTRIBUTE
 #undef HEIMDAL_PRINTF_ATTRIBUTE
 #define HEIMDAL_PRINTF_ATTRIBUTE(x)
+
+struct heim_context_s {
+    heim_log_facility       *log_dest;
+    heim_log_facility       *warn_dest;
+    heim_log_facility       *debug_dest;
+    char                    *time_fmt;
+    unsigned int            log_utc:1;
+    unsigned int            homedir_access:1;
+    struct et_list          *et_list;
+    char                    *error_string;
+    heim_error_code         error_code;
+};