From 58613ea7f3ee3af10948c7f46edf39e440727a17 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 8 Sep 2014 11:12:50 +0400 Subject: [PATCH] fix MSVC build --- src/auth.c | 2 +- src/common.h | 4 +--- src/handler.c | 7 +------ src/md5.h | 9 +-------- src/ostypes.h | 12 +++++++++++- src/sasl.c | 16 +++------------- src/scram.c | 6 +++--- src/scram.h | 3 ++- src/sha1.c | 14 +------------- src/sha1.h | 3 +++ src/util.c | 2 +- src/util.h | 4 ---- 12 files changed, 28 insertions(+), 54 deletions(-) diff --git a/src/auth.c b/src/auth.c index 8d1b947..4cbe461 100644 --- a/src/auth.c +++ b/src/auth.c @@ -25,7 +25,7 @@ #include "common.h" #include "sasl.h" -#ifdef _WIN32 +#ifdef _MSC_VER #define strcasecmp stricmp #endif diff --git a/src/common.h b/src/common.h index 822707f..c0a6834 100644 --- a/src/common.h +++ b/src/common.h @@ -21,12 +21,10 @@ #include #include -#ifndef _WIN32 -#include -#endif #include "strophe.h" +#include "ostypes.h" #include "sock.h" #include "tls.h" #include "hash.h" diff --git a/src/handler.c b/src/handler.c index d382ca8..201e665 100644 --- a/src/handler.c +++ b/src/handler.c @@ -23,14 +23,9 @@ #include #include -#ifndef _WIN32 -#include -#else -#include "ostypes.h" -#endif - #include "strophe.h" #include "common.h" +#include "ostypes.h" /** Fire off all stanza handlers that match. * This function is called internally by the event loop whenever stanzas diff --git a/src/md5.h b/src/md5.h index 1ce4cab..f2a9ac3 100644 --- a/src/md5.h +++ b/src/md5.h @@ -11,15 +11,8 @@ #ifndef MD5_H #define MD5_H -/* we use the uint32_t type from stdint.h - * if it is not available, add a typedef here: - */ /* make sure the stdint.h types are available */ -#if defined(_MSC_VER) /* Microsoft Visual C++ */ - typedef unsigned int uint32_t; -#else -#include -#endif +#include "ostypes.h" struct MD5Context { uint32_t buf[4]; diff --git a/src/ostypes.h b/src/ostypes.h index 0794b2b..d8992a6 100644 --- a/src/ostypes.h +++ b/src/ostypes.h @@ -20,8 +20,18 @@ #ifndef __LIBSTROPHE_OSTYPES_H__ #define __LIBSTROPHE_OSTYPES_H__ -#ifdef _WIN32 +#if defined (_MSC_VER) && _MSC_VER < 1600 +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef __int64 int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; typedef unsigned __int64 uint64_t; +#else +#include #endif #endif /* __LIBSTROPHE_OSTYPES_H__ */ diff --git a/src/sasl.c b/src/sasl.c index f238e1c..b422dbc 100644 --- a/src/sasl.c +++ b/src/sasl.c @@ -21,24 +21,14 @@ #include "strophe.h" #include "common.h" +#include "ostypes.h" #include "sasl.h" #include "md5.h" #include "sha1.h" #include "scram.h" -/* make sure the stdint.h types are available */ -#if defined(_MSC_VER) /* Microsoft Visual C++ */ - typedef signed char int8_t; - typedef short int int16_t; - typedef int int32_t; - typedef __int64 int64_t; - - typedef unsigned char uint8_t; - typedef unsigned short int uint16_t; - typedef unsigned int uint32_t; - /* no uint64_t */ -#else -#include +#ifdef _WIN32 +#define strtok_r strtok_s #endif diff --git a/src/scram.c b/src/scram.c index f31fc77..4bff3f0 100644 --- a/src/scram.c +++ b/src/scram.c @@ -20,10 +20,10 @@ */ #include -#include #include #include "sha1.h" +#include "ostypes.h" #include "scram.h" @@ -36,8 +36,8 @@ static const uint8_t ipad = 0x36; static const uint8_t opad = 0x5C; -static inline void SHA1(const uint8_t* data, size_t len, - uint8_t digest[SHA1_DIGEST_SIZE]) +static void SHA1(const uint8_t* data, size_t len, + uint8_t digest[SHA1_DIGEST_SIZE]) { SHA1_CTX ctx; SHA1_Init(&ctx); diff --git a/src/scram.h b/src/scram.h index c25814d..a40f83d 100644 --- a/src/scram.h +++ b/src/scram.h @@ -19,7 +19,8 @@ #ifndef __LIBSTROPHE_SCRAM_H__ #define __LIBSTROPHE_SCRAM_H__ -#include +/* make sure the stdint.h types are available */ +#include "ostypes.h" #include "sha1.h" diff --git a/src/sha1.c b/src/sha1.c index 9c0ea9c..21cad40 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -86,19 +86,7 @@ A million repetitions of "a" #include /* make sure the stdint.h types are available */ -#if defined(_MSC_VER) /* Microsoft Visual C++ */ - typedef signed char int8_t; - typedef short int int16_t; - typedef int int32_t; - typedef __int64 int64_t; - - typedef unsigned char uint8_t; - typedef unsigned short int uint16_t; - typedef unsigned int uint32_t; - /* no uint64_t */ -#else -#include -#endif +#include "ostypes.h" #include "sha1.h" diff --git a/src/sha1.h b/src/sha1.h index b637f66..10266cb 100644 --- a/src/sha1.h +++ b/src/sha1.h @@ -12,6 +12,9 @@ extern "C" { #endif +/* make sure the stdint.h types are available */ +#include "ostypes.h" + typedef struct { uint32_t state[5]; uint32_t count[2]; diff --git a/src/util.c b/src/util.c index c442fe7..cf9e9ff 100644 --- a/src/util.c +++ b/src/util.c @@ -24,11 +24,11 @@ #else #include #include -#include #endif #include "strophe.h" #include "common.h" +#include "ostypes.h" #include "util.h" /** implement our own strdup that uses the ctx allocator */ diff --git a/src/util.h b/src/util.h index dc00381..8bda48c 100644 --- a/src/util.h +++ b/src/util.h @@ -19,11 +19,7 @@ #ifndef __LIBSTROPHE_UTIL_H__ #define __LIBSTROPHE_UTIL_H__ -#ifndef _WIN32 -#include -#else #include "ostypes.h" -#endif /* timing functions */ uint64_t time_stamp(void);