Author: gsim Date: Fri Oct 10 12:59:02 2014 New Revision: 1630874 URL: http://svn.apache.org/r1630874 Log: PROTON-660: Fix openssl.c build on windows
Modified: qpid/proton/branches/examples/proton-c/src/platform.h qpid/proton/branches/examples/proton-c/src/ssl/openssl.c qpid/proton/branches/examples/proton-c/src/util.c qpid/proton/branches/examples/proton-c/src/util.h Modified: qpid/proton/branches/examples/proton-c/src/platform.h URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/src/platform.h?rev=1630874&r1=1630873&r2=1630874&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-c/src/platform.h (original) +++ qpid/proton/branches/examples/proton-c/src/platform.h Fri Oct 10 12:59:02 2014 @@ -78,10 +78,20 @@ int64_t pn_i_atoll(const char* num); * Provide the expected C99 behavior for these functions. */ #include <stdio.h> + #define snprintf pn_i_snprintf #define vsnprintf pn_i_vsnprintf + int pn_i_snprintf(char *buf, size_t count, const char *fmt, ...); int pn_i_vsnprintf(char *buf, size_t count, const char *fmt, va_list ap); + +#define strcasecmp(A,B) (!pni_eq_nocase(A,B)) +#define strncasecmp(A,B,C) (!pni_eq_n_nocase(A,B,C)) + +#if !defined(S_ISDIR) +# define S_ISDIR(X) ((X) & _S_IFDIR) +#endif + #endif #if defined _MSC_VER || defined _OPENVMS Modified: qpid/proton/branches/examples/proton-c/src/ssl/openssl.c URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/src/ssl/openssl.c?rev=1630874&r1=1630873&r2=1630874&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-c/src/ssl/openssl.c (original) +++ qpid/proton/branches/examples/proton-c/src/ssl/openssl.c Fri Oct 10 12:59:02 2014 @@ -25,6 +25,22 @@ #include "platform.h" #include "util.h" +// openssl on windows expects the user to have already included +// winsock.h + +#ifdef _MSC_VER +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif +#if _WIN32_WINNT < 0x0501 +#error "Proton requires Windows API support for XP or later." +#endif +#include <winsock2.h> +#include <mswsock.h> +#include <Ws2tcpip.h> +#endif + + #include <openssl/ssl.h> #include <openssl/dh.h> #include <openssl/err.h> Modified: qpid/proton/branches/examples/proton-c/src/util.c URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/src/util.c?rev=1630874&r1=1630873&r2=1630874&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-c/src/util.c (original) +++ qpid/proton/branches/examples/proton-c/src/util.c Fri Oct 10 12:59:02 2014 @@ -213,7 +213,7 @@ void pni_fatal(const char *fmt, ...) va_end(ap); } -static bool pn_i_eq_nocase(const char *a, const char *b) +bool pni_eq_nocase(const char *a, const char *b) { while (*b) { if (tolower(*a++) != tolower(*b++)) @@ -222,11 +222,20 @@ static bool pn_i_eq_nocase(const char *a return !(*a); } +bool pni_eq_n_nocase(const char *a, const char *b, int len) +{ + while (*b && len-- > 0 ) { + if (tolower(*a++) != tolower(*b++)) + return false; + } + return !(*a) && !(*b); +} + bool pn_env_bool(const char *name) { char *v = getenv(name); - return v && (pn_i_eq_nocase(v, "true") || pn_i_eq_nocase(v, "1") || - pn_i_eq_nocase(v, "yes") || pn_i_eq_nocase(v, "on")); + return v && (pni_eq_nocase(v, "true") || pni_eq_nocase(v, "1") || + pni_eq_nocase(v, "yes") || pni_eq_nocase(v, "on")); } char *pn_strdup(const char *src) Modified: qpid/proton/branches/examples/proton-c/src/util.h URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/src/util.h?rev=1630874&r1=1630873&r2=1630874&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-c/src/util.h (original) +++ qpid/proton/branches/examples/proton-c/src/util.h Fri Oct 10 12:59:02 2014 @@ -40,6 +40,8 @@ PN_EXTERN ssize_t pn_quote_data(char *ds int pn_quote(pn_string_t *dst, const char *src, size_t size); PN_EXTERN void pn_fprint_data(FILE *stream, const char *bytes, size_t size); PN_EXTERN void pn_print_data(const char *bytes, size_t size); +bool pni_eq_nocase(const char *a, const char *b); +bool pni_eq_n_nocase(const char *a, const char *b, int len); bool pn_env_bool(const char *name); pn_timestamp_t pn_timestamp_min(pn_timestamp_t a, pn_timestamp_t b); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org