From 335849b9346b2c5902e2daf4f0561bdd1748c25d Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 23 Sep 1999 23:08:42 +0000 Subject: [PATCH] Removed unconditionnal references to snprintf, Daniel. --- ChangeLog | 4 ++++ nanohttp.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6c91ade0..53f04f82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Sep 24 01:06:36 CEST 1999 + + * nanohttp.c: conditionned references to snprintf with HAVE_SNPRINTF + Fri Sep 24 00:15:58 CEST 1999 * libxml.spec.in: fixed the alpha compile problem diff --git a/nanohttp.c b/nanohttp.c index 26dcf3a6..e47d983e 100644 --- a/nanohttp.c +++ b/nanohttp.c @@ -619,8 +619,13 @@ retry: return(NULL); } ctxt->fd = ret; +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf),"GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", ctxt->path, ctxt->hostname); +#else + sprintf(buf, "GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", + ctxt->path, ctxt->hostname); +#endif #ifdef DEBUG_HTTP printf("-> GET %s HTTP/1.0\n-> Host: %s\n\n", ctxt->path, ctxt->hostname); @@ -788,50 +793,102 @@ retry: if (input == NULL) { if (headers == NULL) { if ((contentType == NULL) || (*contentType == NULL)) { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\n\r\n", method, ctxt->path, ctxt->hostname); +#else + sprintf(buf, + "%s %s HTTP/1.0\r\nHost: %s\r\n\r\n", + method, ctxt->path, ctxt->hostname); +#endif } else { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\n\r\n", method, ctxt->path, ctxt->hostname, *contentType); +#else + sprintf(buf, + "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\n\r\n", + method, ctxt->path, ctxt->hostname, *contentType); +#endif } } else { if ((contentType == NULL) || (*contentType == NULL)) { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\n%s\r\n", method, ctxt->path, ctxt->hostname, headers); +#else + sprintf(buf, + "%s %s HTTP/1.0\r\nHost: %s\r\n%s\r\n", + method, ctxt->path, ctxt->hostname, headers); +#endif } else { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\n%s\r\n", method, ctxt->path, ctxt->hostname, *contentType, headers); +#else + sprintf(buf, + "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\n%s\r\n", + method, ctxt->path, ctxt->hostname, *contentType, + headers); +#endif } } } else { int len = strlen(input); if (headers == NULL) { if ((contentType == NULL) || (*contentType == NULL)) { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s", method, ctxt->path, ctxt->hostname, len, input); +#else + sprintf(buf, + "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s", + method, ctxt->path, ctxt->hostname, len, input); +#endif } else { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n%s", method, ctxt->path, ctxt->hostname, *contentType, len, input); +#else + sprintf(buf, +"%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n%s", + method, ctxt->path, ctxt->hostname, *contentType, len, + input); +#endif } } else { if ((contentType == NULL) || (*contentType == NULL)) { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Length: %d\r\n%s\r\n%s", method, ctxt->path, ctxt->hostname, len, headers, input); +#else + sprintf(buf, + "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Length: %d\r\n%s\r\n%s", + method, ctxt->path, ctxt->hostname, len, + headers, input); +#endif } else { +#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), "%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\nContent-Length: %d\r\n%s\r\n%s", method, ctxt->path, ctxt->hostname, *contentType, len, headers, input); +#else + sprintf(buf, +"%s %s HTTP/1.0\r\nHost: %s\r\nContent-Type: %s\r\nContent-Length: %d\r\n%s\r\n%s", + method, ctxt->path, ctxt->hostname, *contentType, + len, headers, input); +#endif } } }