From: Alexey Melnikov Date: Fri, 10 Jun 2011 11:46:59 +0000 (+0100) Subject: Some initial Windows portability fixes in include files X-Git-Tag: tr-beta1~106^2~20 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=moonshot.git;a=commitdiff_plain;h=3233c43e48aeeddfa03bce5064708b0e13e1e579 Some initial Windows portability fixes in include files --- diff --git a/moonshot/mech_eap/gssapiP_eap.h b/moonshot/mech_eap/gssapiP_eap.h index 503ac52..372737a 100644 --- a/moonshot/mech_eap/gssapiP_eap.h +++ b/moonshot/mech_eap/gssapiP_eap.h @@ -42,11 +42,15 @@ #include #include #include +#if !defined(WIN32) #include +#endif #include #include #include +#if !defined(WIN32) #include +#endif /* GSS headers */ #include diff --git a/moonshot/mech_eap/util.h b/moonshot/mech_eap/util.h index 906a229..17539a7 100644 --- a/moonshot/mech_eap/util.h +++ b/moonshot/mech_eap/util.h @@ -61,12 +61,22 @@ #ifndef _UTIL_H_ #define _UTIL_H_ 1 +#if !defined(WIN32) #include +#endif #include #include #include +#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;