diff options
Diffstat (limited to 'src/messenger/messenger_api_queue_messages.h')
-rw-r--r-- | src/messenger/messenger_api_queue_messages.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/messenger/messenger_api_queue_messages.h b/src/messenger/messenger_api_queue_messages.h new file mode 100644 index 000000000..8fb2d8098 --- /dev/null +++ b/src/messenger/messenger_api_queue_messages.h | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2023 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Tobias Frisch | ||
22 | * @file src/messenger/messenger_api_queue_messages.h | ||
23 | * @brief messenger api: client implementation of GNUnet MESSENGER service | ||
24 | */ | ||
25 | |||
26 | #ifndef GNUNET_MESSENGER_API_QUEUE_MESSAGES_H | ||
27 | #define GNUNET_MESSENGER_API_QUEUE_MESSAGES_H | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_identity_service.h" | ||
31 | #include "gnunet_util_lib.h" | ||
32 | |||
33 | #include "messenger_api_message.h" | ||
34 | |||
35 | struct GNUNET_MESSENGER_QueueMessage | ||
36 | { | ||
37 | struct GNUNET_MESSENGER_QueueMessage *prev; | ||
38 | struct GNUNET_MESSENGER_QueueMessage *next; | ||
39 | |||
40 | struct GNUNET_IDENTITY_PrivateKey sender; | ||
41 | struct GNUNET_MESSENGER_Message *message; | ||
42 | }; | ||
43 | |||
44 | struct GNUNET_MESSENGER_QueueMessages | ||
45 | { | ||
46 | struct GNUNET_MESSENGER_QueueMessage *head; | ||
47 | struct GNUNET_MESSENGER_QueueMessage *tail; | ||
48 | }; | ||
49 | |||
50 | /** | ||
51 | * Initializes queue of messages as empty queue. | ||
52 | * | ||
53 | * @param[out] messages Queue of messages | ||
54 | */ | ||
55 | void | ||
56 | init_queue_messages (struct GNUNET_MESSENGER_QueueMessages *messages); | ||
57 | |||
58 | /** | ||
59 | * Clears the queue of messages. | ||
60 | * | ||
61 | * @param[in,out] messages Queue of messages | ||
62 | */ | ||
63 | void | ||
64 | clear_queue_messages (struct GNUNET_MESSENGER_QueueMessages *messages); | ||
65 | |||
66 | /** | ||
67 | * Adds a specific <i>message</i> to the end of the queue. | ||
68 | * | ||
69 | * @param[in,out] messages Queue of messages | ||
70 | * @param[in] sender Private sender key | ||
71 | * @param[in] message Message | ||
72 | */ | ||
73 | void | ||
74 | enqueue_to_messages (struct GNUNET_MESSENGER_QueueMessages *messages, | ||
75 | const struct GNUNET_IDENTITY_PrivateKey *sender, | ||
76 | const struct GNUNET_MESSENGER_Message *message); | ||
77 | |||
78 | /** | ||
79 | * Remove the message from the front of the queue and returns it. | ||
80 | * | ||
81 | * @param[in,out] messages Queue of messages | ||
82 | * @param[out] sender Private sender key | ||
83 | * @return Message from front or NULL | ||
84 | */ | ||
85 | struct GNUNET_MESSENGER_Message* | ||
86 | dequeue_from_messages (struct GNUNET_MESSENGER_QueueMessages *messages, | ||
87 | struct GNUNET_IDENTITY_PrivateKey *sender); | ||
88 | |||
89 | #endif //GNUNET_MESSENGER_API_QUEUE_MESSAGES_H | ||