diff options
Diffstat (limited to 'src/include/gnunet_mq_lib.h')
-rw-r--r-- | src/include/gnunet_mq_lib.h | 224 |
1 files changed, 114 insertions, 110 deletions
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index 1839a68bd..37f21e5b1 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h | |||
@@ -50,9 +50,9 @@ | |||
50 | * @return the MQ message | 50 | * @return the MQ message |
51 | */ | 51 | */ |
52 | #define GNUNET_MQ_msg_extra(mvar, esize, type) \ | 52 | #define GNUNET_MQ_msg_extra(mvar, esize, type) \ |
53 | GNUNET_MQ_msg_(((struct GNUNET_MessageHeader **)&(mvar)), \ | 53 | GNUNET_MQ_msg_ (((struct GNUNET_MessageHeader **) &(mvar)), \ |
54 | (esize) + sizeof *(mvar), \ | 54 | (esize) + sizeof *(mvar), \ |
55 | (type)) | 55 | (type)) |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Allocate a GNUNET_MQ_Envelope. | 58 | * Allocate a GNUNET_MQ_Envelope. |
@@ -64,7 +64,7 @@ | |||
64 | * @param type type of the message | 64 | * @param type type of the message |
65 | * @return the allocated envelope | 65 | * @return the allocated envelope |
66 | */ | 66 | */ |
67 | #define GNUNET_MQ_msg(mvar, type) GNUNET_MQ_msg_extra(mvar, 0, type) | 67 | #define GNUNET_MQ_msg(mvar, type) GNUNET_MQ_msg_extra (mvar, 0, type) |
68 | 68 | ||
69 | 69 | ||
70 | /** | 70 | /** |
@@ -74,7 +74,7 @@ | |||
74 | * @param type type of the message | 74 | * @param type type of the message |
75 | */ | 75 | */ |
76 | #define GNUNET_MQ_msg_header(type) \ | 76 | #define GNUNET_MQ_msg_header(type) \ |
77 | GNUNET_MQ_msg_(NULL, sizeof(struct GNUNET_MessageHeader), type) | 77 | GNUNET_MQ_msg_ (NULL, sizeof(struct GNUNET_MessageHeader), type) |
78 | 78 | ||
79 | 79 | ||
80 | /** | 80 | /** |
@@ -86,7 +86,7 @@ | |||
86 | * @param type type of the message | 86 | * @param type type of the message |
87 | */ | 87 | */ |
88 | #define GNUNET_MQ_msg_header_extra(mh, esize, type) \ | 88 | #define GNUNET_MQ_msg_header_extra(mh, esize, type) \ |
89 | GNUNET_MQ_msg_(&mh, (esize) + sizeof(struct GNUNET_MessageHeader), type) | 89 | GNUNET_MQ_msg_ (&mh, (esize) + sizeof(struct GNUNET_MessageHeader), type) |
90 | 90 | ||
91 | 91 | ||
92 | /** | 92 | /** |
@@ -102,11 +102,11 @@ | |||
102 | #define GNUNET_MQ_msg_nested_mh(mvar, type, mh) \ | 102 | #define GNUNET_MQ_msg_nested_mh(mvar, type, mh) \ |
103 | ({ \ | 103 | ({ \ |
104 | struct GNUNET_MQ_Envelope *_ev; \ | 104 | struct GNUNET_MQ_Envelope *_ev; \ |
105 | _ev = GNUNET_MQ_msg_nested_mh_((struct GNUNET_MessageHeader **)&(mvar), \ | 105 | _ev = GNUNET_MQ_msg_nested_mh_ ((struct GNUNET_MessageHeader **) &(mvar), \ |
106 | sizeof(*(mvar)), \ | 106 | sizeof(*(mvar)), \ |
107 | (type), \ | 107 | (type), \ |
108 | (mh)); \ | 108 | (mh)); \ |
109 | (void)(mvar)->header; /* type check */ \ | 109 | (void) (mvar)->header; /* type check */ \ |
110 | _ev; \ | 110 | _ev; \ |
111 | }) | 111 | }) |
112 | 112 | ||
@@ -120,8 +120,8 @@ | |||
120 | * or NULL if the given message in @a var does not have any space after the message struct | 120 | * or NULL if the given message in @a var does not have any space after the message struct |
121 | */ | 121 | */ |
122 | #define GNUNET_MQ_extract_nested_mh(var) \ | 122 | #define GNUNET_MQ_extract_nested_mh(var) \ |
123 | GNUNET_MQ_extract_nested_mh_((struct GNUNET_MessageHeader *)(var), \ | 123 | GNUNET_MQ_extract_nested_mh_ ((struct GNUNET_MessageHeader *) (var), \ |
124 | sizeof(*(var))) | 124 | sizeof(*(var))) |
125 | 125 | ||
126 | 126 | ||
127 | /** | 127 | /** |
@@ -133,8 +133,8 @@ | |||
133 | * OR NULL in case of a malformed message. | 133 | * OR NULL in case of a malformed message. |
134 | */ | 134 | */ |
135 | const struct GNUNET_MessageHeader * | 135 | const struct GNUNET_MessageHeader * |
136 | GNUNET_MQ_extract_nested_mh_(const struct GNUNET_MessageHeader *mh, | 136 | GNUNET_MQ_extract_nested_mh_ (const struct GNUNET_MessageHeader *mh, |
137 | uint16_t base_size); | 137 | uint16_t base_size); |
138 | 138 | ||
139 | 139 | ||
140 | /** | 140 | /** |
@@ -150,7 +150,7 @@ struct GNUNET_MQ_Envelope; | |||
150 | * @return message contained in the envelope | 150 | * @return message contained in the envelope |
151 | */ | 151 | */ |
152 | const struct GNUNET_MessageHeader * | 152 | const struct GNUNET_MessageHeader * |
153 | GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env); | 153 | GNUNET_MQ_env_get_msg (const struct GNUNET_MQ_Envelope *env); |
154 | 154 | ||
155 | 155 | ||
156 | /** | 156 | /** |
@@ -160,7 +160,7 @@ GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env); | |||
160 | * @return next one, or NULL | 160 | * @return next one, or NULL |
161 | */ | 161 | */ |
162 | const struct GNUNET_MQ_Envelope * | 162 | const struct GNUNET_MQ_Envelope * |
163 | GNUNET_MQ_env_next(const struct GNUNET_MQ_Envelope *env); | 163 | GNUNET_MQ_env_next (const struct GNUNET_MQ_Envelope *env); |
164 | 164 | ||
165 | 165 | ||
166 | /** | 166 | /** |
@@ -173,10 +173,10 @@ GNUNET_MQ_env_next(const struct GNUNET_MQ_Envelope *env); | |||
173 | * @param nested_mh the message to append to the message after base_size | 173 | * @param nested_mh the message to append to the message after base_size |
174 | */ | 174 | */ |
175 | struct GNUNET_MQ_Envelope * | 175 | struct GNUNET_MQ_Envelope * |
176 | GNUNET_MQ_msg_nested_mh_(struct GNUNET_MessageHeader **mhp, | 176 | GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp, |
177 | uint16_t base_size, | 177 | uint16_t base_size, |
178 | uint16_t type, | 178 | uint16_t type, |
179 | const struct GNUNET_MessageHeader *nested_mh); | 179 | const struct GNUNET_MessageHeader *nested_mh); |
180 | 180 | ||
181 | 181 | ||
182 | /** | 182 | /** |
@@ -188,7 +188,8 @@ struct GNUNET_MQ_Handle; | |||
188 | /** | 188 | /** |
189 | * Error codes for the queue. | 189 | * Error codes for the queue. |
190 | */ | 190 | */ |
191 | enum GNUNET_MQ_Error { | 191 | enum GNUNET_MQ_Error |
192 | { | ||
192 | /** | 193 | /** |
193 | * Failed to read message from the network. | 194 | * Failed to read message from the network. |
194 | * FIXME: Likely not properly distinguished | 195 | * FIXME: Likely not properly distinguished |
@@ -223,7 +224,8 @@ enum GNUNET_MQ_Error { | |||
223 | /** | 224 | /** |
224 | * Per envelope preferences and priorities. | 225 | * Per envelope preferences and priorities. |
225 | */ | 226 | */ |
226 | enum GNUNET_MQ_PriorityPreferences { | 227 | enum GNUNET_MQ_PriorityPreferences |
228 | { | ||
227 | /** | 229 | /** |
228 | * Lowest priority, i.e. background traffic (i.e. NSE, FS). | 230 | * Lowest priority, i.e. background traffic (i.e. NSE, FS). |
229 | * This is the default! | 231 | * This is the default! |
@@ -382,9 +384,9 @@ typedef void (*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error); | |||
382 | * @param[in|out] env element to insert at the tail | 384 | * @param[in|out] env element to insert at the tail |
383 | */ | 385 | */ |
384 | void | 386 | void |
385 | GNUNET_MQ_dll_insert_head(struct GNUNET_MQ_Envelope **env_head, | 387 | GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, |
386 | struct GNUNET_MQ_Envelope **env_tail, | 388 | struct GNUNET_MQ_Envelope **env_tail, |
387 | struct GNUNET_MQ_Envelope *env); | 389 | struct GNUNET_MQ_Envelope *env); |
388 | 390 | ||
389 | 391 | ||
390 | /** | 392 | /** |
@@ -400,9 +402,9 @@ GNUNET_MQ_dll_insert_head(struct GNUNET_MQ_Envelope **env_head, | |||
400 | * @param[in|out] env element to insert at the tail | 402 | * @param[in|out] env element to insert at the tail |
401 | */ | 403 | */ |
402 | void | 404 | void |
403 | GNUNET_MQ_dll_insert_tail(struct GNUNET_MQ_Envelope **env_head, | 405 | GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, |
404 | struct GNUNET_MQ_Envelope **env_tail, | 406 | struct GNUNET_MQ_Envelope **env_tail, |
405 | struct GNUNET_MQ_Envelope *env); | 407 | struct GNUNET_MQ_Envelope *env); |
406 | 408 | ||
407 | 409 | ||
408 | /** | 410 | /** |
@@ -418,9 +420,9 @@ GNUNET_MQ_dll_insert_tail(struct GNUNET_MQ_Envelope **env_head, | |||
418 | * @param[in|out] env element to remove from the DLL | 420 | * @param[in|out] env element to remove from the DLL |
419 | */ | 421 | */ |
420 | void | 422 | void |
421 | GNUNET_MQ_dll_remove(struct GNUNET_MQ_Envelope **env_head, | 423 | GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, |
422 | struct GNUNET_MQ_Envelope **env_tail, | 424 | struct GNUNET_MQ_Envelope **env_tail, |
423 | struct GNUNET_MQ_Envelope *env); | 425 | struct GNUNET_MQ_Envelope *env); |
424 | 426 | ||
425 | 427 | ||
426 | /** | 428 | /** |
@@ -434,7 +436,7 @@ GNUNET_MQ_dll_remove(struct GNUNET_MQ_Envelope **env_head, | |||
434 | * Needs to be freed with #GNUNET_free. | 436 | * Needs to be freed with #GNUNET_free. |
435 | */ | 437 | */ |
436 | struct GNUNET_MQ_MessageHandler * | 438 | struct GNUNET_MQ_MessageHandler * |
437 | GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers); | 439 | GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers); |
438 | 440 | ||
439 | 441 | ||
440 | /** | 442 | /** |
@@ -450,9 +452,9 @@ GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers); | |||
450 | * Needs to be freed with #GNUNET_free. | 452 | * Needs to be freed with #GNUNET_free. |
451 | */ | 453 | */ |
452 | struct GNUNET_MQ_MessageHandler * | 454 | struct GNUNET_MQ_MessageHandler * |
453 | GNUNET_MQ_copy_handlers2(const struct GNUNET_MQ_MessageHandler *handlers, | 455 | GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers, |
454 | GNUNET_MQ_MessageCallback agpl_handler, | 456 | GNUNET_MQ_MessageCallback agpl_handler, |
455 | void *agpl_cls); | 457 | void *agpl_cls); |
456 | 458 | ||
457 | 459 | ||
458 | /** | 460 | /** |
@@ -462,13 +464,14 @@ GNUNET_MQ_copy_handlers2(const struct GNUNET_MQ_MessageHandler *handlers, | |||
462 | * @return The number of handlers in the array. | 464 | * @return The number of handlers in the array. |
463 | */ | 465 | */ |
464 | unsigned int | 466 | unsigned int |
465 | GNUNET_MQ_count_handlers(const struct GNUNET_MQ_MessageHandler *handlers); | 467 | GNUNET_MQ_count_handlers (const struct GNUNET_MQ_MessageHandler *handlers); |
466 | 468 | ||
467 | 469 | ||
468 | /** | 470 | /** |
469 | * Message handler for a specific message type. | 471 | * Message handler for a specific message type. |
470 | */ | 472 | */ |
471 | struct GNUNET_MQ_MessageHandler { | 473 | struct GNUNET_MQ_MessageHandler |
474 | { | ||
472 | /** | 475 | /** |
473 | * Callback to validate a message of the specified @e type. | 476 | * Callback to validate a message of the specified @e type. |
474 | * The closure given to @e mv will be this struct (not @e ctx). | 477 | * The closure given to @e mv will be this struct (not @e ctx). |
@@ -546,7 +549,7 @@ struct GNUNET_MQ_MessageHandler { | |||
546 | ({ \ | 549 | ({ \ |
547 | void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \ | 550 | void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \ |
548 | ((struct GNUNET_MQ_MessageHandler){ NULL, \ | 551 | ((struct GNUNET_MQ_MessageHandler){ NULL, \ |
549 | (GNUNET_MQ_MessageCallback)_cb, \ | 552 | (GNUNET_MQ_MessageCallback) _cb, \ |
550 | (ctx), \ | 553 | (ctx), \ |
551 | (code), \ | 554 | (code), \ |
552 | sizeof(str) }); \ | 555 | sizeof(str) }); \ |
@@ -594,12 +597,12 @@ struct GNUNET_MQ_MessageHandler { | |||
594 | * @param ctx context for the callbacks | 597 | * @param ctx context for the callbacks |
595 | */ | 598 | */ |
596 | #define GNUNET_MQ_hd_var_size(name, code, str, ctx) \ | 599 | #define GNUNET_MQ_hd_var_size(name, code, str, ctx) \ |
597 | __extension__({ \ | 600 | __extension__ ({ \ |
598 | int (*_mv)(void *cls, const str *msg) = &check_ ## name; \ | 601 | int (*_mv)(void *cls, const str *msg) = &check_ ## name; \ |
599 | void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \ | 602 | void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \ |
600 | ((struct GNUNET_MQ_MessageHandler){ (GNUNET_MQ_MessageValidationCallback) \ | 603 | ((struct GNUNET_MQ_MessageHandler){ (GNUNET_MQ_MessageValidationCallback) \ |
601 | _mv, \ | 604 | _mv, \ |
602 | (GNUNET_MQ_MessageCallback)_cb, \ | 605 | (GNUNET_MQ_MessageCallback) _cb, \ |
603 | (ctx), \ | 606 | (ctx), \ |
604 | (code), \ | 607 | (code), \ |
605 | sizeof(str) }); \ | 608 | sizeof(str) }); \ |
@@ -618,15 +621,15 @@ struct GNUNET_MQ_MessageHandler { | |||
618 | */ | 621 | */ |
619 | #define GNUNET_MQ_check_zero_termination(m) \ | 622 | #define GNUNET_MQ_check_zero_termination(m) \ |
620 | { \ | 623 | { \ |
621 | const char *str = (const char *)&m[1]; \ | 624 | const char *str = (const char *) &m[1]; \ |
622 | const struct GNUNET_MessageHeader *hdr = \ | 625 | const struct GNUNET_MessageHeader *hdr = \ |
623 | (const struct GNUNET_MessageHeader *)m; \ | 626 | (const struct GNUNET_MessageHeader *) m; \ |
624 | uint16_t slen = ntohs(hdr->size) - sizeof(*m); \ | 627 | uint16_t slen = ntohs (hdr->size) - sizeof(*m); \ |
625 | if ((0 == slen) || (memchr(str, 0, slen) != &str[slen - 1])) \ | 628 | if ((0 == slen) || (memchr (str, 0, slen) != &str[slen - 1])) \ |
626 | { \ | 629 | { \ |
627 | GNUNET_break(0); \ | 630 | GNUNET_break (0); \ |
628 | return GNUNET_NO; \ | 631 | return GNUNET_NO; \ |
629 | } \ | 632 | } \ |
630 | } | 633 | } |
631 | 634 | ||
632 | 635 | ||
@@ -645,16 +648,16 @@ struct GNUNET_MQ_MessageHandler { | |||
645 | #define GNUNET_MQ_check_boxed_message(m) \ | 648 | #define GNUNET_MQ_check_boxed_message(m) \ |
646 | { \ | 649 | { \ |
647 | const struct GNUNET_MessageHeader *inbox = \ | 650 | const struct GNUNET_MessageHeader *inbox = \ |
648 | (const struct GNUNET_MessageHeader *)&m[1]; \ | 651 | (const struct GNUNET_MessageHeader *) &m[1]; \ |
649 | const struct GNUNET_MessageHeader *hdr = \ | 652 | const struct GNUNET_MessageHeader *hdr = \ |
650 | (const struct GNUNET_MessageHeader *)m; \ | 653 | (const struct GNUNET_MessageHeader *) m; \ |
651 | uint16_t slen = ntohs(hdr->size) - sizeof(*m); \ | 654 | uint16_t slen = ntohs (hdr->size) - sizeof(*m); \ |
652 | if ((slen < sizeof(struct GNUNET_MessageHeader)) || \ | 655 | if ((slen < sizeof(struct GNUNET_MessageHeader)) || \ |
653 | (slen != ntohs(inbox->size))) \ | 656 | (slen != ntohs (inbox->size))) \ |
654 | { \ | 657 | { \ |
655 | GNUNET_break(0); \ | 658 | GNUNET_break (0); \ |
656 | return GNUNET_NO; \ | 659 | return GNUNET_NO; \ |
657 | } \ | 660 | } \ |
658 | } | 661 | } |
659 | 662 | ||
660 | 663 | ||
@@ -671,8 +674,8 @@ struct GNUNET_MQ_MessageHandler { | |||
671 | * #GNUNET_SYSERR if message was rejected by check function | 674 | * #GNUNET_SYSERR if message was rejected by check function |
672 | */ | 675 | */ |
673 | int | 676 | int |
674 | GNUNET_MQ_handle_message(const struct GNUNET_MQ_MessageHandler *handlers, | 677 | GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, |
675 | const struct GNUNET_MessageHeader *mh); | 678 | const struct GNUNET_MessageHeader *mh); |
676 | 679 | ||
677 | 680 | ||
678 | /** | 681 | /** |
@@ -684,9 +687,9 @@ GNUNET_MQ_handle_message(const struct GNUNET_MQ_MessageHandler *handlers, | |||
684 | * @return the allocated MQ message | 687 | * @return the allocated MQ message |
685 | */ | 688 | */ |
686 | struct GNUNET_MQ_Envelope * | 689 | struct GNUNET_MQ_Envelope * |
687 | GNUNET_MQ_msg_(struct GNUNET_MessageHeader **mhp, | 690 | GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, |
688 | uint16_t size, | 691 | uint16_t size, |
689 | uint16_t type); | 692 | uint16_t type); |
690 | 693 | ||
691 | 694 | ||
692 | /** | 695 | /** |
@@ -696,7 +699,7 @@ GNUNET_MQ_msg_(struct GNUNET_MessageHeader **mhp, | |||
696 | * @return envelope containing @a hdr | 699 | * @return envelope containing @a hdr |
697 | */ | 700 | */ |
698 | struct GNUNET_MQ_Envelope * | 701 | struct GNUNET_MQ_Envelope * |
699 | GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr); | 702 | GNUNET_MQ_msg_copy (const struct GNUNET_MessageHeader *hdr); |
700 | 703 | ||
701 | 704 | ||
702 | /** | 705 | /** |
@@ -707,7 +710,7 @@ GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr); | |||
707 | * @param mqm the message to discard | 710 | * @param mqm the message to discard |
708 | */ | 711 | */ |
709 | void | 712 | void |
710 | GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm); | 713 | GNUNET_MQ_discard (struct GNUNET_MQ_Envelope *mqm); |
711 | 714 | ||
712 | 715 | ||
713 | /** | 716 | /** |
@@ -718,7 +721,7 @@ GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm); | |||
718 | * @return the current envelope | 721 | * @return the current envelope |
719 | */ | 722 | */ |
720 | struct GNUNET_MQ_Envelope * | 723 | struct GNUNET_MQ_Envelope * |
721 | GNUNET_MQ_get_current_envelope(struct GNUNET_MQ_Handle *mq); | 724 | GNUNET_MQ_get_current_envelope (struct GNUNET_MQ_Handle *mq); |
722 | 725 | ||
723 | 726 | ||
724 | /** | 727 | /** |
@@ -729,7 +732,7 @@ GNUNET_MQ_get_current_envelope(struct GNUNET_MQ_Handle *mq); | |||
729 | * @return copy of @a env | 732 | * @return copy of @a env |
730 | */ | 733 | */ |
731 | struct GNUNET_MQ_Envelope * | 734 | struct GNUNET_MQ_Envelope * |
732 | GNUNET_MQ_env_copy(struct GNUNET_MQ_Envelope *env); | 735 | GNUNET_MQ_env_copy (struct GNUNET_MQ_Envelope *env); |
733 | 736 | ||
734 | 737 | ||
735 | /** | 738 | /** |
@@ -739,7 +742,7 @@ GNUNET_MQ_env_copy(struct GNUNET_MQ_Envelope *env); | |||
739 | * @return the last envelope in the queue | 742 | * @return the last envelope in the queue |
740 | */ | 743 | */ |
741 | struct GNUNET_MQ_Envelope * | 744 | struct GNUNET_MQ_Envelope * |
742 | GNUNET_MQ_get_last_envelope(struct GNUNET_MQ_Handle *mq); | 745 | GNUNET_MQ_get_last_envelope (struct GNUNET_MQ_Handle *mq); |
743 | 746 | ||
744 | 747 | ||
745 | /** | 748 | /** |
@@ -751,8 +754,8 @@ GNUNET_MQ_get_last_envelope(struct GNUNET_MQ_Handle *mq); | |||
751 | * @param pp priority and preferences to set for @a env | 754 | * @param pp priority and preferences to set for @a env |
752 | */ | 755 | */ |
753 | void | 756 | void |
754 | GNUNET_MQ_env_set_options(struct GNUNET_MQ_Envelope *env, | 757 | GNUNET_MQ_env_set_options (struct GNUNET_MQ_Envelope *env, |
755 | enum GNUNET_MQ_PriorityPreferences pp); | 758 | enum GNUNET_MQ_PriorityPreferences pp); |
756 | 759 | ||
757 | 760 | ||
758 | /** | 761 | /** |
@@ -762,7 +765,7 @@ GNUNET_MQ_env_set_options(struct GNUNET_MQ_Envelope *env, | |||
762 | * @return priority and preferences to use | 765 | * @return priority and preferences to use |
763 | */ | 766 | */ |
764 | enum GNUNET_MQ_PriorityPreferences | 767 | enum GNUNET_MQ_PriorityPreferences |
765 | GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env); | 768 | GNUNET_MQ_env_get_options (struct GNUNET_MQ_Envelope *env); |
766 | 769 | ||
767 | 770 | ||
768 | /** | 771 | /** |
@@ -774,8 +777,8 @@ GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env); | |||
774 | * @return combined priority and preferences to use | 777 | * @return combined priority and preferences to use |
775 | */ | 778 | */ |
776 | enum GNUNET_MQ_PriorityPreferences | 779 | enum GNUNET_MQ_PriorityPreferences |
777 | GNUNET_MQ_env_combine_options(enum GNUNET_MQ_PriorityPreferences p1, | 780 | GNUNET_MQ_env_combine_options (enum GNUNET_MQ_PriorityPreferences p1, |
778 | enum GNUNET_MQ_PriorityPreferences p2); | 781 | enum GNUNET_MQ_PriorityPreferences p2); |
779 | 782 | ||
780 | 783 | ||
781 | /** | 784 | /** |
@@ -786,7 +789,7 @@ GNUNET_MQ_env_combine_options(enum GNUNET_MQ_PriorityPreferences p1, | |||
786 | * @return NULL if queue is empty (or has no envelope that is not under transmission) | 789 | * @return NULL if queue is empty (or has no envelope that is not under transmission) |
787 | */ | 790 | */ |
788 | struct GNUNET_MQ_Envelope * | 791 | struct GNUNET_MQ_Envelope * |
789 | GNUNET_MQ_unsent_head(struct GNUNET_MQ_Handle *mq); | 792 | GNUNET_MQ_unsent_head (struct GNUNET_MQ_Handle *mq); |
790 | 793 | ||
791 | 794 | ||
792 | /** | 795 | /** |
@@ -796,8 +799,8 @@ GNUNET_MQ_unsent_head(struct GNUNET_MQ_Handle *mq); | |||
796 | * @param pp priority and preferences to use by default | 799 | * @param pp priority and preferences to use by default |
797 | */ | 800 | */ |
798 | void | 801 | void |
799 | GNUNET_MQ_set_options(struct GNUNET_MQ_Handle *mq, | 802 | GNUNET_MQ_set_options (struct GNUNET_MQ_Handle *mq, |
800 | enum GNUNET_MQ_PriorityPreferences pp); | 803 | enum GNUNET_MQ_PriorityPreferences pp); |
801 | 804 | ||
802 | 805 | ||
803 | /** | 806 | /** |
@@ -807,7 +810,7 @@ GNUNET_MQ_set_options(struct GNUNET_MQ_Handle *mq, | |||
807 | * @return number of queued, non-transmitted messages | 810 | * @return number of queued, non-transmitted messages |
808 | */ | 811 | */ |
809 | unsigned int | 812 | unsigned int |
810 | GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq); | 813 | GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq); |
811 | 814 | ||
812 | 815 | ||
813 | /** | 816 | /** |
@@ -818,7 +821,7 @@ GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq); | |||
818 | * @param ev the envelope with the message to send. | 821 | * @param ev the envelope with the message to send. |
819 | */ | 822 | */ |
820 | void | 823 | void |
821 | GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev); | 824 | GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev); |
822 | 825 | ||
823 | 826 | ||
824 | /** | 827 | /** |
@@ -829,8 +832,8 @@ GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev); | |||
829 | * @param ev the envelope with the message to send. | 832 | * @param ev the envelope with the message to send. |
830 | */ | 833 | */ |
831 | void | 834 | void |
832 | GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, | 835 | GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq, |
833 | const struct GNUNET_MQ_Envelope *ev); | 836 | const struct GNUNET_MQ_Envelope *ev); |
834 | 837 | ||
835 | 838 | ||
836 | /** | 839 | /** |
@@ -841,7 +844,7 @@ GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, | |||
841 | * @param ev queued envelope to cancel | 844 | * @param ev queued envelope to cancel |
842 | */ | 845 | */ |
843 | void | 846 | void |
844 | GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev); | 847 | GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev); |
845 | 848 | ||
846 | 849 | ||
847 | /** | 850 | /** |
@@ -851,7 +854,7 @@ GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev); | |||
851 | * @param assoc_data to associate | 854 | * @param assoc_data to associate |
852 | */ | 855 | */ |
853 | uint32_t | 856 | uint32_t |
854 | GNUNET_MQ_assoc_add(struct GNUNET_MQ_Handle *mq, void *assoc_data); | 857 | GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, void *assoc_data); |
855 | 858 | ||
856 | 859 | ||
857 | /** | 860 | /** |
@@ -862,7 +865,7 @@ GNUNET_MQ_assoc_add(struct GNUNET_MQ_Handle *mq, void *assoc_data); | |||
862 | * @return the associated data | 865 | * @return the associated data |
863 | */ | 866 | */ |
864 | void * | 867 | void * |
865 | GNUNET_MQ_assoc_get(struct GNUNET_MQ_Handle *mq, uint32_t request_id); | 868 | GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id); |
866 | 869 | ||
867 | 870 | ||
868 | /** | 871 | /** |
@@ -873,7 +876,7 @@ GNUNET_MQ_assoc_get(struct GNUNET_MQ_Handle *mq, uint32_t request_id); | |||
873 | * @return the associated data | 876 | * @return the associated data |
874 | */ | 877 | */ |
875 | void * | 878 | void * |
876 | GNUNET_MQ_assoc_remove(struct GNUNET_MQ_Handle *mq, uint32_t request_id); | 879 | GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, uint32_t request_id); |
877 | 880 | ||
878 | 881 | ||
879 | /** | 882 | /** |
@@ -889,13 +892,13 @@ GNUNET_MQ_assoc_remove(struct GNUNET_MQ_Handle *mq, uint32_t request_id); | |||
889 | * @return a new message queue | 892 | * @return a new message queue |
890 | */ | 893 | */ |
891 | struct GNUNET_MQ_Handle * | 894 | struct GNUNET_MQ_Handle * |
892 | GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, | 895 | GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send, |
893 | GNUNET_MQ_DestroyImpl destroy, | 896 | GNUNET_MQ_DestroyImpl destroy, |
894 | GNUNET_MQ_CancelImpl cancel, | 897 | GNUNET_MQ_CancelImpl cancel, |
895 | void *impl_state, | 898 | void *impl_state, |
896 | const struct GNUNET_MQ_MessageHandler *handlers, | 899 | const struct GNUNET_MQ_MessageHandler *handlers, |
897 | GNUNET_MQ_ErrorHandler error_handler, | 900 | GNUNET_MQ_ErrorHandler error_handler, |
898 | void *cls); | 901 | void *cls); |
899 | 902 | ||
900 | 903 | ||
901 | /** | 904 | /** |
@@ -906,8 +909,8 @@ GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, | |||
906 | * @param handlers_cls new closure to use | 909 | * @param handlers_cls new closure to use |
907 | */ | 910 | */ |
908 | void | 911 | void |
909 | GNUNET_MQ_set_handlers_closure(struct GNUNET_MQ_Handle *mq, | 912 | GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq, |
910 | void *handlers_cls); | 913 | void *handlers_cls); |
911 | 914 | ||
912 | 915 | ||
913 | /** | 916 | /** |
@@ -920,9 +923,9 @@ GNUNET_MQ_set_handlers_closure(struct GNUNET_MQ_Handle *mq, | |||
920 | * @param cb_cls closure for the callback | 923 | * @param cb_cls closure for the callback |
921 | */ | 924 | */ |
922 | void | 925 | void |
923 | GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, | 926 | GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *ev, |
924 | GNUNET_SCHEDULER_TaskCallback cb, | 927 | GNUNET_SCHEDULER_TaskCallback cb, |
925 | void *cb_cls); | 928 | void *cb_cls); |
926 | 929 | ||
927 | 930 | ||
928 | /** | 931 | /** |
@@ -931,7 +934,7 @@ GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, | |||
931 | * @param mq message queue to destroy | 934 | * @param mq message queue to destroy |
932 | */ | 935 | */ |
933 | void | 936 | void |
934 | GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq); | 937 | GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq); |
935 | 938 | ||
936 | 939 | ||
937 | /** | 940 | /** |
@@ -951,9 +954,9 @@ struct GNUNET_MQ_DestroyNotificationHandle; | |||
951 | * @return handle for #GNUNET_MQ_destroy_notify_cancel(). | 954 | * @return handle for #GNUNET_MQ_destroy_notify_cancel(). |
952 | */ | 955 | */ |
953 | struct GNUNET_MQ_DestroyNotificationHandle * | 956 | struct GNUNET_MQ_DestroyNotificationHandle * |
954 | GNUNET_MQ_destroy_notify(struct GNUNET_MQ_Handle *mq, | 957 | GNUNET_MQ_destroy_notify (struct GNUNET_MQ_Handle *mq, |
955 | GNUNET_SCHEDULER_TaskCallback cb, | 958 | GNUNET_SCHEDULER_TaskCallback cb, |
956 | void *cb_cls); | 959 | void *cb_cls); |
957 | 960 | ||
958 | /** | 961 | /** |
959 | * Cancel registration from #GNUNET_MQ_destroy_notify(). | 962 | * Cancel registration from #GNUNET_MQ_destroy_notify(). |
@@ -961,7 +964,7 @@ GNUNET_MQ_destroy_notify(struct GNUNET_MQ_Handle *mq, | |||
961 | * @param dnh handle for registration to cancel | 964 | * @param dnh handle for registration to cancel |
962 | */ | 965 | */ |
963 | void | 966 | void |
964 | GNUNET_MQ_destroy_notify_cancel( | 967 | GNUNET_MQ_destroy_notify_cancel ( |
965 | struct GNUNET_MQ_DestroyNotificationHandle *dnh); | 968 | struct GNUNET_MQ_DestroyNotificationHandle *dnh); |
966 | 969 | ||
967 | 970 | ||
@@ -976,8 +979,8 @@ GNUNET_MQ_destroy_notify_cancel( | |||
976 | * @param mh message to dispatch | 979 | * @param mh message to dispatch |
977 | */ | 980 | */ |
978 | void | 981 | void |
979 | GNUNET_MQ_inject_message(struct GNUNET_MQ_Handle *mq, | 982 | GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, |
980 | const struct GNUNET_MessageHeader *mh); | 983 | const struct GNUNET_MessageHeader *mh); |
981 | 984 | ||
982 | 985 | ||
983 | /** | 986 | /** |
@@ -991,8 +994,8 @@ GNUNET_MQ_inject_message(struct GNUNET_MQ_Handle *mq, | |||
991 | * @param error the error type | 994 | * @param error the error type |
992 | */ | 995 | */ |
993 | void | 996 | void |
994 | GNUNET_MQ_inject_error(struct GNUNET_MQ_Handle *mq, | 997 | GNUNET_MQ_inject_error (struct GNUNET_MQ_Handle *mq, |
995 | enum GNUNET_MQ_Error error); | 998 | enum GNUNET_MQ_Error error); |
996 | 999 | ||
997 | 1000 | ||
998 | /** | 1001 | /** |
@@ -1006,7 +1009,7 @@ GNUNET_MQ_inject_error(struct GNUNET_MQ_Handle *mq, | |||
1006 | * @param mq message queue to send the next message with | 1009 | * @param mq message queue to send the next message with |
1007 | */ | 1010 | */ |
1008 | void | 1011 | void |
1009 | GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq); | 1012 | GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq); |
1010 | 1013 | ||
1011 | 1014 | ||
1012 | /** | 1015 | /** |
@@ -1020,7 +1023,7 @@ GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq); | |||
1020 | * @param mq message queue to send the next message with | 1023 | * @param mq message queue to send the next message with |
1021 | */ | 1024 | */ |
1022 | void | 1025 | void |
1023 | GNUNET_MQ_impl_send_in_flight(struct GNUNET_MQ_Handle *mq); | 1026 | GNUNET_MQ_impl_send_in_flight (struct GNUNET_MQ_Handle *mq); |
1024 | 1027 | ||
1025 | 1028 | ||
1026 | /** | 1029 | /** |
@@ -1038,7 +1041,7 @@ GNUNET_MQ_impl_send_in_flight(struct GNUNET_MQ_Handle *mq); | |||
1038 | * @return message to send, never NULL | 1041 | * @return message to send, never NULL |
1039 | */ | 1042 | */ |
1040 | void * | 1043 | void * |
1041 | GNUNET_MQ_impl_state(struct GNUNET_MQ_Handle *mq); | 1044 | GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq); |
1042 | 1045 | ||
1043 | 1046 | ||
1044 | /** | 1047 | /** |
@@ -1051,7 +1054,7 @@ GNUNET_MQ_impl_state(struct GNUNET_MQ_Handle *mq); | |||
1051 | * @return message to send, never NULL | 1054 | * @return message to send, never NULL |
1052 | */ | 1055 | */ |
1053 | const struct GNUNET_MessageHeader * | 1056 | const struct GNUNET_MessageHeader * |
1054 | GNUNET_MQ_impl_current(struct GNUNET_MQ_Handle *mq); | 1057 | GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq); |
1055 | 1058 | ||
1056 | 1059 | ||
1057 | /** | 1060 | /** |
@@ -1059,7 +1062,8 @@ GNUNET_MQ_impl_current(struct GNUNET_MQ_Handle *mq); | |||
1059 | * | 1062 | * |
1060 | * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference` | 1063 | * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference` |
1061 | */ | 1064 | */ |
1062 | enum GNUNET_MQ_PreferenceKind { | 1065 | enum GNUNET_MQ_PreferenceKind |
1066 | { | ||
1063 | /** | 1067 | /** |
1064 | * No preference was expressed. | 1068 | * No preference was expressed. |
1065 | */ | 1069 | */ |
@@ -1099,7 +1103,7 @@ enum GNUNET_MQ_PreferenceKind { | |||
1099 | * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference` | 1103 | * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference` |
1100 | */ | 1104 | */ |
1101 | const char * | 1105 | const char * |
1102 | GNUNET_MQ_preference_to_string(enum GNUNET_MQ_PreferenceKind type); | 1106 | GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type); |
1103 | 1107 | ||
1104 | 1108 | ||
1105 | #endif | 1109 | #endif |