libmicrohttpd

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

commit b90c37b2f38d97952613e26627b3e8ebf9932112
parent 8c8db696a0b7974b432100b8f4466f11163b66cc
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  6 Feb 2009 06:12:33 +0000

incompatible API change to allow 64-bit uploads and downloads on 32-bit systems

Diffstat:
MChangeLog | 14++++++++++++++
Mconfigure.ac | 4++--
Mdoc/chapters/basicauthentication.inc | 2+-
Mdoc/chapters/exploringrequests.inc | 2+-
Mdoc/chapters/hellobrowser.inc | 2+-
Mdoc/chapters/largerpost.inc | 4++--
Mdoc/chapters/processingpost.inc | 4++--
Mdoc/chapters/responseheaders.inc | 2+-
Mdoc/examples/basicauthentication.c | 2+-
Mdoc/examples/hellobrowser.c | 2+-
Mdoc/examples/largepost.c | 4++--
Mdoc/examples/logging.c | 2+-
Mdoc/examples/responseheaders.c | 2+-
Mdoc/examples/simplepost.c | 4++--
Mdoc/examples/tlsauthentication.c | 2+-
Mdoc/microhttpd.texi | 18+++++++++---------
Msrc/daemon/connection.c | 13+++++++------
Msrc/daemon/daemon.c | 2+-
Msrc/daemon/daemon_test.c | 2+-
Msrc/daemon/internal.c | 2+-
Msrc/daemon/internal.h | 12++++++------
Msrc/daemon/memorypool.c | 21+++++++++++++--------
Msrc/daemon/memorypool.h | 13++++++++-----
Msrc/daemon/postprocessor.c | 44+++++++++++++++++++++++---------------------
Msrc/daemon/postprocessor_large_test.c | 4++--
Msrc/daemon/postprocessor_test.c | 2+-
Msrc/daemon/response.c | 6+++---
Msrc/examples/fileserver_example.c | 2+-
Msrc/examples/fileserver_example_external_select.c | 2+-
Msrc/examples/https_fileserver_example.c | 4++--
Msrc/examples/minimal_example_comet.c | 4++--
Msrc/include/microhttpd.h | 28+++++++++++++++-------------
Msrc/include/platform.h | 3++-
Msrc/testcurl/daemon_options_test.c | 2+-
Msrc/testcurl/daemontest_get.c | 3++-
Msrc/testcurl/daemontest_get_chunked.c | 5+++--
Msrc/testcurl/daemontest_large_put.c | 3++-
Msrc/testcurl/daemontest_long_header.c | 3++-
Msrc/testcurl/daemontest_parse_cookies.c | 3++-
Msrc/testcurl/daemontest_post.c | 5+++--
Msrc/testcurl/daemontest_post_loop.c | 3++-
Msrc/testcurl/daemontest_postform.c | 5+++--
Msrc/testcurl/daemontest_process_arguments.c | 3++-
Msrc/testcurl/daemontest_process_headers.c | 3++-
Msrc/testcurl/daemontest_put.c | 3++-
Msrc/testcurl/daemontest_put_chunked.c | 3++-
Msrc/testcurl/https/mhds_session_info_test.c | 2+-
Msrc/testcurl/https/tls_cipher_change_test.c | 2+-
Msrc/testcurl/https/tls_test_common.c | 7+++----
Msrc/testzzuf/daemontest_get.c | 3++-
Msrc/testzzuf/daemontest_get_chunked.c | 5+++--
Msrc/testzzuf/daemontest_large_put.c | 3++-
Msrc/testzzuf/daemontest_long_header.c | 3++-
Msrc/testzzuf/daemontest_post.c | 5+++--
Msrc/testzzuf/daemontest_postform.c | 5+++--
Msrc/testzzuf/daemontest_put.c | 3++-
Msrc/testzzuf/daemontest_put_chunked.c | 3++-
57 files changed, 183 insertions(+), 136 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,17 @@ +Thu Feb 5 22:43:45 MST 2009 + Incompatible API change to allow 64-bit uploads and downloads. + Clients must use "uint64_t" for the "pos" + argument (MHD_ContentReaderCallback) and the "off" + argument (MHD_PostDataIterator) and the "size" + argument (MHD_create_response_from_callback) now. + Also, "unsigned int" was changed to "size_t" for + the "upload_data_size" argument (MHD_AccessHandlerCallback), + the argument to MHD_OPTION_CONNECTION_MEMORY_LIMIT, + the "block_size" argument (MHD_create_response_from_callback), + the "buffer_size" argument (MHD_create_post_processor) and + the "post_data_len" argument (MHD_post_process). You may + need to #include <stdint.h> before <microhttpd.h> from now on. -CG + Thu Feb 5 20:21:08 MST 2009 Allow getting address information about the connecting client after the accept call. -CG diff --git a/configure.ac b/configure.ac @@ -27,8 +27,8 @@ AM_CONFIG_HEADER([MHD_config.h]) AH_TOP([#define _GNU_SOURCE 1]) -LIB_VERSION_CURRENT=4 -LIB_VERSION_REVISION=3 +LIB_VERSION_CURRENT=5 +LIB_VERSION_REVISION=0 LIB_VERSION_AGE=0 AC_SUBST(LIB_VERSION_CURRENT) AC_SUBST(LIB_VERSION_REVISION) diff --git a/doc/chapters/basicauthentication.inc b/doc/chapters/basicauthentication.inc @@ -44,7 +44,7 @@ Not even the headers will be looked at on the first iteration. @verbatim int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **con_cls) { if (0 != strcmp(method, "GET")) return MHD_NO; diff --git a/doc/chapters/exploringrequests.inc b/doc/chapters/exploringrequests.inc @@ -11,7 +11,7 @@ without much ado by the server. @verbatim int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { ... return MHD_NO; diff --git a/doc/chapters/hellobrowser.inc b/doc/chapters/hellobrowser.inc @@ -37,7 +37,7 @@ Talking about the reply, it is defined as a string right after the function head @verbatim int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { const char *page = "<html><body>Hello, browser!</body></html>"; @end verbatim diff --git a/doc/chapters/largerpost.inc b/doc/chapters/largerpost.inc @@ -86,7 +86,7 @@ a postprocessor has been created and the post iterator is called at least once. @verbatim int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { if (NULL == *con_cls) { @@ -195,7 +195,7 @@ the posted data has to be written to the correct file. That is why we store a fi @verbatim int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, - const char *transfer_encoding, const char *data, size_t off, size_t size) + const char *transfer_encoding, const char *data, uint64_t off, size_t size) { struct connection_info_struct *con_info = (struct connection_info_struct*) coninfo_cls; @end verbatim diff --git a/doc/chapters/processingpost.inc b/doc/chapters/processingpost.inc @@ -75,7 +75,7 @@ came in. But in this example, the name is assumed to fit entirely inside one sin @verbatim int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, - const char *transfer_encoding, const char *data, size_t off, size_t size) + const char *transfer_encoding, const char *data, uint64_t off, size_t size) { struct connection_info_struct *con_info = (struct connection_info_struct*) coninfo_cls; @@ -150,7 +150,7 @@ iterations and other functions. @verbatim int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { if(NULL == *con_cls) { diff --git a/doc/chapters/responseheaders.inc b/doc/chapters/responseheaders.inc @@ -25,7 +25,7 @@ Once again, we can base the new example on the @code{hellobrowser} program. int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { unsigned char *buffer = NULL; struct MHD_Response *response; diff --git a/doc/examples/basicauthentication.c b/doc/examples/basicauthentication.c @@ -109,7 +109,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { if (0 != strcmp (method, "GET")) return MHD_NO; diff --git a/doc/examples/hellobrowser.c b/doc/examples/hellobrowser.c @@ -7,7 +7,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { const char *page = "<html><body>Hello, browser!</body></html>"; struct MHD_Response *response; diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c @@ -65,7 +65,7 @@ send_page (struct MHD_Connection *connection, const char *page, int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, - const char *transfer_encoding, const char *data, size_t off, + const char *transfer_encoding, const char *data, uint64_t off, size_t size) { FILE *fp; @@ -136,7 +136,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { if (NULL == *con_cls) { diff --git a/doc/examples/logging.c b/doc/examples/logging.c @@ -16,7 +16,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { printf ("New request %s for %s using version %s\n", method, url, version); diff --git a/doc/examples/responseheaders.c b/doc/examples/responseheaders.c @@ -33,7 +33,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { unsigned char *buffer = NULL; struct MHD_Response *response; diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c @@ -53,7 +53,7 @@ send_page (struct MHD_Connection *connection, const char *page) int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, - const char *transfer_encoding, const char *data, size_t off, + const char *transfer_encoding, const char *data, uint64_t off, size_t size) { struct connection_info_struct *con_info = @@ -108,7 +108,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { if (NULL == *con_cls) { diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c @@ -162,7 +162,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, void **con_cls) + size_t *upload_data_size, void **con_cls) { if (0 != strcmp (method, "GET")) return MHD_NO; diff --git a/doc/microhttpd.texi b/doc/microhttpd.texi @@ -251,7 +251,7 @@ No more options / last option. This is used to terminate the VARARGs list. @item MHD_OPTION_CONNECTION_MEMORY_LIMIT -Maximum memory size per connection (followed by an @code{unsigned int}). +Maximum memory size per connection (followed by a @code{size_t}). @item MHD_OPTION_CONNECTION_LIMIT Maximum number of concurrenct connections to accept (followed by an @@ -551,7 +551,7 @@ length of the address information. @end deftypefn -@deftypefn {Function Pointer} int {*MHD_AccessHandlerCallback} (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, unsigned int *upload_data_size, void **con_cls) +@deftypefn {Function Pointer} int {*MHD_AccessHandlerCallback} (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) Invoked in the context of a connection to answer a request from the client. This callback must call @mhd{} functions (example: the @code{MHD_Response} ones) to provide content to give back to the client @@ -654,7 +654,7 @@ iteration. @end deftypefn -@deftypefn {Function Pointer} int {*MHD_ContentReaderCallback} (void *cls, size_t pos, char *buf, int max) +@deftypefn {Function Pointer} int {*MHD_ContentReaderCallback} (void *cls, uint64_t pos, char *buf, int max) Callback used by @mhd{} in order to obtain content. The callback has to copy at most @var{max} bytes of content into @var{buf}. The total number of bytes that has been placed into @var{buf} should be returned. @@ -691,7 +691,7 @@ It should be used to free resources associated with the content reader. @end deftypefn -@deftypefn {Function Pointer} int {*MHD_PostDataIterator} (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, size_t off, size_t size) +@deftypefn {Function Pointer} int {*MHD_PostDataIterator} (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) Iterator over key-value pairs where the value maybe made available in increments and/or may not be zero-terminated. Used for processing @code{POST} data. @@ -1005,7 +1005,7 @@ the @code{MHD_Response} object is released. @section Creating response objects -@deftypefun {struct MHD_Response *} MHD_create_response_from_callback (size_t size, unsigned int block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) +@deftypefun {struct MHD_Response *} MHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) Create a response object. The response object can be extended with header information and then it can be used any number of times. @@ -1167,7 +1167,7 @@ access_handler (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **con_cls) @{ static int old_connection_marker; @@ -1195,7 +1195,7 @@ access_handler (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **con_cls) @{ struct MHD_PostProcessor * pp = *con_cls; @@ -1234,7 +1234,7 @@ always terminate normally. -@deftypefun {struct MHD_PostProcessor *} MHD_create_post_processor (struct MHD_Connection *connection, unsigned int buffer_size, MHD_PostDataIterator iterator, void *iterator_cls) +@deftypefun {struct MHD_PostProcessor *} MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iterator, void *iterator_cls) Create a PostProcessor. A PostProcessor can be used to (incrementally) parse the data portion of a @code{POST} request. @@ -1261,7 +1261,7 @@ a PP handle. @end deftypefun -@deftypefun int MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, unsigned int post_data_len) +@deftypefun int MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) Parse and process @code{POST} data. Call this function when @code{POST} data is available (usually during an @code{MHD_AccessHandlerCallback}) with the @var{upload_data} and @var{upload_data_size}. Whenever diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -366,7 +366,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) int ret; char *buf; struct MHD_Response *response; - unsigned int size; + size_t size; char cbuf[10]; /* 10: max strlen of "%x\r\n" */ int cblen; @@ -466,7 +466,8 @@ add_extra_headers (struct MHD_Connection *connection) MHD_HTTP_HEADER_CONTENT_LENGTH)) { SPRINTF (buf, - "%llu", (unsigned long long) connection->response->total_size); + "%llu", + connection->response->total_size); MHD_add_response_header (connection->response, MHD_HTTP_HEADER_CONTENT_LENGTH, buf); } @@ -1087,11 +1088,11 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) static void call_connection_handler (struct MHD_Connection *connection) { - unsigned int processed; - unsigned int available; - unsigned int used; + size_t processed; + size_t available; + size_t used; + size_t i; int instant_retry; - unsigned int i; int malformed; char *buffer_head; diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -861,7 +861,7 @@ MHD_start_daemon_va (unsigned int options, switch (opt) { case MHD_OPTION_CONNECTION_MEMORY_LIMIT: - retVal->pool_size = va_arg (ap, unsigned int); + retVal->pool_size = va_arg (ap, size_t); break; case MHD_OPTION_CONNECTION_LIMIT: retVal->max_connections = va_arg (ap, unsigned int); diff --git a/src/daemon/daemon_test.c b/src/daemon/daemon_test.c @@ -65,7 +65,7 @@ ahc_nothing (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { return MHD_NO; diff --git a/src/daemon/internal.c b/src/daemon/internal.c @@ -118,7 +118,7 @@ MHD_tls_log_func (int level, const char *str) /** * Process escape sequences ('+'=space, %HH) */ -unsigned int +size_t MHD_http_unescape (char *val) { char *rpos = val; diff --git a/src/daemon/internal.h b/src/daemon/internal.h @@ -62,7 +62,7 @@ void MHD_tls_log_func (int level, const char *str); * @return length of the resulting val (strlen(val) maybe * shorter afterwards due to elimination of escape sequences) */ -unsigned int MHD_http_unescape (char *val); +size_t MHD_http_unescape (char *val); /** * Header or cookie in HTTP request or response. @@ -145,7 +145,7 @@ struct MHD_Response /** * Set to -1 if size is not known. */ - size_t total_size; + uint64_t total_size; /** * Size of data. @@ -161,7 +161,7 @@ struct MHD_Response * At what offset in the stream is the * beginning of data located? */ - size_t data_start; + uint64_t data_start; }; @@ -485,14 +485,14 @@ struct MHD_Connection * How many more bytes of the body do we expect * to read? "-1" for unknown. */ - size_t remaining_upload_size; + uint64_t remaining_upload_size; /** * Current write position in the actual response * (excluding headers, content only; should be 0 * while sending headers). */ - size_t response_write_position; + uint64_t response_write_position; /** * Position in the 100 CONTINUE message that @@ -699,7 +699,7 @@ struct MHD_Daemon /** * Size of the per-connection memory pools. */ - unsigned int pool_size; + size_t pool_size; /** * Limit on the number of parallel connections. diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman and Christian Grothoff + (C) 2007, 2009 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -44,17 +44,17 @@ struct MemoryPool /** * Size of the pool. */ - unsigned int size; + size_t size; /** * Offset of the first unallocated byte. */ - unsigned int pos; + size_t pos; /** * Offset of the last unallocated byte. */ - unsigned int end; + size_t end; /** * MHD_NO if pool was malloc'ed, MHD_YES if mmapped. @@ -68,7 +68,7 @@ struct MemoryPool * @param max maximum size of the pool */ struct MemoryPool * -MHD_pool_create (unsigned int max) +MHD_pool_create (size_t max) { struct MemoryPool *pool; @@ -122,7 +122,8 @@ MHD_pool_destroy (struct MemoryPool *pool) * bytes */ void * -MHD_pool_allocate (struct MemoryPool *pool, unsigned int size, int from_end) +MHD_pool_allocate (struct MemoryPool *pool, + size_t size, int from_end) { void *ret; @@ -159,7 +160,9 @@ MHD_pool_allocate (struct MemoryPool *pool, unsigned int size, int from_end) */ void * MHD_pool_reallocate (struct MemoryPool *pool, - void *old, unsigned int old_size, unsigned int new_size) + void *old, + size_t old_size, + size_t new_size) { void *ret; @@ -204,7 +207,9 @@ MHD_pool_reallocate (struct MemoryPool *pool, * @return addr new address of "keep" (if it had to change) */ void * -MHD_pool_reset (struct MemoryPool *pool, void *keep, unsigned int size) +MHD_pool_reset (struct MemoryPool *pool, + void *keep, + size_t size) { if (keep != NULL) { diff --git a/src/daemon/memorypool.h b/src/daemon/memorypool.h @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman and Christian Grothoff + (C) 2007, 2009 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -42,7 +42,7 @@ struct MemoryPool; * * @param max maximum size of the pool */ -struct MemoryPool *MHD_pool_create (unsigned int max); +struct MemoryPool *MHD_pool_create (size_t max); /** * Destroy a memory pool. @@ -59,7 +59,7 @@ void MHD_pool_destroy (struct MemoryPool *pool); * bytes */ void *MHD_pool_allocate (struct MemoryPool *pool, - unsigned int size, int from_end); + size_t size, int from_end); /** * Reallocate a block of memory obtained from the pool. @@ -79,7 +79,8 @@ void *MHD_pool_allocate (struct MemoryPool *pool, */ void *MHD_pool_reallocate (struct MemoryPool *pool, void *old, - unsigned int old_size, unsigned int new_size); + size_t old_size, + size_t new_size); /** * Clear all entries from the memory pool except @@ -89,6 +90,8 @@ void *MHD_pool_reallocate (struct MemoryPool *pool, * @param size how many bytes need to be kept at this address * @return addr new address of "keep" (if it had to change) */ -void *MHD_pool_reset (struct MemoryPool *pool, void *keep, unsigned int size); +void *MHD_pool_reset (struct MemoryPool *pool, + void *keep, + size_t size); #endif diff --git a/src/daemon/postprocessor.c b/src/daemon/postprocessor.c @@ -172,22 +172,22 @@ struct MHD_PostProcessor /** * Size of our buffer for the key. */ - unsigned int buffer_size; + size_t buffer_size; /** * Current position in the key buffer. */ - unsigned int buffer_pos; + size_t buffer_pos; /** * Current position in xbuf. */ - unsigned int xbuf_pos; + size_t xbuf_pos; /** * Current offset in the value being processed. */ - unsigned int value_offset; + uint64_t value_offset; /** * strlen(boundary) -- if boundary != NULL. @@ -247,7 +247,7 @@ struct MHD_PostProcessor */ struct MHD_PostProcessor * MHD_create_post_processor (struct MHD_Connection *connection, - unsigned int buffer_size, + size_t buffer_size, MHD_PostDataIterator ikvi, void *cls) { struct MHD_PostProcessor *ret; @@ -304,13 +304,14 @@ MHD_create_post_processor (struct MHD_Connection *connection, */ static int post_process_urlencoded (struct MHD_PostProcessor *pp, - const char *post_data, unsigned int post_data_len) + const char *post_data, + size_t post_data_len) { - unsigned int equals; - unsigned int amper; - unsigned int poff; - unsigned int xoff; - unsigned int delta; + size_t equals; + size_t amper; + size_t poff; + size_t xoff; + size_t delta; int end_of_value_found; char *buf; char xbuf[XBUF_SIZE + 1]; @@ -472,7 +473,7 @@ static int find_boundary (struct MHD_PostProcessor *pp, const char *boundary, size_t blen, - unsigned int *ioffptr, + size_t *ioffptr, enum PP_State next_state, enum PP_State next_dash_state) { char *buf = (char *) &pp[1]; @@ -554,10 +555,10 @@ try_get_value (const char *buf, const char *key, char **destination) */ static int process_multipart_headers (struct MHD_PostProcessor *pp, - unsigned int *ioffptr, enum PP_State next_state) + size_t *ioffptr, enum PP_State next_state) { char *buf = (char *) &pp[1]; - unsigned int newline; + size_t newline; newline = 0; while ((newline < pp->buffer_pos) && @@ -615,14 +616,14 @@ process_multipart_headers (struct MHD_PostProcessor *pp, */ static int process_value_to_boundary (struct MHD_PostProcessor *pp, - unsigned int *ioffptr, + size_t *ioffptr, const char *boundary, size_t blen, enum PP_State next_state, enum PP_State next_dash_state) { char *buf = (char *) &pp[1]; - unsigned int newline; + size_t newline; /* all data in buf until the boundary (\r\n--+boundary) is part of the value */ @@ -716,12 +717,13 @@ free_unmarked (struct MHD_PostProcessor *pp) */ static int post_process_multipart (struct MHD_PostProcessor *pp, - const char *post_data, unsigned int post_data_len) + const char *post_data, + size_t post_data_len) { char *buf; - unsigned int max; - unsigned int ioff; - unsigned int poff; + size_t max; + size_t ioff; + size_t poff; int state_changed; buf = (char *) &pp[1]; @@ -999,7 +1001,7 @@ END: */ int MHD_post_process (struct MHD_PostProcessor *pp, - const char *post_data, unsigned int post_data_len) + const char *post_data, size_t post_data_len) { if (post_data_len == 0) return MHD_YES; diff --git a/src/daemon/postprocessor_large_test.c b/src/daemon/postprocessor_large_test.c @@ -39,12 +39,12 @@ value_checker (void *cls, const char *filename, const char *content_type, const char *transfer_encoding, - const char *data, size_t off, size_t size) + const char *data, uint64_t off, size_t size) { unsigned int *pos = cls; #if 0 fprintf (stderr, - "VC: %u %u `%s' `%s' `%s' `%s' `%.*s'\n", + "VC: %llu %u `%s' `%s' `%s' `%s' `%.*s'\n", off, size, key, filename, content_type, transfer_encoding, size, data); #endif diff --git a/src/daemon/postprocessor_test.c b/src/daemon/postprocessor_test.c @@ -79,7 +79,7 @@ value_checker (void *cls, const char *filename, const char *content_type, const char *transfer_encoding, - const char *data, size_t off, size_t size) + const char *data, uint64_t off, size_t size) { int *want_off = cls; int idx = *want_off; diff --git a/src/daemon/response.c b/src/daemon/response.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman and Christian Grothoff + (C) 2007, 2009 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -175,8 +175,8 @@ MHD_get_response_header (struct MHD_Response *response, const char *key) * @return NULL on error (i.e. invalid arguments, out of memory) */ struct MHD_Response * -MHD_create_response_from_callback (size_t size, - unsigned int block_size, +MHD_create_response_from_callback (uint64_t size, + size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) diff --git a/src/examples/fileserver_example.c b/src/examples/fileserver_example.c @@ -30,7 +30,7 @@ #define PAGE "<html><head><title>File not found</title></head><body>File not found</body></html>" static int -file_reader (void *cls, size_t pos, char *buf, int max) +file_reader (void *cls, uint64_t pos, char *buf, int max) { FILE *file = cls; diff --git a/src/examples/fileserver_example_external_select.c b/src/examples/fileserver_example_external_select.c @@ -30,7 +30,7 @@ #define PAGE "<html><head><title>File not found</title></head><body>File not found</body></html>" static int -file_reader (void *cls, size_t pos, char *buf, int max) +file_reader (void *cls, uint64_t pos, char *buf, int max) { FILE *file = cls; diff --git a/src/examples/https_fileserver_example.c b/src/examples/https_fileserver_example.c @@ -97,7 +97,7 @@ const char key_pem[] = "-----END RSA PRIVATE KEY-----\n"; static int -file_reader (void *cls, size_t pos, char *buf, int max) +file_reader (void *cls, uint64_t pos, char *buf, int max) { FILE *file = cls; @@ -112,7 +112,7 @@ http_ahc (void *cls, const char *url, const char *method, const char *upload_data, - const char *version, unsigned int *upload_data_size, void **ptr) + const char *version, size_t *upload_data_size, void **ptr) { static int aptr; struct MHD_Response *response; diff --git a/src/examples/minimal_example_comet.c b/src/examples/minimal_example_comet.c @@ -26,7 +26,7 @@ #include <microhttpd.h> static int -data_generator (void *cls, size_t pos, char *buf, int max) +data_generator (void *cls, uint64_t pos, char *buf, int max) { if (max < 80) return 0; @@ -41,7 +41,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, void **ptr) + const char *upload_data, size_t *upload_data_size, void **ptr) { static int aptr; struct MHD_Response *response; diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -59,9 +59,9 @@ * thread-safe (with the exception of 'MHD_set_connection_value', * which must only be used in a particular context).<p> * - * NEW: Before including "microhttpd.h" you should add the - * necessary includes to define the "size_t", "fd_set", "socklen_t" and - * "struct sockaddr" data types (which headers are needed may + * NEW: Before including "microhttpd.h" you should add the necessary + * includes to define the "uint64_t", "size_t", "fd_set", "socklen_t" + * and "struct sockaddr" data types (which headers are needed may * depend on your platform; for possible suggestions consult * "platform.h" in the MHD distribution). * @@ -297,8 +297,8 @@ enum MHD_OPTION MHD_OPTION_END = 0, /** - * Maximum memory size per connection (followed by an - * unsigned int). + * Maximum memory size per connection (followed by a + * size_t). */ MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1, @@ -663,7 +663,7 @@ typedef int const char *method, const char *version, const char *upload_data, - unsigned int *upload_data_size, + size_t *upload_data_size, void **con_cls); /** @@ -731,7 +731,10 @@ typedef int * requests using the same TCP connection). */ typedef int - (*MHD_ContentReaderCallback) (void *cls, size_t pos, char *buf, int max); + (*MHD_ContentReaderCallback) (void *cls, + uint64_t pos, + char *buf, + int max); /** * This method is called by libmicrohttpd if we @@ -767,7 +770,7 @@ typedef int const char *filename, const char *content_type, const char *transfer_encoding, - const char *data, size_t off, size_t size); + const char *data, uint64_t off, size_t size); /* **************** Daemon handling functions ***************** */ @@ -967,9 +970,8 @@ MHD_queue_response (struct MHD_Connection *connection, * @param crfc callback to call to free crc_cls resources * @return NULL on error (i.e. invalid arguments, out of memory) */ -struct MHD_Response *MHD_create_response_from_callback (size_t size, - unsigned int - block_size, +struct MHD_Response *MHD_create_response_from_callback (uint64_t size, + size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback @@ -1079,7 +1081,7 @@ const char *MHD_get_response_header (struct MHD_Response *response, */ struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection *connection, - unsigned int buffer_size, + size_t buffer_size, MHD_PostDataIterator iter, void *cls); @@ -1099,7 +1101,7 @@ struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection */ int MHD_post_process (struct MHD_PostProcessor *pp, - const char *post_data, unsigned int post_data_len); + const char *post_data, size_t post_data_len); /** * Release PostProcessor resources. diff --git a/src/include/platform.h b/src/include/platform.h @@ -46,6 +46,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #include <string.h> #include <unistd.h> #include <stdarg.h> @@ -54,7 +55,7 @@ #include <signal.h> #include <pthread.h> -/* different OSes have size_t, fd_set in +/* different OSes have fd_set in a broad range of header files; we just include most of them (if they are available) */ diff --git a/src/testcurl/daemon_options_test.c b/src/testcurl/daemon_options_test.c @@ -40,7 +40,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { return 0; diff --git a/src/testcurl/daemontest_get.c b/src/testcurl/daemontest_get.c @@ -26,6 +26,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -63,7 +64,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int ptr; diff --git a/src/testcurl/daemontest_get_chunked.c b/src/testcurl/daemontest_get_chunked.c @@ -29,6 +29,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -63,7 +64,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) * data in chunks. */ static int -crc (void *cls, size_t pos, char *buf, int max) +crc (void *cls, uint64_t pos, char *buf, int max) { struct MHD_Response **responseptr = cls; @@ -93,7 +94,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, void **ptr) + const char *upload_data, size_t *upload_data_size, void **ptr) { static int aptr; const char *me = cls; diff --git a/src/testcurl/daemontest_large_put.c b/src/testcurl/daemontest_large_put.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -89,7 +90,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { int *done = cls; diff --git a/src/testcurl/daemontest_long_header.c b/src/testcurl/daemontest_long_header.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -69,7 +70,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { const char *me = cls; diff --git a/src/testcurl/daemontest_parse_cookies.c b/src/testcurl/daemontest_parse_cookies.c @@ -26,6 +26,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -63,7 +64,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int ptr; diff --git a/src/testcurl/daemontest_post.c b/src/testcurl/daemontest_post.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -70,7 +71,7 @@ post_iterator (void *cls, const char *filename, const char *content_type, const char *transfer_encoding, - const char *value, size_t off, size_t size) + const char *value, uint64_t off, size_t size) { int *eok = cls; @@ -89,7 +90,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int eok; diff --git a/src/testcurl/daemontest_post_loop.c b/src/testcurl/daemontest_post_loop.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -66,7 +67,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **mptr) { static int marker; diff --git a/src/testcurl/daemontest_postform.c b/src/testcurl/daemontest_postform.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -68,7 +69,7 @@ post_iterator (void *cls, const char *filename, const char *content_type, const char *transfer_encoding, - const char *value, size_t off, size_t size) + const char *value, uint64_t off, size_t size) { int *eok = cls; @@ -90,7 +91,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int eok; diff --git a/src/testcurl/daemontest_process_arguments.c b/src/testcurl/daemontest_process_arguments.c @@ -26,6 +26,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -63,7 +64,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int ptr; diff --git a/src/testcurl/daemontest_process_headers.c b/src/testcurl/daemontest_process_headers.c @@ -26,6 +26,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -75,7 +76,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int ptr; diff --git a/src/testcurl/daemontest_put.c b/src/testcurl/daemontest_put.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -76,7 +77,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { int *done = cls; diff --git a/src/testcurl/daemontest_put_chunked.c b/src/testcurl/daemontest_put_chunked.c @@ -26,6 +26,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -77,7 +78,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { int *done = cls; diff --git a/src/testcurl/https/mhds_session_info_test.c b/src/testcurl/https/mhds_session_info_test.c @@ -44,7 +44,7 @@ static int query_session_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *upload_data, const char *version, - unsigned int *upload_data_size, void **ptr) + size_t *upload_data_size, void **ptr) { struct MHD_Response *response; int ret; diff --git a/src/testcurl/https/tls_cipher_change_test.c b/src/testcurl/https/tls_cipher_change_test.c @@ -42,7 +42,7 @@ char *http_get_req = "GET / HTTP/1.1\r\n\r\n"; static int rehandshake_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *upload_data, - const char *version, unsigned int *upload_data_size, + const char *version, size_t *upload_data_size, void **ptr) { int ret; diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c @@ -23,7 +23,6 @@ * @brief Common tls test functions * @author Sagie Amir */ - #include "tls_test_common.h" #include "tls_test_keys.h" #include "gnutls.h" @@ -55,7 +54,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) } static int -file_reader (void *cls, size_t pos, char *buf, int max) +file_reader (void *cls, uint64_t pos, char *buf, int max) { FILE *file = cls; fseek (file, pos, SEEK_SET); @@ -68,7 +67,7 @@ file_reader (void *cls, size_t pos, char *buf, int max) int http_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *upload_data, - const char *version, unsigned int *upload_data_size, void **ptr) + const char *version, size_t *upload_data_size, void **ptr) { static int aptr; struct MHD_Response *response; @@ -112,7 +111,7 @@ http_ahc (void *cls, struct MHD_Connection *connection, int http_dummy_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *upload_data, - const char *version, unsigned int *upload_data_size, + const char *version, size_t *upload_data_size, void **ptr) { return 0; diff --git a/src/testzzuf/daemontest_get.c b/src/testzzuf/daemontest_get.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -64,7 +65,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int ptr; diff --git a/src/testzzuf/daemontest_get_chunked.c b/src/testzzuf/daemontest_get_chunked.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -61,7 +62,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) * data in chunks. */ static int -crc (void *cls, size_t pos, char *buf, int max) +crc (void *cls, uint64_t pos, char *buf, int max) { struct MHD_Response **responseptr = cls; @@ -91,7 +92,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, void **ptr) + const char *upload_data, size_t *upload_data_size, void **ptr) { static int aptr; const char *me = cls; diff --git a/src/testzzuf/daemontest_large_put.c b/src/testzzuf/daemontest_large_put.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -87,7 +88,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { int *done = cls; diff --git a/src/testzzuf/daemontest_long_header.c b/src/testzzuf/daemontest_long_header.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -71,7 +72,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { const char *me = cls; diff --git a/src/testzzuf/daemontest_post.c b/src/testzzuf/daemontest_post.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -73,7 +74,7 @@ post_iterator (void *cls, const char *filename, const char *content_type, const char *transfer_encoding, - const char *value, size_t off, size_t size) + const char *value, uint64_t off, size_t size) { int *eok = cls; @@ -92,7 +93,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int eok; diff --git a/src/testzzuf/daemontest_postform.c b/src/testzzuf/daemontest_postform.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -71,7 +72,7 @@ post_iterator (void *cls, const char *filename, const char *content_type, const char *transfer_encoding, - const char *value, size_t off, size_t size) + const char *value, uint64_t off, size_t size) { int *eok = cls; @@ -95,7 +96,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { static int eok; diff --git a/src/testzzuf/daemontest_put.c b/src/testzzuf/daemontest_put.c @@ -25,6 +25,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -79,7 +80,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { int *done = cls; diff --git a/src/testzzuf/daemontest_put_chunked.c b/src/testzzuf/daemontest_put_chunked.c @@ -26,6 +26,7 @@ */ #include "MHD_config.h" +#include "platform.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> @@ -79,7 +80,7 @@ ahc_echo (void *cls, const char *url, const char *method, const char *version, - const char *upload_data, unsigned int *upload_data_size, + const char *upload_data, size_t *upload_data_size, void **unused) { int *done = cls;