Christian Grothoff 15 лет назад
Родитель
Сommit
b4abb360a4

+ 3 - 0
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
 

+ 2 - 2
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;

+ 2 - 2
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;
 

+ 4 - 4
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;

+ 2 - 2
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;
 

+ 2 - 2
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;
 

+ 2 - 2
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;

+ 4 - 2
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

+ 2 - 2
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;
 

+ 2 - 2
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;