aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemontest_put.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemontest_put.c')
-rw-r--r--src/daemon/daemontest_put.c562
1 files changed, 232 insertions, 330 deletions
diff --git a/src/daemon/daemontest_put.c b/src/daemon/daemontest_put.c
index e2f03bdf..342161c8 100644
--- a/src/daemon/daemontest_put.c
+++ b/src/daemon/daemontest_put.c
@@ -34,87 +34,82 @@
34 34
35static int oneone; 35static int oneone;
36 36
37struct CBC { 37struct CBC
38 char * buf; 38{
39 char *buf;
39 size_t pos; 40 size_t pos;
40 size_t size; 41 size_t size;
41}; 42};
42 43
43static size_t putBuffer(void * stream, 44static size_t
44 size_t size, 45putBuffer (void *stream, size_t size, size_t nmemb, void *ptr)
45 size_t nmemb, 46{
46 void * ptr) { 47 unsigned int *pos = ptr;
47 unsigned int * pos = ptr;
48 unsigned int wrt; 48 unsigned int wrt;
49 49
50 wrt = size * nmemb; 50 wrt = size * nmemb;
51 if (wrt > 8 - (*pos)) 51 if (wrt > 8 - (*pos))
52 wrt = 8 - (*pos); 52 wrt = 8 - (*pos);
53 memcpy(stream, 53 memcpy (stream, &("Hello123"[*pos]), wrt);
54 &("Hello123"[*pos]),
55 wrt);
56 (*pos) += wrt; 54 (*pos) += wrt;
57 return wrt; 55 return wrt;
58} 56}
59 57
60static size_t copyBuffer(void * ptr, 58static size_t
61 size_t size, 59copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
62 size_t nmemb, 60{
63 void * ctx) { 61 struct CBC *cbc = ctx;
64 struct CBC * cbc = ctx;
65 62
66 if (cbc->pos + size * nmemb > cbc->size) 63 if (cbc->pos + size * nmemb > cbc->size)
67 return 0; /* overflow */ 64 return 0; /* overflow */
68 memcpy(&cbc->buf[cbc->pos], 65 memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
69 ptr,
70 size * nmemb);
71 cbc->pos += size * nmemb; 66 cbc->pos += size * nmemb;
72 return size * nmemb; 67 return size * nmemb;
73} 68}
74 69
75static int ahc_echo(void * cls, 70static int
76 struct MHD_Connection * connection, 71ahc_echo (void *cls,
77 const char * url, 72 struct MHD_Connection *connection,
78 const char * method, 73 const char *url,
79 const char * version, 74 const char *method,
80 const char * upload_data, 75 const char *version,
81 unsigned int * upload_data_size) { 76 const char *upload_data, unsigned int *upload_data_size)
82 int * done = cls; 77{
83 struct MHD_Response * response; 78 int *done = cls;
79 struct MHD_Response *response;
84 int ret; 80 int ret;
85 81
86 if (0 != strcmp("PUT", method)) 82 if (0 != strcmp ("PUT", method))
87 return MHD_NO; /* unexpected method */ 83 return MHD_NO; /* unexpected method */
88 if ((*done) == 0) { 84 if ((*done) == 0)
89 if (*upload_data_size != 8) 85 {
90 return MHD_YES; /* not yet ready */ 86 if (*upload_data_size != 8)
91 if (0 == memcmp(upload_data, 87 return MHD_YES; /* not yet ready */
92 "Hello123", 88 if (0 == memcmp (upload_data, "Hello123", 8))
93 8)) { 89 {
94 *upload_data_size = 0; 90 *upload_data_size = 0;
95 } else { 91 }
96 printf("Invalid upload data `%8s'!\n", 92 else
97 upload_data); 93 {
98 return MHD_NO; 94 printf ("Invalid upload data `%8s'!\n", upload_data);
95 return MHD_NO;
96 }
97 *done = 1;
98 return MHD_YES;
99 } 99 }
100 *done = 1; 100 response = MHD_create_response_from_data (strlen (url),
101 return MHD_YES; 101 (void *) url, MHD_NO, MHD_YES);
102 } 102 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
103 response = MHD_create_response_from_data(strlen(url), 103 MHD_destroy_response (response);
104 (void*) url,
105 MHD_NO,
106 MHD_YES);
107 ret = MHD_queue_response(connection,
108 MHD_HTTP_OK,
109 response);
110 MHD_destroy_response(response);
111 return ret; 104 return ret;
112} 105}
113 106
114 107
115static int testInternalPut() { 108static int
116 struct MHD_Daemon * d; 109testInternalPut ()
117 CURL * c; 110{
111 struct MHD_Daemon *d;
112 CURL *c;
118 char buf[2048]; 113 char buf[2048];
119 struct CBC cbc; 114 struct CBC cbc;
120 unsigned int pos = 0; 115 unsigned int pos = 0;
@@ -123,85 +118,58 @@ static int testInternalPut() {
123 cbc.buf = buf; 118 cbc.buf = buf;
124 cbc.size = 2048; 119 cbc.size = 2048;
125 cbc.pos = 0; 120 cbc.pos = 0;
126 d = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, 121 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
127 1080, 122 1080,
128 NULL, 123 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
129 NULL,
130 &ahc_echo,
131 &done_flag,
132 MHD_OPTION_END);
133 if (d == NULL) 124 if (d == NULL)
134 return 1; 125 return 1;
135 c = curl_easy_init(); 126 c = curl_easy_init ();
136 curl_easy_setopt(c, 127 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world");
137 CURLOPT_URL, 128 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
138 "http://localhost:1080/hello_world"); 129 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
139 curl_easy_setopt(c, 130 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
140 CURLOPT_WRITEFUNCTION, 131 curl_easy_setopt (c, CURLOPT_READDATA, &pos);
141 &copyBuffer); 132 curl_easy_setopt (c, CURLOPT_UPLOAD, 1L);
142 curl_easy_setopt(c, 133 curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L);
143 CURLOPT_WRITEDATA, 134 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
144 &cbc); 135 curl_easy_setopt (c, CURLOPT_TIMEOUT, 15L);
145 curl_easy_setopt(c,
146 CURLOPT_READFUNCTION,
147 &putBuffer);
148 curl_easy_setopt(c,
149 CURLOPT_READDATA,
150 &pos);
151 curl_easy_setopt(c,
152 CURLOPT_UPLOAD,
153 1L);
154 curl_easy_setopt(c,
155 CURLOPT_INFILESIZE_LARGE,
156 (curl_off_t) 8L);
157 curl_easy_setopt(c,
158 CURLOPT_FAILONERROR,
159 1);
160 curl_easy_setopt(c,
161 CURLOPT_TIMEOUT,
162 15L);
163 if (oneone) 136 if (oneone)
164 curl_easy_setopt(c, 137 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
165 CURLOPT_HTTP_VERSION,
166 CURL_HTTP_VERSION_1_1);
167 else 138 else
168 curl_easy_setopt(c, 139 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
169 CURLOPT_HTTP_VERSION, 140 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L);
170 CURL_HTTP_VERSION_1_0);
171 curl_easy_setopt(c,
172 CURLOPT_CONNECTTIMEOUT,
173 15L);
174 // NOTE: use of CONNECTTIMEOUT without also 141 // NOTE: use of CONNECTTIMEOUT without also
175 // setting NOSIGNAL results in really weird 142 // setting NOSIGNAL results in really weird
176 // crashes on my system! 143 // crashes on my system!
177 curl_easy_setopt(c, 144 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
178 CURLOPT_NOSIGNAL, 145 if (CURLE_OK != curl_easy_perform (c))
179 1); 146 {
180 if (CURLE_OK != curl_easy_perform(c)) { 147 curl_easy_cleanup (c);
181 curl_easy_cleanup(c); 148 MHD_stop_daemon (d);
182 MHD_stop_daemon(d); 149 return 2;
183 return 2; 150 }
184 } 151 curl_easy_cleanup (c);
185 curl_easy_cleanup(c); 152 if (cbc.pos != strlen ("/hello_world"))
186 if (cbc.pos != strlen("/hello_world")) { 153 {
187 MHD_stop_daemon(d); 154 MHD_stop_daemon (d);
188 return 4; 155 return 4;
189 } 156 }
190 157
191 if (0 != strncmp("/hello_world", 158 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
192 cbc.buf, 159 {
193 strlen("/hello_world"))) { 160 MHD_stop_daemon (d);
194 MHD_stop_daemon(d); 161 return 8;
195 return 8; 162 }
196 } 163 MHD_stop_daemon (d);
197 MHD_stop_daemon(d);
198 164
199 return 0; 165 return 0;
200} 166}
201 167
202static int testMultithreadedPut() { 168static int
203 struct MHD_Daemon * d; 169testMultithreadedPut ()
204 CURL * c; 170{
171 struct MHD_Daemon *d;
172 CURL *c;
205 char buf[2048]; 173 char buf[2048];
206 struct CBC cbc; 174 struct CBC cbc;
207 unsigned int pos = 0; 175 unsigned int pos = 0;
@@ -210,94 +178,68 @@ static int testMultithreadedPut() {
210 cbc.buf = buf; 178 cbc.buf = buf;
211 cbc.size = 2048; 179 cbc.size = 2048;
212 cbc.pos = 0; 180 cbc.pos = 0;
213 d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 181 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG,
214 1081, 182 1081,
215 NULL, NULL, 183 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
216 &ahc_echo,
217 &done_flag,
218 MHD_OPTION_END);
219 if (d == NULL) 184 if (d == NULL)
220 return 16; 185 return 16;
221 c = curl_easy_init(); 186 c = curl_easy_init ();
222 curl_easy_setopt(c, 187 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world");
223 CURLOPT_URL, 188 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
224 "http://localhost:1081/hello_world"); 189 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
225 curl_easy_setopt(c, 190 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
226 CURLOPT_WRITEFUNCTION, 191 curl_easy_setopt (c, CURLOPT_READDATA, &pos);
227 &copyBuffer); 192 curl_easy_setopt (c, CURLOPT_UPLOAD, 1L);
228 curl_easy_setopt(c, 193 curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L);
229 CURLOPT_WRITEDATA, 194 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
230 &cbc); 195 curl_easy_setopt (c, CURLOPT_TIMEOUT, 15L);
231 curl_easy_setopt(c,
232 CURLOPT_READFUNCTION,
233 &putBuffer);
234 curl_easy_setopt(c,
235 CURLOPT_READDATA,
236 &pos);
237 curl_easy_setopt(c,
238 CURLOPT_UPLOAD,
239 1L);
240 curl_easy_setopt(c,
241 CURLOPT_INFILESIZE_LARGE,
242 (curl_off_t) 8L);
243 curl_easy_setopt(c,
244 CURLOPT_FAILONERROR,
245 1);
246 curl_easy_setopt(c,
247 CURLOPT_TIMEOUT,
248 15L);
249 if (oneone) 196 if (oneone)
250 curl_easy_setopt(c, 197 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
251 CURLOPT_HTTP_VERSION,
252 CURL_HTTP_VERSION_1_1);
253 else 198 else
254 curl_easy_setopt(c, 199 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
255 CURLOPT_HTTP_VERSION, 200 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L);
256 CURL_HTTP_VERSION_1_0);
257 curl_easy_setopt(c,
258 CURLOPT_CONNECTTIMEOUT,
259 15L);
260 // NOTE: use of CONNECTTIMEOUT without also 201 // NOTE: use of CONNECTTIMEOUT without also
261 // setting NOSIGNAL results in really weird 202 // setting NOSIGNAL results in really weird
262 // crashes on my system! 203 // crashes on my system!
263 curl_easy_setopt(c, 204 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
264 CURLOPT_NOSIGNAL, 205 if (CURLE_OK != curl_easy_perform (c))
265 1); 206 {
266 if (CURLE_OK != curl_easy_perform(c)) { 207 curl_easy_cleanup (c);
267 curl_easy_cleanup(c); 208 MHD_stop_daemon (d);
268 MHD_stop_daemon(d); 209 return 32;
269 return 32; 210 }
270 } 211 curl_easy_cleanup (c);
271 curl_easy_cleanup(c); 212 if (cbc.pos != strlen ("/hello_world"))
272 if (cbc.pos != strlen("/hello_world")) { 213 {
273 MHD_stop_daemon(d); 214 MHD_stop_daemon (d);
274 return 64; 215 return 64;
275 } 216 }
276 if (0 != strncmp("/hello_world", 217 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
277 cbc.buf, 218 {
278 strlen("/hello_world"))) { 219 MHD_stop_daemon (d);
279 MHD_stop_daemon(d); 220 return 128;
280 return 128; 221 }
281 } 222 MHD_stop_daemon (d);
282 MHD_stop_daemon(d);
283 223
284 return 0; 224 return 0;
285} 225}
286 226
287 227
288static int testExternalPut() { 228static int
289 struct MHD_Daemon * d; 229testExternalPut ()
290 CURL * c; 230{
231 struct MHD_Daemon *d;
232 CURL *c;
291 char buf[2048]; 233 char buf[2048];
292 struct CBC cbc; 234 struct CBC cbc;
293 CURLM * multi; 235 CURLM *multi;
294 CURLMcode mret; 236 CURLMcode mret;
295 fd_set rs; 237 fd_set rs;
296 fd_set ws; 238 fd_set ws;
297 fd_set es; 239 fd_set es;
298 int max; 240 int max;
299 int running; 241 int running;
300 struct CURLMsg * msg; 242 struct CURLMsg *msg;
301 time_t start; 243 time_t start;
302 struct timeval tv; 244 struct timeval tv;
303 unsigned int pos = 0; 245 unsigned int pos = 0;
@@ -307,166 +249,126 @@ static int testExternalPut() {
307 cbc.buf = buf; 249 cbc.buf = buf;
308 cbc.size = 2048; 250 cbc.size = 2048;
309 cbc.pos = 0; 251 cbc.pos = 0;
310 d = MHD_start_daemon(MHD_USE_DEBUG, 252 d = MHD_start_daemon (MHD_USE_DEBUG,
311 1082, 253 1082,
312 NULL, 254 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
313 NULL,
314 &ahc_echo,
315 &done_flag,
316 MHD_OPTION_END);
317 if (d == NULL) 255 if (d == NULL)
318 return 256; 256 return 256;
319 c = curl_easy_init(); 257 c = curl_easy_init ();
320 curl_easy_setopt(c, 258 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1082/hello_world");
321 CURLOPT_URL, 259 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
322 "http://localhost:1082/hello_world"); 260 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
323 curl_easy_setopt(c, 261 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
324 CURLOPT_WRITEFUNCTION, 262 curl_easy_setopt (c, CURLOPT_READDATA, &pos);
325 &copyBuffer); 263 curl_easy_setopt (c, CURLOPT_UPLOAD, 1L);
326 curl_easy_setopt(c, 264 curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L);
327 CURLOPT_WRITEDATA, 265 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
328 &cbc); 266 curl_easy_setopt (c, CURLOPT_TIMEOUT, 15L);
329 curl_easy_setopt(c,
330 CURLOPT_READFUNCTION,
331 &putBuffer);
332 curl_easy_setopt(c,
333 CURLOPT_READDATA,
334 &pos);
335 curl_easy_setopt(c,
336 CURLOPT_UPLOAD,
337 1L);
338 curl_easy_setopt(c,
339 CURLOPT_INFILESIZE_LARGE,
340 (curl_off_t) 8L);
341 curl_easy_setopt(c,
342 CURLOPT_FAILONERROR,
343 1);
344 curl_easy_setopt(c,
345 CURLOPT_TIMEOUT,
346 15L);
347 if (oneone) 267 if (oneone)
348 curl_easy_setopt(c, 268 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
349 CURLOPT_HTTP_VERSION,
350 CURL_HTTP_VERSION_1_1);
351 else 269 else
352 curl_easy_setopt(c, 270 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
353 CURLOPT_HTTP_VERSION, 271 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L);
354 CURL_HTTP_VERSION_1_0);
355 curl_easy_setopt(c,
356 CURLOPT_CONNECTTIMEOUT,
357 15L);
358 // NOTE: use of CONNECTTIMEOUT without also 272 // NOTE: use of CONNECTTIMEOUT without also
359 // setting NOSIGNAL results in really weird 273 // setting NOSIGNAL results in really weird
360 // crashes on my system! 274 // crashes on my system!
361 curl_easy_setopt(c, 275 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
362 CURLOPT_NOSIGNAL,
363 1);
364 276
365 277
366 multi = curl_multi_init(); 278 multi = curl_multi_init ();
367 if (multi == NULL) { 279 if (multi == NULL)
368 curl_easy_cleanup(c); 280 {
369 MHD_stop_daemon(d); 281 curl_easy_cleanup (c);
370 return 512; 282 MHD_stop_daemon (d);
371 } 283 return 512;
372 mret = curl_multi_add_handle(multi, c); 284 }
373 if (mret != CURLM_OK) { 285 mret = curl_multi_add_handle (multi, c);
374 curl_multi_cleanup(multi); 286 if (mret != CURLM_OK)
375 curl_easy_cleanup(c); 287 {
376 MHD_stop_daemon(d); 288 curl_multi_cleanup (multi);
377 return 1024; 289 curl_easy_cleanup (c);
378 } 290 MHD_stop_daemon (d);
379 start = time(NULL); 291 return 1024;
380 while ( (time(NULL) - start < 5) && 292 }
381 (multi != NULL) ) { 293 start = time (NULL);
382 max = 0; 294 while ((time (NULL) - start < 5) && (multi != NULL))
383 FD_ZERO(&rs); 295 {
384 FD_ZERO(&ws); 296 max = 0;
385 FD_ZERO(&es); 297 FD_ZERO (&rs);
386 curl_multi_perform(multi, &running); 298 FD_ZERO (&ws);
387 mret = curl_multi_fdset(multi, 299 FD_ZERO (&es);
388 &rs, 300 curl_multi_perform (multi, &running);
389 &ws, 301 mret = curl_multi_fdset (multi, &rs, &ws, &es, &max);
390 &es, 302 if (mret != CURLM_OK)
391 &max); 303 {
392 if (mret != CURLM_OK) { 304 curl_multi_remove_handle (multi, c);
393 curl_multi_remove_handle(multi, c); 305 curl_multi_cleanup (multi);
394 curl_multi_cleanup(multi); 306 curl_easy_cleanup (c);
395 curl_easy_cleanup(c); 307 MHD_stop_daemon (d);
396 MHD_stop_daemon(d); 308 return 2048;
397 return 2048; 309 }
310 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
311 {
312 curl_multi_remove_handle (multi, c);
313 curl_multi_cleanup (multi);
314 curl_easy_cleanup (c);
315 MHD_stop_daemon (d);
316 return 4096;
317 }
318 tv.tv_sec = 0;
319 tv.tv_usec = 1000;
320 select (max + 1, &rs, &ws, &es, &tv);
321 curl_multi_perform (multi, &running);
322 if (running == 0)
323 {
324 msg = curl_multi_info_read (multi, &running);
325 if (msg == NULL)
326 break;
327 if (msg->msg == CURLMSG_DONE)
328 {
329 if (msg->data.result != CURLE_OK)
330 printf ("%s failed at %s:%d: `%s'\n",
331 "curl_multi_perform",
332 __FILE__,
333 __LINE__, curl_easy_strerror (msg->data.result));
334 curl_multi_remove_handle (multi, c);
335 curl_multi_cleanup (multi);
336 curl_easy_cleanup (c);
337 c = NULL;
338 multi = NULL;
339 }
340 }
341 MHD_run (d);
398 } 342 }
399 if (MHD_YES != MHD_get_fdset(d, 343 if (multi != NULL)
400 &rs, 344 {
401 &ws, 345 curl_multi_remove_handle (multi, c);
402 &es, 346 curl_easy_cleanup (c);
403 &max)) { 347 curl_multi_cleanup (multi);
404 curl_multi_remove_handle(multi, c);
405 curl_multi_cleanup(multi);
406 curl_easy_cleanup(c);
407 MHD_stop_daemon(d);
408 return 4096;
409 } 348 }
410 tv.tv_sec = 0; 349 MHD_stop_daemon (d);
411 tv.tv_usec = 1000; 350 if (cbc.pos != strlen ("/hello_world"))
412 select(max + 1,
413 &rs,
414 &ws,
415 &es,
416 &tv);
417 curl_multi_perform(multi, &running);
418 if (running == 0) {
419 msg = curl_multi_info_read(multi,
420 &running);
421 if (msg == NULL)
422 break;
423 if (msg->msg == CURLMSG_DONE) {
424 if (msg->data.result != CURLE_OK)
425 printf("%s failed at %s:%d: `%s'\n",
426 "curl_multi_perform",
427 __FILE__,
428 __LINE__,
429 curl_easy_strerror(msg->data.result));
430 curl_multi_remove_handle(multi, c);
431 curl_multi_cleanup(multi);
432 curl_easy_cleanup(c);
433 c = NULL;
434 multi = NULL;
435 }
436 }
437 MHD_run(d);
438 }
439 if (multi != NULL) {
440 curl_multi_remove_handle(multi, c);
441 curl_easy_cleanup(c);
442 curl_multi_cleanup(multi);
443 }
444 MHD_stop_daemon(d);
445 if (cbc.pos != strlen("/hello_world"))
446 return 8192; 351 return 8192;
447 if (0 != strncmp("/hello_world", 352 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
448 cbc.buf,
449 strlen("/hello_world")))
450 return 16384; 353 return 16384;
451 return 0; 354 return 0;
452} 355}
453 356
454 357
455 358
456int main(int argc, 359int
457 char * const * argv) { 360main (int argc, char *const *argv)
361{
458 unsigned int errorCount = 0; 362 unsigned int errorCount = 0;
459 363
460 oneone = NULL != strstr(argv[0], "11"); 364 oneone = NULL != strstr (argv[0], "11");
461 if (0 != curl_global_init(CURL_GLOBAL_WIN32)) 365 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
462 return 2; 366 return 2;
463 errorCount += testInternalPut(); 367 errorCount += testInternalPut ();
464 errorCount += testMultithreadedPut(); 368 errorCount += testMultithreadedPut ();
465 errorCount += testExternalPut(); 369 errorCount += testExternalPut ();
466 if (errorCount != 0) 370 if (errorCount != 0)
467 fprintf(stderr, 371 fprintf (stderr, "Error (code: %u)\n", errorCount);
468 "Error (code: %u)\n", 372 curl_global_cleanup ();
469 errorCount); 373 return errorCount != 0; /* 0 == pass */
470 curl_global_cleanup();
471 return errorCount != 0; /* 0 == pass */
472} 374}