libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 54edb3cd8fb0d8269cbfa29a67a4c2055386d1c6
parent 913ced4bdd28c16b62e1847cb035b6036b569ffc
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 22 Dec 2014 19:42:18 +0000

Replace snprintf with platform-independent macro

Diffstat:
Msrc/include/platform_interface.h | 7+++++++
Msrc/microhttpd/basicauth.c | 2+-
Msrc/microhttpd/connection.c | 2+-
Msrc/microhttpd/digestauth.c | 4++--
4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/include/platform_interface.h b/src/include/platform_interface.h @@ -72,6 +72,13 @@ #define MHD_str_equal_caseless_n_(a,b,n) (0==_strnicmp((a),(b),(n))) #endif +/* Platform-independent snprintf name */ +#if !defined(_WIN32) || defined(__CYGWIN__) +#define MHD_snprintf_ snprintf +#else +#define MHD_snprintf_ W32_snprintf +#endif + /* MHD_socket_close_(fd) close any FDs (non-W32) / close only socket FDs (W32) */ diff --git a/src/microhttpd/basicauth.c b/src/microhttpd/basicauth.c @@ -121,7 +121,7 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, size_t hlen = strlen(realm) + strlen("Basic realm=\"\"") + 1; char header[hlen]; - snprintf (header, + MHD_snprintf_ (header, sizeof (header), "Basic realm=\"%s\"", realm); diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -476,7 +476,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) } if (ret > 0xFFFFFF) ret = 0xFFFFFF; - snprintf (cbuf, + MHD_snprintf_ (cbuf, sizeof (cbuf), "%X\r\n", (unsigned int) ret); cblen = strlen (cbuf); diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c @@ -791,7 +791,7 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection, return MHD_NO; } /* Building the authentication header */ - hlen = snprintf (NULL, + hlen = MHD_snprintf_(NULL, 0, "Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"%s", realm, @@ -803,7 +803,7 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection, { char header[hlen + 1]; - snprintf (header, + MHD_snprintf_(header, sizeof(header), "Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"%s", realm,