aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-08 23:36:41 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-08 23:36:41 +0200
commitde872dea2d88f183c3f434c694acdcdb373f639c (patch)
treefb9084eb931c9789060e65ee3be3dc5adcb30e73
parent6347f514aa2388e774d5bf356df8046864e5f73c (diff)
downloadlibmicrohttpd-de872dea2d88f183c3f434c694acdcdb373f639c.tar.gz
libmicrohttpd-de872dea2d88f183c3f434c694acdcdb373f639c.zip
define and use 'enum MHD_Result'
-rw-r--r--ChangeLog7
-rw-r--r--doc/examples/basicauthentication.c62
-rw-r--r--doc/examples/hellobrowser.c25
-rw-r--r--doc/examples/largepost.c302
-rw-r--r--doc/examples/logging.c18
-rw-r--r--doc/examples/responseheaders.c56
-rw-r--r--doc/examples/sessions.c561
-rw-r--r--doc/examples/simplepost.c156
-rw-r--r--doc/examples/tlsauthentication.c150
-rw-r--r--src/examples/authorization_example.c4
-rw-r--r--src/examples/benchmark.c2
-rw-r--r--src/examples/benchmark_https.c2
-rw-r--r--src/examples/chunked_example.c4
-rw-r--r--src/examples/demo.c16
-rw-r--r--src/examples/demo_https.c18
-rw-r--r--src/examples/digest_auth_example.c4
-rw-r--r--src/examples/dual_stack_example.c4
-rw-r--r--src/examples/fileserver_example.c4
-rw-r--r--src/examples/fileserver_example_dirs.c4
-rw-r--r--src/examples/fileserver_example_external_select.c4
-rw-r--r--src/examples/http_chunked_compression.c8
-rw-r--r--src/examples/http_compression.c10
-rw-r--r--src/examples/https_fileserver_example.c4
-rw-r--r--src/examples/minimal_example.c4
-rw-r--r--src/examples/minimal_example_comet.c4
-rw-r--r--src/examples/minimal_example_empty.c4
-rw-r--r--src/examples/minimal_example_empty_tls.c4
-rw-r--r--src/examples/post_example.c30
-rw-r--r--src/examples/querystring_example.c4
-rw-r--r--src/examples/refuse_post_example.c4
-rw-r--r--src/examples/suspend_resume_epoll.c4
-rw-r--r--src/examples/timeout.c4
-rw-r--r--src/examples/upgrade_example.c4
-rw-r--r--src/microhttpd/test_daemon.c6
-rw-r--r--src/microhttpd/test_postprocessor.c12
-rw-r--r--src/microhttpd/test_postprocessor_amp.c2
-rw-r--r--src/microhttpd/test_postprocessor_large.c2
-rw-r--r--src/microhttpd/test_upgrade.c4
-rw-r--r--src/microhttpd/test_upgrade_large.c4
-rw-r--r--src/testcurl/https/test_empty_response.c4
-rw-r--r--src/testcurl/https/test_https_get.c4
-rw-r--r--src/testcurl/https/test_https_get_select.c4
-rw-r--r--src/testcurl/https/test_https_session_info.c17
-rw-r--r--src/testcurl/https/tls_test_common.c6
-rw-r--r--src/testcurl/https/tls_test_common.h4
-rw-r--r--src/testcurl/perf_get.c4
-rw-r--r--src/testcurl/perf_get_concurrent.c4
-rw-r--r--src/testcurl/test_callback.c4
-rw-r--r--src/testcurl/test_concurrent_stop.c4
-rw-r--r--src/testcurl/test_delete.c4
-rw-r--r--src/testcurl/test_digestauth.c4
-rw-r--r--src/testcurl/test_digestauth_sha256.c4
-rw-r--r--src/testcurl/test_digestauth_with_arguments.c4
-rw-r--r--src/testcurl/test_get.c8
-rw-r--r--src/testcurl/test_get_chunked.c4
-rw-r--r--src/testcurl/test_get_response_cleanup.c4
-rw-r--r--src/testcurl/test_get_sendfile.c6
-rw-r--r--src/testcurl/test_iplimit.c4
-rw-r--r--src/testcurl/test_large_put.c4
-rw-r--r--src/testcurl/test_long_header.c6
-rw-r--r--src/testcurl/test_parse_cookies.c4
-rw-r--r--src/testcurl/test_patch.c4
-rw-r--r--src/testcurl/test_post.c10
-rw-r--r--src/testcurl/test_post_loop.c4
-rw-r--r--src/testcurl/test_postform.c6
-rw-r--r--src/testcurl/test_process_arguments.c4
-rw-r--r--src/testcurl/test_process_headers.c6
-rw-r--r--src/testcurl/test_put.c4
-rw-r--r--src/testcurl/test_put_chunked.c4
-rw-r--r--src/testcurl/test_quiesce.c4
-rw-r--r--src/testcurl/test_quiesce_stream.c4
-rw-r--r--src/testcurl/test_termination.c4
-rw-r--r--src/testcurl/test_timeout.c4
-rw-r--r--src/testcurl/test_urlparse.c6
-rw-r--r--src/testzzuf/test_get.c4
-rw-r--r--src/testzzuf/test_get_chunked.c4
-rw-r--r--src/testzzuf/test_long_header.c17
-rw-r--r--src/testzzuf/test_post.c6
-rw-r--r--src/testzzuf/test_post_form.c6
-rw-r--r--src/testzzuf/test_put.c4
-rw-r--r--src/testzzuf/test_put_chunked.c4
-rw-r--r--src/testzzuf/test_put_large.c6
82 files changed, 890 insertions, 857 deletions
diff --git a/ChangeLog b/ChangeLog
index ca0a8847..3ce14755 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
1Wed 08 Apr 2020 10:53:01 PM CEST 1Wed 08 Apr 2020 10:53:01 PM CEST
2 Introduce `enum MHD_Result` for #MHD_YES/#MHD_NO to avoid using 'int' so much. -CG 2 Introduce `enum MHD_Result` for #MHD_YES/#MHD_NO to avoid using 'int' so much.
3 Note that this change WILL cause compiler warnings until (most) MHD callbacks
4 in application code change their return type from 'int' to 'enum MHD_Result'.
5 That said, avoiding possible confusions of different enums is going to make
6 the code more robust in the future. For conditional compilation, test
7 for "MHD_VERSION >= 0x00097002". -CG
3 8
4Sat 07 Mar 2020 05:20:33 PM CET 9Sat 07 Mar 2020 05:20:33 PM CET
5 Fixed #6090 (misc. severe socket handling bugs on OS X). -CG 10 Fixed #6090 (misc. severe socket handling bugs on OS X). -CG
diff --git a/doc/examples/basicauthentication.c b/doc/examples/basicauthentication.c
index 88cb79b7..5d156f04 100644
--- a/doc/examples/basicauthentication.c
+++ b/doc/examples/basicauthentication.c
@@ -17,7 +17,7 @@
17#define PORT 8888 17#define PORT 8888
18 18
19 19
20static int 20static enum MHD_Result
21answer_to_connection (void *cls, struct MHD_Connection *connection, 21answer_to_connection (void *cls, struct MHD_Connection *connection,
22 const char *url, const char *method, 22 const char *url, const char *method,
23 const char *version, const char *upload_data, 23 const char *version, const char *upload_data,
@@ -28,45 +28,47 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
28 int fail; 28 int fail;
29 int ret; 29 int ret;
30 struct MHD_Response *response; 30 struct MHD_Response *response;
31 (void)cls; /* Unused. Silent compiler warning. */ 31 (void) cls; /* Unused. Silent compiler warning. */
32 (void)url; /* Unused. Silent compiler warning. */ 32 (void) url; /* Unused. Silent compiler warning. */
33 (void)version; /* Unused. Silent compiler warning. */ 33 (void) version; /* Unused. Silent compiler warning. */
34 (void)upload_data; /* Unused. Silent compiler warning. */ 34 (void) upload_data; /* Unused. Silent compiler warning. */
35 (void)upload_data_size; /* Unused. Silent compiler warning. */ 35 (void) upload_data_size; /* Unused. Silent compiler warning. */
36 36
37 if (0 != strcmp (method, "GET")) 37 if (0 != strcmp (method, "GET"))
38 return MHD_NO; 38 return MHD_NO;
39 if (NULL == *con_cls) 39 if (NULL == *con_cls)
40 { 40 {
41 *con_cls = connection; 41 *con_cls = connection;
42 return MHD_YES; 42 return MHD_YES;
43 } 43 }
44 pass = NULL; 44 pass = NULL;
45 user = MHD_basic_auth_get_username_password (connection, 45 user = MHD_basic_auth_get_username_password (connection,
46 &pass); 46 &pass);
47 fail = ( (NULL == user) || 47 fail = ( (NULL == user) ||
48 (0 != strcmp (user, "root")) || 48 (0 != strcmp (user, "root")) ||
49 (0 != strcmp (pass, "pa$$w0rd") ) ); 49 (0 != strcmp (pass, "pa$$w0rd") ) );
50 if (NULL != user) MHD_free (user); 50 if (NULL != user)
51 if (NULL != pass) MHD_free (pass); 51 MHD_free (user);
52 if (NULL != pass)
53 MHD_free (pass);
52 if (fail) 54 if (fail)
53 { 55 {
54 const char *page = "<html><body>Go away.</body></html>"; 56 const char *page = "<html><body>Go away.</body></html>";
55 response = 57 response =
56 MHD_create_response_from_buffer (strlen (page), (void *) page, 58 MHD_create_response_from_buffer (strlen (page), (void *) page,
57 MHD_RESPMEM_PERSISTENT); 59 MHD_RESPMEM_PERSISTENT);
58 ret = MHD_queue_basic_auth_fail_response (connection, 60 ret = MHD_queue_basic_auth_fail_response (connection,
59 "my realm", 61 "my realm",
60 response); 62 response);
61 } 63 }
62 else 64 else
63 { 65 {
64 const char *page = "<html><body>A secret.</body></html>"; 66 const char *page = "<html><body>A secret.</body></html>";
65 response = 67 response =
66 MHD_create_response_from_buffer (strlen (page), (void *) page, 68 MHD_create_response_from_buffer (strlen (page), (void *) page,
67 MHD_RESPMEM_PERSISTENT); 69 MHD_RESPMEM_PERSISTENT);
68 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 70 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
69 } 71 }
70 MHD_destroy_response (response); 72 MHD_destroy_response (response);
71 return ret; 73 return ret;
72} 74}
diff --git a/doc/examples/hellobrowser.c b/doc/examples/hellobrowser.c
index dce4ee6d..0c13c24d 100644
--- a/doc/examples/hellobrowser.c
+++ b/doc/examples/hellobrowser.c
@@ -14,7 +14,7 @@
14 14
15#define PORT 8888 15#define PORT 8888
16 16
17static int 17static enum MHD_Result
18answer_to_connection (void *cls, struct MHD_Connection *connection, 18answer_to_connection (void *cls, struct MHD_Connection *connection,
19 const char *url, const char *method, 19 const char *url, const char *method,
20 const char *version, const char *upload_data, 20 const char *version, const char *upload_data,
@@ -22,18 +22,18 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
22{ 22{
23 const char *page = "<html><body>Hello, browser!</body></html>"; 23 const char *page = "<html><body>Hello, browser!</body></html>";
24 struct MHD_Response *response; 24 struct MHD_Response *response;
25 int ret; 25 enum MHD_Result ret;
26 (void)cls; /* Unused. Silent compiler warning. */ 26 (void) cls; /* Unused. Silent compiler warning. */
27 (void)url; /* Unused. Silent compiler warning. */ 27 (void) url; /* Unused. Silent compiler warning. */
28 (void)method; /* Unused. Silent compiler warning. */ 28 (void) method; /* Unused. Silent compiler warning. */
29 (void)version; /* Unused. Silent compiler warning. */ 29 (void) version; /* Unused. Silent compiler warning. */
30 (void)upload_data; /* Unused. Silent compiler warning. */ 30 (void) upload_data; /* Unused. Silent compiler warning. */
31 (void)upload_data_size; /* Unused. Silent compiler warning. */ 31 (void) upload_data_size; /* Unused. Silent compiler warning. */
32 (void)con_cls; /* Unused. Silent compiler warning. */ 32 (void) con_cls; /* Unused. Silent compiler warning. */
33 33
34 response = 34 response =
35 MHD_create_response_from_buffer (strlen (page), (void *) page, 35 MHD_create_response_from_buffer (strlen (page), (void *) page,
36 MHD_RESPMEM_PERSISTENT); 36 MHD_RESPMEM_PERSISTENT);
37 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 37 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
38 MHD_destroy_response (response); 38 MHD_destroy_response (response);
39 39
@@ -46,7 +46,8 @@ main (void)
46{ 46{
47 struct MHD_Daemon *daemon; 47 struct MHD_Daemon *daemon;
48 48
49 daemon = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, PORT, NULL, NULL, 49 daemon = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
50 PORT, NULL, NULL,
50 &answer_to_connection, NULL, MHD_OPTION_END); 51 &answer_to_connection, NULL, MHD_OPTION_END);
51 if (NULL == daemon) 52 if (NULL == daemon)
52 return 1; 53 return 1;
diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c
index 8ef7c9fe..8618209f 100644
--- a/doc/examples/largepost.c
+++ b/doc/examples/largepost.c
@@ -15,11 +15,11 @@
15 15
16#ifdef _MSC_VER 16#ifdef _MSC_VER
17#ifndef strcasecmp 17#ifndef strcasecmp
18#define strcasecmp(a,b) _stricmp((a),(b)) 18#define strcasecmp(a,b) _stricmp ((a),(b))
19#endif /* !strcasecmp */ 19#endif /* !strcasecmp */
20#endif /* _MSC_VER */ 20#endif /* _MSC_VER */
21 21
22#if defined(_MSC_VER) && _MSC_VER+0 <= 1800 22#if defined(_MSC_VER) && _MSC_VER + 0 <= 1800
23/* Substitution is OK while return value is not used */ 23/* Substitution is OK while return value is not used */
24#define snprintf _snprintf 24#define snprintf _snprintf
25#endif 25#endif
@@ -29,10 +29,10 @@
29#define MAXCLIENTS 2 29#define MAXCLIENTS 2
30 30
31enum ConnectionType 31enum ConnectionType
32 { 32{
33 GET = 0, 33 GET = 0,
34 POST = 1 34 POST = 1
35 }; 35};
36 36
37static unsigned int nr_of_uploading_clients = 0; 37static unsigned int nr_of_uploading_clients = 0;
38 38
@@ -66,7 +66,8 @@ struct connection_info_struct
66}; 66};
67 67
68 68
69const char *askpage = "<html><body>\n\ 69const char *askpage =
70 "<html><body>\n\
70 Upload a file, please!<br>\n\ 71 Upload a file, please!<br>\n\
71 There are %u clients uploading at the moment.<br>\n\ 72 There are %u clients uploading at the moment.<br>\n\
72 <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\ 73 <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\
@@ -85,23 +86,23 @@ const char *fileexistspage =
85 "<html><body>This file already exists.</body></html>"; 86 "<html><body>This file already exists.</body></html>";
86const char *fileioerror = 87const char *fileioerror =
87 "<html><body>IO error writing to disk.</body></html>"; 88 "<html><body>IO error writing to disk.</body></html>";
88const char* const postprocerror = 89const char*const postprocerror =
89 "<html><head><title>Error</title></head><body>Error processing POST data</body></html>"; 90 "<html><head><title>Error</title></head><body>Error processing POST data</body></html>";
90 91
91 92
92static int 93static enum MHD_Result
93send_page (struct MHD_Connection *connection, 94send_page (struct MHD_Connection *connection,
94 const char *page, 95 const char *page,
95 int status_code) 96 int status_code)
96{ 97{
97 int ret; 98 enum MHD_Result ret;
98 struct MHD_Response *response; 99 struct MHD_Response *response;
99 100
100 response = 101 response =
101 MHD_create_response_from_buffer (strlen (page), 102 MHD_create_response_from_buffer (strlen (page),
102 (void *) page, 103 (void *) page,
103 MHD_RESPMEM_MUST_COPY); 104 MHD_RESPMEM_MUST_COPY);
104 if (!response) 105 if (! response)
105 return MHD_NO; 106 return MHD_NO;
106 MHD_add_response_header (response, 107 MHD_add_response_header (response,
107 MHD_HTTP_HEADER_CONTENT_TYPE, 108 MHD_HTTP_HEADER_CONTENT_TYPE,
@@ -115,7 +116,7 @@ send_page (struct MHD_Connection *connection,
115} 116}
116 117
117 118
118static int 119static enum MHD_Result
119iterate_post (void *coninfo_cls, 120iterate_post (void *coninfo_cls,
120 enum MHD_ValueKind kind, 121 enum MHD_ValueKind kind,
121 const char *key, 122 const char *key,
@@ -128,50 +129,50 @@ iterate_post (void *coninfo_cls,
128{ 129{
129 struct connection_info_struct *con_info = coninfo_cls; 130 struct connection_info_struct *con_info = coninfo_cls;
130 FILE *fp; 131 FILE *fp;
131 (void)kind; /* Unused. Silent compiler warning. */ 132 (void) kind; /* Unused. Silent compiler warning. */
132 (void)content_type; /* Unused. Silent compiler warning. */ 133 (void) content_type; /* Unused. Silent compiler warning. */
133 (void)transfer_encoding; /* Unused. Silent compiler warning. */ 134 (void) transfer_encoding; /* Unused. Silent compiler warning. */
134 (void)off; /* Unused. Silent compiler warning. */ 135 (void) off; /* Unused. Silent compiler warning. */
135 136
136 if (0 != strcmp (key, "file")) 137 if (0 != strcmp (key, "file"))
138 {
139 con_info->answerstring = servererrorpage;
140 con_info->answercode = MHD_HTTP_BAD_REQUEST;
141 return MHD_YES;
142 }
143
144 if (! con_info->fp)
145 {
146 if (0 != con_info->answercode) /* something went wrong */
147 return MHD_YES;
148 if (NULL != (fp = fopen (filename, "rb")))
137 { 149 {
138 con_info->answerstring = servererrorpage; 150 fclose (fp);
139 con_info->answercode = MHD_HTTP_BAD_REQUEST; 151 con_info->answerstring = fileexistspage;
152 con_info->answercode = MHD_HTTP_FORBIDDEN;
140 return MHD_YES; 153 return MHD_YES;
141 } 154 }
142 155 /* NOTE: This is technically a race with the 'fopen()' above,
143 if (! con_info->fp) 156 but there is no easy fix, short of moving to open(O_EXCL)
157 instead of using fopen(). For the example, we do not care. */
158 con_info->fp = fopen (filename, "ab");
159 if (! con_info->fp)
144 { 160 {
145 if (0 != con_info->answercode) /* something went wrong */ 161 con_info->answerstring = fileioerror;
146 return MHD_YES; 162 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
147 if (NULL != (fp = fopen (filename, "rb"))) 163 return MHD_YES;
148 {
149 fclose (fp);
150 con_info->answerstring = fileexistspage;
151 con_info->answercode = MHD_HTTP_FORBIDDEN;
152 return MHD_YES;
153 }
154 /* NOTE: This is technically a race with the 'fopen()' above,
155 but there is no easy fix, short of moving to open(O_EXCL)
156 instead of using fopen(). For the example, we do not care. */
157 con_info->fp = fopen (filename, "ab");
158 if (!con_info->fp)
159 {
160 con_info->answerstring = fileioerror;
161 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
162 return MHD_YES;
163 }
164 } 164 }
165 }
165 166
166 if (size > 0) 167 if (size > 0)
168 {
169 if (! fwrite (data, sizeof (char), size, con_info->fp))
167 { 170 {
168 if (! fwrite (data, sizeof (char), size, con_info->fp)) 171 con_info->answerstring = fileioerror;
169 { 172 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
170 con_info->answerstring = fileioerror; 173 return MHD_YES;
171 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
172 return MHD_YES;
173 }
174 } 174 }
175 }
175 176
176 return MHD_YES; 177 return MHD_YES;
177} 178}
@@ -184,31 +185,31 @@ request_completed (void *cls,
184 enum MHD_RequestTerminationCode toe) 185 enum MHD_RequestTerminationCode toe)
185{ 186{
186 struct connection_info_struct *con_info = *con_cls; 187 struct connection_info_struct *con_info = *con_cls;
187 (void)cls; /* Unused. Silent compiler warning. */ 188 (void) cls; /* Unused. Silent compiler warning. */
188 (void)connection; /* Unused. Silent compiler warning. */ 189 (void) connection; /* Unused. Silent compiler warning. */
189 (void)toe; /* Unused. Silent compiler warning. */ 190 (void) toe; /* Unused. Silent compiler warning. */
190 191
191 if (NULL == con_info) 192 if (NULL == con_info)
192 return; 193 return;
193 194
194 if (con_info->connectiontype == POST) 195 if (con_info->connectiontype == POST)
196 {
197 if (NULL != con_info->postprocessor)
195 { 198 {
196 if (NULL != con_info->postprocessor) 199 MHD_destroy_post_processor (con_info->postprocessor);
197 { 200 nr_of_uploading_clients--;
198 MHD_destroy_post_processor (con_info->postprocessor);
199 nr_of_uploading_clients--;
200 }
201
202 if (con_info->fp)
203 fclose (con_info->fp);
204 } 201 }
205 202
203 if (con_info->fp)
204 fclose (con_info->fp);
205 }
206
206 free (con_info); 207 free (con_info);
207 *con_cls = NULL; 208 *con_cls = NULL;
208} 209}
209 210
210 211
211static int 212static enum MHD_Result
212answer_to_connection (void *cls, 213answer_to_connection (void *cls,
213 struct MHD_Connection *connection, 214 struct MHD_Connection *connection,
214 const char *url, 215 const char *url,
@@ -218,109 +219,109 @@ answer_to_connection (void *cls,
218 size_t *upload_data_size, 219 size_t *upload_data_size,
219 void **con_cls) 220 void **con_cls)
220{ 221{
221 (void)cls; /* Unused. Silent compiler warning. */ 222 (void) cls; /* Unused. Silent compiler warning. */
222 (void)url; /* Unused. Silent compiler warning. */ 223 (void) url; /* Unused. Silent compiler warning. */
223 (void)version; /* Unused. Silent compiler warning. */ 224 (void) version; /* Unused. Silent compiler warning. */
224 225
225 if (NULL == *con_cls) 226 if (NULL == *con_cls)
226 { 227 {
227 /* First call, setup data structures */ 228 /* First call, setup data structures */
228 struct connection_info_struct *con_info; 229 struct connection_info_struct *con_info;
230
231 if (nr_of_uploading_clients >= MAXCLIENTS)
232 return send_page (connection,
233 busypage,
234 MHD_HTTP_SERVICE_UNAVAILABLE);
229 235
230 if (nr_of_uploading_clients >= MAXCLIENTS) 236 con_info = malloc (sizeof (struct connection_info_struct));
231 return send_page (connection, 237 if (NULL == con_info)
232 busypage, 238 return MHD_NO;
233 MHD_HTTP_SERVICE_UNAVAILABLE); 239 con_info->answercode = 0; /* none yet */
240 con_info->fp = NULL;
234 241
235 con_info = malloc (sizeof (struct connection_info_struct)); 242 if (0 == strcasecmp (method, MHD_HTTP_METHOD_POST))
236 if (NULL == con_info) 243 {
244 con_info->postprocessor =
245 MHD_create_post_processor (connection,
246 POSTBUFFERSIZE,
247 &iterate_post,
248 (void *) con_info);
249
250 if (NULL == con_info->postprocessor)
251 {
252 free (con_info);
237 return MHD_NO; 253 return MHD_NO;
238 con_info->answercode = 0; /* none yet */ 254 }
239 con_info->fp = NULL;
240 255
241 if (0 == strcasecmp (method, MHD_HTTP_METHOD_POST)) 256 nr_of_uploading_clients++;
242 {
243 con_info->postprocessor =
244 MHD_create_post_processor (connection,
245 POSTBUFFERSIZE,
246 &iterate_post,
247 (void *) con_info);
248 257
249 if (NULL == con_info->postprocessor) 258 con_info->connectiontype = POST;
250 { 259 }
251 free (con_info); 260 else
252 return MHD_NO; 261 {
253 } 262 con_info->connectiontype = GET;
263 }
254 264
255 nr_of_uploading_clients++; 265 *con_cls = (void *) con_info;
256 266
257 con_info->connectiontype = POST; 267 return MHD_YES;
258 } 268 }
259 else
260 {
261 con_info->connectiontype = GET;
262 }
263 269
264 *con_cls = (void *) con_info; 270 if (0 == strcasecmp (method, MHD_HTTP_METHOD_GET))
271 {
272 /* We just return the standard form for uploads on all GET requests */
273 char buffer[1024];
274
275 snprintf (buffer,
276 sizeof (buffer),
277 askpage,
278 nr_of_uploading_clients);
279 return send_page (connection,
280 buffer,
281 MHD_HTTP_OK);
282 }
265 283
266 return MHD_YES; 284 if (0 == strcasecmp (method, MHD_HTTP_METHOD_POST))
267 } 285 {
286 struct connection_info_struct *con_info = *con_cls;
268 287
269 if (0 == strcasecmp (method, MHD_HTTP_METHOD_GET)) 288 if (0 != *upload_data_size)
270 { 289 {
271 /* We just return the standard form for uploads on all GET requests */ 290 /* Upload not yet done */
272 char buffer[1024]; 291 if (0 != con_info->answercode)
292 {
293 /* we already know the answer, skip rest of upload */
294 *upload_data_size = 0;
295 return MHD_YES;
296 }
297 if (MHD_YES !=
298 MHD_post_process (con_info->postprocessor,
299 upload_data,
300 *upload_data_size))
301 {
302 con_info->answerstring = postprocerror;
303 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
304 }
305 *upload_data_size = 0;
273 306
274 snprintf (buffer, 307 return MHD_YES;
275 sizeof (buffer),
276 askpage,
277 nr_of_uploading_clients);
278 return send_page (connection,
279 buffer,
280 MHD_HTTP_OK);
281 } 308 }
282 309 /* Upload finished */
283 if (0 == strcasecmp (method, MHD_HTTP_METHOD_POST)) 310 if (NULL != con_info->fp)
284 { 311 {
285 struct connection_info_struct *con_info = *con_cls; 312 fclose (con_info->fp);
286 313 con_info->fp = NULL;
287 if (0 != *upload_data_size)
288 {
289 /* Upload not yet done */
290 if (0 != con_info->answercode)
291 {
292 /* we already know the answer, skip rest of upload */
293 *upload_data_size = 0;
294 return MHD_YES;
295 }
296 if (MHD_YES !=
297 MHD_post_process (con_info->postprocessor,
298 upload_data,
299 *upload_data_size))
300 {
301 con_info->answerstring = postprocerror;
302 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
303 }
304 *upload_data_size = 0;
305
306 return MHD_YES;
307 }
308 /* Upload finished */
309 if (NULL != con_info->fp)
310 {
311 fclose (con_info->fp);
312 con_info->fp = NULL;
313 }
314 if (0 == con_info->answercode)
315 {
316 /* No errors encountered, declare success */
317 con_info->answerstring = completepage;
318 con_info->answercode = MHD_HTTP_OK;
319 }
320 return send_page (connection,
321 con_info->answerstring,
322 con_info->answercode);
323 } 314 }
315 if (0 == con_info->answercode)
316 {
317 /* No errors encountered, declare success */
318 con_info->answerstring = completepage;
319 con_info->answercode = MHD_HTTP_OK;
320 }
321 return send_page (connection,
322 con_info->answerstring,
323 con_info->answercode);
324 }
324 325
325 /* Note a GET or a POST, generate error */ 326 /* Note a GET or a POST, generate error */
326 return send_page (connection, 327 return send_page (connection,
@@ -337,14 +338,15 @@ main ()
337 daemon = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD, 338 daemon = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD,
338 PORT, NULL, NULL, 339 PORT, NULL, NULL,
339 &answer_to_connection, NULL, 340 &answer_to_connection, NULL,
340 MHD_OPTION_NOTIFY_COMPLETED, &request_completed, NULL, 341 MHD_OPTION_NOTIFY_COMPLETED, &request_completed,
342 NULL,
341 MHD_OPTION_END); 343 MHD_OPTION_END);
342 if (NULL == daemon) 344 if (NULL == daemon)
343 { 345 {
344 fprintf (stderr, 346 fprintf (stderr,
345 "Failed to start daemon\n"); 347 "Failed to start daemon\n");
346 return 1; 348 return 1;
347 } 349 }
348 (void) getchar (); 350 (void) getchar ();
349 MHD_stop_daemon (daemon); 351 MHD_stop_daemon (daemon);
350 return 0; 352 return 0;
diff --git a/doc/examples/logging.c b/doc/examples/logging.c
index 239fbe7d..22ff7e62 100644
--- a/doc/examples/logging.c
+++ b/doc/examples/logging.c
@@ -14,28 +14,28 @@
14#define PORT 8888 14#define PORT 8888
15 15
16 16
17static int 17static enum MHD_Result
18print_out_key (void *cls, enum MHD_ValueKind kind, const char *key, 18print_out_key (void *cls, enum MHD_ValueKind kind, const char *key,
19 const char *value) 19 const char *value)
20{ 20{
21 (void)cls; /* Unused. Silent compiler warning. */ 21 (void) cls; /* Unused. Silent compiler warning. */
22 (void)kind; /* Unused. Silent compiler warning. */ 22 (void) kind; /* Unused. Silent compiler warning. */
23 printf ("%s: %s\n", key, value); 23 printf ("%s: %s\n", key, value);
24 return MHD_YES; 24 return MHD_YES;
25} 25}
26 26
27 27
28static int 28static enum MHD_Result
29answer_to_connection (void *cls, struct MHD_Connection *connection, 29answer_to_connection (void *cls, struct MHD_Connection *connection,
30 const char *url, const char *method, 30 const char *url, const char *method,
31 const char *version, const char *upload_data, 31 const char *version, const char *upload_data,
32 size_t *upload_data_size, void **con_cls) 32 size_t *upload_data_size, void **con_cls)
33{ 33{
34 (void)cls; /* Unused. Silent compiler warning. */ 34 (void) cls; /* Unused. Silent compiler warning. */
35 (void)version; /* Unused. Silent compiler warning. */ 35 (void) version; /* Unused. Silent compiler warning. */
36 (void)upload_data; /* Unused. Silent compiler warning. */ 36 (void) upload_data; /* Unused. Silent compiler warning. */
37 (void)upload_data_size; /* Unused. Silent compiler warning. */ 37 (void) upload_data_size; /* Unused. Silent compiler warning. */
38 (void)con_cls; /* Unused. Silent compiler warning. */ 38 (void) con_cls; /* Unused. Silent compiler warning. */
39 printf ("New %s request for %s using version %s\n", method, url, version); 39 printf ("New %s request for %s using version %s\n", method, url, version);
40 40
41 MHD_get_connection_values (connection, MHD_HEADER_KIND, print_out_key, 41 MHD_get_connection_values (connection, MHD_HEADER_KIND, print_out_key,
diff --git a/doc/examples/responseheaders.c b/doc/examples/responseheaders.c
index 0f459c2e..5c0580b6 100644
--- a/doc/examples/responseheaders.c
+++ b/doc/examples/responseheaders.c
@@ -19,7 +19,7 @@
19#define FILENAME "picture.png" 19#define FILENAME "picture.png"
20#define MIMETYPE "image/png" 20#define MIMETYPE "image/png"
21 21
22static int 22static enum MHD_Result
23answer_to_connection (void *cls, struct MHD_Connection *connection, 23answer_to_connection (void *cls, struct MHD_Connection *connection,
24 const char *url, const char *method, 24 const char *url, const char *method,
25 const char *version, const char *upload_data, 25 const char *version, const char *upload_data,
@@ -27,43 +27,43 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
27{ 27{
28 struct MHD_Response *response; 28 struct MHD_Response *response;
29 int fd; 29 int fd;
30 int ret; 30 enum MHD_Result ret;
31 struct stat sbuf; 31 struct stat sbuf;
32 (void)cls; /* Unused. Silent compiler warning. */ 32 (void) cls; /* Unused. Silent compiler warning. */
33 (void)url; /* Unused. Silent compiler warning. */ 33 (void) url; /* Unused. Silent compiler warning. */
34 (void)version; /* Unused. Silent compiler warning. */ 34 (void) version; /* Unused. Silent compiler warning. */
35 (void)upload_data; /* Unused. Silent compiler warning. */ 35 (void) upload_data; /* Unused. Silent compiler warning. */
36 (void)upload_data_size; /* Unused. Silent compiler warning. */ 36 (void) upload_data_size; /* Unused. Silent compiler warning. */
37 (void)con_cls; /* Unused. Silent compiler warning. */ 37 (void) con_cls; /* Unused. Silent compiler warning. */
38 38
39 if (0 != strcmp (method, "GET")) 39 if (0 != strcmp (method, "GET"))
40 return MHD_NO; 40 return MHD_NO;
41 41
42 if ( (-1 == (fd = open (FILENAME, O_RDONLY))) || 42 if ( (-1 == (fd = open (FILENAME, O_RDONLY))) ||
43 (0 != fstat (fd, &sbuf)) ) 43 (0 != fstat (fd, &sbuf)) )
44 { 44 {
45 const char *errorstr = 45 const char *errorstr =
46 "<html><body>An internal server error has occured!\ 46 "<html><body>An internal server error has occured!\
47 </body></html>"; 47 </body></html>";
48 /* error accessing file */ 48 /* error accessing file */
49 if (fd != -1) 49 if (fd != -1)
50 (void) close (fd); 50 (void) close (fd);
51 response = 51 response =
52 MHD_create_response_from_buffer (strlen (errorstr), 52 MHD_create_response_from_buffer (strlen (errorstr),
53 (void *) errorstr, 53 (void *) errorstr,
54 MHD_RESPMEM_PERSISTENT); 54 MHD_RESPMEM_PERSISTENT);
55 if (NULL != response) 55 if (NULL != response)
56 { 56 {
57 ret = 57 ret =
58 MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, 58 MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR,
59 response); 59 response);
60 MHD_destroy_response (response); 60 MHD_destroy_response (response);
61 61
62 return ret; 62 return ret;
63 }
64 else
65 return MHD_NO;
66 } 63 }
64 else
65 return MHD_NO;
66 }
67 response = 67 response =
68 MHD_create_response_from_fd_at_offset64 (sbuf.st_size, fd, 0); 68 MHD_create_response_from_fd_at_offset64 (sbuf.st_size, fd, 0);
69 MHD_add_response_header (response, "Content-Type", MIMETYPE); 69 MHD_add_response_header (response, "Content-Type", MIMETYPE);
diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c
index b5b25440..adabc610 100644
--- a/doc/examples/sessions.c
+++ b/doc/examples/sessions.c
@@ -11,7 +11,7 @@
11#include <time.h> 11#include <time.h>
12#include <microhttpd.h> 12#include <microhttpd.h>
13 13
14#if defined _WIN32 && !defined(__MINGW64_VERSION_MAJOR) 14#if defined _WIN32 && ! defined(__MINGW64_VERSION_MAJOR)
15static int 15static int
16asprintf (char **resultp, const char *format, ...) 16asprintf (char **resultp, const char *format, ...)
17{ 17{
@@ -32,7 +32,7 @@ asprintf (char **resultp, const char *format, ...)
32 if (result != NULL) 32 if (result != NULL)
33 { 33 {
34 int len2 = _vscprintf ((char *) format, argptr); 34 int len2 = _vscprintf ((char *) format, argptr);
35 if (len2 != len - 1 || len2 <= 0) 35 if ((len2 != len - 1) || (len2 <= 0))
36 { 36 {
37 free (result); 37 free (result);
38 result = NULL; 38 result = NULL;
@@ -49,37 +49,45 @@ asprintf (char **resultp, const char *format, ...)
49 va_end (argptr); 49 va_end (argptr);
50 return len; 50 return len;
51} 51}
52
53
52#endif 54#endif
53 55
54/** 56/**
55 * Invalid method page. 57 * Invalid method page.
56 */ 58 */
57#define METHOD_ERROR "<html><head><title>Illegal request</title></head><body>Go away.</body></html>" 59#define METHOD_ERROR \
60 "<html><head><title>Illegal request</title></head><body>Go away.</body></html>"
58 61
59/** 62/**
60 * Invalid URL page. 63 * Invalid URL page.
61 */ 64 */
62#define NOT_FOUND_ERROR "<html><head><title>Not found</title></head><body>Go away.</body></html>" 65#define NOT_FOUND_ERROR \
66 "<html><head><title>Not found</title></head><body>Go away.</body></html>"
63 67
64/** 68/**
65 * Front page. (/) 69 * Front page. (/)
66 */ 70 */
67#define MAIN_PAGE "<html><head><title>Welcome</title></head><body><form action=\"/2\" method=\"post\">What is your name? <input type=\"text\" name=\"v1\" value=\"%s\" /><input type=\"submit\" value=\"Next\" /></body></html>" 71#define MAIN_PAGE \
72 "<html><head><title>Welcome</title></head><body><form action=\"/2\" method=\"post\">What is your name? <input type=\"text\" name=\"v1\" value=\"%s\" /><input type=\"submit\" value=\"Next\" /></body></html>"
68 73
69/** 74/**
70 * Second page. (/2) 75 * Second page. (/2)
71 */ 76 */
72#define SECOND_PAGE "<html><head><title>Tell me more</title></head><body><a href=\"/\">previous</a> <form action=\"/S\" method=\"post\">%s, what is your job? <input type=\"text\" name=\"v2\" value=\"%s\" /><input type=\"submit\" value=\"Next\" /></body></html>" 77#define SECOND_PAGE \
78 "<html><head><title>Tell me more</title></head><body><a href=\"/\">previous</a> <form action=\"/S\" method=\"post\">%s, what is your job? <input type=\"text\" name=\"v2\" value=\"%s\" /><input type=\"submit\" value=\"Next\" /></body></html>"
73 79
74/** 80/**
75 * Second page (/S) 81 * Second page (/S)
76 */ 82 */
77#define SUBMIT_PAGE "<html><head><title>Ready to submit?</title></head><body><form action=\"/F\" method=\"post\"><a href=\"/2\">previous </a> <input type=\"hidden\" name=\"DONE\" value=\"yes\" /><input type=\"submit\" value=\"Submit\" /></body></html>" 83#define SUBMIT_PAGE \
84 "<html><head><title>Ready to submit?</title></head><body><form action=\"/F\" method=\"post\"><a href=\"/2\">previous </a> <input type=\"hidden\" name=\"DONE\" value=\"yes\" /><input type=\"submit\" value=\"Submit\" /></body></html>"
78 85
79/** 86/**
80 * Last page. 87 * Last page.
81 */ 88 */
82#define LAST_PAGE "<html><head><title>Thank you</title></head><body>Thank you.</body></html>" 89#define LAST_PAGE \
90 "<html><head><title>Thank you</title></head><body>Thank you.</body></html>"
83 91
84/** 92/**
85 * Name of our cookie. 93 * Name of our cookie.
@@ -159,8 +167,6 @@ struct Request
159static struct Session *sessions; 167static struct Session *sessions;
160 168
161 169
162
163
164/** 170/**
165 * Return the session handle for this connection, or 171 * Return the session handle for this connection, or
166 * create one if this is a new user. 172 * create one if this is a new user.
@@ -172,40 +178,40 @@ get_session (struct MHD_Connection *connection)
172 const char *cookie; 178 const char *cookie;
173 179
174 cookie = MHD_lookup_connection_value (connection, 180 cookie = MHD_lookup_connection_value (connection,
175 MHD_COOKIE_KIND, 181 MHD_COOKIE_KIND,
176 COOKIE_NAME); 182 COOKIE_NAME);
177 if (cookie != NULL) 183 if (cookie != NULL)
184 {
185 /* find existing session */
186 ret = sessions;
187 while (NULL != ret)
178 { 188 {
179 /* find existing session */ 189 if (0 == strcmp (cookie, ret->sid))
180 ret = sessions; 190 break;
181 while (NULL != ret) 191 ret = ret->next;
182 {
183 if (0 == strcmp (cookie, ret->sid))
184 break;
185 ret = ret->next;
186 }
187 if (NULL != ret)
188 {
189 ret->rc++;
190 return ret;
191 }
192 } 192 }
193 if (NULL != ret)
194 {
195 ret->rc++;
196 return ret;
197 }
198 }
193 /* create fresh session */ 199 /* create fresh session */
194 ret = calloc (1, sizeof (struct Session)); 200 ret = calloc (1, sizeof (struct Session));
195 if (NULL == ret) 201 if (NULL == ret)
196 { 202 {
197 fprintf (stderr, "calloc error: %s\n", strerror (errno)); 203 fprintf (stderr, "calloc error: %s\n", strerror (errno));
198 return NULL; 204 return NULL;
199 } 205 }
200 /* not a super-secure way to generate a random session ID, 206 /* not a super-secure way to generate a random session ID,
201 but should do for a simple example... */ 207 but should do for a simple example... */
202 snprintf (ret->sid, 208 snprintf (ret->sid,
203 sizeof (ret->sid), 209 sizeof (ret->sid),
204 "%X%X%X%X", 210 "%X%X%X%X",
205 (unsigned int) rand (), 211 (unsigned int) rand (),
206 (unsigned int) rand (), 212 (unsigned int) rand (),
207 (unsigned int) rand (), 213 (unsigned int) rand (),
208 (unsigned int) rand ()); 214 (unsigned int) rand ());
209 ret->rc++; 215 ret->rc++;
210 ret->start = time (NULL); 216 ret->start = time (NULL);
211 ret->next = sessions; 217 ret->next = sessions;
@@ -221,12 +227,12 @@ get_session (struct MHD_Connection *connection)
221 * @param mime mime type to use 227 * @param mime mime type to use
222 * @param session session information 228 * @param session session information
223 * @param connection connection to process 229 * @param connection connection to process
224 * @param MHD_YES on success, MHD_NO on failure 230 * @param #MHD_YES on success, #MHD_NO on failure
225 */ 231 */
226typedef int (*PageHandler)(const void *cls, 232typedef enum MHD_Result (*PageHandler)(const void *cls,
227 const char *mime, 233 const char *mime,
228 struct Session *session, 234 struct Session *session,
229 struct MHD_Connection *connection); 235 struct MHD_Connection *connection);
230 236
231 237
232/** 238/**
@@ -264,22 +270,22 @@ struct Page
264 */ 270 */
265static void 271static void
266add_session_cookie (struct Session *session, 272add_session_cookie (struct Session *session,
267 struct MHD_Response *response) 273 struct MHD_Response *response)
268{ 274{
269 char cstr[256]; 275 char cstr[256];
270 snprintf (cstr, 276 snprintf (cstr,
271 sizeof (cstr), 277 sizeof (cstr),
272 "%s=%s", 278 "%s=%s",
273 COOKIE_NAME, 279 COOKIE_NAME,
274 session->sid); 280 session->sid);
275 if (MHD_NO == 281 if (MHD_NO ==
276 MHD_add_response_header (response, 282 MHD_add_response_header (response,
277 MHD_HTTP_HEADER_SET_COOKIE, 283 MHD_HTTP_HEADER_SET_COOKIE,
278 cstr)) 284 cstr))
279 { 285 {
280 fprintf (stderr, 286 fprintf (stderr,
281 "Failed to set session cookie header!\n"); 287 "Failed to set session cookie header!\n");
282 } 288 }
283} 289}
284 290
285 291
@@ -292,27 +298,27 @@ add_session_cookie (struct Session *session,
292 * @param session session handle 298 * @param session session handle
293 * @param connection connection to use 299 * @param connection connection to use
294 */ 300 */
295static int 301static enum MHD_Result
296serve_simple_form (const void *cls, 302serve_simple_form (const void *cls,
297 const char *mime, 303 const char *mime,
298 struct Session *session, 304 struct Session *session,
299 struct MHD_Connection *connection) 305 struct MHD_Connection *connection)
300{ 306{
301 int ret; 307 enum MHD_Result ret;
302 const char *form = cls; 308 const char *form = cls;
303 struct MHD_Response *response; 309 struct MHD_Response *response;
304 310
305 /* return static form */ 311 /* return static form */
306 response = MHD_create_response_from_buffer (strlen (form), 312 response = MHD_create_response_from_buffer (strlen (form),
307 (void *) form, 313 (void *) form,
308 MHD_RESPMEM_PERSISTENT); 314 MHD_RESPMEM_PERSISTENT);
309 add_session_cookie (session, response); 315 add_session_cookie (session, response);
310 MHD_add_response_header (response, 316 MHD_add_response_header (response,
311 MHD_HTTP_HEADER_CONTENT_ENCODING, 317 MHD_HTTP_HEADER_CONTENT_ENCODING,
312 mime); 318 mime);
313 ret = MHD_queue_response (connection, 319 ret = MHD_queue_response (connection,
314 MHD_HTTP_OK, 320 MHD_HTTP_OK,
315 response); 321 response);
316 MHD_destroy_response (response); 322 MHD_destroy_response (response);
317 return ret; 323 return ret;
318} 324}
@@ -326,35 +332,35 @@ serve_simple_form (const void *cls,
326 * @param session session handle 332 * @param session session handle
327 * @param connection connection to use 333 * @param connection connection to use
328 */ 334 */
329static int 335static enum MHD_Result
330fill_v1_form (const void *cls, 336fill_v1_form (const void *cls,
331 const char *mime, 337 const char *mime,
332 struct Session *session, 338 struct Session *session,
333 struct MHD_Connection *connection) 339 struct MHD_Connection *connection)
334{ 340{
335 int ret; 341 enum MHD_Result ret;
336 const char *form = cls; 342 const char *form = cls;
337 char *reply; 343 char *reply;
338 struct MHD_Response *response; 344 struct MHD_Response *response;
339 345
340 if (-1 == asprintf (&reply, 346 if (-1 == asprintf (&reply,
341 form, 347 form,
342 session->value_1)) 348 session->value_1))
343 { 349 {
344 /* oops */ 350 /* oops */
345 return MHD_NO; 351 return MHD_NO;
346 } 352 }
347 /* return static form */ 353 /* return static form */
348 response = MHD_create_response_from_buffer (strlen (reply), 354 response = MHD_create_response_from_buffer (strlen (reply),
349 (void *) reply, 355 (void *) reply,
350 MHD_RESPMEM_MUST_FREE); 356 MHD_RESPMEM_MUST_FREE);
351 add_session_cookie (session, response); 357 add_session_cookie (session, response);
352 MHD_add_response_header (response, 358 MHD_add_response_header (response,
353 MHD_HTTP_HEADER_CONTENT_ENCODING, 359 MHD_HTTP_HEADER_CONTENT_ENCODING,
354 mime); 360 mime);
355 ret = MHD_queue_response (connection, 361 ret = MHD_queue_response (connection,
356 MHD_HTTP_OK, 362 MHD_HTTP_OK,
357 response); 363 response);
358 MHD_destroy_response (response); 364 MHD_destroy_response (response);
359 return ret; 365 return ret;
360} 366}
@@ -368,36 +374,36 @@ fill_v1_form (const void *cls,
368 * @param session session handle 374 * @param session session handle
369 * @param connection connection to use 375 * @param connection connection to use
370 */ 376 */
371static int 377static enum MHD_Result
372fill_v1_v2_form (const void *cls, 378fill_v1_v2_form (const void *cls,
373 const char *mime, 379 const char *mime,
374 struct Session *session, 380 struct Session *session,
375 struct MHD_Connection *connection) 381 struct MHD_Connection *connection)
376{ 382{
377 int ret; 383 enum MHD_Result ret;
378 const char *form = cls; 384 const char *form = cls;
379 char *reply; 385 char *reply;
380 struct MHD_Response *response; 386 struct MHD_Response *response;
381 387
382 if (-1 == asprintf (&reply, 388 if (-1 == asprintf (&reply,
383 form, 389 form,
384 session->value_1, 390 session->value_1,
385 session->value_2)) 391 session->value_2))
386 { 392 {
387 /* oops */ 393 /* oops */
388 return MHD_NO; 394 return MHD_NO;
389 } 395 }
390 /* return static form */ 396 /* return static form */
391 response = MHD_create_response_from_buffer (strlen (reply), 397 response = MHD_create_response_from_buffer (strlen (reply),
392 (void *) reply, 398 (void *) reply,
393 MHD_RESPMEM_MUST_FREE); 399 MHD_RESPMEM_MUST_FREE);
394 add_session_cookie (session, response); 400 add_session_cookie (session, response);
395 MHD_add_response_header (response, 401 MHD_add_response_header (response,
396 MHD_HTTP_HEADER_CONTENT_ENCODING, 402 MHD_HTTP_HEADER_CONTENT_ENCODING,
397 mime); 403 mime);
398 ret = MHD_queue_response (connection, 404 ret = MHD_queue_response (connection,
399 MHD_HTTP_OK, 405 MHD_HTTP_OK,
400 response); 406 response);
401 MHD_destroy_response (response); 407 MHD_destroy_response (response);
402 return ret; 408 return ret;
403} 409}
@@ -411,27 +417,27 @@ fill_v1_v2_form (const void *cls,
411 * @param session session handle 417 * @param session session handle
412 * @param connection connection to use 418 * @param connection connection to use
413 */ 419 */
414static int 420static enum MHD_Result
415not_found_page (const void *cls, 421not_found_page (const void *cls,
416 const char *mime, 422 const char *mime,
417 struct Session *session, 423 struct Session *session,
418 struct MHD_Connection *connection) 424 struct MHD_Connection *connection)
419{ 425{
420 int ret; 426 enum MHD_Result ret;
421 struct MHD_Response *response; 427 struct MHD_Response *response;
422 (void)cls; /* Unused. Silent compiler warning. */ 428 (void) cls; /* Unused. Silent compiler warning. */
423 (void)session; /* Unused. Silent compiler warning. */ 429 (void) session; /* Unused. Silent compiler warning. */
424 430
425 /* unsupported HTTP method */ 431 /* unsupported HTTP method */
426 response = MHD_create_response_from_buffer (strlen (NOT_FOUND_ERROR), 432 response = MHD_create_response_from_buffer (strlen (NOT_FOUND_ERROR),
427 (void *) NOT_FOUND_ERROR, 433 (void *) NOT_FOUND_ERROR,
428 MHD_RESPMEM_PERSISTENT); 434 MHD_RESPMEM_PERSISTENT);
429 ret = MHD_queue_response (connection, 435 ret = MHD_queue_response (connection,
430 MHD_HTTP_NOT_FOUND, 436 MHD_HTTP_NOT_FOUND,
431 response); 437 response);
432 MHD_add_response_header (response, 438 MHD_add_response_header (response,
433 MHD_HTTP_HEADER_CONTENT_ENCODING, 439 MHD_HTTP_HEADER_CONTENT_ENCODING,
434 mime); 440 mime);
435 MHD_destroy_response (response); 441 MHD_destroy_response (response);
436 return ret; 442 return ret;
437} 443}
@@ -440,15 +446,13 @@ not_found_page (const void *cls,
440/** 446/**
441 * List of all pages served by this HTTP server. 447 * List of all pages served by this HTTP server.
442 */ 448 */
443static struct Page pages[] = 449static struct Page pages[] = {
444 { 450 { "/", "text/html", &fill_v1_form, MAIN_PAGE },
445 { "/", "text/html", &fill_v1_form, MAIN_PAGE }, 451 { "/2", "text/html", &fill_v1_v2_form, SECOND_PAGE },
446 { "/2", "text/html", &fill_v1_v2_form, SECOND_PAGE }, 452 { "/S", "text/html", &serve_simple_form, SUBMIT_PAGE },
447 { "/S", "text/html", &serve_simple_form, SUBMIT_PAGE }, 453 { "/F", "text/html", &serve_simple_form, LAST_PAGE },
448 { "/F", "text/html", &serve_simple_form, LAST_PAGE }, 454 { NULL, NULL, &not_found_page, NULL } /* 404 */
449 { NULL, NULL, &not_found_page, NULL } /* 404 */ 455};
450 };
451
452 456
453 457
454/** 458/**
@@ -470,53 +474,53 @@ static struct Page pages[] =
470 * @return MHD_YES to continue iterating, 474 * @return MHD_YES to continue iterating,
471 * MHD_NO to abort the iteration 475 * MHD_NO to abort the iteration
472 */ 476 */
473static int 477static enum MHD_Result
474post_iterator (void *cls, 478post_iterator (void *cls,
475 enum MHD_ValueKind kind, 479 enum MHD_ValueKind kind,
476 const char *key, 480 const char *key,
477 const char *filename, 481 const char *filename,
478 const char *content_type, 482 const char *content_type,
479 const char *transfer_encoding, 483 const char *transfer_encoding,
480 const char *data, uint64_t off, size_t size) 484 const char *data, uint64_t off, size_t size)
481{ 485{
482 struct Request *request = cls; 486 struct Request *request = cls;
483 struct Session *session = request->session; 487 struct Session *session = request->session;
484 (void)kind; /* Unused. Silent compiler warning. */ 488 (void) kind; /* Unused. Silent compiler warning. */
485 (void)filename; /* Unused. Silent compiler warning. */ 489 (void) filename; /* Unused. Silent compiler warning. */
486 (void)content_type; /* Unused. Silent compiler warning. */ 490 (void) content_type; /* Unused. Silent compiler warning. */
487 (void)transfer_encoding; /* Unused. Silent compiler warning. */ 491 (void) transfer_encoding; /* Unused. Silent compiler warning. */
488 492
489 if (0 == strcmp ("DONE", key)) 493 if (0 == strcmp ("DONE", key))
490 { 494 {
491 fprintf (stdout, 495 fprintf (stdout,
492 "Session `%s' submitted `%s', `%s'\n", 496 "Session `%s' submitted `%s', `%s'\n",
493 session->sid, 497 session->sid,
494 session->value_1, 498 session->value_1,
495 session->value_2); 499 session->value_2);
496 return MHD_YES; 500 return MHD_YES;
497 } 501 }
498 if (0 == strcmp ("v1", key)) 502 if (0 == strcmp ("v1", key))
499 { 503 {
500 if (size + off > sizeof(session->value_1)) 504 if (size + off > sizeof(session->value_1))
501 size = sizeof (session->value_1) - off; 505 size = sizeof (session->value_1) - off;
502 memcpy (&session->value_1[off], 506 memcpy (&session->value_1[off],
503 data, 507 data,
504 size); 508 size);
505 if (size + off < sizeof (session->value_1)) 509 if (size + off < sizeof (session->value_1))
506 session->value_1[size+off] = '\0'; 510 session->value_1[size + off] = '\0';
507 return MHD_YES; 511 return MHD_YES;
508 } 512 }
509 if (0 == strcmp ("v2", key)) 513 if (0 == strcmp ("v2", key))
510 { 514 {
511 if (size + off > sizeof(session->value_2)) 515 if (size + off > sizeof(session->value_2))
512 size = sizeof (session->value_2) - off; 516 size = sizeof (session->value_2) - off;
513 memcpy (&session->value_2[off], 517 memcpy (&session->value_2[off],
514 data, 518 data,
515 size); 519 size);
516 if (size + off < sizeof (session->value_2)) 520 if (size + off < sizeof (session->value_2))
517 session->value_2[size+off] = '\0'; 521 session->value_2[size + off] = '\0';
518 return MHD_YES; 522 return MHD_YES;
519 } 523 }
520 fprintf (stderr, "Unsupported form value `%s'\n", key); 524 fprintf (stderr, "Unsupported form value `%s'\n", key);
521 return MHD_YES; 525 return MHD_YES;
522} 526}
@@ -556,101 +560,101 @@ post_iterator (void *cls,
556 * MHS_NO if the socket must be closed due to a serios 560 * MHS_NO if the socket must be closed due to a serios
557 * error while handling the request 561 * error while handling the request
558 */ 562 */
559static int 563static enum MHD_Result
560create_response (void *cls, 564create_response (void *cls,
561 struct MHD_Connection *connection, 565 struct MHD_Connection *connection,
562 const char *url, 566 const char *url,
563 const char *method, 567 const char *method,
564 const char *version, 568 const char *version,
565 const char *upload_data, 569 const char *upload_data,
566 size_t *upload_data_size, 570 size_t *upload_data_size,
567 void **ptr) 571 void **ptr)
568{ 572{
569 struct MHD_Response *response; 573 struct MHD_Response *response;
570 struct Request *request; 574 struct Request *request;
571 struct Session *session; 575 struct Session *session;
572 int ret; 576 enum MHD_Result ret;
573 unsigned int i; 577 unsigned int i;
574 (void)cls; /* Unused. Silent compiler warning. */ 578 (void) cls; /* Unused. Silent compiler warning. */
575 (void)version; /* Unused. Silent compiler warning. */ 579 (void) version; /* Unused. Silent compiler warning. */
576 580
577 request = *ptr; 581 request = *ptr;
578 if (NULL == request) 582 if (NULL == request)
583 {
584 request = calloc (1, sizeof (struct Request));
585 if (NULL == request)
579 { 586 {
580 request = calloc (1, sizeof (struct Request)); 587 fprintf (stderr, "calloc error: %s\n", strerror (errno));
581 if (NULL == request) 588 return MHD_NO;
582 { 589 }
583 fprintf (stderr, "calloc error: %s\n", strerror (errno)); 590 *ptr = request;
584 return MHD_NO; 591 if (0 == strcmp (method, MHD_HTTP_METHOD_POST))
585 } 592 {
586 *ptr = request; 593 request->pp = MHD_create_post_processor (connection, 1024,
587 if (0 == strcmp (method, MHD_HTTP_METHOD_POST)) 594 &post_iterator, request);
588 { 595 if (NULL == request->pp)
589 request->pp = MHD_create_post_processor (connection, 1024, 596 {
590 &post_iterator, request); 597 fprintf (stderr, "Failed to setup post processor for `%s'\n",
591 if (NULL == request->pp) 598 url);
592 { 599 return MHD_NO; /* internal error */
593 fprintf (stderr, "Failed to setup post processor for `%s'\n", 600 }
594 url);
595 return MHD_NO; /* internal error */
596 }
597 }
598 return MHD_YES;
599 } 601 }
602 return MHD_YES;
603 }
600 if (NULL == request->session) 604 if (NULL == request->session)
605 {
606 request->session = get_session (connection);
607 if (NULL == request->session)
601 { 608 {
602 request->session = get_session (connection); 609 fprintf (stderr, "Failed to setup session for `%s'\n",
603 if (NULL == request->session) 610 url);
604 { 611 return MHD_NO; /* internal error */
605 fprintf (stderr, "Failed to setup session for `%s'\n",
606 url);
607 return MHD_NO; /* internal error */
608 }
609 } 612 }
613 }
610 session = request->session; 614 session = request->session;
611 session->start = time (NULL); 615 session->start = time (NULL);
612 if (0 == strcmp (method, MHD_HTTP_METHOD_POST)) 616 if (0 == strcmp (method, MHD_HTTP_METHOD_POST))
617 {
618 /* evaluate POST data */
619 MHD_post_process (request->pp,
620 upload_data,
621 *upload_data_size);
622 if (0 != *upload_data_size)
613 { 623 {
614 /* evaluate POST data */ 624 *upload_data_size = 0;
615 MHD_post_process (request->pp, 625 return MHD_YES;
616 upload_data,
617 *upload_data_size);
618 if (0 != *upload_data_size)
619 {
620 *upload_data_size = 0;
621 return MHD_YES;
622 }
623 /* done with POST data, serve response */
624 MHD_destroy_post_processor (request->pp);
625 request->pp = NULL;
626 method = MHD_HTTP_METHOD_GET; /* fake 'GET' */
627 if (NULL != request->post_url)
628 url = request->post_url;
629 } 626 }
627 /* done with POST data, serve response */
628 MHD_destroy_post_processor (request->pp);
629 request->pp = NULL;
630 method = MHD_HTTP_METHOD_GET; /* fake 'GET' */
631 if (NULL != request->post_url)
632 url = request->post_url;
633 }
630 634
631 if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || 635 if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) ||
632 (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) 636 (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) )
633 { 637 {
634 /* find out which page to serve */ 638 /* find out which page to serve */
635 i=0; 639 i = 0;
636 while ( (pages[i].url != NULL) && 640 while ( (pages[i].url != NULL) &&
637 (0 != strcmp (pages[i].url, url)) ) 641 (0 != strcmp (pages[i].url, url)) )
638 i++; 642 i++;
639 ret = pages[i].handler (pages[i].handler_cls, 643 ret = pages[i].handler (pages[i].handler_cls,
640 pages[i].mime, 644 pages[i].mime,
641 session, connection); 645 session, connection);
642 if (ret != MHD_YES) 646 if (ret != MHD_YES)
643 fprintf (stderr, "Failed to create page for `%s'\n", 647 fprintf (stderr, "Failed to create page for `%s'\n",
644 url); 648 url);
645 return ret; 649 return ret;
646 } 650 }
647 /* unsupported HTTP method */ 651 /* unsupported HTTP method */
648 response = MHD_create_response_from_buffer (strlen (METHOD_ERROR), 652 response = MHD_create_response_from_buffer (strlen (METHOD_ERROR),
649 (void *) METHOD_ERROR, 653 (void *) METHOD_ERROR,
650 MHD_RESPMEM_PERSISTENT); 654 MHD_RESPMEM_PERSISTENT);
651 ret = MHD_queue_response (connection, 655 ret = MHD_queue_response (connection,
652 MHD_HTTP_NOT_ACCEPTABLE, 656 MHD_HTTP_NOT_ACCEPTABLE,
653 response); 657 response);
654 MHD_destroy_response (response); 658 MHD_destroy_response (response);
655 return ret; 659 return ret;
656} 660}
@@ -667,14 +671,14 @@ create_response (void *cls,
667 */ 671 */
668static void 672static void
669request_completed_callback (void *cls, 673request_completed_callback (void *cls,
670 struct MHD_Connection *connection, 674 struct MHD_Connection *connection,
671 void **con_cls, 675 void **con_cls,
672 enum MHD_RequestTerminationCode toe) 676 enum MHD_RequestTerminationCode toe)
673{ 677{
674 struct Request *request = *con_cls; 678 struct Request *request = *con_cls;
675 (void)cls; /* Unused. Silent compiler warning. */ 679 (void) cls; /* Unused. Silent compiler warning. */
676 (void)connection; /* Unused. Silent compiler warning. */ 680 (void) connection; /* Unused. Silent compiler warning. */
677 (void)toe; /* Unused. Silent compiler warning. */ 681 (void) toe; /* Unused. Silent compiler warning. */
678 682
679 if (NULL == request) 683 if (NULL == request)
680 return; 684 return;
@@ -702,21 +706,21 @@ expire_sessions ()
702 prev = NULL; 706 prev = NULL;
703 pos = sessions; 707 pos = sessions;
704 while (NULL != pos) 708 while (NULL != pos)
709 {
710 next = pos->next;
711 if (now - pos->start > 60 * 60)
705 { 712 {
706 next = pos->next; 713 /* expire sessions after 1h */
707 if (now - pos->start > 60 * 60) 714 if (NULL == prev)
708 { 715 sessions = pos->next;
709 /* expire sessions after 1h */
710 if (NULL == prev)
711 sessions = pos->next;
712 else
713 prev->next = next;
714 free (pos);
715 }
716 else 716 else
717 prev = pos; 717 prev->next = next;
718 pos = next; 718 free (pos);
719 } 719 }
720 else
721 prev = pos;
722 pos = next;
723 }
720} 724}
721 725
722 726
@@ -737,48 +741,49 @@ main (int argc, char *const *argv)
737 MHD_UNSIGNED_LONG_LONG mhd_timeout; 741 MHD_UNSIGNED_LONG_LONG mhd_timeout;
738 742
739 if (argc != 2) 743 if (argc != 2)
740 { 744 {
741 printf ("%s PORT\n", argv[0]); 745 printf ("%s PORT\n", argv[0]);
742 return 1; 746 return 1;
743 } 747 }
744 /* initialize PRNG */ 748 /* initialize PRNG */
745 srand ((unsigned int) time (NULL)); 749 srand ((unsigned int) time (NULL));
746 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 750 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
747 atoi (argv[1]), 751 atoi (argv[1]),
748 NULL, NULL, 752 NULL, NULL,
749 &create_response, NULL, 753 &create_response, NULL,
750 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 15, 754 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 15,
751 MHD_OPTION_NOTIFY_COMPLETED, &request_completed_callback, NULL, 755 MHD_OPTION_NOTIFY_COMPLETED,
752 MHD_OPTION_END); 756 &request_completed_callback, NULL,
757 MHD_OPTION_END);
753 if (NULL == d) 758 if (NULL == d)
754 return 1; 759 return 1;
755 while (1) 760 while (1)
761 {
762 expire_sessions ();
763 max = 0;
764 FD_ZERO (&rs);
765 FD_ZERO (&ws);
766 FD_ZERO (&es);
767 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
768 break; /* fatal internal error */
769 if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES)
756 { 770 {
757 expire_sessions (); 771 tv.tv_sec = mhd_timeout / 1000;
758 max = 0; 772 tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000;
759 FD_ZERO (&rs); 773 tvp = &tv;
760 FD_ZERO (&ws);
761 FD_ZERO (&es);
762 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
763 break; /* fatal internal error */
764 if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES)
765 {
766 tv.tv_sec = mhd_timeout / 1000;
767 tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000;
768 tvp = &tv;
769 }
770 else
771 tvp = NULL;
772 if (-1 == select (max + 1, &rs, &ws, &es, tvp))
773 {
774 if (EINTR != errno)
775 fprintf (stderr,
776 "Aborting due to error during select: %s\n",
777 strerror (errno));
778 break;
779 }
780 MHD_run (d);
781 } 774 }
775 else
776 tvp = NULL;
777 if (-1 == select (max + 1, &rs, &ws, &es, tvp))
778 {
779 if (EINTR != errno)
780 fprintf (stderr,
781 "Aborting due to error during select: %s\n",
782 strerror (errno));
783 break;
784 }
785 MHD_run (d);
786 }
782 MHD_stop_daemon (d); 787 MHD_stop_daemon (d);
783 return 0; 788 return 0;
784} 789}
diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c
index a3bba94a..1e52e5dd 100644
--- a/doc/examples/simplepost.c
+++ b/doc/examples/simplepost.c
@@ -13,7 +13,7 @@
13#include <string.h> 13#include <string.h>
14#include <stdlib.h> 14#include <stdlib.h>
15 15
16#if defined(_MSC_VER) && _MSC_VER+0 <= 1800 16#if defined(_MSC_VER) && _MSC_VER + 0 <= 1800
17/* Substitution is OK while return value is not used */ 17/* Substitution is OK while return value is not used */
18#define snprintf _snprintf 18#define snprintf _snprintf
19#endif 19#endif
@@ -33,7 +33,8 @@ struct connection_info_struct
33 struct MHD_PostProcessor *postprocessor; 33 struct MHD_PostProcessor *postprocessor;
34}; 34};
35 35
36const char *askpage = "<html><body>\ 36const char *askpage =
37 "<html><body>\
37 What's your name, Sir?<br>\ 38 What's your name, Sir?<br>\
38 <form action=\"/namepost\" method=\"post\">\ 39 <form action=\"/namepost\" method=\"post\">\
39 <input name=\"name\" type=\"text\">\ 40 <input name=\"name\" type=\"text\">\
@@ -47,17 +48,17 @@ const char *errorpage =
47 "<html><body>This doesn't seem to be right.</body></html>"; 48 "<html><body>This doesn't seem to be right.</body></html>";
48 49
49 50
50static int 51static enum MHD_Result
51send_page (struct MHD_Connection *connection, const char *page) 52send_page (struct MHD_Connection *connection, const char *page)
52{ 53{
53 int ret; 54 enum MHD_Result ret;
54 struct MHD_Response *response; 55 struct MHD_Response *response;
55 56
56 57
57 response = 58 response =
58 MHD_create_response_from_buffer (strlen (page), (void *) page, 59 MHD_create_response_from_buffer (strlen (page), (void *) page,
59 MHD_RESPMEM_PERSISTENT); 60 MHD_RESPMEM_PERSISTENT);
60 if (!response) 61 if (! response)
61 return MHD_NO; 62 return MHD_NO;
62 63
63 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 64 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
@@ -67,135 +68,138 @@ send_page (struct MHD_Connection *connection, const char *page)
67} 68}
68 69
69 70
70static int 71static enum MHD_Result
71iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, 72iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
72 const char *filename, const char *content_type, 73 const char *filename, const char *content_type,
73 const char *transfer_encoding, const char *data, uint64_t off, 74 const char *transfer_encoding, const char *data, uint64_t off,
74 size_t size) 75 size_t size)
75{ 76{
76 struct connection_info_struct *con_info = coninfo_cls; 77 struct connection_info_struct *con_info = coninfo_cls;
77 (void)kind; /* Unused. Silent compiler warning. */ 78 (void) kind; /* Unused. Silent compiler warning. */
78 (void)filename; /* Unused. Silent compiler warning. */ 79 (void) filename; /* Unused. Silent compiler warning. */
79 (void)content_type; /* Unused. Silent compiler warning. */ 80 (void) content_type; /* Unused. Silent compiler warning. */
80 (void)transfer_encoding; /* Unused. Silent compiler warning. */ 81 (void) transfer_encoding; /* Unused. Silent compiler warning. */
81 (void)off; /* Unused. Silent compiler warning. */ 82 (void) off; /* Unused. Silent compiler warning. */
82 83
83 if (0 == strcmp (key, "name")) 84 if (0 == strcmp (key, "name"))
85 {
86 if ((size > 0) && (size <= MAXNAMESIZE))
84 { 87 {
85 if ((size > 0) && (size <= MAXNAMESIZE)) 88 char *answerstring;
86 { 89 answerstring = malloc (MAXANSWERSIZE);
87 char *answerstring; 90 if (! answerstring)
88 answerstring = malloc (MAXANSWERSIZE); 91 return MHD_NO;
89 if (!answerstring)
90 return MHD_NO;
91
92 snprintf (answerstring, MAXANSWERSIZE, greetingpage, data);
93 con_info->answerstring = answerstring;
94 }
95 else
96 con_info->answerstring = NULL;
97 92
98 return MHD_NO; 93 snprintf (answerstring, MAXANSWERSIZE, greetingpage, data);
94 con_info->answerstring = answerstring;
99 } 95 }
96 else
97 con_info->answerstring = NULL;
98
99 return MHD_NO;
100 }
100 101
101 return MHD_YES; 102 return MHD_YES;
102} 103}
103 104
105
104static void 106static void
105request_completed (void *cls, struct MHD_Connection *connection, 107request_completed (void *cls, struct MHD_Connection *connection,
106 void **con_cls, enum MHD_RequestTerminationCode toe) 108 void **con_cls, enum MHD_RequestTerminationCode toe)
107{ 109{
108 struct connection_info_struct *con_info = *con_cls; 110 struct connection_info_struct *con_info = *con_cls;
109 (void)cls; /* Unused. Silent compiler warning. */ 111 (void) cls; /* Unused. Silent compiler warning. */
110 (void)connection; /* Unused. Silent compiler warning. */ 112 (void) connection; /* Unused. Silent compiler warning. */
111 (void)toe; /* Unused. Silent compiler warning. */ 113 (void) toe; /* Unused. Silent compiler warning. */
112 114
113 if (NULL == con_info) 115 if (NULL == con_info)
114 return; 116 return;
115 117
116 if (con_info->connectiontype == POST) 118 if (con_info->connectiontype == POST)
117 { 119 {
118 MHD_destroy_post_processor (con_info->postprocessor); 120 MHD_destroy_post_processor (con_info->postprocessor);
119 if (con_info->answerstring) 121 if (con_info->answerstring)
120 free (con_info->answerstring); 122 free (con_info->answerstring);
121 } 123 }
122 124
123 free (con_info); 125 free (con_info);
124 *con_cls = NULL; 126 *con_cls = NULL;
125} 127}
126 128
127 129
128static int 130static enum MHD_Result
129answer_to_connection (void *cls, struct MHD_Connection *connection, 131answer_to_connection (void *cls, struct MHD_Connection *connection,
130 const char *url, const char *method, 132 const char *url, const char *method,
131 const char *version, const char *upload_data, 133 const char *version, const char *upload_data,
132 size_t *upload_data_size, void **con_cls) 134 size_t *upload_data_size, void **con_cls)
133{ 135{
134 (void)cls; /* Unused. Silent compiler warning. */ 136 (void) cls; /* Unused. Silent compiler warning. */
135 (void)url; /* Unused. Silent compiler warning. */ 137 (void) url; /* Unused. Silent compiler warning. */
136 (void)version; /* Unused. Silent compiler warning. */ 138 (void) version; /* Unused. Silent compiler warning. */
137 139
138 if (NULL == *con_cls) 140 if (NULL == *con_cls)
139 { 141 {
140 struct connection_info_struct *con_info; 142 struct connection_info_struct *con_info;
141 143
142 con_info = malloc (sizeof (struct connection_info_struct)); 144 con_info = malloc (sizeof (struct connection_info_struct));
143 if (NULL == con_info) 145 if (NULL == con_info)
144 return MHD_NO; 146 return MHD_NO;
145 con_info->answerstring = NULL; 147 con_info->answerstring = NULL;
146 148
147 if (0 == strcmp (method, "POST")) 149 if (0 == strcmp (method, "POST"))
148 { 150 {
149 con_info->postprocessor = 151 con_info->postprocessor =
150 MHD_create_post_processor (connection, POSTBUFFERSIZE, 152 MHD_create_post_processor (connection, POSTBUFFERSIZE,
151 iterate_post, (void *) con_info); 153 iterate_post, (void *) con_info);
152 154
153 if (NULL == con_info->postprocessor) 155 if (NULL == con_info->postprocessor)
154 { 156 {
155 free (con_info); 157 free (con_info);
156 return MHD_NO; 158 return MHD_NO;
157 } 159 }
158 160
159 con_info->connectiontype = POST; 161 con_info->connectiontype = POST;
160 } 162 }
161 else 163 else
162 con_info->connectiontype = GET; 164 con_info->connectiontype = GET;
163 165
164 *con_cls = (void *) con_info; 166 *con_cls = (void *) con_info;
165 167
166 return MHD_YES; 168 return MHD_YES;
167 } 169 }
168 170
169 if (0 == strcmp (method, "GET")) 171 if (0 == strcmp (method, "GET"))
170 { 172 {
171 return send_page (connection, askpage); 173 return send_page (connection, askpage);
172 } 174 }
173 175
174 if (0 == strcmp (method, "POST")) 176 if (0 == strcmp (method, "POST"))
177 {
178 struct connection_info_struct *con_info = *con_cls;
179
180 if (*upload_data_size != 0)
175 { 181 {
176 struct connection_info_struct *con_info = *con_cls; 182 MHD_post_process (con_info->postprocessor, upload_data,
177 183 *upload_data_size);
178 if (*upload_data_size != 0) 184 *upload_data_size = 0;
179 { 185
180 MHD_post_process (con_info->postprocessor, upload_data, 186 return MHD_YES;
181 *upload_data_size);
182 *upload_data_size = 0;
183
184 return MHD_YES;
185 }
186 else if (NULL != con_info->answerstring)
187 return send_page (connection, con_info->answerstring);
188 } 187 }
188 else if (NULL != con_info->answerstring)
189 return send_page (connection, con_info->answerstring);
190 }
189 191
190 return send_page (connection, errorpage); 192 return send_page (connection, errorpage);
191} 193}
192 194
195
193int 196int
194main () 197main ()
195{ 198{
196 struct MHD_Daemon *daemon; 199 struct MHD_Daemon *daemon;
197 200
198 daemon = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, PORT, NULL, NULL, 201 daemon = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
202 PORT, NULL, NULL,
199 &answer_to_connection, NULL, 203 &answer_to_connection, NULL,
200 MHD_OPTION_NOTIFY_COMPLETED, request_completed, 204 MHD_OPTION_NOTIFY_COMPLETED, request_completed,
201 NULL, MHD_OPTION_END); 205 NULL, MHD_OPTION_END);
diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c
index 43b41bf1..ca8187bc 100644
--- a/doc/examples/tlsauthentication.c
+++ b/doc/examples/tlsauthentication.c
@@ -38,20 +38,20 @@ string_to_base64 (const char *message)
38 return NULL; 38 return NULL;
39 tmp[0] = 0; 39 tmp[0] = 0;
40 for (i = 0; i < length; i += 3) 40 for (i = 0; i < length; i += 3)
41 { 41 {
42 l = (((unsigned long) message[i]) << 16) 42 l = (((unsigned long) message[i]) << 16)
43 | (((i + 1) < length) ? (((unsigned long) message[i + 1]) << 8) : 0) 43 | (((i + 1) < length) ? (((unsigned long) message[i + 1]) << 8) : 0)
44 | (((i + 2) < length) ? ((unsigned long) message[i + 2]) : 0); 44 | (((i + 2) < length) ? ((unsigned long) message[i + 2]) : 0);
45 45
46 46
47 strncat (tmp, &lookup[(l >> 18) & 0x3F], 1); 47 strncat (tmp, &lookup[(l >> 18) & 0x3F], 1);
48 strncat (tmp, &lookup[(l >> 12) & 0x3F], 1); 48 strncat (tmp, &lookup[(l >> 12) & 0x3F], 1);
49 49
50 if (i + 1 < length) 50 if (i + 1 < length)
51 strncat (tmp, &lookup[(l >> 6) & 0x3F], 1); 51 strncat (tmp, &lookup[(l >> 6) & 0x3F], 1);
52 if (i + 2 < length) 52 if (i + 2 < length)
53 strncat (tmp, &lookup[l & 0x3F], 1); 53 strncat (tmp, &lookup[l & 0x3F], 1);
54 } 54 }
55 55
56 if (length % 3) 56 if (length % 3)
57 strncat (tmp, "===", 3 - length % 3); 57 strncat (tmp, "===", 3 - length % 3);
@@ -67,16 +67,16 @@ get_file_size (const char *filename)
67 67
68 fp = fopen (filename, "rb"); 68 fp = fopen (filename, "rb");
69 if (fp) 69 if (fp)
70 { 70 {
71 long size; 71 long size;
72 72
73 if ((0 != fseek (fp, 0, SEEK_END)) || (-1 == (size = ftell (fp)))) 73 if ((0 != fseek (fp, 0, SEEK_END)) || (-1 == (size = ftell (fp))))
74 size = 0; 74 size = 0;
75 75
76 fclose (fp); 76 fclose (fp);
77 77
78 return size; 78 return size;
79 } 79 }
80 else 80 else
81 return 0; 81 return 0;
82} 82}
@@ -99,58 +99,58 @@ load_file (const char *filename)
99 99
100 buffer = malloc (size + 1); 100 buffer = malloc (size + 1);
101 if (! buffer) 101 if (! buffer)
102 { 102 {
103 fclose (fp); 103 fclose (fp);
104 return NULL; 104 return NULL;
105 } 105 }
106 buffer[size] = '\0'; 106 buffer[size] = '\0';
107 107
108 if (size != (long)fread (buffer, 1, size, fp)) 108 if (size != (long) fread (buffer, 1, size, fp))
109 { 109 {
110 free (buffer); 110 free (buffer);
111 buffer = NULL; 111 buffer = NULL;
112 } 112 }
113 113
114 fclose (fp); 114 fclose (fp);
115 return buffer; 115 return buffer;
116} 116}
117 117
118 118
119static int 119static enum MHD_Result
120ask_for_authentication (struct MHD_Connection *connection, const char *realm) 120ask_for_authentication (struct MHD_Connection *connection, const char *realm)
121{ 121{
122 int ret; 122 enum MHD_Result ret;
123 struct MHD_Response *response; 123 struct MHD_Response *response;
124 char *headervalue; 124 char *headervalue;
125 size_t slen; 125 size_t slen;
126 const char *strbase = "Basic realm="; 126 const char *strbase = "Basic realm=";
127 127
128 response = MHD_create_response_from_buffer (0, NULL, 128 response = MHD_create_response_from_buffer (0, NULL,
129 MHD_RESPMEM_PERSISTENT); 129 MHD_RESPMEM_PERSISTENT);
130 if (!response) 130 if (! response)
131 return MHD_NO; 131 return MHD_NO;
132 132
133 slen = strlen (strbase) + strlen (realm) + 1; 133 slen = strlen (strbase) + strlen (realm) + 1;
134 if (NULL == (headervalue = malloc (slen))) 134 if (NULL == (headervalue = malloc (slen)))
135 return MHD_NO; 135 return MHD_NO;
136 snprintf (headervalue, 136 snprintf (headervalue,
137 slen, 137 slen,
138 "%s%s", 138 "%s%s",
139 strbase, 139 strbase,
140 realm); 140 realm);
141 ret = MHD_add_response_header (response, 141 ret = MHD_add_response_header (response,
142 "WWW-Authenticate", 142 "WWW-Authenticate",
143 headervalue); 143 headervalue);
144 free (headervalue); 144 free (headervalue);
145 if (! ret) 145 if (! ret)
146 { 146 {
147 MHD_destroy_response (response); 147 MHD_destroy_response (response);
148 return MHD_NO; 148 return MHD_NO;
149 } 149 }
150 150
151 ret = MHD_queue_response (connection, 151 ret = MHD_queue_response (connection,
152 MHD_HTTP_UNAUTHORIZED, 152 MHD_HTTP_UNAUTHORIZED,
153 response); 153 response);
154 MHD_destroy_response (response); 154 MHD_destroy_response (response);
155 return ret; 155 return ret;
156} 156}
@@ -159,7 +159,7 @@ ask_for_authentication (struct MHD_Connection *connection, const char *realm)
159static int 159static int
160is_authenticated (struct MHD_Connection *connection, 160is_authenticated (struct MHD_Connection *connection,
161 const char *username, 161 const char *username,
162 const char *password) 162 const char *password)
163{ 163{
164 const char *headervalue; 164 const char *headervalue;
165 char *expected_b64; 165 char *expected_b64;
@@ -180,10 +180,10 @@ is_authenticated (struct MHD_Connection *connection,
180 if (NULL == (expected = malloc (slen))) 180 if (NULL == (expected = malloc (slen)))
181 return 0; 181 return 0;
182 snprintf (expected, 182 snprintf (expected,
183 slen, 183 slen,
184 "%s:%s", 184 "%s:%s",
185 username, 185 username,
186 password); 186 password);
187 expected_b64 = string_to_base64 (expected); 187 expected_b64 = string_to_base64 (expected);
188 free (expected); 188 free (expected);
189 if (NULL == expected_b64) 189 if (NULL == expected_b64)
@@ -196,17 +196,17 @@ is_authenticated (struct MHD_Connection *connection,
196} 196}
197 197
198 198
199static int 199static enum MHD_Result
200secret_page (struct MHD_Connection *connection) 200secret_page (struct MHD_Connection *connection)
201{ 201{
202 int ret; 202 enum MHD_Result ret;
203 struct MHD_Response *response; 203 struct MHD_Response *response;
204 const char *page = "<html><body>A secret.</body></html>"; 204 const char *page = "<html><body>A secret.</body></html>";
205 205
206 response = 206 response =
207 MHD_create_response_from_buffer (strlen (page), (void *) page, 207 MHD_create_response_from_buffer (strlen (page), (void *) page,
208 MHD_RESPMEM_PERSISTENT); 208 MHD_RESPMEM_PERSISTENT);
209 if (!response) 209 if (! response)
210 return MHD_NO; 210 return MHD_NO;
211 211
212 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 212 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
@@ -216,27 +216,27 @@ secret_page (struct MHD_Connection *connection)
216} 216}
217 217
218 218
219static int 219static enum MHD_Result
220answer_to_connection (void *cls, struct MHD_Connection *connection, 220answer_to_connection (void *cls, struct MHD_Connection *connection,
221 const char *url, const char *method, 221 const char *url, const char *method,
222 const char *version, const char *upload_data, 222 const char *version, const char *upload_data,
223 size_t *upload_data_size, void **con_cls) 223 size_t *upload_data_size, void **con_cls)
224{ 224{
225 (void)cls; /* Unused. Silent compiler warning. */ 225 (void) cls; /* Unused. Silent compiler warning. */
226 (void)url; /* Unused. Silent compiler warning. */ 226 (void) url; /* Unused. Silent compiler warning. */
227 (void)version; /* Unused. Silent compiler warning. */ 227 (void) version; /* Unused. Silent compiler warning. */
228 (void)upload_data; /* Unused. Silent compiler warning. */ 228 (void) upload_data; /* Unused. Silent compiler warning. */
229 (void)upload_data_size; /* Unused. Silent compiler warning. */ 229 (void) upload_data_size; /* Unused. Silent compiler warning. */
230 230
231 if (0 != strcmp (method, "GET")) 231 if (0 != strcmp (method, "GET"))
232 return MHD_NO; 232 return MHD_NO;
233 if (NULL == *con_cls) 233 if (NULL == *con_cls)
234 { 234 {
235 *con_cls = connection; 235 *con_cls = connection;
236 return MHD_YES; 236 return MHD_YES;
237 } 237 }
238 238
239 if (!is_authenticated (connection, USER, PASSWORD)) 239 if (! is_authenticated (connection, USER, PASSWORD))
240 return ask_for_authentication (connection, REALM); 240 return ask_for_authentication (connection, REALM);
241 241
242 return secret_page (connection); 242 return secret_page (connection);
@@ -254,14 +254,14 @@ main ()
254 cert_pem = load_file (SERVERCERTFILE); 254 cert_pem = load_file (SERVERCERTFILE);
255 255
256 if ((key_pem == NULL) || (cert_pem == NULL)) 256 if ((key_pem == NULL) || (cert_pem == NULL))
257 { 257 {
258 printf ("The key/certificate files could not be read.\n"); 258 printf ("The key/certificate files could not be read.\n");
259 if (NULL != key_pem) 259 if (NULL != key_pem)
260 free (key_pem); 260 free (key_pem);
261 if (NULL != cert_pem) 261 if (NULL != cert_pem)
262 free (cert_pem); 262 free (cert_pem);
263 return 1; 263 return 1;
264 } 264 }
265 265
266 daemon = 266 daemon =
267 MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS, PORT, NULL, 267 MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS, PORT, NULL,
@@ -269,14 +269,14 @@ main ()
269 MHD_OPTION_HTTPS_MEM_KEY, key_pem, 269 MHD_OPTION_HTTPS_MEM_KEY, key_pem,
270 MHD_OPTION_HTTPS_MEM_CERT, cert_pem, MHD_OPTION_END); 270 MHD_OPTION_HTTPS_MEM_CERT, cert_pem, MHD_OPTION_END);
271 if (NULL == daemon) 271 if (NULL == daemon)
272 { 272 {
273 printf ("%s\n", cert_pem); 273 printf ("%s\n", cert_pem);
274 274
275 free (key_pem); 275 free (key_pem);
276 free (cert_pem); 276 free (cert_pem);
277 277
278 return 1; 278 return 1;
279 } 279 }
280 280
281 (void) getchar (); 281 (void) getchar ();
282 282
diff --git a/src/examples/authorization_example.c b/src/examples/authorization_example.c
index 40bffcb7..644b03ef 100644
--- a/src/examples/authorization_example.c
+++ b/src/examples/authorization_example.c
@@ -39,7 +39,7 @@
39 "<html><head><title>Access denied</title></head><body>Access denied</body></html>" 39 "<html><head><title>Access denied</title></head><body>Access denied</body></html>"
40 40
41 41
42static int 42static enum MHD_Result
43ahc_echo (void *cls, 43ahc_echo (void *cls,
44 struct MHD_Connection *connection, 44 struct MHD_Connection *connection,
45 const char *url, 45 const char *url,
@@ -50,7 +50,7 @@ ahc_echo (void *cls,
50 static int aptr; 50 static int aptr;
51 const char *me = cls; 51 const char *me = cls;
52 struct MHD_Response *response; 52 struct MHD_Response *response;
53 int ret; 53 enum MHD_Result ret;
54 char *user; 54 char *user;
55 char *pass; 55 char *pass;
56 int fail; 56 int fail;
diff --git a/src/examples/benchmark.c b/src/examples/benchmark.c
index 9b07e5c8..939995c9 100644
--- a/src/examples/benchmark.c
+++ b/src/examples/benchmark.c
@@ -106,7 +106,7 @@ uri_logger_cb (void *cls,
106} 106}
107 107
108 108
109static int 109static enum MHD_Result
110ahc_echo (void *cls, 110ahc_echo (void *cls,
111 struct MHD_Connection *connection, 111 struct MHD_Connection *connection,
112 const char *url, 112 const char *url,
diff --git a/src/examples/benchmark_https.c b/src/examples/benchmark_https.c
index 53b83e0a..6f0cd478 100644
--- a/src/examples/benchmark_https.c
+++ b/src/examples/benchmark_https.c
@@ -106,7 +106,7 @@ uri_logger_cb (void *cls,
106} 106}
107 107
108 108
109static int 109static enum MHD_Result
110ahc_echo (void *cls, 110ahc_echo (void *cls,
111 struct MHD_Connection *connection, 111 struct MHD_Connection *connection,
112 const char *url, 112 const char *url,
diff --git a/src/examples/chunked_example.c b/src/examples/chunked_example.c
index 9b2cb51c..19a37155 100644
--- a/src/examples/chunked_example.c
+++ b/src/examples/chunked_example.c
@@ -86,7 +86,7 @@ static const char simple_response_text[] =
86 "<body>Simple response text</body></html>"; 86 "<body>Simple response text</body></html>";
87 87
88 88
89static int 89static enum MHD_Result
90ahc_echo (void *cls, 90ahc_echo (void *cls,
91 struct MHD_Connection *connection, 91 struct MHD_Connection *connection,
92 const char *url, 92 const char *url,
@@ -99,7 +99,7 @@ ahc_echo (void *cls,
99 static int aptr; 99 static int aptr;
100 struct ResponseContentCallbackParam *callback_param; 100 struct ResponseContentCallbackParam *callback_param;
101 struct MHD_Response *response; 101 struct MHD_Response *response;
102 int ret; 102 enum MHD_Result ret;
103 (void) cls; /* Unused. Silent compiler warning. */ 103 (void) cls; /* Unused. Silent compiler warning. */
104 (void) url; /* Unused. Silent compiler warning. */ 104 (void) url; /* Unused. Silent compiler warning. */
105 (void) version; /* Unused. Silent compiler warning. */ 105 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/demo.c b/src/examples/demo.c
index c7ad4b30..978bd235 100644
--- a/src/examples/demo.c
+++ b/src/examples/demo.c
@@ -264,7 +264,7 @@ struct ResponseDataContext
264 * @param dirname name of the directory to list 264 * @param dirname name of the directory to list
265 * @return #MHD_YES on success, #MHD_NO on error 265 * @return #MHD_YES on success, #MHD_NO on error
266 */ 266 */
267static int 267static enum MHD_Result
268list_directory (struct ResponseDataContext *rdc, 268list_directory (struct ResponseDataContext *rdc,
269 const char *dirname) 269 const char *dirname)
270{ 270{
@@ -444,7 +444,7 @@ struct UploadContext
444 * @param size number of bytes in 'data' 444 * @param size number of bytes in 'data'
445 * @return #MHD_NO on allocation failure, #MHD_YES on success 445 * @return #MHD_NO on allocation failure, #MHD_YES on success
446 */ 446 */
447static int 447static enum MHD_Result
448do_append (char **ret, 448do_append (char **ret,
449 const char *data, 449 const char *data,
450 size_t size) 450 size_t size)
@@ -493,7 +493,7 @@ do_append (char **ret,
493 * @return #MHD_YES to continue iterating, 493 * @return #MHD_YES to continue iterating,
494 * #MHD_NO to abort the iteration 494 * #MHD_NO to abort the iteration
495 */ 495 */
496static int 496static enum MHD_Result
497process_upload_data (void *cls, 497process_upload_data (void *cls,
498 enum MHD_ValueKind kind, 498 enum MHD_ValueKind kind,
499 const char *key, 499 const char *key,
@@ -662,12 +662,12 @@ response_completed_callback (void *cls,
662 * Return the current directory listing. 662 * Return the current directory listing.
663 * 663 *
664 * @param connection connection to return the directory for 664 * @param connection connection to return the directory for
665 * @return MHD_YES on success, MHD_NO on error 665 * @return #MHD_YES on success, #MHD_NO on error
666 */ 666 */
667static int 667static enum MHD_Result
668return_directory_response (struct MHD_Connection *connection) 668return_directory_response (struct MHD_Connection *connection)
669{ 669{
670 int ret; 670 enum MHD_Result ret;
671 671
672 (void) pthread_mutex_lock (&mutex); 672 (void) pthread_mutex_lock (&mutex);
673 if (NULL == cached_directory_response) 673 if (NULL == cached_directory_response)
@@ -696,7 +696,7 @@ return_directory_response (struct MHD_Connection *connection)
696 * @param ptr our context 696 * @param ptr our context
697 * @return #MHD_YES on success, #MHD_NO to drop connection 697 * @return #MHD_YES on success, #MHD_NO to drop connection
698 */ 698 */
699static int 699static enum MHD_Result
700generate_page (void *cls, 700generate_page (void *cls,
701 struct MHD_Connection *connection, 701 struct MHD_Connection *connection,
702 const char *url, 702 const char *url,
@@ -706,7 +706,7 @@ generate_page (void *cls,
706 size_t *upload_data_size, void **ptr) 706 size_t *upload_data_size, void **ptr)
707{ 707{
708 struct MHD_Response *response; 708 struct MHD_Response *response;
709 int ret; 709 enum MHD_Result ret;
710 int fd; 710 int fd;
711 struct stat buf; 711 struct stat buf;
712 (void) cls; /* Unused. Silent compiler warning. */ 712 (void) cls; /* Unused. Silent compiler warning. */
diff --git a/src/examples/demo_https.c b/src/examples/demo_https.c
index 7cd98b68..2a60fcda 100644
--- a/src/examples/demo_https.c
+++ b/src/examples/demo_https.c
@@ -267,7 +267,7 @@ struct ResponseDataContext
267 * @param dirname name of the directory to list 267 * @param dirname name of the directory to list
268 * @return MHD_YES on success, MHD_NO on error 268 * @return MHD_YES on success, MHD_NO on error
269 */ 269 */
270static int 270static enum MHD_Result
271list_directory (struct ResponseDataContext *rdc, 271list_directory (struct ResponseDataContext *rdc,
272 const char *dirname) 272 const char *dirname)
273{ 273{
@@ -447,7 +447,7 @@ struct UploadContext
447 * @param size number of bytes in 'data' 447 * @param size number of bytes in 'data'
448 * @return #MHD_NO on allocation failure, #MHD_YES on success 448 * @return #MHD_NO on allocation failure, #MHD_YES on success
449 */ 449 */
450static int 450static enum MHD_Result
451do_append (char **ret, 451do_append (char **ret,
452 const char *data, 452 const char *data,
453 size_t size) 453 size_t size)
@@ -493,10 +493,10 @@ do_append (char **ret,
493 * specified offset 493 * specified offset
494 * @param off offset of data in the overall value 494 * @param off offset of data in the overall value
495 * @param size number of bytes in data available 495 * @param size number of bytes in data available
496 * @return MHD_YES to continue iterating, 496 * @return #MHD_YES to continue iterating,
497 * MHD_NO to abort the iteration 497 * #MHD_NO to abort the iteration
498 */ 498 */
499static int 499static enum MHD_Result
500process_upload_data (void *cls, 500process_upload_data (void *cls,
501 enum MHD_ValueKind kind, 501 enum MHD_ValueKind kind,
502 const char *key, 502 const char *key,
@@ -667,10 +667,10 @@ response_completed_callback (void *cls,
667 * @param connection connection to return the directory for 667 * @param connection connection to return the directory for
668 * @return MHD_YES on success, MHD_NO on error 668 * @return MHD_YES on success, MHD_NO on error
669 */ 669 */
670static int 670static enum MHD_Result
671return_directory_response (struct MHD_Connection *connection) 671return_directory_response (struct MHD_Connection *connection)
672{ 672{
673 int ret; 673 enum MHD_Result ret;
674 674
675 (void) pthread_mutex_lock (&mutex); 675 (void) pthread_mutex_lock (&mutex);
676 if (NULL == cached_directory_response) 676 if (NULL == cached_directory_response)
@@ -699,7 +699,7 @@ return_directory_response (struct MHD_Connection *connection)
699 * @param ptr our context 699 * @param ptr our context
700 * @return #MHD_YES on success, #MHD_NO to drop connection 700 * @return #MHD_YES on success, #MHD_NO to drop connection
701 */ 701 */
702static int 702static enum MHD_Result
703generate_page (void *cls, 703generate_page (void *cls,
704 struct MHD_Connection *connection, 704 struct MHD_Connection *connection,
705 const char *url, 705 const char *url,
@@ -709,7 +709,7 @@ generate_page (void *cls,
709 size_t *upload_data_size, void **ptr) 709 size_t *upload_data_size, void **ptr)
710{ 710{
711 struct MHD_Response *response; 711 struct MHD_Response *response;
712 int ret; 712 enum MHD_Result ret;
713 int fd; 713 int fd;
714 struct stat buf; 714 struct stat buf;
715 (void) cls; /* Unused. Silent compiler warning. */ 715 (void) cls; /* Unused. Silent compiler warning. */
diff --git a/src/examples/digest_auth_example.c b/src/examples/digest_auth_example.c
index 25fb4086..e3edf206 100644
--- a/src/examples/digest_auth_example.c
+++ b/src/examples/digest_auth_example.c
@@ -34,7 +34,7 @@
34 34
35#define MY_OPAQUE_STR "11733b200778ce33060f31c9af70a870ba96ddd4" 35#define MY_OPAQUE_STR "11733b200778ce33060f31c9af70a870ba96ddd4"
36 36
37static int 37static enum MHD_Result
38ahc_echo (void *cls, 38ahc_echo (void *cls,
39 struct MHD_Connection *connection, 39 struct MHD_Connection *connection,
40 const char *url, 40 const char *url,
@@ -46,7 +46,7 @@ ahc_echo (void *cls,
46 char *username; 46 char *username;
47 const char *password = "testpass"; 47 const char *password = "testpass";
48 const char *realm = "test@example.com"; 48 const char *realm = "test@example.com";
49 int ret; 49 enum MHD_Result ret;
50 (void) cls; /* Unused. Silent compiler warning. */ 50 (void) cls; /* Unused. Silent compiler warning. */
51 (void) url; /* Unused. Silent compiler warning. */ 51 (void) url; /* Unused. Silent compiler warning. */
52 (void) method; /* Unused. Silent compiler warning. */ 52 (void) method; /* Unused. Silent compiler warning. */
diff --git a/src/examples/dual_stack_example.c b/src/examples/dual_stack_example.c
index ffacec4a..15bafc44 100644
--- a/src/examples/dual_stack_example.c
+++ b/src/examples/dual_stack_example.c
@@ -28,7 +28,7 @@
28#define PAGE \ 28#define PAGE \
29 "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" 29 "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>"
30 30
31static int 31static enum MHD_Result
32ahc_echo (void *cls, 32ahc_echo (void *cls,
33 struct MHD_Connection *connection, 33 struct MHD_Connection *connection,
34 const char *url, 34 const char *url,
@@ -39,7 +39,7 @@ ahc_echo (void *cls,
39 static int aptr; 39 static int aptr;
40 const char *me = cls; 40 const char *me = cls;
41 struct MHD_Response *response; 41 struct MHD_Response *response;
42 int ret; 42 enum MHD_Result ret;
43 (void) url; /* Unused. Silent compiler warning. */ 43 (void) url; /* Unused. Silent compiler warning. */
44 (void) version; /* Unused. Silent compiler warning. */ 44 (void) version; /* Unused. Silent compiler warning. */
45 (void) upload_data; /* Unused. Silent compiler warning. */ 45 (void) upload_data; /* Unused. Silent compiler warning. */
diff --git a/src/examples/fileserver_example.c b/src/examples/fileserver_example.c
index 46e6aad6..767810f9 100644
--- a/src/examples/fileserver_example.c
+++ b/src/examples/fileserver_example.c
@@ -41,7 +41,7 @@
41#define S_ISREG(x) (S_IFREG == (x & S_IFREG)) 41#define S_ISREG(x) (S_IFREG == (x & S_IFREG))
42#endif /* S_ISREG */ 42#endif /* S_ISREG */
43 43
44static int 44static enum MHD_Result
45ahc_echo (void *cls, 45ahc_echo (void *cls,
46 struct MHD_Connection *connection, 46 struct MHD_Connection *connection,
47 const char *url, 47 const char *url,
@@ -52,7 +52,7 @@ ahc_echo (void *cls,
52{ 52{
53 static int aptr; 53 static int aptr;
54 struct MHD_Response *response; 54 struct MHD_Response *response;
55 int ret; 55 enum MHD_Result ret;
56 int fd; 56 int fd;
57 struct stat buf; 57 struct stat buf;
58 (void) cls; /* Unused. Silent compiler warning. */ 58 (void) cls; /* Unused. Silent compiler warning. */
diff --git a/src/examples/fileserver_example_dirs.c b/src/examples/fileserver_example_dirs.c
index 2b544b69..e6c9ed1f 100644
--- a/src/examples/fileserver_example_dirs.c
+++ b/src/examples/fileserver_example_dirs.c
@@ -81,7 +81,7 @@ dir_reader (void *cls, uint64_t pos, char *buf, size_t max)
81} 81}
82 82
83 83
84static int 84static enum MHD_Result
85ahc_echo (void *cls, 85ahc_echo (void *cls,
86 struct MHD_Connection *connection, 86 struct MHD_Connection *connection,
87 const char *url, 87 const char *url,
@@ -92,7 +92,7 @@ ahc_echo (void *cls,
92{ 92{
93 static int aptr; 93 static int aptr;
94 struct MHD_Response *response; 94 struct MHD_Response *response;
95 int ret; 95 enum MHD_Result ret;
96 FILE *file; 96 FILE *file;
97 int fd; 97 int fd;
98 DIR *dir; 98 DIR *dir;
diff --git a/src/examples/fileserver_example_external_select.c b/src/examples/fileserver_example_external_select.c
index 187cdf7e..7209751f 100644
--- a/src/examples/fileserver_example_external_select.c
+++ b/src/examples/fileserver_example_external_select.c
@@ -48,7 +48,7 @@ free_callback (void *cls)
48} 48}
49 49
50 50
51static int 51static enum MHD_Result
52ahc_echo (void *cls, 52ahc_echo (void *cls,
53 struct MHD_Connection *connection, 53 struct MHD_Connection *connection,
54 const char *url, 54 const char *url,
@@ -59,7 +59,7 @@ ahc_echo (void *cls,
59{ 59{
60 static int aptr; 60 static int aptr;
61 struct MHD_Response *response; 61 struct MHD_Response *response;
62 int ret; 62 enum MHD_Result ret;
63 FILE *file; 63 FILE *file;
64 int fd; 64 int fd;
65 struct stat buf; 65 struct stat buf;
diff --git a/src/examples/http_chunked_compression.c b/src/examples/http_chunked_compression.c
index ba71923b..07fd00ec 100644
--- a/src/examples/http_chunked_compression.c
+++ b/src/examples/http_chunked_compression.c
@@ -51,13 +51,13 @@ struct Holder
51 void *buf; 51 void *buf;
52}; 52};
53 53
54static int 54static enum MHD_Result
55compress_buf (z_stream *strm, const void *src, size_t src_size, size_t *offset, 55compress_buf (z_stream *strm, const void *src, size_t src_size, size_t *offset,
56 void **dest, size_t *dest_size, 56 void **dest, size_t *dest_size,
57 void *tmp) 57 void *tmp)
58{ 58{
59 unsigned int have; 59 unsigned int have;
60 int ret; 60 enum MHD_Result ret;
61 int flush; 61 int flush;
62 void *tmp_dest; 62 void *tmp_dest;
63 *dest = NULL; 63 *dest = NULL;
@@ -152,14 +152,14 @@ free_cb (void *cls)
152} 152}
153 153
154 154
155static int 155static enum MHD_Result
156ahc_echo (void *cls, struct MHD_Connection *con, const char *url, const 156ahc_echo (void *cls, struct MHD_Connection *con, const char *url, const
157 char *method, const char *version, 157 char *method, const char *version,
158 const char *upload_data, size_t *upload_size, void **ptr) 158 const char *upload_data, size_t *upload_size, void **ptr)
159{ 159{
160 struct Holder *holder; 160 struct Holder *holder;
161 struct MHD_Response *res; 161 struct MHD_Response *res;
162 int ret; 162 enum MHD_Result ret;
163 (void) cls; 163 (void) cls;
164 (void) url; 164 (void) url;
165 (void) method; 165 (void) method;
diff --git a/src/examples/http_compression.c b/src/examples/http_compression.c
index f7d8db21..0419a803 100644
--- a/src/examples/http_compression.c
+++ b/src/examples/http_compression.c
@@ -31,7 +31,7 @@
31 "hello, hello. This is a 'hello world' message for the world, " \ 31 "hello, hello. This is a 'hello world' message for the world, " \
32 "repeat, for the world.</body></html>" 32 "repeat, for the world.</body></html>"
33 33
34static int 34static enum MHD_Result
35can_compress (struct MHD_Connection *con) 35can_compress (struct MHD_Connection *con)
36{ 36{
37 const char *ae; 37 const char *ae;
@@ -60,7 +60,7 @@ can_compress (struct MHD_Connection *con)
60} 60}
61 61
62 62
63static int 63static enum MHD_Result
64body_compress (void **buf, 64body_compress (void **buf,
65 size_t *buf_size) 65 size_t *buf_size)
66{ 66{
@@ -90,7 +90,7 @@ body_compress (void **buf,
90} 90}
91 91
92 92
93static int 93static enum MHD_Result
94ahc_echo (void *cls, 94ahc_echo (void *cls,
95 struct MHD_Connection *connection, 95 struct MHD_Connection *connection,
96 const char *url, 96 const char *url,
@@ -99,8 +99,8 @@ ahc_echo (void *cls,
99 const char *upload_data, size_t *upload_data_size, void **ptr) 99 const char *upload_data, size_t *upload_data_size, void **ptr)
100{ 100{
101 struct MHD_Response *response; 101 struct MHD_Response *response;
102 int ret; 102 enum MHD_Result ret;
103 int comp; 103 enum MHD_Result comp;
104 size_t body_len; 104 size_t body_len;
105 char *body_str; 105 char *body_str;
106 (void) cls; /* Unused. Silent compiler warning. */ 106 (void) cls; /* Unused. Silent compiler warning. */
diff --git a/src/examples/https_fileserver_example.c b/src/examples/https_fileserver_example.c
index 627bc739..5148c8b6 100644
--- a/src/examples/https_fileserver_example.c
+++ b/src/examples/https_fileserver_example.c
@@ -113,7 +113,7 @@ file_free_callback (void *cls)
113 113
114 114
115/* HTTP access handler call back */ 115/* HTTP access handler call back */
116static int 116static enum MHD_Result
117http_ahc (void *cls, 117http_ahc (void *cls,
118 struct MHD_Connection *connection, 118 struct MHD_Connection *connection,
119 const char *url, 119 const char *url,
@@ -124,7 +124,7 @@ http_ahc (void *cls,
124{ 124{
125 static int aptr; 125 static int aptr;
126 struct MHD_Response *response; 126 struct MHD_Response *response;
127 int ret; 127 enum MHD_Result ret;
128 FILE *file; 128 FILE *file;
129 int fd; 129 int fd;
130 struct stat buf; 130 struct stat buf;
diff --git a/src/examples/minimal_example.c b/src/examples/minimal_example.c
index d6589cf9..a02b5d50 100644
--- a/src/examples/minimal_example.c
+++ b/src/examples/minimal_example.c
@@ -28,7 +28,7 @@
28#define PAGE \ 28#define PAGE \
29 "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" 29 "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>"
30 30
31static int 31static enum MHD_Result
32ahc_echo (void *cls, 32ahc_echo (void *cls,
33 struct MHD_Connection *connection, 33 struct MHD_Connection *connection,
34 const char *url, 34 const char *url,
@@ -41,7 +41,7 @@ ahc_echo (void *cls,
41 static int aptr; 41 static int aptr;
42 const char *me = cls; 42 const char *me = cls;
43 struct MHD_Response *response; 43 struct MHD_Response *response;
44 int ret; 44 enum MHD_Result ret;
45 45
46 (void) url; /* Unused. Silent compiler warning. */ 46 (void) url; /* Unused. Silent compiler warning. */
47 (void) version; /* Unused. Silent compiler warning. */ 47 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/minimal_example_comet.c b/src/examples/minimal_example_comet.c
index 80c4258a..c36bf2ce 100644
--- a/src/examples/minimal_example_comet.c
+++ b/src/examples/minimal_example_comet.c
@@ -38,7 +38,7 @@ data_generator (void *cls, uint64_t pos, char *buf, size_t max)
38} 38}
39 39
40 40
41static int 41static enum MHD_Result
42ahc_echo (void *cls, 42ahc_echo (void *cls,
43 struct MHD_Connection *connection, 43 struct MHD_Connection *connection,
44 const char *url, 44 const char *url,
@@ -48,7 +48,7 @@ ahc_echo (void *cls,
48{ 48{
49 static int aptr; 49 static int aptr;
50 struct MHD_Response *response; 50 struct MHD_Response *response;
51 int ret; 51 enum MHD_Result ret;
52 (void) cls; /* Unused. Silent compiler warning. */ 52 (void) cls; /* Unused. Silent compiler warning. */
53 (void) url; /* Unused. Silent compiler warning. */ 53 (void) url; /* Unused. Silent compiler warning. */
54 (void) version; /* Unused. Silent compiler warning. */ 54 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/minimal_example_empty.c b/src/examples/minimal_example_empty.c
index 2de1cc8b..986a2504 100644
--- a/src/examples/minimal_example_empty.c
+++ b/src/examples/minimal_example_empty.c
@@ -26,7 +26,7 @@
26#include <microhttpd.h> 26#include <microhttpd.h>
27 27
28 28
29static int 29static enum MHD_Result
30ahc_echo (void *cls, 30ahc_echo (void *cls,
31 struct MHD_Connection *connection, 31 struct MHD_Connection *connection,
32 const char *url, 32 const char *url,
@@ -38,7 +38,7 @@ ahc_echo (void *cls,
38{ 38{
39 static int aptr; 39 static int aptr;
40 struct MHD_Response *response; 40 struct MHD_Response *response;
41 int ret; 41 enum MHD_Result ret;
42 42
43 (void) url; /* Unused. Silent compiler warning. */ 43 (void) url; /* Unused. Silent compiler warning. */
44 (void) version; /* Unused. Silent compiler warning. */ 44 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/minimal_example_empty_tls.c b/src/examples/minimal_example_empty_tls.c
index e3daca5f..0b9a0e25 100644
--- a/src/examples/minimal_example_empty_tls.c
+++ b/src/examples/minimal_example_empty_tls.c
@@ -26,7 +26,7 @@
26#include <microhttpd.h> 26#include <microhttpd.h>
27 27
28 28
29static int 29static enum MHD_Result
30ahc_echo (void *cls, 30ahc_echo (void *cls,
31 struct MHD_Connection *connection, 31 struct MHD_Connection *connection,
32 const char *url, 32 const char *url,
@@ -38,7 +38,7 @@ ahc_echo (void *cls,
38{ 38{
39 static int aptr; 39 static int aptr;
40 struct MHD_Response *response; 40 struct MHD_Response *response;
41 int ret; 41 enum MHD_Result ret;
42 42
43 (void) url; /* Unused. Silent compiler warning. */ 43 (void) url; /* Unused. Silent compiler warning. */
44 (void) version; /* Unused. Silent compiler warning. */ 44 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/post_example.c b/src/examples/post_example.c
index 885cdb1a..55ca3aa8 100644
--- a/src/examples/post_example.c
+++ b/src/examples/post_example.c
@@ -205,10 +205,10 @@ get_session (struct MHD_Connection *connection)
205 * @param connection connection to process 205 * @param connection connection to process
206 * @param MHD_YES on success, MHD_NO on failure 206 * @param MHD_YES on success, MHD_NO on failure
207 */ 207 */
208typedef int (*PageHandler)(const void *cls, 208typedef enum MHD_Result (*PageHandler)(const void *cls,
209 const char *mime, 209 const char *mime,
210 struct Session *session, 210 struct Session *session,
211 struct MHD_Connection *connection); 211 struct MHD_Connection *connection);
212 212
213 213
214/** 214/**
@@ -274,13 +274,13 @@ add_session_cookie (struct Session *session,
274 * @param session session handle 274 * @param session session handle
275 * @param connection connection to use 275 * @param connection connection to use
276 */ 276 */
277static int 277static enum MHD_Result
278serve_simple_form (const void *cls, 278serve_simple_form (const void *cls,
279 const char *mime, 279 const char *mime,
280 struct Session *session, 280 struct Session *session,
281 struct MHD_Connection *connection) 281 struct MHD_Connection *connection)
282{ 282{
283 int ret; 283 enum MHD_Result ret;
284 const char *form = cls; 284 const char *form = cls;
285 struct MHD_Response *response; 285 struct MHD_Response *response;
286 286
@@ -310,13 +310,13 @@ serve_simple_form (const void *cls,
310 * @param session session handle 310 * @param session session handle
311 * @param connection connection to use 311 * @param connection connection to use
312 */ 312 */
313static int 313static enum MHD_Result
314fill_v1_form (const void *cls, 314fill_v1_form (const void *cls,
315 const char *mime, 315 const char *mime,
316 struct Session *session, 316 struct Session *session,
317 struct MHD_Connection *connection) 317 struct MHD_Connection *connection)
318{ 318{
319 int ret; 319 enum MHD_Result ret;
320 size_t slen; 320 size_t slen;
321 char *reply; 321 char *reply;
322 struct MHD_Response *response; 322 struct MHD_Response *response;
@@ -359,13 +359,13 @@ fill_v1_form (const void *cls,
359 * @param session session handle 359 * @param session session handle
360 * @param connection connection to use 360 * @param connection connection to use
361 */ 361 */
362static int 362static enum MHD_Result
363fill_v1_v2_form (const void *cls, 363fill_v1_v2_form (const void *cls,
364 const char *mime, 364 const char *mime,
365 struct Session *session, 365 struct Session *session,
366 struct MHD_Connection *connection) 366 struct MHD_Connection *connection)
367{ 367{
368 int ret; 368 enum MHD_Result ret;
369 char *reply; 369 char *reply;
370 struct MHD_Response *response; 370 struct MHD_Response *response;
371 size_t slen; 371 size_t slen;
@@ -410,13 +410,13 @@ fill_v1_v2_form (const void *cls,
410 * @param session session handle 410 * @param session session handle
411 * @param connection connection to use 411 * @param connection connection to use
412 */ 412 */
413static int 413static enum MHD_Result
414not_found_page (const void *cls, 414not_found_page (const void *cls,
415 const char *mime, 415 const char *mime,
416 struct Session *session, 416 struct Session *session,
417 struct MHD_Connection *connection) 417 struct MHD_Connection *connection)
418{ 418{
419 int ret; 419 enum MHD_Result ret;
420 struct MHD_Response *response; 420 struct MHD_Response *response;
421 (void) cls; /* Unused. Silent compiler warning. */ 421 (void) cls; /* Unused. Silent compiler warning. */
422 (void) session; /* Unused. Silent compiler warning. */ 422 (void) session; /* Unused. Silent compiler warning. */
@@ -469,7 +469,7 @@ static struct Page pages[] = {
469 * @return MHD_YES to continue iterating, 469 * @return MHD_YES to continue iterating,
470 * MHD_NO to abort the iteration 470 * MHD_NO to abort the iteration
471 */ 471 */
472static int 472static enum MHD_Result
473post_iterator (void *cls, 473post_iterator (void *cls,
474 enum MHD_ValueKind kind, 474 enum MHD_ValueKind kind,
475 const char *key, 475 const char *key,
@@ -554,7 +554,7 @@ post_iterator (void *cls,
554 * MHS_NO if the socket must be closed due to a serios 554 * MHS_NO if the socket must be closed due to a serios
555 * error while handling the request 555 * error while handling the request
556 */ 556 */
557static int 557static enum MHD_Result
558create_response (void *cls, 558create_response (void *cls,
559 struct MHD_Connection *connection, 559 struct MHD_Connection *connection,
560 const char *url, 560 const char *url,
@@ -567,7 +567,7 @@ create_response (void *cls,
567 struct MHD_Response *response; 567 struct MHD_Response *response;
568 struct Request *request; 568 struct Request *request;
569 struct Session *session; 569 struct Session *session;
570 int ret; 570 enum MHD_Result ret;
571 unsigned int i; 571 unsigned int i;
572 (void) cls; /* Unused. Silent compiler warning. */ 572 (void) cls; /* Unused. Silent compiler warning. */
573 (void) version; /* Unused. Silent compiler warning. */ 573 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/querystring_example.c b/src/examples/querystring_example.c
index 8abd8596..4bff891a 100644
--- a/src/examples/querystring_example.c
+++ b/src/examples/querystring_example.c
@@ -29,7 +29,7 @@
29#define PAGE \ 29#define PAGE \
30 "<html><head><title>libmicrohttpd demo</title></head><body>Query string for &quot;%s&quot; was &quot;%s&quot;</body></html>" 30 "<html><head><title>libmicrohttpd demo</title></head><body>Query string for &quot;%s&quot; was &quot;%s&quot;</body></html>"
31 31
32static int 32static enum MHD_Result
33ahc_echo (void *cls, 33ahc_echo (void *cls,
34 struct MHD_Connection *connection, 34 struct MHD_Connection *connection,
35 const char *url, 35 const char *url,
@@ -42,7 +42,7 @@ ahc_echo (void *cls,
42 const char *val; 42 const char *val;
43 char *me; 43 char *me;
44 struct MHD_Response *response; 44 struct MHD_Response *response;
45 int ret; 45 enum MHD_Result ret;
46 (void) url; /* Unused. Silent compiler warning. */ 46 (void) url; /* Unused. Silent compiler warning. */
47 (void) version; /* Unused. Silent compiler warning. */ 47 (void) version; /* Unused. Silent compiler warning. */
48 (void) upload_data; /* Unused. Silent compiler warning. */ 48 (void) upload_data; /* Unused. Silent compiler warning. */
diff --git a/src/examples/refuse_post_example.c b/src/examples/refuse_post_example.c
index 3a34f36d..7e100d9f 100644
--- a/src/examples/refuse_post_example.c
+++ b/src/examples/refuse_post_example.c
@@ -35,7 +35,7 @@ const char *askpage =
35#define BUSYPAGE \ 35#define BUSYPAGE \
36 "<html><head><title>Webserver busy</title></head><body>We are too busy to process POSTs right now.</body></html>" 36 "<html><head><title>Webserver busy</title></head><body>We are too busy to process POSTs right now.</body></html>"
37 37
38static int 38static enum MHD_Result
39ahc_echo (void *cls, 39ahc_echo (void *cls,
40 struct MHD_Connection *connection, 40 struct MHD_Connection *connection,
41 const char *url, 41 const char *url,
@@ -46,7 +46,7 @@ ahc_echo (void *cls,
46 static int aptr; 46 static int aptr;
47 const char *me = cls; 47 const char *me = cls;
48 struct MHD_Response *response; 48 struct MHD_Response *response;
49 int ret; 49 enum MHD_Result ret;
50 (void) cls; /* Unused. Silent compiler warning. */ 50 (void) cls; /* Unused. Silent compiler warning. */
51 (void) url; /* Unused. Silent compiler warning. */ 51 (void) url; /* Unused. Silent compiler warning. */
52 (void) version; /* Unused. Silent compiler warning. */ 52 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/suspend_resume_epoll.c b/src/examples/suspend_resume_epoll.c
index a69fdc4a..afa1169c 100644
--- a/src/examples/suspend_resume_epoll.c
+++ b/src/examples/suspend_resume_epoll.c
@@ -43,7 +43,7 @@ static int epfd;
43static struct epoll_event evt; 43static struct epoll_event evt;
44 44
45 45
46static int 46static enum MHD_Result
47ahc_echo (void *cls, 47ahc_echo (void *cls,
48 struct MHD_Connection *connection, 48 struct MHD_Connection *connection,
49 const char *url, 49 const char *url,
@@ -52,7 +52,7 @@ ahc_echo (void *cls,
52 const char *upload_data, size_t *upload_data_size, void **ptr) 52 const char *upload_data, size_t *upload_data_size, void **ptr)
53{ 53{
54 struct MHD_Response *response; 54 struct MHD_Response *response;
55 int ret; 55 enum MHD_Result ret;
56 struct Request*req; 56 struct Request*req;
57 struct itimerspec ts; 57 struct itimerspec ts;
58 58
diff --git a/src/examples/timeout.c b/src/examples/timeout.c
index cfb66950..b31ff21f 100644
--- a/src/examples/timeout.c
+++ b/src/examples/timeout.c
@@ -29,7 +29,7 @@
29 29
30#define PORT 8080 30#define PORT 8080
31 31
32static int 32static enum MHD_Result
33answer_to_connection (void *cls, 33answer_to_connection (void *cls,
34 struct MHD_Connection *connection, 34 struct MHD_Connection *connection,
35 const char *url, 35 const char *url,
@@ -41,7 +41,7 @@ answer_to_connection (void *cls,
41{ 41{
42 const char *page = "<html><body>Hello timeout!</body></html>"; 42 const char *page = "<html><body>Hello timeout!</body></html>";
43 struct MHD_Response *response; 43 struct MHD_Response *response;
44 int ret; 44 enum MHD_Result ret;
45 (void) cls; /* Unused. Silent compiler warning. */ 45 (void) cls; /* Unused. Silent compiler warning. */
46 (void) url; /* Unused. Silent compiler warning. */ 46 (void) url; /* Unused. Silent compiler warning. */
47 (void) version; /* Unused. Silent compiler warning. */ 47 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/examples/upgrade_example.c b/src/examples/upgrade_example.c
index 98675e09..85a06646 100644
--- a/src/examples/upgrade_example.c
+++ b/src/examples/upgrade_example.c
@@ -240,7 +240,7 @@ uh_cb (void *cls,
240} 240}
241 241
242 242
243static int 243static enum MHD_Result
244ahc_echo (void *cls, 244ahc_echo (void *cls,
245 struct MHD_Connection *connection, 245 struct MHD_Connection *connection,
246 const char *url, 246 const char *url,
@@ -252,7 +252,7 @@ ahc_echo (void *cls,
252{ 252{
253 static int aptr; 253 static int aptr;
254 struct MHD_Response *response; 254 struct MHD_Response *response;
255 int ret; 255 enum MHD_Result ret;
256 (void) cls; /* Unused. Silent compiler warning. */ 256 (void) cls; /* Unused. Silent compiler warning. */
257 (void) url; /* Unused. Silent compiler warning. */ 257 (void) url; /* Unused. Silent compiler warning. */
258 (void) version; /* Unused. Silent compiler warning. */ 258 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/microhttpd/test_daemon.c b/src/microhttpd/test_daemon.c
index 4f600ef0..430c8e18 100644
--- a/src/microhttpd/test_daemon.c
+++ b/src/microhttpd/test_daemon.c
@@ -52,7 +52,7 @@ testStartError ()
52} 52}
53 53
54 54
55static int 55static enum MHD_Result
56apc_nothing (void *cls, 56apc_nothing (void *cls,
57 const struct sockaddr *addr, 57 const struct sockaddr *addr,
58 socklen_t addrlen) 58 socklen_t addrlen)
@@ -63,7 +63,7 @@ apc_nothing (void *cls,
63} 63}
64 64
65 65
66static int 66static enum MHD_Result
67apc_all (void *cls, 67apc_all (void *cls,
68 const struct sockaddr *addr, 68 const struct sockaddr *addr,
69 socklen_t addrlen) 69 socklen_t addrlen)
@@ -74,7 +74,7 @@ apc_all (void *cls,
74} 74}
75 75
76 76
77static int 77static enum MHD_Result
78ahc_nothing (void *cls, 78ahc_nothing (void *cls,
79 struct MHD_Connection *connection, 79 struct MHD_Connection *connection,
80 const char *url, 80 const char *url,
diff --git a/src/microhttpd/test_postprocessor.c b/src/microhttpd/test_postprocessor.c
index 2c37565c..e70171cc 100644
--- a/src/microhttpd/test_postprocessor.c
+++ b/src/microhttpd/test_postprocessor.c
@@ -92,7 +92,7 @@ mismatch (const char *a, const char *b)
92} 92}
93 93
94 94
95static int 95static enum MHD_Result
96value_checker (void *cls, 96value_checker (void *cls,
97 enum MHD_ValueKind kind, 97 enum MHD_ValueKind kind,
98 const char *key, 98 const char *key,
@@ -140,10 +140,10 @@ value_checker (void *cls,
140 fprintf (stderr, 140 fprintf (stderr,
141 "Wanted: `%s' `%s' `%s' `%s' `%s'\n", 141 "Wanted: `%s' `%s' `%s' `%s' `%s'\n",
142 want[idx], 142 want[idx],
143 want[idx+1], 143 want[idx + 1],
144 want[idx+2], 144 want[idx + 2],
145 want[idx+3], 145 want[idx + 3],
146 want[idx+4]); 146 want[idx + 4]);
147 fprintf (stderr, 147 fprintf (stderr,
148 "Unexpected result: %d/%d/%d/%d/%d/%d/%d\n", 148 "Unexpected result: %d/%d/%d/%d/%d/%d/%d\n",
149 (idx < 0), 149 (idx < 0),
@@ -155,7 +155,7 @@ value_checker (void *cls,
155 (0 != memcmp (data, &want[idx + 4][off], size))); 155 (0 != memcmp (data, &want[idx + 4][off], size)));
156 return MHD_NO; 156 return MHD_NO;
157 } 157 }
158 if ( ( (NULL == want[idx+4]) && 158 if ( ( (NULL == want[idx + 4]) &&
159 (0 == off + size) ) || 159 (0 == off + size) ) ||
160 (off + size == strlen (want[idx + 4])) ) 160 (off + size == strlen (want[idx + 4])) )
161 *want_off = idx + 5; 161 *want_off = idx + 5;
diff --git a/src/microhttpd/test_postprocessor_amp.c b/src/microhttpd/test_postprocessor_amp.c
index 54936979..8692d443 100644
--- a/src/microhttpd/test_postprocessor_amp.c
+++ b/src/microhttpd/test_postprocessor_amp.c
@@ -7,7 +7,7 @@
7 7
8uint64_t num_errors; 8uint64_t num_errors;
9 9
10int 10enum MHD_Result
11check_post (void *cls, enum MHD_ValueKind kind, const char*key, 11check_post (void *cls, enum MHD_ValueKind kind, const char*key,
12 const char*filename, const char*content_type, 12 const char*filename, const char*content_type,
13 const char*content_encoding, const char*data, 13 const char*content_encoding, const char*data,
diff --git a/src/microhttpd/test_postprocessor_large.c b/src/microhttpd/test_postprocessor_large.c
index 0e2a10d2..678de808 100644
--- a/src/microhttpd/test_postprocessor_large.c
+++ b/src/microhttpd/test_postprocessor_large.c
@@ -33,7 +33,7 @@
33#include <unistd.h> 33#include <unistd.h>
34#endif 34#endif
35 35
36static int 36static enum MHD_Result
37value_checker (void *cls, 37value_checker (void *cls,
38 enum MHD_ValueKind kind, 38 enum MHD_ValueKind kind,
39 const char *key, 39 const char *key,
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 404c2854..b3aecafa 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -843,7 +843,7 @@ upgrade_cb (void *cls,
843 * #MHD_NO if the socket must be closed due to a serios 843 * #MHD_NO if the socket must be closed due to a serios
844 * error while handling the request 844 * error while handling the request
845 */ 845 */
846static int 846static enum MHD_Result
847ahc_upgrade (void *cls, 847ahc_upgrade (void *cls,
848 struct MHD_Connection *connection, 848 struct MHD_Connection *connection,
849 const char *url, 849 const char *url,
@@ -854,7 +854,7 @@ ahc_upgrade (void *cls,
854 void **con_cls) 854 void **con_cls)
855{ 855{
856 struct MHD_Response *resp; 856 struct MHD_Response *resp;
857 int ret; 857 enum MHD_Result ret;
858 (void) cls; 858 (void) cls;
859 (void) url; 859 (void) url;
860 (void) method; /* Unused. Silent compiler warning. */ 860 (void) method; /* Unused. Silent compiler warning. */
diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c
index a17293db..d8d35838 100644
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@ -867,7 +867,7 @@ upgrade_cb (void *cls,
867 * #MHD_NO if the socket must be closed due to a serios 867 * #MHD_NO if the socket must be closed due to a serios
868 * error while handling the request 868 * error while handling the request
869 */ 869 */
870static int 870static enum MHD_Result
871ahc_upgrade (void *cls, 871ahc_upgrade (void *cls,
872 struct MHD_Connection *connection, 872 struct MHD_Connection *connection,
873 const char *url, 873 const char *url,
@@ -878,7 +878,7 @@ ahc_upgrade (void *cls,
878 void **con_cls) 878 void **con_cls)
879{ 879{
880 struct MHD_Response *resp; 880 struct MHD_Response *resp;
881 int ret; 881 enum MHD_Result ret;
882 (void) cls; 882 (void) cls;
883 (void) url; 883 (void) url;
884 (void) method; /* Unused. Silent compiler warning. */ 884 (void) method; /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c
index 6f29fbe5..28430388 100644
--- a/src/testcurl/https/test_empty_response.c
+++ b/src/testcurl/https/test_empty_response.c
@@ -38,7 +38,7 @@ extern const char srv_self_signed_cert_pem[];
38 38
39static int oneone; 39static int oneone;
40 40
41static int 41static enum MHD_Result
42ahc_echo (void *cls, 42ahc_echo (void *cls,
43 struct MHD_Connection *connection, 43 struct MHD_Connection *connection,
44 const char *url, 44 const char *url,
@@ -48,7 +48,7 @@ ahc_echo (void *cls,
48 void **unused) 48 void **unused)
49{ 49{
50 struct MHD_Response *response; 50 struct MHD_Response *response;
51 int ret; 51 enum MHD_Result ret;
52 (void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */ 52 (void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */
53 (void) upload_data; (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */ 53 (void) upload_data; (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */
54 54
diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c
index c012fa46..b8de81a9 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -91,7 +91,7 @@ test_secure_get (FILE *test_fd,
91} 91}
92 92
93 93
94static int 94static enum MHD_Result
95ahc_empty (void *cls, 95ahc_empty (void *cls,
96 struct MHD_Connection *connection, 96 struct MHD_Connection *connection,
97 const char *url, 97 const char *url,
@@ -103,7 +103,7 @@ ahc_empty (void *cls,
103{ 103{
104 static int ptr; 104 static int ptr;
105 struct MHD_Response *response; 105 struct MHD_Response *response;
106 int ret; 106 enum MHD_Result ret;
107 (void) cls; 107 (void) cls;
108 (void) url; 108 (void) url;
109 (void) url; 109 (void) url;
diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c
index e5bd73f5..d42f4463 100644
--- a/src/testcurl/https/test_https_get_select.c
+++ b/src/testcurl/https/test_https_get_select.c
@@ -39,7 +39,7 @@ extern const char srv_self_signed_cert_pem[];
39 39
40static int oneone; 40static int oneone;
41 41
42static int 42static enum MHD_Result
43ahc_echo (void *cls, 43ahc_echo (void *cls,
44 struct MHD_Connection *connection, 44 struct MHD_Connection *connection,
45 const char *url, 45 const char *url,
@@ -51,7 +51,7 @@ ahc_echo (void *cls,
51 static int ptr; 51 static int ptr;
52 const char *me = cls; 52 const char *me = cls;
53 struct MHD_Response *response; 53 struct MHD_Response *response;
54 int ret; 54 enum MHD_Result ret;
55 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 55 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
56 56
57 if (0 != strcmp (me, method)) 57 if (0 != strcmp (me, method))
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c
index e961edc4..f8b37cff 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -41,14 +41,15 @@ struct MHD_Daemon *d;
41 * HTTP access handler call back 41 * HTTP access handler call back
42 * used to query negotiated security parameters 42 * used to query negotiated security parameters
43 */ 43 */
44static int 44static enum MHD_Result
45query_session_ahc (void *cls, struct MHD_Connection *connection, 45query_session_ahc (void *cls, struct MHD_Connection *connection,
46 const char *url, const char *method, 46 const char *url, const char *method,
47 const char *version, const char *upload_data, 47 const char *version, const char *upload_data,
48 size_t *upload_data_size, void **ptr) 48 size_t *upload_data_size, void **ptr)
49{ 49{
50 struct MHD_Response *response; 50 struct MHD_Response *response;
51 int ret; 51 enum MHD_Result ret;
52 int gret;
52 (void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */ 53 (void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */
53 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 54 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
54 55
@@ -59,11 +60,11 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
59 } 60 }
60 61
61 if (GNUTLS_TLS1_1 != 62 if (GNUTLS_TLS1_1 !=
62 (ret = MHD_get_connection_info 63 (gret = MHD_get_connection_info
63 (connection, 64 (connection,
64 MHD_CONNECTION_INFO_PROTOCOL)->protocol)) 65 MHD_CONNECTION_INFO_PROTOCOL)->protocol))
65 { 66 {
66 if (GNUTLS_TLS1_2 == ret) 67 if (GNUTLS_TLS1_2 == gret)
67 { 68 {
68 /* as usual, TLS implementations sometimes don't 69 /* as usual, TLS implementations sometimes don't
69 quite do what was asked, just mildly complain... */ 70 quite do what was asked, just mildly complain... */
@@ -76,8 +77,8 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
76 fprintf (stderr, 77 fprintf (stderr,
77 "Error: requested protocol mismatch (wanted %d, got %d)\n", 78 "Error: requested protocol mismatch (wanted %d, got %d)\n",
78 GNUTLS_TLS1_1, 79 GNUTLS_TLS1_1,
79 ret); 80 gret);
80 return -1; 81 return MHD_NO;
81 } 82 }
82 } 83 }
83 84
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c
index f68f5979..a704be5f 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -176,7 +176,7 @@ copyBuffer (void *ptr,
176/** 176/**
177 * HTTP access handler call back 177 * HTTP access handler call back
178 */ 178 */
179int 179enum MHD_Result
180http_ahc (void *cls, 180http_ahc (void *cls,
181 struct MHD_Connection *connection, 181 struct MHD_Connection *connection,
182 const char *url, 182 const char *url,
@@ -188,7 +188,7 @@ http_ahc (void *cls,
188{ 188{
189 static int aptr; 189 static int aptr;
190 struct MHD_Response *response; 190 struct MHD_Response *response;
191 int ret; 191 enum MHD_Result ret;
192 (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ 192 (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */
193 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 193 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
194 194
@@ -211,7 +211,7 @@ http_ahc (void *cls,
211 211
212 212
213/* HTTP access handler call back */ 213/* HTTP access handler call back */
214int 214enum MHD_Result
215http_dummy_ahc (void *cls, 215http_dummy_ahc (void *cls,
216 struct MHD_Connection *connection, 216 struct MHD_Connection *connection,
217 const char *url, 217 const char *url,
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h
index 36f5ffa5..fd2a47b1 100644
--- a/src/testcurl/https/tls_test_common.h
+++ b/src/testcurl/https/tls_test_common.h
@@ -95,12 +95,12 @@ print_test_result (int test_outcome, char *test_name);
95size_t 95size_t
96copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx); 96copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx);
97 97
98int 98enum MHD_Result
99http_ahc (void *cls, struct MHD_Connection *connection, 99http_ahc (void *cls, struct MHD_Connection *connection,
100 const char *url, const char *method, const char *upload_data, 100 const char *url, const char *method, const char *upload_data,
101 const char *version, size_t *upload_data_size, void **ptr); 101 const char *version, size_t *upload_data_size, void **ptr);
102 102
103int 103enum MHD_Result
104http_dummy_ahc (void *cls, struct MHD_Connection *connection, 104http_dummy_ahc (void *cls, struct MHD_Connection *connection,
105 const char *url, const char *method, const char *upload_data, 105 const char *url, const char *method, const char *upload_data,
106 const char *version, size_t *upload_data_size, 106 const char *version, size_t *upload_data_size,
diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c
index 53992b17..eb33ea0c 100644
--- a/src/testcurl/perf_get.c
+++ b/src/testcurl/perf_get.c
@@ -151,7 +151,7 @@ copyBuffer (void *ptr,
151} 151}
152 152
153 153
154static int 154static enum MHD_Result
155ahc_echo (void *cls, 155ahc_echo (void *cls,
156 struct MHD_Connection *connection, 156 struct MHD_Connection *connection,
157 const char *url, 157 const char *url,
@@ -162,7 +162,7 @@ ahc_echo (void *cls,
162{ 162{
163 static int ptr; 163 static int ptr;
164 const char *me = cls; 164 const char *me = cls;
165 int ret; 165 enum MHD_Result ret;
166 (void) url; (void) version; /* Unused. Silent compiler warning. */ 166 (void) url; (void) version; /* Unused. Silent compiler warning. */
167 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 167 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
168 168
diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c
index 12c57dae..0471143c 100644
--- a/src/testcurl/perf_get_concurrent.c
+++ b/src/testcurl/perf_get_concurrent.c
@@ -146,7 +146,7 @@ copyBuffer (void *ptr,
146} 146}
147 147
148 148
149static int 149static enum MHD_Result
150ahc_echo (void *cls, 150ahc_echo (void *cls,
151 struct MHD_Connection *connection, 151 struct MHD_Connection *connection,
152 const char *url, 152 const char *url,
@@ -157,7 +157,7 @@ ahc_echo (void *cls,
157{ 157{
158 static int ptr; 158 static int ptr;
159 const char *me = cls; 159 const char *me = cls;
160 int ret; 160 enum MHD_Result ret;
161 (void) url; (void) version; /* Unused. Silent compiler warning. */ 161 (void) url; (void) version; /* Unused. Silent compiler warning. */
162 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 162 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
163 163
diff --git a/src/testcurl/test_callback.c b/src/testcurl/test_callback.c
index 2e2be470..d9dfecef 100644
--- a/src/testcurl/test_callback.c
+++ b/src/testcurl/test_callback.c
@@ -58,7 +58,7 @@ called_twice (void *cls, uint64_t pos, char *buf, size_t max)
58} 58}
59 59
60 60
61static int 61static enum MHD_Result
62callback (void *cls, 62callback (void *cls,
63 struct MHD_Connection *connection, 63 struct MHD_Connection *connection,
64 const char *url, 64 const char *url,
@@ -70,7 +70,7 @@ callback (void *cls,
70{ 70{
71 struct callback_closure *cbc = calloc (1, sizeof(struct callback_closure)); 71 struct callback_closure *cbc = calloc (1, sizeof(struct callback_closure));
72 struct MHD_Response *r; 72 struct MHD_Response *r;
73 int ret; 73 enum MHD_Result ret;
74 74
75 (void) cls; 75 (void) cls;
76 (void) url; /* Unused. Silent compiler warning. */ 76 (void) url; /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/test_concurrent_stop.c b/src/testcurl/test_concurrent_stop.c
index 750fddc8..6716f491 100644
--- a/src/testcurl/test_concurrent_stop.c
+++ b/src/testcurl/test_concurrent_stop.c
@@ -134,7 +134,7 @@ copyBuffer (void *ptr,
134} 134}
135 135
136 136
137static int 137static enum MHD_Result
138ahc_echo (void *cls, 138ahc_echo (void *cls,
139 struct MHD_Connection *connection, 139 struct MHD_Connection *connection,
140 const char *url, 140 const char *url,
@@ -146,7 +146,7 @@ ahc_echo (void *cls,
146{ 146{
147 static int ptr; 147 static int ptr;
148 const char *me = cls; 148 const char *me = cls;
149 int ret; 149 enum MHD_Result ret;
150 (void) url; (void) version; /* Unused. Silent compiler warning. */ 150 (void) url; (void) version; /* Unused. Silent compiler warning. */
151 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 151 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
152 152
diff --git a/src/testcurl/test_delete.c b/src/testcurl/test_delete.c
index 8854cde7..ae62311b 100644
--- a/src/testcurl/test_delete.c
+++ b/src/testcurl/test_delete.c
@@ -81,7 +81,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
81} 81}
82 82
83 83
84static int 84static enum MHD_Result
85ahc_echo (void *cls, 85ahc_echo (void *cls,
86 struct MHD_Connection *connection, 86 struct MHD_Connection *connection,
87 const char *url, 87 const char *url,
@@ -92,7 +92,7 @@ ahc_echo (void *cls,
92{ 92{
93 int *done = cls; 93 int *done = cls;
94 struct MHD_Response *response; 94 struct MHD_Response *response;
95 int ret; 95 enum MHD_Result ret;
96 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 96 (void) version; (void) unused; /* Unused. Silent compiler warning. */
97 97
98 if (0 != strcasecmp ("DELETE", method)) 98 if (0 != strcasecmp ("DELETE", method))
diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c
index 4de006b7..9b33eb9b 100644
--- a/src/testcurl/test_digestauth.c
+++ b/src/testcurl/test_digestauth.c
@@ -76,7 +76,7 @@ copyBuffer (void *ptr,
76} 76}
77 77
78 78
79static int 79static enum MHD_Result
80ahc_echo (void *cls, 80ahc_echo (void *cls,
81 struct MHD_Connection *connection, 81 struct MHD_Connection *connection,
82 const char *url, 82 const char *url,
@@ -90,7 +90,7 @@ ahc_echo (void *cls,
90 char *username; 90 char *username;
91 const char *password = "testpass"; 91 const char *password = "testpass";
92 const char *realm = "test@example.com"; 92 const char *realm = "test@example.com";
93 int ret; 93 enum MHD_Result ret;
94 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 94 (void) cls; (void) url; /* Unused. Silent compiler warning. */
95 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 95 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
96 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */ 96 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/test_digestauth_sha256.c b/src/testcurl/test_digestauth_sha256.c
index 3482d14d..ffeabd0c 100644
--- a/src/testcurl/test_digestauth_sha256.c
+++ b/src/testcurl/test_digestauth_sha256.c
@@ -77,7 +77,7 @@ copyBuffer (void *ptr,
77} 77}
78 78
79 79
80static int 80static enum MHD_Result
81ahc_echo (void *cls, 81ahc_echo (void *cls,
82 struct MHD_Connection *connection, 82 struct MHD_Connection *connection,
83 const char *url, 83 const char *url,
@@ -91,7 +91,7 @@ ahc_echo (void *cls,
91 char *username; 91 char *username;
92 const char *password = "testpass"; 92 const char *password = "testpass";
93 const char *realm = "test@example.com"; 93 const char *realm = "test@example.com";
94 int ret; 94 enum MHD_Result ret;
95 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 95 (void) cls; (void) url; /* Unused. Silent compiler warning. */
96 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 96 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
97 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */ 97 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c
index f1927d1a..70d5f644 100644
--- a/src/testcurl/test_digestauth_with_arguments.c
+++ b/src/testcurl/test_digestauth_with_arguments.c
@@ -71,7 +71,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
71} 71}
72 72
73 73
74static int 74static enum MHD_Result
75ahc_echo (void *cls, 75ahc_echo (void *cls,
76 struct MHD_Connection *connection, 76 struct MHD_Connection *connection,
77 const char *url, 77 const char *url,
@@ -84,7 +84,7 @@ ahc_echo (void *cls,
84 char *username; 84 char *username;
85 const char *password = "testpass"; 85 const char *password = "testpass";
86 const char *realm = "test@example.com"; 86 const char *realm = "test@example.com";
87 int ret; 87 enum MHD_Result ret;
88 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 88 (void) cls; (void) url; /* Unused. Silent compiler warning. */
89 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 89 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
90 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */ 90 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c
index 3ab05d9a..91efdefd 100644
--- a/src/testcurl/test_get.c
+++ b/src/testcurl/test_get.c
@@ -98,7 +98,7 @@ log_cb (void *cls,
98} 98}
99 99
100 100
101static int 101static enum MHD_Result
102ahc_echo (void *cls, 102ahc_echo (void *cls,
103 struct MHD_Connection *connection, 103 struct MHD_Connection *connection,
104 const char *url, 104 const char *url,
@@ -110,7 +110,7 @@ ahc_echo (void *cls,
110 static int ptr; 110 static int ptr;
111 const char *me = cls; 111 const char *me = cls;
112 struct MHD_Response *response; 112 struct MHD_Response *response;
113 int ret; 113 enum MHD_Result ret;
114 const char *v; 114 const char *v;
115 (void) version; 115 (void) version;
116 (void) upload_data; 116 (void) upload_data;
@@ -714,7 +714,7 @@ testStopRace (int poll_flag)
714} 714}
715 715
716 716
717static int 717static enum MHD_Result
718ahc_empty (void *cls, 718ahc_empty (void *cls,
719 struct MHD_Connection *connection, 719 struct MHD_Connection *connection,
720 const char *url, 720 const char *url,
@@ -726,7 +726,7 @@ ahc_empty (void *cls,
726{ 726{
727 static int ptr; 727 static int ptr;
728 struct MHD_Response *response; 728 struct MHD_Response *response;
729 int ret; 729 enum MHD_Result ret;
730 (void) cls; 730 (void) cls;
731 (void) url; 731 (void) url;
732 (void) url; 732 (void) url;
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c
index 7be1db60..aa60e2f8 100644
--- a/src/testcurl/test_get_chunked.c
+++ b/src/testcurl/test_get_chunked.c
@@ -106,7 +106,7 @@ crcf (void *ptr)
106} 106}
107 107
108 108
109static int 109static enum MHD_Result
110ahc_echo (void *cls, 110ahc_echo (void *cls,
111 struct MHD_Connection *connection, 111 struct MHD_Connection *connection,
112 const char *url, 112 const char *url,
@@ -118,7 +118,7 @@ ahc_echo (void *cls,
118 const char *me = cls; 118 const char *me = cls;
119 struct MHD_Response *response; 119 struct MHD_Response *response;
120 struct MHD_Response **responseptr; 120 struct MHD_Response **responseptr;
121 int ret; 121 enum MHD_Result ret;
122 122
123 (void) url; 123 (void) url;
124 (void) version; /* Unused. Silent compiler warning. */ 124 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/test_get_response_cleanup.c b/src/testcurl/test_get_response_cleanup.c
index 14c2f240..026fd254 100644
--- a/src/testcurl/test_get_response_cleanup.c
+++ b/src/testcurl/test_get_response_cleanup.c
@@ -116,7 +116,7 @@ push_free_callback (void *cls)
116} 116}
117 117
118 118
119static int 119static enum MHD_Result
120ahc_echo (void *cls, 120ahc_echo (void *cls,
121 struct MHD_Connection *connection, 121 struct MHD_Connection *connection,
122 const char *url, 122 const char *url,
@@ -128,7 +128,7 @@ ahc_echo (void *cls,
128 static int ptr; 128 static int ptr;
129 const char *me = cls; 129 const char *me = cls;
130 struct MHD_Response *response; 130 struct MHD_Response *response;
131 int ret; 131 enum MHD_Result ret;
132 (void) url; (void) version; /* Unused. Silent compiler warning. */ 132 (void) url; (void) version; /* Unused. Silent compiler warning. */
133 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 133 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
134 134
diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c
index ad102f0b..0095731e 100644
--- a/src/testcurl/test_get_sendfile.c
+++ b/src/testcurl/test_get_sendfile.c
@@ -75,7 +75,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
75} 75}
76 76
77 77
78static int 78static enum MHD_Result
79ahc_echo (void *cls, 79ahc_echo (void *cls,
80 struct MHD_Connection *connection, 80 struct MHD_Connection *connection,
81 const char *url, 81 const char *url,
@@ -87,7 +87,7 @@ ahc_echo (void *cls,
87 static int ptr; 87 static int ptr;
88 const char *me = cls; 88 const char *me = cls;
89 struct MHD_Response *response; 89 struct MHD_Response *response;
90 int ret; 90 enum MHD_Result ret;
91 int fd; 91 int fd;
92 (void) url; (void) version; /* Unused. Silent compiler warning. */ 92 (void) url; (void) version; /* Unused. Silent compiler warning. */
93 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 93 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
@@ -490,7 +490,7 @@ testExternalGet ()
490 if (cbc.pos != strlen (TESTSTR)) 490 if (cbc.pos != strlen (TESTSTR))
491 { 491 {
492 fprintf (stderr, 492 fprintf (stderr,
493 "Got %.*s instead of %S!\n", 493 "Got %.*s instead of %s!\n",
494 (int) cbc.pos, 494 (int) cbc.pos,
495 cbc.buf, 495 cbc.buf,
496 TESTSTR); 496 TESTSTR);
diff --git a/src/testcurl/test_iplimit.c b/src/testcurl/test_iplimit.c
index 60570886..3b61f827 100644
--- a/src/testcurl/test_iplimit.c
+++ b/src/testcurl/test_iplimit.c
@@ -74,7 +74,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
74} 74}
75 75
76 76
77static int 77static enum MHD_Result
78ahc_echo (void *cls, 78ahc_echo (void *cls,
79 struct MHD_Connection *connection, 79 struct MHD_Connection *connection,
80 const char *url, 80 const char *url,
@@ -86,7 +86,7 @@ ahc_echo (void *cls,
86 static int ptr; 86 static int ptr;
87 const char *me = cls; 87 const char *me = cls;
88 struct MHD_Response *response; 88 struct MHD_Response *response;
89 int ret; 89 enum MHD_Result ret;
90 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 90 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
91 91
92 if (0 != strcmp (me, method)) 92 if (0 != strcmp (me, method))
diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c
index b52246ef..d93942e4 100644
--- a/src/testcurl/test_large_put.c
+++ b/src/testcurl/test_large_put.c
@@ -118,7 +118,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
118} 118}
119 119
120 120
121static int 121static enum MHD_Result
122ahc_echo (void *cls, 122ahc_echo (void *cls,
123 struct MHD_Connection *connection, 123 struct MHD_Connection *connection,
124 const char *url, 124 const char *url,
@@ -129,7 +129,7 @@ ahc_echo (void *cls,
129{ 129{
130 int *done = cls; 130 int *done = cls;
131 struct MHD_Response *response; 131 struct MHD_Response *response;
132 int ret; 132 enum MHD_Result ret;
133 static size_t processed; 133 static size_t processed;
134 (void) version; /* Unused. Silent compiler warning. */ 134 (void) version; /* Unused. Silent compiler warning. */
135 135
diff --git a/src/testcurl/test_long_header.c b/src/testcurl/test_long_header.c
index 17d8904b..54030c21 100644
--- a/src/testcurl/test_long_header.c
+++ b/src/testcurl/test_long_header.c
@@ -46,7 +46,7 @@
46 46
47static int oneone; 47static int oneone;
48 48
49static int 49static enum MHD_Result
50apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) 50apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen)
51{ 51{
52 (void) cls; (void) addr; (void) addrlen; /* Unused. Silent compiler warning. */ 52 (void) cls; (void) addr; (void) addrlen; /* Unused. Silent compiler warning. */
@@ -69,7 +69,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
69} 69}
70 70
71 71
72static int 72static enum MHD_Result
73ahc_echo (void *cls, 73ahc_echo (void *cls,
74 struct MHD_Connection *connection, 74 struct MHD_Connection *connection,
75 const char *url, 75 const char *url,
@@ -80,7 +80,7 @@ ahc_echo (void *cls,
80{ 80{
81 const char *me = cls; 81 const char *me = cls;
82 struct MHD_Response *response; 82 struct MHD_Response *response;
83 int ret; 83 enum MHD_Result ret;
84 (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 84 (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
85 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */ 85 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */
86 86
diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c
index d4c291ea..8a786cc2 100644
--- a/src/testcurl/test_parse_cookies.c
+++ b/src/testcurl/test_parse_cookies.c
@@ -59,7 +59,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
59} 59}
60 60
61 61
62static int 62static enum MHD_Result
63ahc_echo (void *cls, 63ahc_echo (void *cls,
64 struct MHD_Connection *connection, 64 struct MHD_Connection *connection,
65 const char *url, 65 const char *url,
@@ -71,7 +71,7 @@ ahc_echo (void *cls,
71 static int ptr; 71 static int ptr;
72 const char *me = cls; 72 const char *me = cls;
73 struct MHD_Response *response; 73 struct MHD_Response *response;
74 int ret; 74 enum MHD_Result ret;
75 const char *hdr; 75 const char *hdr;
76 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 76 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
77 77
diff --git a/src/testcurl/test_patch.c b/src/testcurl/test_patch.c
index 86327b0d..6be3ab30 100644
--- a/src/testcurl/test_patch.c
+++ b/src/testcurl/test_patch.c
@@ -81,7 +81,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
81} 81}
82 82
83 83
84static int 84static enum MHD_Result
85ahc_echo (void *cls, 85ahc_echo (void *cls,
86 struct MHD_Connection *connection, 86 struct MHD_Connection *connection,
87 const char *url, 87 const char *url,
@@ -92,7 +92,7 @@ ahc_echo (void *cls,
92{ 92{
93 int *done = cls; 93 int *done = cls;
94 struct MHD_Response *response; 94 struct MHD_Response *response;
95 int ret; 95 enum MHD_Result ret;
96 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 96 (void) version; (void) unused; /* Unused. Silent compiler warning. */
97 97
98 if (0 != strcasecmp ("PATCH", method)) 98 if (0 != strcasecmp ("PATCH", method))
diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c
index 97c9bcc9..675f8db6 100644
--- a/src/testcurl/test_post.c
+++ b/src/testcurl/test_post.c
@@ -97,7 +97,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
97 * in that it fails to support incremental processing. 97 * in that it fails to support incremental processing.
98 * (to be fixed in the future) 98 * (to be fixed in the future)
99 */ 99 */
100static int 100static enum MHD_Result
101post_iterator (void *cls, 101post_iterator (void *cls,
102 enum MHD_ValueKind kind, 102 enum MHD_ValueKind kind,
103 const char *key, 103 const char *key,
@@ -120,7 +120,7 @@ post_iterator (void *cls,
120} 120}
121 121
122 122
123static int 123static enum MHD_Result
124ahc_echo (void *cls, 124ahc_echo (void *cls,
125 struct MHD_Connection *connection, 125 struct MHD_Connection *connection,
126 const char *url, 126 const char *url,
@@ -132,7 +132,7 @@ ahc_echo (void *cls,
132 static int eok; 132 static int eok;
133 struct MHD_Response *response; 133 struct MHD_Response *response;
134 struct MHD_PostProcessor *pp; 134 struct MHD_PostProcessor *pp;
135 int ret; 135 enum MHD_Result ret;
136 (void) cls; (void) version; /* Unused. Silent compiler warning. */ 136 (void) cls; (void) version; /* Unused. Silent compiler warning. */
137 137
138 if (0 != strcasecmp ("POST", method)) 138 if (0 != strcasecmp ("POST", method))
@@ -562,7 +562,7 @@ testExternalPost ()
562} 562}
563 563
564 564
565static int 565static enum MHD_Result
566ahc_cancel (void *cls, 566ahc_cancel (void *cls,
567 struct MHD_Connection *connection, 567 struct MHD_Connection *connection,
568 const char *url, 568 const char *url,
@@ -572,7 +572,7 @@ ahc_cancel (void *cls,
572 void **unused) 572 void **unused)
573{ 573{
574 struct MHD_Response *response; 574 struct MHD_Response *response;
575 int ret; 575 enum MHD_Result ret;
576 (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ 576 (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */
577 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 577 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
578 578
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 38f9de6e..0eaf2730 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -72,7 +72,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
72} 72}
73 73
74 74
75static int 75static enum MHD_Result
76ahc_echo (void *cls, 76ahc_echo (void *cls,
77 struct MHD_Connection *connection, 77 struct MHD_Connection *connection,
78 const char *url, 78 const char *url,
@@ -83,7 +83,7 @@ ahc_echo (void *cls,
83{ 83{
84 static int marker; 84 static int marker;
85 struct MHD_Response *response; 85 struct MHD_Response *response;
86 int ret; 86 enum MHD_Result ret;
87 (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ 87 (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */
88 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 88 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
89 89
diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c
index 25e6d0e4..18a0fc62 100644
--- a/src/testcurl/test_postform.c
+++ b/src/testcurl/test_postform.c
@@ -93,7 +93,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
93 * in that it fails to support incremental processing. 93 * in that it fails to support incremental processing.
94 * (to be fixed in the future) 94 * (to be fixed in the future)
95 */ 95 */
96static int 96static enum MHD_Result
97post_iterator (void *cls, 97post_iterator (void *cls,
98 enum MHD_ValueKind kind, 98 enum MHD_ValueKind kind,
99 const char *key, 99 const char *key,
@@ -119,7 +119,7 @@ post_iterator (void *cls,
119} 119}
120 120
121 121
122static int 122static enum MHD_Result
123ahc_echo (void *cls, 123ahc_echo (void *cls,
124 struct MHD_Connection *connection, 124 struct MHD_Connection *connection,
125 const char *url, 125 const char *url,
@@ -131,7 +131,7 @@ ahc_echo (void *cls,
131 static int eok; 131 static int eok;
132 struct MHD_Response *response; 132 struct MHD_Response *response;
133 struct MHD_PostProcessor *pp; 133 struct MHD_PostProcessor *pp;
134 int ret; 134 enum MHD_Result ret;
135 (void) cls; (void) version; /* Unused. Silent compiler warning. */ 135 (void) cls; (void) version; /* Unused. Silent compiler warning. */
136 136
137 if (0 != strcmp ("POST", method)) 137 if (0 != strcmp ("POST", method))
diff --git a/src/testcurl/test_process_arguments.c b/src/testcurl/test_process_arguments.c
index dc50396d..f7e03531 100644
--- a/src/testcurl/test_process_arguments.c
+++ b/src/testcurl/test_process_arguments.c
@@ -60,7 +60,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
60} 60}
61 61
62 62
63static int 63static enum MHD_Result
64ahc_echo (void *cls, 64ahc_echo (void *cls,
65 struct MHD_Connection *connection, 65 struct MHD_Connection *connection,
66 const char *url, 66 const char *url,
@@ -72,7 +72,7 @@ ahc_echo (void *cls,
72 static int ptr; 72 static int ptr;
73 const char *me = cls; 73 const char *me = cls;
74 struct MHD_Response *response; 74 struct MHD_Response *response;
75 int ret; 75 enum MHD_Result ret;
76 const char *hdr; 76 const char *hdr;
77 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 77 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
78 78
diff --git a/src/testcurl/test_process_headers.c b/src/testcurl/test_process_headers.c
index 34200082..5784f5b7 100644
--- a/src/testcurl/test_process_headers.c
+++ b/src/testcurl/test_process_headers.c
@@ -66,7 +66,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
66} 66}
67 67
68 68
69static int 69static enum MHD_Result
70kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) 70kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
71{ 71{
72 if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && 72 if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) &&
@@ -80,7 +80,7 @@ kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
80} 80}
81 81
82 82
83static int 83static enum MHD_Result
84ahc_echo (void *cls, 84ahc_echo (void *cls,
85 struct MHD_Connection *connection, 85 struct MHD_Connection *connection,
86 const char *url, 86 const char *url,
@@ -92,7 +92,7 @@ ahc_echo (void *cls,
92 static int ptr; 92 static int ptr;
93 const char *me = cls; 93 const char *me = cls;
94 struct MHD_Response *response; 94 struct MHD_Response *response;
95 int ret; 95 enum MHD_Result ret;
96 const char *hdr; 96 const char *hdr;
97 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 97 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
98 98
diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c
index 2326310a..c582a418 100644
--- a/src/testcurl/test_put.c
+++ b/src/testcurl/test_put.c
@@ -81,7 +81,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
81} 81}
82 82
83 83
84static int 84static enum MHD_Result
85ahc_echo (void *cls, 85ahc_echo (void *cls,
86 struct MHD_Connection *connection, 86 struct MHD_Connection *connection,
87 const char *url, 87 const char *url,
@@ -92,7 +92,7 @@ ahc_echo (void *cls,
92{ 92{
93 int *done = cls; 93 int *done = cls;
94 struct MHD_Response *response; 94 struct MHD_Response *response;
95 int ret; 95 enum MHD_Result ret;
96 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 96 (void) version; (void) unused; /* Unused. Silent compiler warning. */
97 97
98 if (0 != strcasecmp ("PUT", method)) 98 if (0 != strcasecmp ("PUT", method))
diff --git a/src/testcurl/test_put_chunked.c b/src/testcurl/test_put_chunked.c
index 0824b286..e393523d 100644
--- a/src/testcurl/test_put_chunked.c
+++ b/src/testcurl/test_put_chunked.c
@@ -81,7 +81,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
81} 81}
82 82
83 83
84static int 84static enum MHD_Result
85ahc_echo (void *cls, 85ahc_echo (void *cls,
86 struct MHD_Connection *connection, 86 struct MHD_Connection *connection,
87 const char *url, 87 const char *url,
@@ -92,7 +92,7 @@ ahc_echo (void *cls,
92{ 92{
93 int *done = cls; 93 int *done = cls;
94 struct MHD_Response *response; 94 struct MHD_Response *response;
95 int ret; 95 enum MHD_Result ret;
96 int have; 96 int have;
97 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 97 (void) version; (void) unused; /* Unused. Silent compiler warning. */
98 98
diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c
index 8a79a3c4..ac0ade30 100644
--- a/src/testcurl/test_quiesce.c
+++ b/src/testcurl/test_quiesce.c
@@ -70,7 +70,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
70} 70}
71 71
72 72
73static int 73static enum MHD_Result
74ahc_echo (void *cls, 74ahc_echo (void *cls,
75 struct MHD_Connection *connection, 75 struct MHD_Connection *connection,
76 const char *url, 76 const char *url,
@@ -82,7 +82,7 @@ ahc_echo (void *cls,
82 static int ptr; 82 static int ptr;
83 const char *me = cls; 83 const char *me = cls;
84 struct MHD_Response *response; 84 struct MHD_Response *response;
85 int ret; 85 enum MHD_Result ret;
86 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 86 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
87 87
88 if (0 != strcmp (me, method)) 88 if (0 != strcmp (me, method))
diff --git a/src/testcurl/test_quiesce_stream.c b/src/testcurl/test_quiesce_stream.c
index cb1e71cb..5a3e601e 100644
--- a/src/testcurl/test_quiesce_stream.c
+++ b/src/testcurl/test_quiesce_stream.c
@@ -132,7 +132,7 @@ free_crc_data (void *crc_data)
132} 132}
133 133
134 134
135static int 135static enum MHD_Result
136http_AccessHandlerCallback (void *cls, 136http_AccessHandlerCallback (void *cls,
137 struct MHD_Connection *connection, 137 struct MHD_Connection *connection,
138 const char *url, 138 const char *url,
@@ -142,7 +142,7 @@ http_AccessHandlerCallback (void *cls,
142 size_t *upload_data_size, 142 size_t *upload_data_size,
143 void **con_cls) 143 void **con_cls)
144{ 144{
145 int ret; 145 enum MHD_Result ret;
146 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 146 (void) cls; (void) url; /* Unused. Silent compiler warning. */
147 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 147 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
148 (void) upload_data_size; /* Unused. Silent compiler warning. */ 148 (void) upload_data_size; /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/test_termination.c b/src/testcurl/test_termination.c
index 17940020..5541ae30 100644
--- a/src/testcurl/test_termination.c
+++ b/src/testcurl/test_termination.c
@@ -47,7 +47,7 @@
47#include <windows.h> 47#include <windows.h>
48#endif 48#endif
49 49
50static int 50static enum MHD_Result
51connection_handler (void *cls, 51connection_handler (void *cls,
52 struct MHD_Connection *connection, 52 struct MHD_Connection *connection,
53 const char *url, 53 const char *url,
@@ -76,7 +76,7 @@ connection_handler (void *cls,
76 struct MHD_Response *response = 76 struct MHD_Response *response =
77 MHD_create_response_from_buffer (strlen ("Response"), "Response", 77 MHD_create_response_from_buffer (strlen ("Response"), "Response",
78 MHD_RESPMEM_PERSISTENT); 78 MHD_RESPMEM_PERSISTENT);
79 int ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 79 enum MHD_Result ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
80 MHD_destroy_response (response); 80 MHD_destroy_response (response);
81 81
82 return ret; 82 return ret;
diff --git a/src/testcurl/test_timeout.c b/src/testcurl/test_timeout.c
index db1c1e6a..018195f4 100644
--- a/src/testcurl/test_timeout.c
+++ b/src/testcurl/test_timeout.c
@@ -121,7 +121,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
121} 121}
122 122
123 123
124static int 124static enum MHD_Result
125ahc_echo (void *cls, 125ahc_echo (void *cls,
126 struct MHD_Connection *connection, 126 struct MHD_Connection *connection,
127 const char *url, 127 const char *url,
@@ -132,7 +132,7 @@ ahc_echo (void *cls,
132{ 132{
133 int *done = cls; 133 int *done = cls;
134 struct MHD_Response *response; 134 struct MHD_Response *response;
135 int ret; 135 enum MHD_Result ret;
136 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 136 (void) version; (void) unused; /* Unused. Silent compiler warning. */
137 137
138 if (0 != strcmp ("PUT", method)) 138 if (0 != strcmp ("PUT", method))
diff --git a/src/testcurl/test_urlparse.c b/src/testcurl/test_urlparse.c
index e8770330..d089ab22 100644
--- a/src/testcurl/test_urlparse.c
+++ b/src/testcurl/test_urlparse.c
@@ -69,7 +69,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
69} 69}
70 70
71 71
72static int 72static enum MHD_Result
73test_values (void *cls, 73test_values (void *cls,
74 enum MHD_ValueKind kind, 74 enum MHD_ValueKind kind,
75 const char *key, 75 const char *key,
@@ -89,7 +89,7 @@ test_values (void *cls,
89} 89}
90 90
91 91
92static int 92static enum MHD_Result
93ahc_echo (void *cls, 93ahc_echo (void *cls,
94 struct MHD_Connection *connection, 94 struct MHD_Connection *connection,
95 const char *url, 95 const char *url,
@@ -101,7 +101,7 @@ ahc_echo (void *cls,
101 static int ptr; 101 static int ptr;
102 const char *me = cls; 102 const char *me = cls;
103 struct MHD_Response *response; 103 struct MHD_Response *response;
104 int ret; 104 enum MHD_Result ret;
105 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 105 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
106 106
107 if (0 != strcmp (me, method)) 107 if (0 != strcmp (me, method))
diff --git a/src/testzzuf/test_get.c b/src/testzzuf/test_get.c
index 83d92ab3..9ef0d4f7 100644
--- a/src/testzzuf/test_get.c
+++ b/src/testzzuf/test_get.c
@@ -60,7 +60,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
60} 60}
61 61
62 62
63static int 63static enum MHD_Result
64ahc_echo (void *cls, 64ahc_echo (void *cls,
65 struct MHD_Connection *connection, 65 struct MHD_Connection *connection,
66 const char *url, 66 const char *url,
@@ -72,7 +72,7 @@ ahc_echo (void *cls,
72 static int ptr; 72 static int ptr;
73 const char *me = cls; 73 const char *me = cls;
74 struct MHD_Response *response; 74 struct MHD_Response *response;
75 int ret; 75 enum MHD_Result ret;
76 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 76 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
77 77
78 if (0 != strcmp (me, method)) 78 if (0 != strcmp (me, method))
diff --git a/src/testzzuf/test_get_chunked.c b/src/testzzuf/test_get_chunked.c
index 8ad7dd6b..9a6536c0 100644
--- a/src/testzzuf/test_get_chunked.c
+++ b/src/testzzuf/test_get_chunked.c
@@ -89,7 +89,7 @@ crcf (void *ptr)
89} 89}
90 90
91 91
92static int 92static enum MHD_Result
93ahc_echo (void *cls, 93ahc_echo (void *cls,
94 struct MHD_Connection *connection, 94 struct MHD_Connection *connection,
95 const char *url, 95 const char *url,
@@ -101,7 +101,7 @@ ahc_echo (void *cls,
101 const char *me = cls; 101 const char *me = cls;
102 struct MHD_Response *response; 102 struct MHD_Response *response;
103 struct MHD_Response **responseptr; 103 struct MHD_Response **responseptr;
104 int ret; 104 enum MHD_Result ret;
105 105
106 (void) url; 106 (void) url;
107 (void) version; /* Unused. Silent compiler warning. */ 107 (void) version; /* Unused. Silent compiler warning. */
diff --git a/src/testzzuf/test_long_header.c b/src/testzzuf/test_long_header.c
index 6595ad4e..add99234 100644
--- a/src/testzzuf/test_long_header.c
+++ b/src/testzzuf/test_long_header.c
@@ -47,7 +47,7 @@
47 47
48static int oneone; 48static int oneone;
49 49
50static int 50static enum MHD_Result
51apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) 51apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen)
52{ 52{
53 (void) cls; (void) addr; (void) addrlen; /* Unused. Silent compiler warning. */ 53 (void) cls; (void) addr; (void) addrlen; /* Unused. Silent compiler warning. */
@@ -70,7 +70,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
70} 70}
71 71
72 72
73static int 73static enum MHD_Result
74ahc_echo (void *cls, 74ahc_echo (void *cls,
75 struct MHD_Connection *connection, 75 struct MHD_Connection *connection,
76 const char *url, 76 const char *url,
@@ -81,7 +81,7 @@ ahc_echo (void *cls,
81{ 81{
82 const char *me = cls; 82 const char *me = cls;
83 struct MHD_Response *response; 83 struct MHD_Response *response;
84 int ret; 84 enum MHD_Result ret;
85 (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 85 (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
86 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */ 86 (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */
87 87
@@ -128,6 +128,11 @@ testLongUrlGet ()
128 128
129 c = curl_easy_init (); 129 c = curl_easy_init ();
130 url = malloc (VERY_LONG); 130 url = malloc (VERY_LONG);
131 if (NULL == url)
132 {
133 zzuf_socat_stop ();
134 return 1;
135 }
131 memset (url, 'a', VERY_LONG); 136 memset (url, 'a', VERY_LONG);
132 url[VERY_LONG - 1] = '\0'; 137 url[VERY_LONG - 1] = '\0';
133 memcpy (url, "http://127.0.0.1:11081/", 138 memcpy (url, "http://127.0.0.1:11081/",
@@ -189,6 +194,12 @@ testLongHeaderGet ()
189 fprintf (stderr, "."); 194 fprintf (stderr, ".");
190 c = curl_easy_init (); 195 c = curl_easy_init ();
191 url = malloc (VERY_LONG); 196 url = malloc (VERY_LONG);
197 if (NULL == url)
198 {
199 zzuf_socat_stop ();
200 curl_easy_cleanup (c);
201 return 16;
202 }
192 memset (url, 'a', VERY_LONG); 203 memset (url, 'a', VERY_LONG);
193 url[VERY_LONG - 1] = '\0'; 204 url[VERY_LONG - 1] = '\0';
194 url[VERY_LONG / 2] = ':'; 205 url[VERY_LONG / 2] = ':';
diff --git a/src/testzzuf/test_post.c b/src/testzzuf/test_post.c
index 637423c8..e3d8512c 100644
--- a/src/testzzuf/test_post.c
+++ b/src/testzzuf/test_post.c
@@ -84,7 +84,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
84 * in that it fails to support incremental processing. 84 * in that it fails to support incremental processing.
85 * (to be fixed in the future) 85 * (to be fixed in the future)
86 */ 86 */
87static int 87static enum MHD_Result
88post_iterator (void *cls, 88post_iterator (void *cls,
89 enum MHD_ValueKind kind, 89 enum MHD_ValueKind kind,
90 const char *key, 90 const char *key,
@@ -107,7 +107,7 @@ post_iterator (void *cls,
107} 107}
108 108
109 109
110static int 110static enum MHD_Result
111ahc_echo (void *cls, 111ahc_echo (void *cls,
112 struct MHD_Connection *connection, 112 struct MHD_Connection *connection,
113 const char *url, 113 const char *url,
@@ -119,7 +119,7 @@ ahc_echo (void *cls,
119 static int eok; 119 static int eok;
120 struct MHD_Response *response; 120 struct MHD_Response *response;
121 struct MHD_PostProcessor *pp; 121 struct MHD_PostProcessor *pp;
122 int ret; 122 enum MHD_Result ret;
123 (void) cls; (void) version; /* Unused. Silent compiler warning. */ 123 (void) cls; (void) version; /* Unused. Silent compiler warning. */
124 124
125 if (0 != strcmp ("POST", method)) 125 if (0 != strcmp ("POST", method))
diff --git a/src/testzzuf/test_post_form.c b/src/testzzuf/test_post_form.c
index a253b96d..f994ab24 100644
--- a/src/testzzuf/test_post_form.c
+++ b/src/testzzuf/test_post_form.c
@@ -82,7 +82,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
82 * in that it fails to support incremental processing. 82 * in that it fails to support incremental processing.
83 * (to be fixed in the future) 83 * (to be fixed in the future)
84 */ 84 */
85static int 85static enum MHD_Result
86post_iterator (void *cls, 86post_iterator (void *cls,
87 enum MHD_ValueKind kind, 87 enum MHD_ValueKind kind,
88 const char *key, 88 const char *key,
@@ -110,7 +110,7 @@ post_iterator (void *cls,
110} 110}
111 111
112 112
113static int 113static enum MHD_Result
114ahc_echo (void *cls, 114ahc_echo (void *cls,
115 struct MHD_Connection *connection, 115 struct MHD_Connection *connection,
116 const char *url, 116 const char *url,
@@ -122,7 +122,7 @@ ahc_echo (void *cls,
122 static int eok; 122 static int eok;
123 struct MHD_Response *response; 123 struct MHD_Response *response;
124 struct MHD_PostProcessor *pp; 124 struct MHD_PostProcessor *pp;
125 int ret; 125 enum MHD_Result ret;
126 (void) cls; (void) version; /* Unused. Silent compiler warning. */ 126 (void) cls; (void) version; /* Unused. Silent compiler warning. */
127 127
128 if (0 != strcmp ("POST", method)) 128 if (0 != strcmp ("POST", method))
diff --git a/src/testzzuf/test_put.c b/src/testzzuf/test_put.c
index 2c79c759..4658d0d4 100644
--- a/src/testzzuf/test_put.c
+++ b/src/testzzuf/test_put.c
@@ -76,7 +76,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
76} 76}
77 77
78 78
79static int 79static enum MHD_Result
80ahc_echo (void *cls, 80ahc_echo (void *cls,
81 struct MHD_Connection *connection, 81 struct MHD_Connection *connection,
82 const char *url, 82 const char *url,
@@ -87,7 +87,7 @@ ahc_echo (void *cls,
87{ 87{
88 int *done = cls; 88 int *done = cls;
89 struct MHD_Response *response; 89 struct MHD_Response *response;
90 int ret; 90 enum MHD_Result ret;
91 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 91 (void) version; (void) unused; /* Unused. Silent compiler warning. */
92 92
93 if (0 != strcmp ("PUT", method)) 93 if (0 != strcmp ("PUT", method))
diff --git a/src/testzzuf/test_put_chunked.c b/src/testzzuf/test_put_chunked.c
index 29108008..35196843 100644
--- a/src/testzzuf/test_put_chunked.c
+++ b/src/testzzuf/test_put_chunked.c
@@ -76,7 +76,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
76} 76}
77 77
78 78
79static int 79static enum MHD_Result
80ahc_echo (void *cls, 80ahc_echo (void *cls,
81 struct MHD_Connection *connection, 81 struct MHD_Connection *connection,
82 const char *url, 82 const char *url,
@@ -87,7 +87,7 @@ ahc_echo (void *cls,
87{ 87{
88 int *done = cls; 88 int *done = cls;
89 struct MHD_Response *response; 89 struct MHD_Response *response;
90 int ret; 90 enum MHD_Result ret;
91 int have; 91 int have;
92 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 92 (void) version; (void) unused; /* Unused. Silent compiler warning. */
93 93
diff --git a/src/testzzuf/test_put_large.c b/src/testzzuf/test_put_large.c
index 56b076c5..abda22cb 100644
--- a/src/testzzuf/test_put_large.c
+++ b/src/testzzuf/test_put_large.c
@@ -84,7 +84,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
84} 84}
85 85
86 86
87static int 87static enum MHD_Result
88ahc_echo (void *cls, 88ahc_echo (void *cls,
89 struct MHD_Connection *connection, 89 struct MHD_Connection *connection,
90 const char *url, 90 const char *url,
@@ -95,7 +95,7 @@ ahc_echo (void *cls,
95{ 95{
96 int *done = cls; 96 int *done = cls;
97 struct MHD_Response *response; 97 struct MHD_Response *response;
98 int ret; 98 enum MHD_Result ret;
99 (void) version; (void) unused; /* Unused. Silent compiler warning. */ 99 (void) version; (void) unused; /* Unused. Silent compiler warning. */
100 100
101 if (0 != strcmp ("PUT", method)) 101 if (0 != strcmp ("PUT", method))
@@ -376,6 +376,8 @@ main (int argc, char *const *argv)
376 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 376 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
377 return 2; 377 return 2;
378 put_buffer = malloc (PUT_SIZE); 378 put_buffer = malloc (PUT_SIZE);
379 if (0 == put_buffer)
380 return 77;
379 memset (put_buffer, 1, PUT_SIZE); 381 memset (put_buffer, 1, PUT_SIZE);
380 if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) 382 if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS))
381 { 383 {