From 3a9ae348bcce79ee87633d0e302eae8d4719d587 Mon Sep 17 00:00:00 2001 From: Marcelo Roberto Jimenez Date: Fri, 11 Mar 2011 17:20:17 -0300 Subject: [PATCH] Created the macros PRIzd and PRIzx to deal with MSVC lack of C99. Thanks to Iain Denniston for pointing it out. --- ChangeLog | 7 +++++++ upnp/inc/UpnpGlobal.h | 14 ++++++++++++-- upnp/src/genlib/net/http/httpreadwrite.c | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a48f08..3ae0475 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,10 +2,17 @@ Version 1.6.13 ******************************************************************************* +2011-03-11 Marcelo Roberto Jimenez + + Created the macros PRIzd and PRIzx to deal with MSVC lack of C99. + Thanks to Iain Denniston for pointing it out. + 2011-03-08 Iain Denniston + Fixes for headers when compiled under C++ 2011-03-08 Iain Denniston + Fix for uuid_unpack incorrect shift precedence. ******************************************************************************* diff --git a/upnp/inc/UpnpGlobal.h b/upnp/inc/UpnpGlobal.h index fef8e7d..f1bb457 100644 --- a/upnp/inc/UpnpGlobal.h +++ b/upnp/inc/UpnpGlobal.h @@ -34,14 +34,18 @@ /* * UPNP_INLINE * PRId64 + * PRIzd * PRIzu + * PRIzx */ #ifdef UPNP_USE_MSVCPP /* define some things the M$ VC++ doesn't know */ #define UPNP_INLINE typedef __int64 int64_t; #define PRId64 "I64d" + #define PRIzd "ld" #define PRIzu "lu" + #define PRIzx "lx" #endif /* UPNP_USE_MSVCPP */ #ifdef UPNP_USE_BCBPP @@ -51,7 +55,9 @@ #warning The Borland C compiler is probably broken on PRId64, #warning please someone provide a proper fix here #define PRId64 "I64d" + #define PRIzd "zd" #define PRIzu "zu" + #define PRIzx "zx" #endif /* UPNP_USE_BCBPP */ #ifdef __GNUC__ @@ -60,7 +66,9 @@ * runtime printf which ends up getting called, not the glibc * printf, so it genuinely doesn't have "zu" */ + #define PRIzd "ld" #define PRIzu "lu" + #define PRIzx "lx" #endif /* __GNUC__ */ #else /*! @@ -93,13 +101,15 @@ /* #define PRId64 PRId64 */ /*! - * \brief Supply the PRIzu printf() macro. + * \brief Supply the PRIz* printf() macros. * - * This macro was invented so that we can live a little longer with + * These macros were invented so that we can live a little longer with * MSVC lack of C99. "z" is the correct printf() size specifier for * the size_t type. */ + #define PRIzd "zd" #define PRIzu "zu" + #define PRIzx "zx" #endif /* diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index 13b34ed..c4a2b34 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -446,7 +446,7 @@ int http_SendMessage(SOCKINFO *info, int *TimeOut, const char *fmt, ...) /* Copy CRLF at the end of the chunk */ memcpy(file_buf + num_read, "\r\n", 2); /* Hex length for the chunk size. */ - sprintf(Chunk_Header, "%zx", num_read); + sprintf(Chunk_Header, "%" PRIzx, num_read); /*itoa(num_read,Chunk_Header,16); */ strcat(Chunk_Header, "\r\n"); /* Copy the chunk size header */ @@ -850,7 +850,7 @@ int http_WriteHttpPost( IN void *Handle, if (!tempbuf) return UPNP_E_OUTOF_MEMORY; /* begin chunk */ - sprintf(tempbuf, "%zx\r\n", *size); + sprintf(tempbuf, "%" PRIzx "\r\n", *size); tempSize = strlen(tempbuf); memcpy(tempbuf + tempSize, buf, *size); memcpy(tempbuf + tempSize + *size, "\r\n", 2);