From e6fa890d3dca6e02556d7d8b922e5108b1bb6116 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Tue, 14 Jun 2005 22:35:15 +0000 Subject: [PATCH] Minor fixes for Win32 build. It now builds, but doesn't link. --- src/ctx.c | 10 +++++++--- src/event.c | 2 ++ src/handler.c | 5 +++++ src/ostypes.h | 22 ++++++++++++++++++++++ src/sock.c | 1 + src/sock.h | 1 + src/stanza.c | 14 +++++++++----- src/util.h | 2 ++ 8 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 src/ostypes.h diff --git a/src/ctx.c b/src/ctx.c index 9fff62d..ad3e6c4 100644 --- a/src/ctx.c +++ b/src/ctx.c @@ -21,6 +21,10 @@ #include "common.h" #include "util.h" +#ifdef _WIN32 +#define vsnprintf _vsnprintf +#endif + /** version **/ /* TODO: update from the build system? */ @@ -75,10 +79,10 @@ void *xmpp_alloc(const xmpp_ctx_t * const ctx, const size_t size) void xmpp_free(const xmpp_ctx_t * const ctx, void *p) { - return ctx->mem->free(p); + ctx->mem->free(p); } -void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p, +void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p, const size_t size) { return ctx->mem->realloc(p, size); @@ -86,7 +90,7 @@ void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p, /* logger */ -void xmpp_log(const xmpp_ctx_t * const ctx, +void xmpp_log(const xmpp_ctx_t * const ctx, const xmpp_log_level_t level, const char * const area, const char * const fmt, diff --git a/src/event.c b/src/event.c index e174bf3..bafc650 100644 --- a/src/event.c +++ b/src/event.c @@ -16,7 +16,9 @@ #include #include +#ifndef _WIN32 #include +#endif #include "strophe.h" #include "common.h" diff --git a/src/handler.c b/src/handler.c index 47fcaa9..4ef4323 100644 --- a/src/handler.c +++ b/src/handler.c @@ -15,7 +15,12 @@ #include #include #include + +#ifndef _WIN32 #include +#else +#include "ostypes.h" +#endif #include "strophe.h" #include "common.h" diff --git a/src/ostypes.h b/src/ostypes.h new file mode 100644 index 0000000..5181790 --- /dev/null +++ b/src/ostypes.h @@ -0,0 +1,22 @@ +/* ostypes.h +** XMPP client library -- type definitions for platforms without stdint.h +** +** Copyright (C) 2005 OGG, LCC. All rights reserved. +** +** This software is provided AS-IS with no warranty, either express +** or implied. +** +** This software is distributed under license and may not be copied, +** modified or distributed except as expressly authorized under the +** terms of the license contained in the file LICENSE.txt in this +** distribution. +*/ + +#ifndef __LIBSTROPHE_OSTYPES_H__ +#define __LIBSTROPHE_OSTYPES_H__ + +#ifdef _WIN32 +typedef unsigned __int64 uint64_t; +#endif + +#endif /* __LIBSTROPHE_OSTYPES_H__ */ diff --git a/src/sock.c b/src/sock.c index 2c1ad8a..62d9a3b 100644 --- a/src/sock.c +++ b/src/sock.c @@ -18,6 +18,7 @@ #ifdef _WIN32 #include +#include #define snprintf _snprintf #else #include diff --git a/src/sock.h b/src/sock.h index 37edf38..b8b25b0 100644 --- a/src/sock.h +++ b/src/sock.h @@ -20,6 +20,7 @@ #ifndef _WIN32 typedef int sock_t; #else +#include typedef SOCKET sock_t; #endif diff --git a/src/stanza.c b/src/stanza.c index 0fa50fb..f838953 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -19,6 +19,10 @@ #include "common.h" #include "hash.h" +#ifdef _WIN32 +#define inline __inline +#endif + /* allocate an initialize a blank stanza */ xmpp_stanza_t *xmpp_stanza_new(xmpp_ctx_t *ctx) { @@ -82,7 +86,7 @@ xmpp_stanza_t *xmpp_stanza_copy(const xmpp_stanza_t * const stanza) iter = hash_iter_new(stanza->attributes); if (!iter) { printf("DEBUG HERE\n"); goto copy_error; } while ((key = hash_iter_next(iter))) { - val = xmpp_strdup(stanza->ctx, + val = xmpp_strdup(stanza->ctx, (char *)hash_get(stanza->attributes, key)); if (!val) goto copy_error; @@ -153,8 +157,8 @@ static inline void _render_update(int *written, const int length, } } -/* always returns number of bytes written or that would have been - * written if the buffer was large enough +/* always returns number of bytes written or that would have been + * written if the buffer was large enough * return values < 0 indicate some error occured, * and return values > buflen indicate buffer was not large enough */ @@ -303,7 +307,7 @@ char *xmpp_stanza_get_name(xmpp_stanza_t * const stanza) /* convinience function to copy attributes from the xml parser * callback into a stanza. this replaces all previous attributes */ -void xmpp_stanza_set_attributes(xmpp_stanza_t *stanza, +void xmpp_stanza_set_attributes(xmpp_stanza_t * const stanza, const char * const * const attr) { int i; @@ -311,7 +315,7 @@ void xmpp_stanza_set_attributes(xmpp_stanza_t *stanza, if (stanza->attributes != NULL) hash_release(stanza->attributes); - + stanza->attributes = hash_new(stanza->ctx, 8, xmpp_free); if (!stanza->attributes) return; diff --git a/src/util.h b/src/util.h index ecc1e41..ef6ee2e 100644 --- a/src/util.h +++ b/src/util.h @@ -17,6 +17,8 @@ #ifndef _WIN32 #include +#else +#include "ostypes.h" #endif /* timing functions */