diff options
Diffstat (limited to 'src/include/gnunet_mq_lib.h')
-rw-r--r-- | src/include/gnunet_mq_lib.h | 75 |
1 files changed, 50 insertions, 25 deletions
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index 37bba8c1b..3eca71f0f 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h | |||
@@ -18,7 +18,17 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "gnunet_common.h" | ||
22 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
23 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
24 | #endif | ||
25 | |||
26 | |||
21 | /** | 27 | /** |
28 | * @addtogroup libgnunetutil | ||
29 | * Multi-function utilities library for GNUnet programs | ||
30 | * @{ | ||
31 | * | ||
22 | * @author Florian Dold | 32 | * @author Florian Dold |
23 | * @author Christian Grothoff | 33 | * @author Christian Grothoff |
24 | * | 34 | * |
@@ -35,6 +45,7 @@ | |||
35 | #ifndef GNUNET_MQ_LIB_H | 45 | #ifndef GNUNET_MQ_LIB_H |
36 | #define GNUNET_MQ_LIB_H | 46 | #define GNUNET_MQ_LIB_H |
37 | 47 | ||
48 | |||
38 | #include "gnunet_scheduler_lib.h" | 49 | #include "gnunet_scheduler_lib.h" |
39 | 50 | ||
40 | /** | 51 | /** |
@@ -305,7 +316,8 @@ enum GNUNET_MQ_PriorityPreferences | |||
305 | * @param cls closure | 316 | * @param cls closure |
306 | * @param msg the received message | 317 | * @param msg the received message |
307 | */ | 318 | */ |
308 | typedef void (*GNUNET_MQ_MessageCallback) ( | 319 | typedef void |
320 | (*GNUNET_MQ_MessageCallback) ( | ||
309 | void *cls, | 321 | void *cls, |
310 | const struct GNUNET_MessageHeader *msg); | 322 | const struct GNUNET_MessageHeader *msg); |
311 | 323 | ||
@@ -318,7 +330,8 @@ typedef void (*GNUNET_MQ_MessageCallback) ( | |||
318 | * @return #GNUNET_OK if the message is well-formed, | 330 | * @return #GNUNET_OK if the message is well-formed, |
319 | * #GNUNET_SYSERR if not | 331 | * #GNUNET_SYSERR if not |
320 | */ | 332 | */ |
321 | typedef int (*GNUNET_MQ_MessageValidationCallback) ( | 333 | typedef int |
334 | (*GNUNET_MQ_MessageValidationCallback) ( | ||
322 | void *cls, | 335 | void *cls, |
323 | const struct GNUNET_MessageHeader *msg); | 336 | const struct GNUNET_MessageHeader *msg); |
324 | 337 | ||
@@ -331,9 +344,10 @@ typedef int (*GNUNET_MQ_MessageValidationCallback) ( | |||
331 | * @param msg the message to send | 344 | * @param msg the message to send |
332 | * @param impl_state state of the implementation | 345 | * @param impl_state state of the implementation |
333 | */ | 346 | */ |
334 | typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq, | 347 | typedef void |
335 | const struct GNUNET_MessageHeader *msg, | 348 | (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq, |
336 | void *impl_state); | 349 | const struct GNUNET_MessageHeader *msg, |
350 | void *impl_state); | ||
337 | 351 | ||
338 | 352 | ||
339 | /** | 353 | /** |
@@ -345,8 +359,9 @@ typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq, | |||
345 | * @param mq the message queue to destroy | 359 | * @param mq the message queue to destroy |
346 | * @param impl_state state of the implementation | 360 | * @param impl_state state of the implementation |
347 | */ | 361 | */ |
348 | typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq, | 362 | typedef void |
349 | void *impl_state); | 363 | (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq, |
364 | void *impl_state); | ||
350 | 365 | ||
351 | 366 | ||
352 | /** | 367 | /** |
@@ -355,8 +370,9 @@ typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq, | |||
355 | * @param mq message queue | 370 | * @param mq message queue |
356 | * @param impl_state state specific to the implementation | 371 | * @param impl_state state specific to the implementation |
357 | */ | 372 | */ |
358 | typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq, | 373 | typedef void |
359 | void *impl_state); | 374 | (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq, |
375 | void *impl_state); | ||
360 | 376 | ||
361 | 377 | ||
362 | /** | 378 | /** |
@@ -368,7 +384,9 @@ typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq, | |||
368 | * @param cls closure | 384 | * @param cls closure |
369 | * @param error error code | 385 | * @param error error code |
370 | */ | 386 | */ |
371 | typedef void (*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error); | 387 | typedef void |
388 | (*GNUNET_MQ_ErrorHandler) (void *cls, | ||
389 | enum GNUNET_MQ_Error error); | ||
372 | 390 | ||
373 | 391 | ||
374 | /** | 392 | /** |
@@ -379,9 +397,9 @@ typedef void (*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error); | |||
379 | * FIFO of envelopes independent of MQ itself and wants to | 397 | * FIFO of envelopes independent of MQ itself and wants to |
380 | * re-use the pointers internal to @a env. Use with caution. | 398 | * re-use the pointers internal to @a env. Use with caution. |
381 | * | 399 | * |
382 | * @param[in|out] env_head of envelope DLL | 400 | * @param[in,out] env_head of envelope DLL |
383 | * @param[in|out] env_tail tail of envelope DLL | 401 | * @param[in,out] env_tail tail of envelope DLL |
384 | * @param[in|out] env element to insert at the tail | 402 | * @param[in,out] env element to insert at the tail |
385 | */ | 403 | */ |
386 | void | 404 | void |
387 | GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, | 405 | GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, |
@@ -397,9 +415,9 @@ GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, | |||
397 | * FIFO of envelopes independent of MQ itself and wants to | 415 | * FIFO of envelopes independent of MQ itself and wants to |
398 | * re-use the pointers internal to @a env. Use with caution. | 416 | * re-use the pointers internal to @a env. Use with caution. |
399 | * | 417 | * |
400 | * @param[in|out] env_head of envelope DLL | 418 | * @param[in,out] env_head of envelope DLL |
401 | * @param[in|out] env_tail tail of envelope DLL | 419 | * @param[in,out] env_tail tail of envelope DLL |
402 | * @param[in|out] env element to insert at the tail | 420 | * @param[in,out] env element to insert at the tail |
403 | */ | 421 | */ |
404 | void | 422 | void |
405 | GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, | 423 | GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, |
@@ -415,9 +433,9 @@ GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, | |||
415 | * FIFO of envelopes independent of MQ itself and wants to | 433 | * FIFO of envelopes independent of MQ itself and wants to |
416 | * re-use the pointers internal to @a env. Use with caution. | 434 | * re-use the pointers internal to @a env. Use with caution. |
417 | * | 435 | * |
418 | * @param[in|out] env_head of envelope DLL | 436 | * @param[in,out] env_head of envelope DLL |
419 | * @param[in|out] env_tail tail of envelope DLL | 437 | * @param[in,out] env_tail tail of envelope DLL |
420 | * @param[in|out] env element to remove from the DLL | 438 | * @param[in,out] env element to remove from the DLL |
421 | */ | 439 | */ |
422 | void | 440 | void |
423 | GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, | 441 | GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, |
@@ -590,6 +608,7 @@ struct GNUNET_MQ_MessageHandler | |||
590 | * "context"), | 608 | * "context"), |
591 | * GNUNET_MQ_handler_end() | 609 | * GNUNET_MQ_handler_end() |
592 | * }; | 610 | * }; |
611 | * </code> | ||
593 | * | 612 | * |
594 | * @param name unique basename for the functions | 613 | * @param name unique basename for the functions |
595 | * @param code message type constant | 614 | * @param code message type constant |
@@ -673,7 +692,7 @@ struct GNUNET_MQ_MessageHandler | |||
673 | * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, | 692 | * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, |
674 | * #GNUNET_SYSERR if message was rejected by check function | 693 | * #GNUNET_SYSERR if message was rejected by check function |
675 | */ | 694 | */ |
676 | int | 695 | enum GNUNET_GenericReturnValue |
677 | GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, | 696 | GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, |
678 | const struct GNUNET_MessageHeader *mh); | 697 | const struct GNUNET_MessageHeader *mh); |
679 | 698 | ||
@@ -821,7 +840,8 @@ GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq); | |||
821 | * @param ev the envelope with the message to send. | 840 | * @param ev the envelope with the message to send. |
822 | */ | 841 | */ |
823 | void | 842 | void |
824 | GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev); | 843 | GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, |
844 | struct GNUNET_MQ_Envelope *ev); | ||
825 | 845 | ||
826 | 846 | ||
827 | /** | 847 | /** |
@@ -854,7 +874,8 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev); | |||
854 | * @param assoc_data to associate | 874 | * @param assoc_data to associate |
855 | */ | 875 | */ |
856 | uint32_t | 876 | uint32_t |
857 | GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, void *assoc_data); | 877 | GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, |
878 | void *assoc_data); | ||
858 | 879 | ||
859 | 880 | ||
860 | /** | 881 | /** |
@@ -865,7 +886,8 @@ GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, void *assoc_data); | |||
865 | * @return the associated data | 886 | * @return the associated data |
866 | */ | 887 | */ |
867 | void * | 888 | void * |
868 | GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id); | 889 | GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, |
890 | uint32_t request_id); | ||
869 | 891 | ||
870 | 892 | ||
871 | /** | 893 | /** |
@@ -876,7 +898,8 @@ GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id); | |||
876 | * @return the associated data | 898 | * @return the associated data |
877 | */ | 899 | */ |
878 | void * | 900 | void * |
879 | GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, uint32_t request_id); | 901 | GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, |
902 | uint32_t request_id); | ||
880 | 903 | ||
881 | 904 | ||
882 | /** | 905 | /** |
@@ -972,7 +995,7 @@ GNUNET_MQ_destroy_notify_cancel ( | |||
972 | * Call the message message handler that was registered | 995 | * Call the message message handler that was registered |
973 | * for the type of the given message in the given message queue. | 996 | * for the type of the given message in the given message queue. |
974 | * | 997 | * |
975 | * This function is indented to be used for the implementation | 998 | * This function is intended to be used for the implementation |
976 | * of message queues. | 999 | * of message queues. |
977 | * | 1000 | * |
978 | * @param mq message queue with the handlers | 1001 | * @param mq message queue with the handlers |
@@ -1109,3 +1132,5 @@ GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type); | |||
1109 | #endif | 1132 | #endif |
1110 | 1133 | ||
1111 | /** @} */ /* end of group mq */ | 1134 | /** @} */ /* end of group mq */ |
1135 | |||
1136 | /** @} */ /* end of group addition */ | ||