diff --git a/ChangeLog b/ChangeLog index db181856..026e5255 100644 --- 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 index ae2b8615..6700bab1 100644 --- 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 index e2258063..f470a236 100644 --- a/src/examples/fileserver_example.c +++ b/src/examples/fileserver_example.c @@ -29,8 +29,8 @@ #define PAGE "File not foundFile not found" -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 index 3bdb64ff..8c874994 100644 --- a/src/examples/fileserver_example_dirs.c +++ b/src/examples/fileserver_example_dirs.c @@ -30,8 +30,8 @@ #define PAGE "File not foundFile not found" -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 index 76e40c7a..aabe1d96 100644 --- a/src/examples/fileserver_example_external_select.c +++ b/src/examples/fileserver_example_external_select.c @@ -29,8 +29,8 @@ #define PAGE "File not foundFile not found" -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 index 4df9e359..fe1512ed 100644 --- 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 index 4aeb5db6..9b25889e 100644 --- a/src/examples/minimal_example_comet.c +++ b/src/examples/minimal_example_comet.c @@ -25,8 +25,8 @@ #include "platform.h" #include -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 index fa01680a..2ba791b9 100644 --- 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 index 6aef68ad..e5b1a73a 100644 --- 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 index 29ee5028..655f402a 100644 --- 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;