libmicrohttpd

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

commit 46a4adb3a2abf2666eaa5586884ac543ec2e283d
parent 45e7e0d0e95962c90b78eea44981774634c52893
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 20 Dec 2010 20:24:17 +0000

mantis 1631

Diffstat:
MChangeLog | 5+++++
Mdoc/microhttpd.texi | 14++++++++++++++
Msrc/daemon/connection.c | 8++++----
Msrc/daemon/daemon.c | 4++--
Msrc/examples/fileserver_example_external_select.c | 2+-
Msrc/include/microhttpd.h | 19++++++++++++++++++-
6 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +Mon Dec 20 21:22:57 CET 2010 + Added macro MHD_LONG_LONG to allow change of MHD's "long long" use + to some other type on platforms that do not support "long long" + (Mantis #1631). -CG/bplant + Sun Dec 19 19:54:15 CET 2010 Added 'MHD_create_response_from_fd_at_offset'. -CG diff --git a/doc/microhttpd.texi b/doc/microhttpd.texi @@ -245,6 +245,20 @@ ignore_sigpipe () } @end verbatim +@section MHD_LONG_LONG +@cindex long long +@cindex IAR +@cindex ARM +@cindex cortex m3 + +Some platforms do not support @code{long long}. Hence MHD defines +a macro @code{MHD_LONG_LONG} which will default to @code{long long}. +If your platform does not support @code{long long}, you should +change "platform.h" to define @code{MHD_LONG_LONG} to an appropriate +alternative type and also define @code{MHD_LONG_LONG_PRINTF} to the +corresponding format string for printing such a data type (without +the percent sign). + @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -526,8 +526,8 @@ add_extra_headers (struct MHD_Connection *connection) MHD_HTTP_HEADER_CONTENT_LENGTH)) { SPRINTF (buf, - "%llu", - (unsigned long long)connection->response->total_size); + "%" MHD_LONG_LONG_PRINTF "u", + (unsigned MHD_LONG_LONG)connection->response->total_size); MHD_add_response_header (connection->response, MHD_HTTP_HEADER_CONTENT_LENGTH, buf); } @@ -1641,7 +1641,7 @@ static void parse_connection_headers (struct MHD_Connection *connection) { const char *clen; - unsigned long long cval; + unsigned MHD_LONG_LONG cval; struct MHD_Response *response; const char *enc; @@ -1675,7 +1675,7 @@ parse_connection_headers (struct MHD_Connection *connection) MHD_HTTP_HEADER_CONTENT_LENGTH); if (clen != NULL) { - if (1 != SSCANF (clen, "%llu", &cval)) + if (1 != SSCANF (clen, "%" MHD_LONG_LONG_PRINTF "u", &cval)) { #if HAVE_MESSAGES MHD_DLOG (connection->daemon, diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -1088,7 +1088,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) * necessiate the use of a timeout right now). */ int -MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout) +MHD_get_timeout (struct MHD_Daemon *daemon, unsigned MHD_LONG_LONG *timeout) { time_t earliest_deadline; time_t now; @@ -1140,7 +1140,7 @@ MHD_select (struct MHD_Daemon *daemon, int may_block) fd_set es; int max; struct timeval timeout; - unsigned long long ltimeout; + unsigned MHD_LONG_LONG ltimeout; int ds; timeout.tv_sec = 0; diff --git a/src/examples/fileserver_example_external_select.c b/src/examples/fileserver_example_external_select.c @@ -110,7 +110,7 @@ main (int argc, char *const *argv) fd_set ws; fd_set es; int max; - unsigned long long mhd_timeout; + unsigned MHD_LONG_LONG mhd_timeout; if (argc != 3) { diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -141,6 +141,22 @@ extern "C" #define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1) #endif +/** + * Not all architectures and printf's support the long long type. + * This gives the ability to replace long long with just a long, + * standard int or a short. + */ +#ifndef MHD_LONG_LONG +#define MHD_LONG_LONG long long +#endif +#ifndef MHD_LONG_LONG_PRINTF +/** + * Format string for printing a variable of type 'MHD_LONG_LONG'. + * You should only redefine this if you also define MHD_LONG_LONG. + */ +#define MHD_LONG_LONG_PRINTF "ll" +#endif + /** * HTTP response codes. @@ -1035,7 +1051,8 @@ MHD_get_fdset (struct MHD_Daemon *daemon, * not used (or no connections exist that would * necessiate the use of a timeout right now). */ -int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout); +int MHD_get_timeout (struct MHD_Daemon *daemon, + unsigned MHD_LONG_LONG *timeout); /**