GNUnet 0.21.0
gnunet_container_lib.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001-2015 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
55#include "gnunet_common.h"
56#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
57#error "Only <gnunet_util_lib.h> can be included directly."
58#endif
59
60#ifndef GNUNET_CONTAINER_LIB_H
61#define GNUNET_CONTAINER_LIB_H
62
63#ifdef __cplusplus
64extern "C" {
65#if 0 /* keep Emacsens' auto-indent happy */
66}
67#endif
68#endif
69
70
71/* add error and config prototypes */
72
73#include "gnunet_crypto_lib.h"
74
75
91int
92GNUNET_try_compression (const char *data,
93 size_t old_size,
94 char **result,
95 size_t *new_size);
96
97
108char *
109GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
110
111
112/* ******************* bloomfilter ***************** */
113
119
120
131 struct GNUNET_HashCode *next);
132
133
148 size_t size,
149 unsigned int k);
150
151
168 size_t size,
169 unsigned int k);
170
171
183 const struct GNUNET_CONTAINER_BloomFilter *bf,
184 char *data,
185 size_t size);
186
187
196bool
198 const struct GNUNET_CONTAINER_BloomFilter *bf,
199 const struct GNUNET_HashCode *e);
200
201
209void
211 const struct GNUNET_HashCode *e);
212
213
221void
223 const struct GNUNET_HashCode *e);
224
225
235 const struct GNUNET_CONTAINER_BloomFilter *bf);
236
237
246void
248
249
256size_t
258 const struct GNUNET_CONTAINER_BloomFilter *bf);
259
260
268size_t
270 const struct GNUNET_CONTAINER_BloomFilter *bf);
271
272
279void
281
282
297 const char *data,
298 size_t size);
299
300
314 const struct GNUNET_CONTAINER_BloomFilter *to_or);
315
316
329void
332 void *iterator_cls,
333 size_t size,
334 unsigned int k);
335
336
337
338/* ******************************* HashMap **************************** */
339
345
352
358{
366
372
379
391
392
404typedef enum GNUNET_GenericReturnValue
406 void *cls,
407 const struct GNUNET_HashCode *key,
408 void *value);
409
410
429 int do_not_copy_keys);
430
431
439void
442
443
455void *
458 const struct GNUNET_HashCode *key);
459
460
475 const struct GNUNET_HashCode *key,
476 const void *value);
477
487int
490 const struct GNUNET_HashCode *key);
491
492
501unsigned int
503
504
518 const struct GNUNET_HashCode *key);
519
520
535 const struct GNUNET_HashCode *key,
536 const void *value);
537
538
555 const struct GNUNET_HashCode *key,
556 void *value,
558
566unsigned int
568 const struct GNUNET_CONTAINER_MultiHashMap *map);
569
570
581int
585 void *it_cls);
586
587
603 const struct GNUNET_CONTAINER_MultiHashMap *map);
604
605
624 struct GNUNET_HashCode *key,
625 const void **value);
626
627
634void
637
638
653 const struct GNUNET_HashCode *key,
655 void *it_cls);
656
657
669unsigned int
673 void *it_cls);
674
675
676/* ***************** Version of Multihashmap for peer identities ****************** */
677
689typedef enum GNUNET_GenericReturnValue
691 void *cls,
692 const struct GNUNET_PeerIdentity *key,
693 void *value);
694
695
700
701
719GNUNET_CONTAINER_multipeermap_create (unsigned int len, int do_not_copy_keys);
720
721
729void
732
733
745void *
748 const struct GNUNET_PeerIdentity *key);
749
750
765 const struct GNUNET_PeerIdentity *key,
766 const void *value);
767
777int
780 const struct GNUNET_PeerIdentity *key);
781
782
796 const struct GNUNET_PeerIdentity *key);
797
798
813 const struct GNUNET_PeerIdentity *key,
814 const void *value);
815
816
830int
833 const struct GNUNET_PeerIdentity *key,
834 void *value,
836
837
845unsigned int
847 const struct GNUNET_CONTAINER_MultiPeerMap *map);
848
849
860int
864 void *it_cls);
865
866
883 const struct GNUNET_CONTAINER_MultiPeerMap *map);
884
885
907 struct GNUNET_PeerIdentity *key,
908 const void **value);
909
910
917void
920
921
933int
936 const struct GNUNET_PeerIdentity *key,
938 void *it_cls);
939
940
952unsigned int
956 void *it_cls);
957
958
959/* ***************** Version of Multihashmap for short hashes ****************** */
960
972typedef enum GNUNET_GenericReturnValue
974 void *cls,
975 const struct GNUNET_ShortHashCode *key,
976 void *value);
977
978
983
984
1002GNUNET_CONTAINER_multishortmap_create (unsigned int len, int do_not_copy_keys);
1003
1004
1012void
1015
1016
1028void *
1030 const struct GNUNET_CONTAINER_MultiShortmap *map,
1031 const struct GNUNET_ShortHashCode *key);
1032
1033
1046int
1049 const struct GNUNET_ShortHashCode *key,
1050 const void *value);
1051
1061int
1064 const struct GNUNET_ShortHashCode *key);
1065
1066
1077int
1079 const struct GNUNET_CONTAINER_MultiShortmap *map,
1080 const struct GNUNET_ShortHashCode *key);
1081
1082
1094int
1096 const struct GNUNET_CONTAINER_MultiShortmap *map,
1097 const struct GNUNET_ShortHashCode *key,
1098 const void *value);
1099
1100
1117 const struct GNUNET_ShortHashCode *key,
1118 void *value,
1120
1121
1129unsigned int
1131 const struct GNUNET_CONTAINER_MultiShortmap *map);
1132
1133
1144int
1148 void *it_cls);
1149
1150
1152
1153
1169 const struct GNUNET_CONTAINER_MultiShortmap *map);
1170
1171
1190 struct GNUNET_ShortHashCode *key,
1191 const void **value);
1192
1193
1200void
1203
1204
1216int
1219 const struct GNUNET_ShortHashCode *key,
1221 void *it_cls);
1222
1223
1235unsigned int
1237 const struct GNUNET_CONTAINER_MultiShortmap *map,
1239 void *it_cls);
1240
1241
1242/* ***************** Version of Multihashmap for UUIDs ****************** */
1243
1244
1256typedef enum GNUNET_GenericReturnValue
1258 void *cls,
1259 const struct GNUNET_Uuid *key,
1260 void *value);
1261
1262
1267
1268
1286GNUNET_CONTAINER_multiuuidmap_create (unsigned int len, int do_not_copy_keys);
1287
1288
1296void
1299
1300
1312void *
1314 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1315 const struct GNUNET_Uuid *key);
1316
1317
1332 const struct GNUNET_Uuid *key,
1333 const void *value);
1334
1344int
1347 const struct GNUNET_Uuid *key);
1348
1349
1362 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1363 const struct GNUNET_Uuid *key);
1364
1365
1379 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1380 const struct GNUNET_Uuid *key,
1381 const void *value);
1382
1383
1400 const struct GNUNET_Uuid *key,
1401 void *value,
1403
1404
1412unsigned int
1414 const struct GNUNET_CONTAINER_MultiUuidmap *map);
1415
1416
1431 void *it_cls);
1432
1433
1435
1436
1452 const struct GNUNET_CONTAINER_MultiUuidmap *map);
1453
1454
1473 struct GNUNET_Uuid *key,
1474 const void **value);
1475
1476
1483void
1486
1487
1499int
1502 const struct GNUNET_Uuid *key,
1504 void *it_cls);
1505
1506
1518unsigned int
1520 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1522 void *it_cls);
1523
1524
1525/* Version of multihashmap with 32 bit keys */
1526
1532
1533
1540
1541
1553typedef enum GNUNET_GenericReturnValue
1555 void *cls,
1556 uint32_t key,
1557 void *value);
1558
1559
1569
1570
1578void
1581
1582
1590unsigned int
1592 const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1593
1594
1606void *
1609 uint32_t key);
1610
1611
1622int
1626 void *it_cls);
1627
1628
1644 uint32_t key,
1645 const void *value);
1646
1647
1657int
1660 uint32_t key);
1661
1662
1676 uint32_t key);
1677
1678
1693 uint32_t key,
1694 const void *value);
1695
1696
1713 uint32_t key,
1714 void *value,
1716
1717
1729int
1732 uint32_t key,
1734 void *it_cls);
1735
1736
1751 const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1752
1753
1771 uint32_t *key,
1772 const void **value);
1773
1774
1780void
1783
1784
1785/* ******************** doubly-linked list *************** */
1786/* To avoid mistakes: head->prev == tail->next == NULL */
1787
1797#define GNUNET_CONTAINER_DLL_insert(head, tail, element) \
1798 do \
1799 { \
1800 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1801 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1802 (element)->next = (head); \
1803 (element)->prev = NULL; \
1804 if ((tail) == NULL) \
1805 (tail) = element; \
1806 else \
1807 (head)->prev = element; \
1808 (head) = (element); \
1809 } while (0)
1810
1811
1821#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element) \
1822 do \
1823 { \
1824 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1825 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1826 (element)->prev = (tail); \
1827 (element)->next = NULL; \
1828 if ((head) == NULL) \
1829 (head) = element; \
1830 else \
1831 (tail)->next = element; \
1832 (tail) = (element); \
1833 } while (0)
1834
1835
1846#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element) \
1847 do \
1848 { \
1849 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1850 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1851 (element)->prev = (other); \
1852 if (NULL == other) \
1853 { \
1854 (element)->next = (head); \
1855 (head) = (element); \
1856 } \
1857 else \
1858 { \
1859 (element)->next = (other)->next; \
1860 (other)->next = (element); \
1861 } \
1862 if (NULL == (element)->next) \
1863 (tail) = (element); \
1864 else \
1865 (element)->next->prev = (element); \
1866 } while (0)
1867
1868
1879#define GNUNET_CONTAINER_DLL_insert_before(head, tail, other, element) \
1880 do \
1881 { \
1882 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1883 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1884 (element)->next = (other); \
1885 if (NULL == other) \
1886 { \
1887 (element)->prev = (tail); \
1888 (tail) = (element); \
1889 } \
1890 else \
1891 { \
1892 (element)->prev = (other)->prev; \
1893 (other)->prev = (element); \
1894 } \
1895 if (NULL == (element)->prev) \
1896 (head) = (element); \
1897 else \
1898 (element)->prev->next = (element); \
1899 } while (0)
1900
1901
1916#define GNUNET_CONTAINER_DLL_remove(head, tail, element) \
1917 do \
1918 { \
1919 GNUNET_assert (((element)->prev != NULL) || ((head) == (element))); \
1920 GNUNET_assert (((element)->next != NULL) || ((tail) == (element))); \
1921 if ((element)->prev == NULL) \
1922 (head) = (element)->next; \
1923 else \
1924 (element)->prev->next = (element)->next; \
1925 if ((element)->next == NULL) \
1926 (tail) = (element)->prev; \
1927 else \
1928 (element)->next->prev = (element)->prev; \
1929 (element)->next = NULL; \
1930 (element)->prev = NULL; \
1931 } while (0)
1932
1933
1934/* ************ Multi-DLL interface, allows DLL elements to be
1935 in multiple lists at the same time *********************** */
1936
1947#define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element) \
1948 do \
1949 { \
1950 GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
1951 GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
1952 (element)->next_ ## mdll = (head); \
1953 (element)->prev_ ## mdll = NULL; \
1954 if ((tail) == NULL) \
1955 (tail) = element; \
1956 else \
1957 (head)->prev_ ## mdll = element; \
1958 (head) = (element); \
1959 } while (0)
1960
1961
1972#define GNUNET_CONTAINER_MDLL_insert_tail(mdll, head, tail, element) \
1973 do \
1974 { \
1975 GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
1976 GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
1977 (element)->prev_ ## mdll = (tail); \
1978 (element)->next_ ## mdll = NULL; \
1979 if ((head) == NULL) \
1980 (head) = element; \
1981 else \
1982 (tail)->next_ ## mdll = element; \
1983 (tail) = (element); \
1984 } while (0)
1985
1986
1998#define GNUNET_CONTAINER_MDLL_insert_after(mdll, head, tail, other, element) \
1999 do \
2000 { \
2001 GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
2002 GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
2003 (element)->prev_ ## mdll = (other); \
2004 if (NULL == other) \
2005 { \
2006 (element)->next_ ## mdll = (head); \
2007 (head) = (element); \
2008 } \
2009 else \
2010 { \
2011 (element)->next_ ## mdll = (other)->next_ ## mdll; \
2012 (other)->next_ ## mdll = (element); \
2013 } \
2014 if (NULL == (element)->next_ ## mdll) \
2015 (tail) = (element); \
2016 else \
2017 (element)->next_ ## mdll->prev_ ## mdll = (element); \
2018 } while (0)
2019
2020
2032#define GNUNET_CONTAINER_MDLL_insert_before(mdll, head, tail, other, element) \
2033 do \
2034 { \
2035 GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
2036 GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
2037 (element)->next_ ## mdll = (other); \
2038 if (NULL == other) \
2039 { \
2040 (element)->prev = (tail); \
2041 (tail) = (element); \
2042 } \
2043 else \
2044 { \
2045 (element)->prev_ ## mdll = (other)->prev_ ## mdll; \
2046 (other)->prev_ ## mdll = (element); \
2047 } \
2048 if (NULL == (element)->prev_ ## mdll) \
2049 (head) = (element); \
2050 else \
2051 (element)->prev_ ## mdll->next_ ## mdll = (element); \
2052 } while (0)
2053
2054
2066#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element) \
2067 do \
2068 { \
2069 GNUNET_assert (((element)->prev_ ## mdll != NULL) || ((head) == (element))); \
2070 GNUNET_assert (((element)->next_ ## mdll != NULL) || ((tail) == (element))); \
2071 if ((element)->prev_ ## mdll == NULL) \
2072 (head) = (element)->next_ ## mdll; \
2073 else \
2074 (element)->prev_ ## mdll->next_ ## mdll = (element)->next_ ## mdll; \
2075 if ((element)->next_ ## mdll == NULL) \
2076 (tail) = (element)->prev_ ## mdll; \
2077 else \
2078 (element)->next_ ## mdll->prev_ ## mdll = (element)->prev_ ## mdll; \
2079 (element)->next_ ## mdll = NULL; \
2080 (element)->prev_ ## mdll = NULL; \
2081 } while (0)
2082
2083
2097#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, \
2098 comparator, \
2099 comparator_cls, \
2100 head, \
2101 tail, \
2102 element) \
2103 do \
2104 { \
2105 if ((NULL == head) || (0 < comparator (comparator_cls, element, head))) \
2106 { \
2107 /* insert at head, element < head */ \
2108 GNUNET_CONTAINER_DLL_insert (head, tail, element); \
2109 } \
2110 else \
2111 { \
2112 TYPE *pos; \
2113 \
2114 for (pos = head; NULL != pos; pos = pos->next) \
2115 if (0 < comparator (comparator_cls, element, pos)) \
2116 break; /* element < pos */ \
2117 if (NULL == pos) /* => element > tail */ \
2118 { \
2119 GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); \
2120 } \
2121 else /* prev < element < pos */ \
2122 { \
2123 GNUNET_CONTAINER_DLL_insert_after (head, tail, pos->prev, element); \
2124 } \
2125 } \
2126 } while (0)
2127
2128
2129/* ******************** Heap *************** */
2130
2131
2137
2138
2144{
2150
2157
2158
2164
2165
2171
2172
2180struct GNUNET_CONTAINER_Heap *
2182
2183
2191void
2193
2194
2202void *
2204
2205
2217 void **element,
2219
2220
2228unsigned int
2230
2231
2241 const struct GNUNET_CONTAINER_HeapNode *node);
2242
2243
2255typedef enum GNUNET_GenericReturnValue
2257 void *cls,
2258 struct GNUNET_CONTAINER_HeapNode *node,
2259 void *element,
2261
2262
2271void
2274 void *iterator_cls);
2275
2288void *
2290
2291
2303 void *element,
2305
2306
2314void *
2316
2317
2325void *
2327
2328
2336void
2339
2340
2341#if 0 /* keep Emacsens' auto-indent happy */
2342{
2343#endif
2344#ifdef __cplusplus
2345}
2346#endif
2347
2348
2349/* ifndef GNUNET_CONTAINER_LIB_H */
2350#endif
2351 /* end of group addition */
2353
2354/* end of gnunet_container_lib.h */
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
static char * value
Value of the record to add/remove.
static int result
Global testing status.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
cryptographic primitives for GNUnet
void GNUNET_CONTAINER_bloomfilter_resize(struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_CONTAINER_HashCodeIterator iterator, void *iterator_cls, size_t size, unsigned int k)
Resize a bloom filter.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
void GNUNET_CONTAINER_bloomfilter_add(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Add an element to the filter.
bool GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_copy(const struct GNUNET_CONTAINER_BloomFilter *bf)
Create a copy of a bloomfilter.
void GNUNET_CONTAINER_bloomfilter_clear(struct GNUNET_CONTAINER_BloomFilter *bf)
Reset a Bloom filter to empty.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_get_raw_data(const struct GNUNET_CONTAINER_BloomFilter *bf, char *data, size_t size)
Copy the raw data of this Bloom filter into the given data array.
int(* GNUNET_CONTAINER_HashCodeIterator)(void *cls, struct GNUNET_HashCode *next)
Iterator over struct GNUNET_HashCode.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_or2(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_CONTAINER_BloomFilter *to_or)
"or" the entries of the given raw data array with the data of the given Bloom filter.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_load(const char *filename, size_t size, unsigned int k)
Load a Bloom filter from a file.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_or(struct GNUNET_CONTAINER_BloomFilter *bf, const char *data, size_t size)
"or" the entries of the given raw data array with the data of the given Bloom filter.
size_t GNUNET_CONTAINER_bloomfilter_get_size(const struct GNUNET_CONTAINER_BloomFilter *bf)
Get size of the bloom filter.
void GNUNET_CONTAINER_bloomfilter_remove(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Remove an element from the filter.
void GNUNET_CONTAINER_bloomfilter_free(struct GNUNET_CONTAINER_BloomFilter *bf)
Free the space associated with a filter in memory, flush to drive if needed (do not free the space on...
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_contains_value(const struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, const void *value)
Check if the map contains the given value under the given key.
unsigned int GNUNET_CONTAINER_multiuuidmap_size(const struct GNUNET_CONTAINER_MultiUuidmap *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiUuidmap * GNUNET_CONTAINER_multiuuidmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
unsigned int GNUNET_CONTAINER_multishortmap_get_random(const struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Call it on a random value from the map, or not at all if the map is empty.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMapIterator * GNUNET_CONTAINER_multipeermap_iterator_create(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Create an iterator for a multihashmap.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL).
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_PeerMapIterator)(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains_value(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Check if the map contains the given value under the given key.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
unsigned int GNUNET_CONTAINER_multiuuidmap_get_random(const struct GNUNET_CONTAINER_MultiUuidmap *map, GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, void *it_cls)
Call it on a random value from the map, or not at all if the map is empty.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_iterator_next(struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, struct GNUNET_Uuid *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_contains(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Check if the map contains any value under the given key (including values that are NULL).
void GNUNET_CONTAINER_multishortmap_iterator_destroy(struct GNUNET_CONTAINER_MultiShortmapIterator *iter)
Destroy a multishortmap iterator.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_iterator_next(struct GNUNET_CONTAINER_MultiHashMapIterator *iter, struct GNUNET_HashCode *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains_value(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Check if the map contains the given value under the given key.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
int GNUNET_CONTAINER_multiuuidmap_remove_all(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key)
Remove all entries for the given key from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MultiHashMapIterator32Callback)(void *cls, uint32_t key, void *value)
Iterator over hash map entries.
struct GNUNET_CONTAINER_MultiShortmapIterator * GNUNET_CONTAINER_multishortmap_iterator_create(const struct GNUNET_CONTAINER_MultiShortmap *map)
Create an iterator for a multihashmap.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_iterator_next(struct GNUNET_CONTAINER_MultiShortmapIterator *iter, struct GNUNET_ShortHashCode *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
unsigned int GNUNET_CONTAINER_multipeermap_get_random(const struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Call it on a random value from the map, or not at all if the map is empty.
void GNUNET_CONTAINER_multipeermap_iterator_destroy(struct GNUNET_CONTAINER_MultiPeerMapIterator *iter)
Destroy a multipeermap iterator.
int GNUNET_CONTAINER_multishortmap_contains_value(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Check if the map contains the given value under the given key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_remove(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, const void *value)
Remove the given key-value pair from the map.
int GNUNET_CONTAINER_multipeermap_remove_all(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Remove all entries for the given key from the map.
void GNUNET_CONTAINER_multiuuidmap_destroy(struct GNUNET_CONTAINER_MultiUuidmap *map)
Destroy a hash map.
GNUNET_CONTAINER_MultiHashMapOption
Options for storing values in the HashMap.
int GNUNET_CONTAINER_multiuuidmap_get_multiple(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_remove_all(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Remove all entries for the given key from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_contains(const struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key)
Check if the map contains any value under the given key (including values that are NULL).
int GNUNET_CONTAINER_multishortmap_get_multiple(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
unsigned int GNUNET_CONTAINER_multihashmap_clear(struct GNUNET_CONTAINER_MultiHashMap *map)
Remove all entries from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
unsigned int GNUNET_CONTAINER_multihashmap_get_random(const struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Call it on a random value from the map, or not at all if the map is empty.
void GNUNET_CONTAINER_multihashmap_iterator_destroy(struct GNUNET_CONTAINER_MultiHashMapIterator *iter)
Destroy a multihashmap iterator.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MultiUuidmapIteratorCallback)(void *cls, const struct GNUNET_Uuid *key, void *value)
Iterator over uuid map entries.
int GNUNET_CONTAINER_multihashmap32_remove_all(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Remove all entries for the given key from the map.
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MultiHashMapIteratorCallback)(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries.
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiUuidmapIterator * GNUNET_CONTAINER_multiuuidmap_iterator_create(const struct GNUNET_CONTAINER_MultiUuidmap *map)
Create an iterator for a multihashmap.
void GNUNET_CONTAINER_multiuuidmap_iterator_destroy(struct GNUNET_CONTAINER_MultiUuidmapIterator *iter)
Destroy a multiuuidmap iterator.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_contains_value(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Check if the map contains the given value under the given key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_iterator_next(struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, struct GNUNET_PeerIdentity *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_iterate(struct GNUNET_CONTAINER_MultiUuidmap *map, GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_put(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void * GNUNET_CONTAINER_multiuuidmap_get(const struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_CONTAINER_MultiHashMapIterator * GNUNET_CONTAINER_multihashmap_iterator_create(const struct GNUNET_CONTAINER_MultiHashMap *map)
Create an iterator for a multihashmap.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
GNUNET_CONTAINER_HeapOrder
Heap type, either max or min.
GNUNET_CONTAINER_HeapCostType GNUNET_CONTAINER_heap_node_get_cost(const struct GNUNET_CONTAINER_HeapNode *node)
Get the current cost of the node.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
void GNUNET_CONTAINER_heap_update_cost(struct GNUNET_CONTAINER_HeapNode *node, GNUNET_CONTAINER_HeapCostType new_cost)
Updates the cost of any node in the tree.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_HeapIterator)(void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, GNUNET_CONTAINER_HeapCostType cost)
Iterator for heap.
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
void GNUNET_CONTAINER_heap_iterate(const struct GNUNET_CONTAINER_Heap *heap, GNUNET_CONTAINER_HeapIterator iterator, void *iterator_cls)
Iterate over all entries in the heap.
uint64_t GNUNET_CONTAINER_HeapCostType
Cost by which elements in a heap can be ordered.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
void * GNUNET_CONTAINER_heap_walk_get_next(struct GNUNET_CONTAINER_Heap *heap)
Perform a random walk of the tree.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.
@ GNUNET_CONTAINER_HEAP_ORDER_MAX
Heap with the maximum cost at the root.
struct GNUNET_CONTAINER_MultiHashMap32Iterator * GNUNET_CONTAINER_multihashmap32_iterator_create(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Create an iterator for a 32-bit multihashmap.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_heap_peek2(const struct GNUNET_CONTAINER_Heap *heap, void **element, GNUNET_CONTAINER_HeapCostType *cost)
Get element and cost stored at the root of heap.
char * GNUNET_decompress(const char *input, size_t input_size, size_t output_size)
Decompress input, return the decompressed data as output.
Definition: compress.c:70
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_iterator_next(struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, uint32_t *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
void GNUNET_CONTAINER_multihashmap32_iterator_destroy(struct GNUNET_CONTAINER_MultiHashMapIterator *iter)
Destroy a 32-bit multihashmap iterator.
int GNUNET_try_compression(const char *data, size_t old_size, char **result, size_t *new_size)
Try to compress the given block of data using libz.
Definition: compress.c:33
size_t GNUNET_CONTAINER_bloomfilter_get_element_addresses(const struct GNUNET_CONTAINER_BloomFilter *bf)
Get the number of the addresses set per element in the bloom filter.
GNUNET_GenericReturnValue
Named constants for return values.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Peermap of PeerIdentities to "struct PeerEntry" (for fast lookup).
Definition: peer.c:63
static unsigned int size
Size of the "table".
Definition: peer.c:68
void * element
Our element.
struct GNUNET_CONTAINER_Heap * heap
Heap this node belongs to.
GNUNET_CONTAINER_HeapCostType cost
Cost for this element.
Handle to a node in a heap.
enum GNUNET_CONTAINER_HeapOrder order
How is the heap sorted?
Internal representation of the hash map.
Internal representation of the hash map.
Internal representation of the hash map.
Internal representation of the hash map.
Internal representation of the hash map.
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
A UUID, a 128 bit "random" value.