Some initial Windows portability fixes in include files
authorAlexey Melnikov <alexey.melnikov@isode.com>
Fri, 10 Jun 2011 11:46:59 +0000 (12:46 +0100)
committerSam Hartman <hartmans@debian.org>
Fri, 1 Jul 2011 10:18:07 +0000 (06:18 -0400)
moonshot/mech_eap/gssapiP_eap.h
moonshot/mech_eap/util.h

index 503ac52..372737a 100644 (file)
 #include <assert.h>
 #include <string.h>
 #include <errno.h>
+#if !defined(WIN32)
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <stdarg.h>
 #include <time.h>
+#if !defined(WIN32)
 #include <sys/param.h>
+#endif
 
 /* GSS headers */
 #include <gssapi/gssapi.h>
index 906a229..17539a7 100644 (file)
 #ifndef _UTIL_H_
 #define _UTIL_H_ 1
 
+#if !defined(WIN32)
 #include <sys/param.h>
+#endif
 #include <string.h>
 #include <errno.h>
 
 #include <krb5.h>
 
+#if defined(WIN32)
+#define INLINE  __inline
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+#else
+#define INLINE inline
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -97,14 +107,14 @@ duplicateBuffer(OM_uint32 *minor,
                 const gss_buffer_t src,
                 gss_buffer_t dst);
 
-static inline int
+static INLINE int
 bufferEqual(const gss_buffer_t b1, const gss_buffer_t b2)
 {
     return (b1->length == b2->length &&
             memcmp(b1->value, b2->value, b2->length) == 0);
 }
 
-static inline int
+static INLINE int
 bufferEqualString(const gss_buffer_t b1, const char *s)
 {
     gss_buffer_desc b2;
@@ -528,7 +538,7 @@ duplicateOidSet(OM_uint32 *minor,
                 const gss_OID_set src,
                 gss_OID_set *dst);
 
-static inline int
+static INLINE int
 oidEqual(const gss_OID_desc *o1, const gss_OID_desc *o2)
 {
     if (o1 == GSS_C_NO_OID)
@@ -699,7 +709,7 @@ verifyTokenHeader(OM_uint32 *minor,
 #define GSSEAP_ONCE_INITIALIZER         PTHREAD_ONCE_INIT
 
 /* Helper functions */
-static inline void
+static INLINE void
 store_uint16_be(uint16_t val, void *vp)
 {
     unsigned char *p = (unsigned char *)vp;
@@ -708,7 +718,7 @@ store_uint16_be(uint16_t val, void *vp)
     p[1] = (val      ) & 0xff;
 }
 
-static inline uint16_t
+static INLINE uint16_t
 load_uint16_be(const void *cvp)
 {
     const unsigned char *p = (const unsigned char *)cvp;
@@ -716,7 +726,7 @@ load_uint16_be(const void *cvp)
     return (p[1] | (p[0] << 8));
 }
 
-static inline void
+static INLINE void
 store_uint32_be(uint32_t val, void *vp)
 {
     unsigned char *p = (unsigned char *)vp;
@@ -727,7 +737,7 @@ store_uint32_be(uint32_t val, void *vp)
     p[3] = (val      ) & 0xff;
 }
 
-static inline uint32_t
+static INLINE uint32_t
 load_uint32_be(const void *cvp)
 {
     const unsigned char *p = (const unsigned char *)cvp;
@@ -737,7 +747,7 @@ load_uint32_be(const void *cvp)
             | ((uint32_t) p[0] << 24));
 }
 
-static inline void
+static INLINE void
 store_uint64_be(uint64_t val, void *vp)
 {
     unsigned char *p = (unsigned char *)vp;
@@ -752,7 +762,7 @@ store_uint64_be(uint64_t val, void *vp)
     p[7] = (unsigned char)((val      ) & 0xff);
 }
 
-static inline uint64_t
+static INLINE uint64_t
 load_uint64_be(const void *cvp)
 {
     const unsigned char *p = (const unsigned char *)cvp;
@@ -760,7 +770,7 @@ load_uint64_be(const void *cvp)
     return ((uint64_t)load_uint32_be(p) << 32) | load_uint32_be(p + 4);
 }
 
-static inline unsigned char *
+static INLINE unsigned char *
 store_buffer(gss_buffer_t buffer, void *vp, int wide_nums)
 {
     unsigned char *p = (unsigned char *)vp;
@@ -781,7 +791,7 @@ store_buffer(gss_buffer_t buffer, void *vp, int wide_nums)
     return p;
 }
 
-static inline unsigned char *
+static INLINE unsigned char *
 load_buffer(const void *cvp, size_t length, gss_buffer_t buffer)
 {
     buffer->length = 0;
@@ -793,7 +803,7 @@ load_buffer(const void *cvp, size_t length, gss_buffer_t buffer)
     return (unsigned char *)cvp + length;
 }
 
-static inline unsigned char *
+static INLINE unsigned char *
 store_oid(gss_OID oid, void *vp)
 {
     gss_buffer_desc buf;
@@ -809,14 +819,14 @@ store_oid(gss_OID oid, void *vp)
     return store_buffer(&buf, vp, FALSE);
 }
 
-static inline void
+static INLINE void
 krbDataToGssBuffer(krb5_data *data, gss_buffer_t buffer)
 {
     buffer->value = (void *)data->data;
     buffer->length = data->length;
 }
 
-static inline void
+static INLINE void
 krbPrincComponentToGssBuffer(krb5_principal krbPrinc,
                              int index, gss_buffer_t buffer)
 {
@@ -829,7 +839,7 @@ krbPrincComponentToGssBuffer(krb5_principal krbPrinc,
 #endif /* HAVE_HEIMDAL_VERSION */
 }
 
-static inline void
+static INLINE void
 krbPrincRealmToGssBuffer(krb5_principal krbPrinc, gss_buffer_t buffer)
 {
 #ifdef HAVE_HEIMDAL_VERSION
@@ -840,7 +850,7 @@ krbPrincRealmToGssBuffer(krb5_principal krbPrinc, gss_buffer_t buffer)
 #endif
 }
 
-static inline void
+static INLINE void
 gssBufferToKrbData(gss_buffer_t buffer, krb5_data *data)
 {
     data->data = (char *)buffer->value;