Windows acceptor build fixes
[moonshot.git] / moonshot / mech_eap / util.h
index 04fa4b9..1ebc452 100644 (file)
@@ -85,7 +85,7 @@ extern "C" {
 #define MIN(_a,_b)  ((_a)<(_b)?(_a):(_b))
 #endif
 
-#if !defined(WIN32) && (!(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)))
+#if !defined(WIN32) && !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
 #define GSSEAP_UNUSED __attribute__ ((__unused__))
 #else
 #define GSSEAP_UNUSED
@@ -776,21 +776,29 @@ verifyTokenHeader(OM_uint32 *minor,
 
 #include <winbase.h>
 
-#define GSSEAP_MUTEX                    CRITICAL_SECTION
+#define GSSEAP_GET_LAST_ERROR()         (GetLastError()) /* XXX FIXME */
 
+#define GSSEAP_MUTEX                    CRITICAL_SECTION
 #define GSSEAP_MUTEX_INIT(m)            (InitializeCriticalSection((m)), 0)
 #define GSSEAP_MUTEX_DESTROY(m)         DeleteCriticalSection((m))
 #define GSSEAP_MUTEX_LOCK(m)            EnterCriticalSection((m))
 #define GSSEAP_MUTEX_UNLOCK(m)          LeaveCriticalSection((m))
+#define GSSEAP_ONCE_LEAVE              do { return TRUE; } while (0)
 
-/* XXX yet to implement thread-local wrappers */
+/* Thread-local is handled separately */
+
+#define GSSEAP_THREAD_ONCE              INIT_ONCE
+#define GSSEAP_ONCE_CALLBACK(cb)        BOOL CALLBACK cb(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context)
+#define GSSEAP_ONCE(o, i)               InitOnceExecuteOnce((o), (i), NULL, NULL)
+#define GSSEAP_ONCE_INITIALIZER         INIT_ONCE_STATIC_INIT
 
 #else
 
 #include <pthread.h>
 
-#define GSSEAP_MUTEX                    pthread_mutex_t
+#define GSSEAP_GET_LAST_ERROR()         (errno)
 
+#define GSSEAP_MUTEX                    pthread_mutex_t
 #define GSSEAP_MUTEX_INIT(m)            pthread_mutex_init((m), NULL)
 #define GSSEAP_MUTEX_DESTROY(m)         pthread_mutex_destroy((m))
 #define GSSEAP_MUTEX_LOCK(m)            pthread_mutex_lock((m))
@@ -802,8 +810,10 @@ verifyTokenHeader(OM_uint32 *minor,
 #define GSSEAP_SETSPECIFIC(k, d)        pthread_setspecific((k), (d))
 
 #define GSSEAP_THREAD_ONCE              pthread_once_t
+#define GSSEAP_ONCE_CALLBACK(cb)        void cb(void)
 #define GSSEAP_ONCE(o, i)               pthread_once((o), (i))
 #define GSSEAP_ONCE_INITIALIZER         PTHREAD_ONCE_INIT
+#define GSSEAP_ONCE_LEAVE              do { } while (0)
 
 #endif /* WIN32 */
 
@@ -956,13 +966,32 @@ gssBufferToKrbData(gss_buffer_t buffer, krb5_data *data)
     data->length = buffer->length;
 }
 
+/* util_tld.c */
+struct gss_eap_status_info;
+
+struct gss_eap_thread_local_data {
+    krb5_context krbContext;
+    struct gss_eap_status_info *statusInfo;
+};
+
+struct gss_eap_thread_local_data *
+gssEapGetThreadLocalData(void);
+
+void
+gssEapDestroyStatusInfo(struct gss_eap_status_info *status);
+
+void
+gssEapDestroyKrbContext(krb5_context context);
+
 #ifdef __cplusplus
 }
 #endif
 
+#ifdef GSSEAP_ENABLE_ACCEPTOR
 #include "util_json.h"
 #include "util_attr.h"
 #include "util_base64.h"
+#endif /* GSSEAP_ENABLE_ACCEPTOR */
 #ifdef GSSEAP_ENABLE_REAUTH
 #include "util_reauth.h"
 #endif