diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2020-11-12 17:32:32 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2020-11-12 17:32:32 +0100 |
commit | e11d1e59e4ae5f7d89c33df3ae9ca8f1ece990cf (patch) | |
tree | 80c08d417bb0c862adcbcde7f55aa7e3a4646d27 /src/messenger/messenger_api_list_tunnels.c | |
parent | fec34163a1f17729c190022a2bf747f48e34f07a (diff) | |
download | gnunet-e11d1e59e4ae5f7d89c33df3ae9ca8f1ece990cf.tar.gz gnunet-e11d1e59e4ae5f7d89c33df3ae9ca8f1ece990cf.zip |
-revert "-merge branch 'jacki/messenger'"
This reverts commit fec34163a1f17729c190022a2bf747f48e34f07a, reversing
changes made to 63fe195e40e55f13ab29e3ba578e97017fc4cc48.
Diffstat (limited to 'src/messenger/messenger_api_list_tunnels.c')
-rw-r--r-- | src/messenger/messenger_api_list_tunnels.c | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/src/messenger/messenger_api_list_tunnels.c b/src/messenger/messenger_api_list_tunnels.c deleted file mode 100644 index 13d8c1906..000000000 --- a/src/messenger/messenger_api_list_tunnels.c +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2020 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_list_tunnels.c | ||
23 | * @brief messenger api: client and service implementation of GNUnet MESSENGER service | ||
24 | */ | ||
25 | |||
26 | #include "messenger_api_list_tunnels.h" | ||
27 | |||
28 | void | ||
29 | init_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels) | ||
30 | { | ||
31 | GNUNET_assert(tunnels); | ||
32 | |||
33 | tunnels->head = NULL; | ||
34 | tunnels->tail = NULL; | ||
35 | } | ||
36 | |||
37 | void | ||
38 | clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels) | ||
39 | { | ||
40 | GNUNET_assert(tunnels); | ||
41 | |||
42 | struct GNUNET_MESSENGER_ListTunnel *element; | ||
43 | |||
44 | for (element = tunnels->head; element; element = tunnels->head) | ||
45 | { | ||
46 | GNUNET_CONTAINER_DLL_remove(tunnels->head, tunnels->tail, element); | ||
47 | GNUNET_PEER_change_rc (element->peer, -1); | ||
48 | GNUNET_free(element); | ||
49 | } | ||
50 | |||
51 | tunnels->head = NULL; | ||
52 | tunnels->tail = NULL; | ||
53 | } | ||
54 | |||
55 | static int | ||
56 | compare_list_tunnels (void *cls, struct GNUNET_MESSENGER_ListTunnel *element0, | ||
57 | struct GNUNET_MESSENGER_ListTunnel *element1) | ||
58 | { | ||
59 | return ((int) element0->peer) - ((int) element1->peer); | ||
60 | } | ||
61 | |||
62 | void | ||
63 | add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer) | ||
64 | { | ||
65 | struct GNUNET_MESSENGER_ListTunnel *element = GNUNET_new(struct GNUNET_MESSENGER_ListTunnel); | ||
66 | |||
67 | element->peer = GNUNET_PEER_intern (peer); | ||
68 | |||
69 | GNUNET_CONTAINER_DLL_insert_sorted(struct GNUNET_MESSENGER_ListTunnel, compare_list_tunnels, NULL, tunnels->head, | ||
70 | tunnels->tail, element); | ||
71 | } | ||
72 | |||
73 | struct GNUNET_MESSENGER_ListTunnel* | ||
74 | find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index) | ||
75 | { | ||
76 | struct GNUNET_MESSENGER_ListTunnel *element; | ||
77 | struct GNUNET_PeerIdentity pid; | ||
78 | |||
79 | if (index) | ||
80 | *index = 0; | ||
81 | |||
82 | for (element = tunnels->head; element; element = element->next) | ||
83 | { | ||
84 | GNUNET_PEER_resolve (element->peer, &pid); | ||
85 | |||
86 | if (0 == GNUNET_memcmp(&pid, peer)) | ||
87 | return element; | ||
88 | |||
89 | if (index) | ||
90 | (*index) = (*index) + 1; | ||
91 | } | ||
92 | |||
93 | return NULL; | ||
94 | } | ||
95 | |||
96 | int | ||
97 | contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer) | ||
98 | { | ||
99 | return find_list_tunnels (tunnels, peer, NULL) != NULL ? GNUNET_YES : GNUNET_NO; | ||
100 | } | ||
101 | |||
102 | struct GNUNET_MESSENGER_ListTunnel* | ||
103 | remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element) | ||
104 | { | ||
105 | struct GNUNET_MESSENGER_ListTunnel *next = element->next; | ||
106 | |||
107 | GNUNET_CONTAINER_DLL_remove(tunnels->head, tunnels->tail, element); | ||
108 | GNUNET_PEER_change_rc (element->peer, -1); | ||
109 | GNUNET_free(element); | ||
110 | |||
111 | return next; | ||
112 | } | ||