libmicrohttpd

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

commit b4abb360a438af83a786b8f8e2df8b5ed0c865ba
parent f33a16a615ae2fd55f1fd7ddf8654a82bcca0228
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 21 Sep 2010 13:13:05 +0000

use size_t

Diffstat:
MChangeLog | 3+++
Msrc/daemon/response.c | 4++--
Msrc/examples/fileserver_example.c | 4++--
Msrc/examples/fileserver_example_dirs.c | 8++++----
Msrc/examples/fileserver_example_external_select.c | 4++--
Msrc/examples/https_fileserver_example.c | 4++--
Msrc/examples/minimal_example_comet.c | 4++--
Msrc/include/microhttpd.h | 6++++--
Msrc/testcurl/daemontest_get_chunked.c | 4++--
Msrc/testzzuf/daemontest_get_chunked.c | 4++--
10 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,6 @@ +Tue Sep 21 15:12:41 CEST 2010 + Use "size_t" for buffer size instead of "int". -CG + Sat Sep 18 07:16:30 CEST 2010 Adding support for SHOUTcast. -CG diff --git a/src/daemon/response.c b/src/daemon/response.c @@ -216,8 +216,8 @@ MHD_create_response_from_callback (uint64_t size, * @param max number of bytes to write at most * @return number of bytes written */ -static int -file_reader (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +file_reader (void *cls, uint64_t pos, char *buf, size_t max) { struct MHD_Response *response = cls; int ret; diff --git a/src/examples/fileserver_example.c b/src/examples/fileserver_example.c @@ -29,8 +29,8 @@ #define PAGE "<html><head><title>File not found</title></head><body>File not found</body></html>" -static int -file_reader (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +file_reader (void *cls, uint64_t pos, char *buf, size_t max) { FILE *file = cls; diff --git a/src/examples/fileserver_example_dirs.c b/src/examples/fileserver_example_dirs.c @@ -30,8 +30,8 @@ #define PAGE "<html><head><title>File not found</title></head><body>File not found</body></html>" -static int -file_reader (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +file_reader (void *cls, uint64_t pos, char *buf, size_t max) { FILE *file = cls; @@ -54,8 +54,8 @@ dir_free_callback (void *cls) closedir (dir); } -static int -dir_reader (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +dir_reader (void *cls, uint64_t pos, char *buf, size_t max) { DIR *dir = cls; struct dirent *e; diff --git a/src/examples/fileserver_example_external_select.c b/src/examples/fileserver_example_external_select.c @@ -29,8 +29,8 @@ #define PAGE "<html><head><title>File not found</title></head><body>File not found</body></html>" -static int -file_reader (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +file_reader (void *cls, uint64_t pos, char *buf, size_t max) { FILE *file = cls; diff --git a/src/examples/https_fileserver_example.c b/src/examples/https_fileserver_example.c @@ -95,8 +95,8 @@ const char key_pem[] = "eRJ6DxULPxABytJrYCRrNqmXi5TCiqR2mtfalEMOPxz8rUU8dYyx\n" "-----END RSA PRIVATE KEY-----\n"; -static int -file_reader (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +file_reader (void *cls, uint64_t pos, char *buf, size_t max) { FILE *file = cls; diff --git a/src/examples/minimal_example_comet.c b/src/examples/minimal_example_comet.c @@ -25,8 +25,8 @@ #include "platform.h" #include <microhttpd.h> -static int -data_generator (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +data_generator (void *cls, uint64_t pos, char *buf, size_t max) { if (max < 80) return 0; diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -866,6 +866,8 @@ typedef int * libmicrohttpd guarantees that "pos" will be * the sum of all non-negative return values * obtained from the content reader so far. + * @param buf where to copy the data + * @param max maximum number of bytes to copy to buf (size of buf) * @return -1 for the end of transmission (or on error); * if a content transfer size was pre-set and the callback * has provided fewer than that amount of data, @@ -876,11 +878,11 @@ typedef int * (possibly allowing the client to perform additional * requests using the same TCP connection). */ -typedef int +typedef ssize_t (*MHD_ContentReaderCallback) (void *cls, uint64_t pos, char *buf, - int max); + size_t max); /** * This method is called by libmicrohttpd if we diff --git a/src/testcurl/daemontest_get_chunked.c b/src/testcurl/daemontest_get_chunked.c @@ -63,8 +63,8 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) * MHD content reader callback that returns * data in chunks. */ -static int -crc (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +crc (void *cls, uint64_t pos, char *buf, size_t max) { struct MHD_Response **responseptr = cls; diff --git a/src/testzzuf/daemontest_get_chunked.c b/src/testzzuf/daemontest_get_chunked.c @@ -61,8 +61,8 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) * MHD content reader callback that returns * data in chunks. */ -static int -crc (void *cls, uint64_t pos, char *buf, int max) +static ssize_t +crc (void *cls, uint64_t pos, char *buf, size_t max) { struct MHD_Response **responseptr = cls;