diff options
Diffstat (limited to 'src/include/microhttpd.h')
-rw-r--r-- | src/include/microhttpd.h | 156 |
1 files changed, 69 insertions, 87 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index e678d4b1..eb96e807 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -52,8 +52,9 @@ | |||
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #ifdef __cplusplus | 54 | #ifdef __cplusplus |
55 | extern "C" { | 55 | extern "C" |
56 | #if 0 /* keep Emacsens' auto-indent happy */ | 56 | { |
57 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
57 | } | 58 | } |
58 | #endif | 59 | #endif |
59 | #endif | 60 | #endif |
@@ -216,7 +217,8 @@ extern "C" { | |||
216 | * implemented or not supported on the target platform (i.e. no | 217 | * implemented or not supported on the target platform (i.e. no |
217 | * support for SSL, threads or IPv6). | 218 | * support for SSL, threads or IPv6). |
218 | */ | 219 | */ |
219 | enum MHD_FLAG { | 220 | enum MHD_FLAG |
221 | { | ||
220 | /** | 222 | /** |
221 | * No options selected. | 223 | * No options selected. |
222 | */ | 224 | */ |
@@ -256,7 +258,8 @@ enum MHD_FLAG { | |||
256 | * MHD options. Passed in the varargs portion | 258 | * MHD options. Passed in the varargs portion |
257 | * of MHD_start_daemon. | 259 | * of MHD_start_daemon. |
258 | */ | 260 | */ |
259 | enum MHD_OPTION { | 261 | enum MHD_OPTION |
262 | { | ||
260 | 263 | ||
261 | /** | 264 | /** |
262 | * No more options / last option. This is used | 265 | * No more options / last option. This is used |
@@ -282,7 +285,8 @@ enum MHD_OPTION { | |||
282 | * The MHD_ValueKind specifies the source of | 285 | * The MHD_ValueKind specifies the source of |
283 | * the key-value pairs in the HTTP protocol. | 286 | * the key-value pairs in the HTTP protocol. |
284 | */ | 287 | */ |
285 | enum MHD_ValueKind { | 288 | enum MHD_ValueKind |
289 | { | ||
286 | 290 | ||
287 | /** | 291 | /** |
288 | * Response header | 292 | * Response header |
@@ -344,9 +348,9 @@ struct MHD_Response; | |||
344 | * @return MHD_YES if connection is allowed, MHD_NO if not | 348 | * @return MHD_YES if connection is allowed, MHD_NO if not |
345 | */ | 349 | */ |
346 | typedef int | 350 | typedef int |
347 | (*MHD_AcceptPolicyCallback)(void * cls, | 351 | (*MHD_AcceptPolicyCallback) (void *cls, |
348 | const struct sockaddr * addr, | 352 | const struct sockaddr * addr, |
349 | socklen_t addrlen); | 353 | socklen_t addrlen); |
350 | 354 | ||
351 | /** | 355 | /** |
352 | * A client has requested the given url using the given method ("GET", | 356 | * A client has requested the given url using the given method ("GET", |
@@ -372,13 +376,13 @@ typedef int | |||
372 | * error while handling the request | 376 | * error while handling the request |
373 | */ | 377 | */ |
374 | typedef int | 378 | typedef int |
375 | (*MHD_AccessHandlerCallback)(void * cls, | 379 | (*MHD_AccessHandlerCallback) (void *cls, |
376 | struct MHD_Connection * connection, | 380 | struct MHD_Connection * connection, |
377 | const char * url, | 381 | const char *url, |
378 | const char * method, | 382 | const char *method, |
379 | const char * version, | 383 | const char *version, |
380 | const char * upload_data, | 384 | const char *upload_data, |
381 | unsigned int * upload_data_size); | 385 | unsigned int *upload_data_size); |
382 | 386 | ||
383 | /** | 387 | /** |
384 | * Iterator over key-value pairs. This iterator | 388 | * Iterator over key-value pairs. This iterator |
@@ -391,10 +395,9 @@ typedef int | |||
391 | * MHD_NO to abort the iteration | 395 | * MHD_NO to abort the iteration |
392 | */ | 396 | */ |
393 | typedef int | 397 | typedef int |
394 | (*MHD_KeyValueIterator)(void * cls, | 398 | (*MHD_KeyValueIterator) (void *cls, |
395 | enum MHD_ValueKind kind, | 399 | enum MHD_ValueKind kind, |
396 | const char * key, | 400 | const char *key, const char *value); |
397 | const char * value); | ||
398 | 401 | ||
399 | /** | 402 | /** |
400 | * Callback used by libmicrohttpd in order to obtain content. The | 403 | * Callback used by libmicrohttpd in order to obtain content. The |
@@ -423,10 +426,7 @@ typedef int | |||
423 | * with the client). | 426 | * with the client). |
424 | */ | 427 | */ |
425 | typedef int | 428 | typedef int |
426 | (*MHD_ContentReaderCallback)(void * cls, | 429 | (*MHD_ContentReaderCallback) (void *cls, size_t pos, char *buf, int max); |
427 | size_t pos, | ||
428 | char * buf, | ||
429 | int max); | ||
430 | 430 | ||
431 | /** | 431 | /** |
432 | * This method is called by libmicrohttpd if we | 432 | * This method is called by libmicrohttpd if we |
@@ -434,8 +434,7 @@ typedef int | |||
434 | * be used to free resources associated with the | 434 | * be used to free resources associated with the |
435 | * content reader. | 435 | * content reader. |
436 | */ | 436 | */ |
437 | typedef void | 437 | typedef void (*MHD_ContentReaderFreeCallback) (void *cls); |
438 | (*MHD_ContentReaderFreeCallback)(void * cls); | ||
439 | 438 | ||
440 | /** | 439 | /** |
441 | * Start a webserver on the given port. | 440 | * Start a webserver on the given port. |
@@ -452,22 +451,19 @@ typedef void | |||
452 | * terminated with MHD_OPTION_END). | 451 | * terminated with MHD_OPTION_END). |
453 | * @return NULL on error, handle to daemon on success | 452 | * @return NULL on error, handle to daemon on success |
454 | */ | 453 | */ |
455 | struct MHD_Daemon * | 454 | struct MHD_Daemon *MHD_start_daemon (unsigned int flags, |
456 | MHD_start_daemon(unsigned int flags, | 455 | unsigned short port, |
457 | unsigned short port, | 456 | MHD_AcceptPolicyCallback apc, |
458 | MHD_AcceptPolicyCallback apc, | 457 | void *apc_cls, |
459 | void * apc_cls, | 458 | MHD_AccessHandlerCallback dh, |
460 | MHD_AccessHandlerCallback dh, | 459 | void *dh_cls, ...); |
461 | void * dh_cls, | ||
462 | ...); | ||
463 | 460 | ||
464 | 461 | ||
465 | 462 | ||
466 | /** | 463 | /** |
467 | * Shutdown an http daemon. | 464 | * Shutdown an http daemon. |
468 | */ | 465 | */ |
469 | void | 466 | void MHD_stop_daemon (struct MHD_Daemon *daemon); |
470 | MHD_stop_daemon(struct MHD_Daemon * daemon); | ||
471 | 467 | ||
472 | 468 | ||
473 | /** | 469 | /** |
@@ -478,11 +474,9 @@ MHD_stop_daemon(struct MHD_Daemon * daemon); | |||
478 | * options for this call. | 474 | * options for this call. |
479 | */ | 475 | */ |
480 | int | 476 | int |
481 | MHD_get_fdset(struct MHD_Daemon * daemon, | 477 | MHD_get_fdset (struct MHD_Daemon *daemon, |
482 | fd_set * read_fd_set, | 478 | fd_set * read_fd_set, |
483 | fd_set * write_fd_set, | 479 | fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd); |
484 | fd_set * except_fd_set, | ||
485 | int * max_fd); | ||
486 | 480 | ||
487 | /** | 481 | /** |
488 | * Run webserver operations (without blocking unless | 482 | * Run webserver operations (without blocking unless |
@@ -494,8 +488,7 @@ MHD_get_fdset(struct MHD_Daemon * daemon, | |||
494 | * daemon was not started with the right | 488 | * daemon was not started with the right |
495 | * options for this call. | 489 | * options for this call. |
496 | */ | 490 | */ |
497 | int | 491 | int MHD_run (struct MHD_Daemon *daemon); |
498 | MHD_run(struct MHD_Daemon * daemon); | ||
499 | 492 | ||
500 | 493 | ||
501 | /** | 494 | /** |
@@ -506,10 +499,9 @@ MHD_run(struct MHD_Daemon * daemon); | |||
506 | * already exists | 499 | * already exists |
507 | */ | 500 | */ |
508 | int | 501 | int |
509 | MHD_register_handler(struct MHD_Daemon * daemon, | 502 | MHD_register_handler (struct MHD_Daemon *daemon, |
510 | const char * uri_prefix, | 503 | const char *uri_prefix, |
511 | MHD_AccessHandlerCallback dh, | 504 | MHD_AccessHandlerCallback dh, void *dh_cls); |
512 | void * dh_cls); | ||
513 | 505 | ||
514 | /** | 506 | /** |
515 | * Unregister an access handler for the URIs beginning with | 507 | * Unregister an access handler for the URIs beginning with |
@@ -520,10 +512,9 @@ MHD_register_handler(struct MHD_Daemon * daemon, | |||
520 | * is not known for this daemon | 512 | * is not known for this daemon |
521 | */ | 513 | */ |
522 | int | 514 | int |
523 | MHD_unregister_handler(struct MHD_Daemon * daemon, | 515 | MHD_unregister_handler (struct MHD_Daemon *daemon, |
524 | const char * uri_prefix, | 516 | const char *uri_prefix, |
525 | MHD_AccessHandlerCallback dh, | 517 | MHD_AccessHandlerCallback dh, void *dh_cls); |
526 | void * dh_cls); | ||
527 | 518 | ||
528 | /** | 519 | /** |
529 | * Get all of the headers from the request. | 520 | * Get all of the headers from the request. |
@@ -534,10 +525,9 @@ MHD_unregister_handler(struct MHD_Daemon * daemon, | |||
534 | * @return number of entries iterated over | 525 | * @return number of entries iterated over |
535 | */ | 526 | */ |
536 | int | 527 | int |
537 | MHD_get_connection_values(struct MHD_Connection * connection, | 528 | MHD_get_connection_values (struct MHD_Connection *connection, |
538 | enum MHD_ValueKind kind, | 529 | enum MHD_ValueKind kind, |
539 | MHD_KeyValueIterator iterator, | 530 | MHD_KeyValueIterator iterator, void *iterator_cls); |
540 | void * iterator_cls); | ||
541 | 531 | ||
542 | /** | 532 | /** |
543 | * Get a particular header value. If multiple | 533 | * Get a particular header value. If multiple |
@@ -546,10 +536,9 @@ MHD_get_connection_values(struct MHD_Connection * connection, | |||
546 | * @param key the header to look for | 536 | * @param key the header to look for |
547 | * @return NULL if no such item was found | 537 | * @return NULL if no such item was found |
548 | */ | 538 | */ |
549 | const char * | 539 | const char *MHD_lookup_connection_value (struct MHD_Connection *connection, |
550 | MHD_lookup_connection_value(struct MHD_Connection * connection, | 540 | enum MHD_ValueKind kind, |
551 | enum MHD_ValueKind kind, | 541 | const char *key); |
552 | const char * key); | ||
553 | 542 | ||
554 | /** | 543 | /** |
555 | * Queue a response to be transmitted to the client (as soon as | 544 | * Queue a response to be transmitted to the client (as soon as |
@@ -562,11 +551,10 @@ MHD_lookup_connection_value(struct MHD_Connection * connection, | |||
562 | * MHD_YES on success or if message has been queued | 551 | * MHD_YES on success or if message has been queued |
563 | */ | 552 | */ |
564 | int | 553 | int |
565 | MHD_queue_response(struct MHD_Connection * connection, | 554 | MHD_queue_response (struct MHD_Connection *connection, |
566 | unsigned int status_code, | 555 | unsigned int status_code, struct MHD_Response *response); |
567 | struct MHD_Response * response); | 556 | |
568 | 557 | ||
569 | |||
570 | /** | 558 | /** |
571 | * Create a response object. The response object can be extended with | 559 | * Create a response object. The response object can be extended with |
572 | * header information and then be used any number of times. | 560 | * header information and then be used any number of times. |
@@ -577,11 +565,11 @@ MHD_queue_response(struct MHD_Connection * connection, | |||
577 | * @param crfc callback to call to free crc_cls resources | 565 | * @param crfc callback to call to free crc_cls resources |
578 | * @return NULL on error (i.e. invalid arguments, out of memory) | 566 | * @return NULL on error (i.e. invalid arguments, out of memory) |
579 | */ | 567 | */ |
580 | struct MHD_Response * | 568 | struct MHD_Response *MHD_create_response_from_callback (size_t size, |
581 | MHD_create_response_from_callback(size_t size, | 569 | MHD_ContentReaderCallback |
582 | MHD_ContentReaderCallback crc, | 570 | crc, void *crc_cls, |
583 | void * crc_cls, | 571 | MHD_ContentReaderFreeCallback |
584 | MHD_ContentReaderFreeCallback crfc); | 572 | crfc); |
585 | 573 | ||
586 | /** | 574 | /** |
587 | * Create a response object. The response object can be extended with | 575 | * Create a response object. The response object can be extended with |
@@ -595,11 +583,10 @@ MHD_create_response_from_callback(size_t size, | |||
595 | * this call returns | 583 | * this call returns |
596 | * @return NULL on error (i.e. invalid arguments, out of memory) | 584 | * @return NULL on error (i.e. invalid arguments, out of memory) |
597 | */ | 585 | */ |
598 | struct MHD_Response * | 586 | struct MHD_Response *MHD_create_response_from_data (size_t size, |
599 | MHD_create_response_from_data(size_t size, | 587 | void *data, |
600 | void * data, | 588 | int must_free, |
601 | int must_free, | 589 | int must_copy); |
602 | int must_copy); | ||
603 | 590 | ||
604 | /** | 591 | /** |
605 | * Destroy a response object and associated resources. Note that | 592 | * Destroy a response object and associated resources. Note that |
@@ -607,8 +594,7 @@ MHD_create_response_from_data(size_t size, | |||
607 | * is still in the queue for some clients, so the memory may not | 594 | * is still in the queue for some clients, so the memory may not |
608 | * necessarily be freed immediatley. | 595 | * necessarily be freed immediatley. |
609 | */ | 596 | */ |
610 | void | 597 | void MHD_destroy_response (struct MHD_Response *response); |
611 | MHD_destroy_response(struct MHD_Response * response); | ||
612 | 598 | ||
613 | /** | 599 | /** |
614 | * Add a header line to the response. | 600 | * Add a header line to the response. |
@@ -616,9 +602,8 @@ MHD_destroy_response(struct MHD_Response * response); | |||
616 | * @return MHD_NO on error (i.e. invalid header or content format). | 602 | * @return MHD_NO on error (i.e. invalid header or content format). |
617 | */ | 603 | */ |
618 | int | 604 | int |
619 | MHD_add_response_header(struct MHD_Response * response, | 605 | MHD_add_response_header (struct MHD_Response *response, |
620 | const char * header, | 606 | const char *header, const char *content); |
621 | const char * content); | ||
622 | 607 | ||
623 | /** | 608 | /** |
624 | * Delete a header line from the response. | 609 | * Delete a header line from the response. |
@@ -626,9 +611,8 @@ MHD_add_response_header(struct MHD_Response * response, | |||
626 | * @return MHD_NO on error (no such header known) | 611 | * @return MHD_NO on error (no such header known) |
627 | */ | 612 | */ |
628 | int | 613 | int |
629 | MHD_del_response_header(struct MHD_Response * response, | 614 | MHD_del_response_header (struct MHD_Response *response, |
630 | const char * header, | 615 | const char *header, const char *content); |
631 | const char * content); | ||
632 | 616 | ||
633 | /** | 617 | /** |
634 | * Get all of the headers added to a response. | 618 | * Get all of the headers added to a response. |
@@ -639,9 +623,8 @@ MHD_del_response_header(struct MHD_Response * response, | |||
639 | * @return number of entries iterated over | 623 | * @return number of entries iterated over |
640 | */ | 624 | */ |
641 | int | 625 | int |
642 | MHD_get_response_headers(struct MHD_Response * response, | 626 | MHD_get_response_headers (struct MHD_Response *response, |
643 | MHD_KeyValueIterator iterator, | 627 | MHD_KeyValueIterator iterator, void *iterator_cls); |
644 | void * iterator_cls); | ||
645 | 628 | ||
646 | 629 | ||
647 | /** | 630 | /** |
@@ -650,12 +633,11 @@ MHD_get_response_headers(struct MHD_Response * response, | |||
650 | * @param key which header to get | 633 | * @param key which header to get |
651 | * @return NULL if header does not exist | 634 | * @return NULL if header does not exist |
652 | */ | 635 | */ |
653 | const char * | 636 | const char *MHD_get_response_header (struct MHD_Response *response, |
654 | MHD_get_response_header(struct MHD_Response * response, | 637 | const char *key); |
655 | const char * key); | ||
656 | 638 | ||
657 | 639 | ||
658 | #if 0 /* keep Emacsens' auto-indent happy */ | 640 | #if 0 /* keep Emacsens' auto-indent happy */ |
659 | { | 641 | { |
660 | #endif | 642 | #endif |
661 | #ifdef __cplusplus | 643 | #ifdef __cplusplus |