aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_container_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_container_lib.h')
-rw-r--r--src/include/gnunet_container_lib.h521
1 files changed, 84 insertions, 437 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index ae6c34f2b..8f36f1c61 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -19,35 +19,57 @@
19 */ 19 */
20 20
21/** 21/**
22 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs
24 * @{
25 *
22 * @author Christian Grothoff 26 * @author Christian Grothoff
23 * @author Nils Durner 27 * @author Nils Durner
24 * 28 *
25 * @file 29 * @file
26 * Container classes for GNUnet 30 * Container classes for GNUnet
27 * 31 *
28 * @defgroup hashmap Container library: MultiHashMap 32 * @addtogroup container
33 * Common data structures in GNUnet programs
34 * @{
35 *
36 * @defgroup hashmap MultiHashMap
29 * Hash map with multiple values per key. 37 * Hash map with multiple values per key.
30 * 38 *
31 * @see [Documentation](https://gnunet.org/util_multihashmap) 39 * @see [Documentation](https://gnunet.org/util_multihashmap)
32 * 40 *
33 * @defgroup heap Container library: Heap 41 * @defgroup heap Heap
34 * Min- or max-heap with arbitrary element removal 42 * Min- or max-heap with arbitrary element removal
35 * 43 *
36 * @defgroup bloomfilter Container library: Bloom filter 44 * @defgroup bloomfilter Bloom filter
37 * Probabilistic set tests 45 * Probabilistic set tests
38 * 46 *
39 * @defgroup dll Container library: Doubly-linked list 47 * @defgroup dll Doubly-linked list
40 * 48 *
41 * @see [Documentation](https://gnunet.org/mdll-api) 49 * @see [Documentation](https://gnunet.org/mdll-api)
42 * 50 *
43 * @defgroup metadata Container library: Metadata 51 *
44 * GNU libextractor key-value pairs 52 * @}
45 */ 53 */
46 54
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
47#ifndef GNUNET_CONTAINER_LIB_H 60#ifndef GNUNET_CONTAINER_LIB_H
48#define GNUNET_CONTAINER_LIB_H 61#define GNUNET_CONTAINER_LIB_H
49 62
63#ifdef __cplusplus
64extern "C" {
65#if 0 /* keep Emacsens' auto-indent happy */
66}
67#endif
68#endif
69
70
50/* add error and config prototypes */ 71/* add error and config prototypes */
72
51#include "gnunet_crypto_lib.h" 73#include "gnunet_crypto_lib.h"
52 74
53 75
@@ -87,114 +109,6 @@ char *
87GNUNET_decompress (const char *input, size_t input_size, size_t output_size); 109GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
88 110
89 111
90#if HAVE_EXTRACTOR_H
91
92#include <extractor.h>
93
94#else
95
96/* definitions from extractor.h we need for the build */
97
98/**
99 * Enumeration defining various sources of keywords. See also
100 * http://dublincore.org/documents/1998/09/dces/
101 */
102enum EXTRACTOR_MetaType
103{
104 EXTRACTOR_METATYPE_RESERVED = 0,
105 EXTRACTOR_METATYPE_MIMETYPE = 1,
106 EXTRACTOR_METATYPE_FILENAME = 2,
107 EXTRACTOR_METATYPE_COMMENT = 3,
108 EXTRACTOR_METATYPE_TITLE = 4,
109 EXTRACTOR_METATYPE_BOOK_TITLE = 5,
110 EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
111 EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
112 EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
113 EXTRACTOR_METATYPE_URL = 29,
114 EXTRACTOR_METATYPE_URI = 30,
115 EXTRACTOR_METATYPE_ISRC = 31,
116 EXTRACTOR_METATYPE_UNKNOWN = 45,
117 EXTRACTOR_METATYPE_DESCRIPTION = 46,
118 EXTRACTOR_METATYPE_KEYWORDS = 49,
119 EXTRACTOR_METATYPE_SUBJECT = 52,
120 EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
121 EXTRACTOR_METATYPE_THUMBNAIL = 114,
122 EXTRACTOR_METATYPE_ALBUM = 129,
123 EXTRACTOR_METATYPE_ARTIST = 130,
124 EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
125 EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
126 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
127};
128
129/**
130 * Format in which the extracted meta data is presented.
131 */
132enum EXTRACTOR_MetaFormat
133{
134 /**
135 * Format is unknown.
136 */
137 EXTRACTOR_METAFORMAT_UNKNOWN = 0,
138
139 /**
140 * 0-terminated, UTF-8 encoded string. "data_len"
141 * is strlen(data)+1.
142 */
143 EXTRACTOR_METAFORMAT_UTF8 = 1,
144
145 /**
146 * Some kind of binary format, see given Mime type.
147 */
148 EXTRACTOR_METAFORMAT_BINARY = 2,
149
150 /**
151 * 0-terminated string. The specific encoding is unknown.
152 * "data_len" is strlen (data)+1.
153 */
154 EXTRACTOR_METAFORMAT_C_STRING = 3
155};
156
157
158/**
159 * Type of a function that libextractor calls for each
160 * meta data item found.
161 *
162 * @param cls closure (user-defined)
163 * @param plugin_name name of the plugin that produced this value;
164 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
165 * used in the main libextractor library and yielding
166 * meta data).
167 * @param type libextractor-type describing the meta data
168 * @param format basic format information about @a data
169 * @param data_mime_type mime-type of @a data (not of the original file);
170 * can be NULL (if mime-type is not known)
171 * @param data actual meta-data found
172 * @param data_len number of bytes in @a data
173 * @return 0 to continue extracting, 1 to abort
174 */
175typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
176 const char *plugin_name,
177 enum EXTRACTOR_MetaType type,
178 enum EXTRACTOR_MetaFormat format,
179 const char *data_mime_type,
180 const char *data,
181 size_t data_len);
182
183#endif
184
185#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
186/* hack for LE < 0.6.3 */
187#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
188#endif
189
190#ifdef __cplusplus
191extern "C" {
192#if 0 /* keep Emacsens' auto-indent happy */
193}
194#endif
195#endif
196
197
198/* ******************* bloomfilter ***************** */ 112/* ******************* bloomfilter ***************** */
199 113
200/** 114/**
@@ -264,7 +178,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data,
264 * @param size the size of the given @a data array 178 * @param size the size of the given @a data array
265 * @return #GNUNET_SYSERR if the data array of the wrong size 179 * @return #GNUNET_SYSERR if the data array of the wrong size
266 */ 180 */
267int 181enum GNUNET_GenericReturnValue
268GNUNET_CONTAINER_bloomfilter_get_raw_data ( 182GNUNET_CONTAINER_bloomfilter_get_raw_data (
269 const struct GNUNET_CONTAINER_BloomFilter *bf, 183 const struct GNUNET_CONTAINER_BloomFilter *bf,
270 char *data, 184 char *data,
@@ -378,7 +292,7 @@ GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf);
378 * @param size size of @a data 292 * @param size size of @a data
379 * @return #GNUNET_OK on success 293 * @return #GNUNET_OK on success
380 */ 294 */
381int 295enum GNUNET_GenericReturnValue
382GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, 296GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
383 const char *data, 297 const char *data,
384 size_t size); 298 size_t size);
@@ -394,7 +308,7 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
394 * @param to_or the bloomfilter to or-in 308 * @param to_or the bloomfilter to or-in
395 * @return #GNUNET_OK on success 309 * @return #GNUNET_OK on success
396 */ 310 */
397int 311enum GNUNET_GenericReturnValue
398GNUNET_CONTAINER_bloomfilter_or2 ( 312GNUNET_CONTAINER_bloomfilter_or2 (
399 struct GNUNET_CONTAINER_BloomFilter *bf, 313 struct GNUNET_CONTAINER_BloomFilter *bf,
400 const struct GNUNET_CONTAINER_BloomFilter *to_or); 314 const struct GNUNET_CONTAINER_BloomFilter *to_or);
@@ -420,285 +334,6 @@ GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
420 unsigned int k); 334 unsigned int k);
421 335
422 336
423/* ****************** metadata ******************* */
424
425/**
426 * @ingroup metadata
427 * Meta data to associate with a file, directory or namespace.
428 */
429struct GNUNET_CONTAINER_MetaData;
430
431
432/**
433 * @ingroup metadata
434 * Create a fresh meta data container.
435 *
436 * @return empty meta-data container
437 */
438struct GNUNET_CONTAINER_MetaData *
439GNUNET_CONTAINER_meta_data_create (void);
440
441
442/**
443 * @ingroup metadata
444 * Duplicate a MetaData token.
445 *
446 * @param md what to duplicate
447 * @return duplicate meta-data container
448 */
449struct GNUNET_CONTAINER_MetaData *
450GNUNET_CONTAINER_meta_data_duplicate (
451 const struct GNUNET_CONTAINER_MetaData *md);
452
453
454/**
455 * @ingroup metadata
456 * Free meta data.
457 *
458 * @param md what to free
459 */
460void
461GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
462
463
464/**
465 * @ingroup metadata
466 * Test if two MDs are equal. We consider them equal if
467 * the meta types, formats and content match (we do not
468 * include the mime types and plugins names in this
469 * consideration).
470 *
471 * @param md1 first value to check
472 * @param md2 other value to check
473 * @return #GNUNET_YES if they are equal
474 */
475int
476GNUNET_CONTAINER_meta_data_test_equal (
477 const struct GNUNET_CONTAINER_MetaData *md1,
478 const struct GNUNET_CONTAINER_MetaData *md2);
479
480
481/**
482 * @ingroup metadata
483 * Extend metadata.
484 *
485 * @param md metadata to extend
486 * @param plugin_name name of the plugin that produced this value;
487 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
488 * used in the main libextractor library and yielding
489 * meta data).
490 * @param type libextractor-type describing the meta data
491 * @param format basic format information about data
492 * @param data_mime_type mime-type of data (not of the original file);
493 * can be NULL (if mime-type is not known)
494 * @param data actual meta-data found
495 * @param data_size number of bytes in data
496 * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
497 * data_mime_type and plugin_name are not considered for "exists" checks
498 */
499int
500GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
501 const char *plugin_name,
502 enum EXTRACTOR_MetaType type,
503 enum EXTRACTOR_MetaFormat format,
504 const char *data_mime_type,
505 const char *data,
506 size_t data_size);
507
508
509/**
510 * @ingroup metadata
511 * Extend metadata. Merges the meta data from the second argument
512 * into the first, discarding duplicate key-value pairs.
513 *
514 * @param md metadata to extend
515 * @param in metadata to merge
516 */
517void
518GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
519 const struct GNUNET_CONTAINER_MetaData *in);
520
521
522/**
523 * @ingroup metadata
524 * Remove an item.
525 *
526 * @param md metadata to manipulate
527 * @param type type of the item to remove
528 * @param data specific value to remove, NULL to remove all
529 * entries of the given type
530 * @param data_size number of bytes in data
531 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md
532 */
533int
534GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
535 enum EXTRACTOR_MetaType type,
536 const char *data,
537 size_t data_size);
538
539
540/**
541 * @ingroup metadata
542 * Remove all items in the container.
543 *
544 * @param md metadata to manipulate
545 */
546void
547GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md);
548
549
550/**
551 * @ingroup metadata
552 * Add the current time as the publication date
553 * to the meta-data.
554 *
555 * @param md metadata to modify
556 */
557void
558GNUNET_CONTAINER_meta_data_add_publication_date (
559 struct GNUNET_CONTAINER_MetaData *md);
560
561
562/**
563 * @ingroup metadata
564 * Iterate over MD entries.
565 *
566 * @param md metadata to inspect
567 * @param iter function to call on each entry, return 0 to continue to iterate
568 * and 1 to abort iteration in this function (GNU libextractor API!)
569 * @param iter_cls closure for @a iter
570 * @return number of entries
571 */
572int
573GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
574 EXTRACTOR_MetaDataProcessor iter,
575 void *iter_cls);
576
577
578/**
579 * @ingroup metadata
580 * Get the first MD entry of the given type. Caller
581 * is responsible for freeing the return value.
582 * Also, only meta data items that are strings (0-terminated)
583 * are returned by this function.
584 *
585 * @param md metadata to inspect
586 * @param type type to look for
587 * @return NULL if no entry was found
588 */
589char *
590GNUNET_CONTAINER_meta_data_get_by_type (
591 const struct GNUNET_CONTAINER_MetaData *md,
592 enum EXTRACTOR_MetaType type);
593
594
595/**
596 * @ingroup metadata
597 * Get the first matching MD entry of the given types. Caller is
598 * responsible for freeing the return value. Also, only meta data
599 * items that are strings (0-terminated) are returned by this
600 * function.
601 *
602 * @param md metadata to inspect
603 * @param ... -1-terminated list of types
604 * @return NULL if we do not have any such entry,
605 * otherwise client is responsible for freeing the value!
606 */
607char *
608GNUNET_CONTAINER_meta_data_get_first_by_types (
609 const struct GNUNET_CONTAINER_MetaData *md,
610 ...);
611
612/**
613 * @ingroup metadata
614 * Get a thumbnail from the meta-data (if present). Only matches meta
615 * data with mime type "image" and binary format.
616 *
617 * @param md metadata to inspect
618 * @param thumb will be set to the thumbnail data. Must be
619 * freed by the caller!
620 * @return number of bytes in thumbnail, 0 if not available
621 */
622size_t
623GNUNET_CONTAINER_meta_data_get_thumbnail (
624 const struct GNUNET_CONTAINER_MetaData *md,
625 unsigned char **thumb);
626
627
628/**
629 * @ingroup metadata
630 * Options for metadata serialization.
631 */
632enum GNUNET_CONTAINER_MetaDataSerializationOptions
633{
634 /**
635 * @ingroup metadata
636 * Serialize all of the data.
637 */
638 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0,
639
640 /**
641 * @ingroup metadata
642 * If not enough space is available, it is acceptable
643 * to only serialize some of the metadata.
644 */
645 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1,
646
647 /**
648 * @ingroup metadata
649 * Speed is of the essence, do not allow compression.
650 */
651 GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2
652};
653
654
655/**
656 * @ingroup metadata
657 * Serialize meta-data to target.
658 *
659 * @param md metadata to serialize
660 * @param target where to write the serialized metadata;
661 * *target can be NULL, in which case memory is allocated
662 * @param max maximum number of bytes available
663 * @param opt is it ok to just write SOME of the
664 * meta-data to match the size constraint,
665 * possibly discarding some data?
666 * @return number of bytes written on success,
667 * -1 on error (typically: not enough
668 * space)
669 */
670ssize_t
671GNUNET_CONTAINER_meta_data_serialize (
672 const struct GNUNET_CONTAINER_MetaData *md,
673 char **target,
674 size_t max,
675 enum GNUNET_CONTAINER_MetaDataSerializationOptions opt);
676
677
678/**
679 * @ingroup metadata
680 * Get the size of the full meta-data in serialized form.
681 *
682 * @param md metadata to inspect
683 * @return number of bytes needed for serialization, -1 on error
684 */
685ssize_t
686GNUNET_CONTAINER_meta_data_get_serialized_size (
687 const struct GNUNET_CONTAINER_MetaData *md);
688
689
690/**
691 * @ingroup metadata
692 * Deserialize meta-data. Initializes md.
693 *
694 * @param input serialized meta-data.
695 * @param size number of bytes available
696 * @return MD on success, NULL on error (e.g.
697 * bad format)
698 */
699struct GNUNET_CONTAINER_MetaData *
700GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size);
701
702 337
703/* ******************************* HashMap **************************** */ 338/* ******************************* HashMap **************************** */
704 339
@@ -766,7 +401,8 @@ enum GNUNET_CONTAINER_MultiHashMapOption
766 * iterate, 401 * iterate,
767 * #GNUNET_NO if not. 402 * #GNUNET_NO if not.
768 */ 403 */
769typedef int (*GNUNET_CONTAINER_MulitHashMapIteratorCallback) ( 404typedef enum GNUNET_GenericReturnValue
405(*GNUNET_CONTAINER_MultiHashMapIteratorCallback)(
770 void *cls, 406 void *cls,
771 const struct GNUNET_HashCode *key, 407 const struct GNUNET_HashCode *key,
772 void *value); 408 void *value);
@@ -834,7 +470,7 @@ GNUNET_CONTAINER_multihashmap_get (
834 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair 470 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
835 * is not in the map 471 * is not in the map
836 */ 472 */
837int 473enum GNUNET_GenericReturnValue
838GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, 474GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
839 const struct GNUNET_HashCode *key, 475 const struct GNUNET_HashCode *key,
840 const void *value); 476 const void *value);
@@ -876,7 +512,7 @@ GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map);
876 * @return #GNUNET_YES if such a value exists, 512 * @return #GNUNET_YES if such a value exists,
877 * #GNUNET_NO if not 513 * #GNUNET_NO if not
878 */ 514 */
879int 515enum GNUNET_GenericReturnValue
880GNUNET_CONTAINER_multihashmap_contains ( 516GNUNET_CONTAINER_multihashmap_contains (
881 const struct GNUNET_CONTAINER_MultiHashMap *map, 517 const struct GNUNET_CONTAINER_MultiHashMap *map,
882 const struct GNUNET_HashCode *key); 518 const struct GNUNET_HashCode *key);
@@ -893,7 +529,7 @@ GNUNET_CONTAINER_multihashmap_contains (
893 * @return #GNUNET_YES if such a value exists, 529 * @return #GNUNET_YES if such a value exists,
894 * #GNUNET_NO if not 530 * #GNUNET_NO if not
895 */ 531 */
896int 532enum GNUNET_GenericReturnValue
897GNUNET_CONTAINER_multihashmap_contains_value ( 533GNUNET_CONTAINER_multihashmap_contains_value (
898 const struct GNUNET_CONTAINER_MultiHashMap *map, 534 const struct GNUNET_CONTAINER_MultiHashMap *map,
899 const struct GNUNET_HashCode *key, 535 const struct GNUNET_HashCode *key,
@@ -913,7 +549,7 @@ GNUNET_CONTAINER_multihashmap_contains_value (
913 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the 549 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the
914 * value already exists 550 * value already exists
915 */ 551 */
916int 552enum GNUNET_GenericReturnValue
917GNUNET_CONTAINER_multihashmap_put ( 553GNUNET_CONTAINER_multihashmap_put (
918 struct GNUNET_CONTAINER_MultiHashMap *map, 554 struct GNUNET_CONTAINER_MultiHashMap *map,
919 const struct GNUNET_HashCode *key, 555 const struct GNUNET_HashCode *key,
@@ -945,7 +581,7 @@ GNUNET_CONTAINER_multihashmap_size (
945int 581int
946GNUNET_CONTAINER_multihashmap_iterate ( 582GNUNET_CONTAINER_multihashmap_iterate (
947 struct GNUNET_CONTAINER_MultiHashMap *map, 583 struct GNUNET_CONTAINER_MultiHashMap *map,
948 GNUNET_CONTAINER_MulitHashMapIteratorCallback it, 584 GNUNET_CONTAINER_MultiHashMapIteratorCallback it,
949 void *it_cls); 585 void *it_cls);
950 586
951 587
@@ -982,7 +618,7 @@ GNUNET_CONTAINER_multihashmap_iterator_create (
982 * @return #GNUNET_YES we returned an element, 618 * @return #GNUNET_YES we returned an element,
983 * #GNUNET_NO if we are out of elements 619 * #GNUNET_NO if we are out of elements
984 */ 620 */
985int 621enum GNUNET_GenericReturnValue
986GNUNET_CONTAINER_multihashmap_iterator_next ( 622GNUNET_CONTAINER_multihashmap_iterator_next (
987 struct GNUNET_CONTAINER_MultiHashMapIterator *iter, 623 struct GNUNET_CONTAINER_MultiHashMapIterator *iter,
988 struct GNUNET_HashCode *key, 624 struct GNUNET_HashCode *key,
@@ -1011,11 +647,11 @@ GNUNET_CONTAINER_multihashmap_iterator_destroy (
1011 * @return the number of key value pairs processed, 647 * @return the number of key value pairs processed,
1012 * #GNUNET_SYSERR if it aborted iteration 648 * #GNUNET_SYSERR if it aborted iteration
1013 */ 649 */
1014int 650enum GNUNET_GenericReturnValue
1015GNUNET_CONTAINER_multihashmap_get_multiple ( 651GNUNET_CONTAINER_multihashmap_get_multiple (
1016 struct GNUNET_CONTAINER_MultiHashMap *map, 652 struct GNUNET_CONTAINER_MultiHashMap *map,
1017 const struct GNUNET_HashCode *key, 653 const struct GNUNET_HashCode *key,
1018 GNUNET_CONTAINER_MulitHashMapIteratorCallback it, 654 GNUNET_CONTAINER_MultiHashMapIteratorCallback it,
1019 void *it_cls); 655 void *it_cls);
1020 656
1021 657
@@ -1033,7 +669,7 @@ GNUNET_CONTAINER_multihashmap_get_multiple (
1033unsigned int 669unsigned int
1034GNUNET_CONTAINER_multihashmap_get_random ( 670GNUNET_CONTAINER_multihashmap_get_random (
1035 const struct GNUNET_CONTAINER_MultiHashMap *map, 671 const struct GNUNET_CONTAINER_MultiHashMap *map,
1036 GNUNET_CONTAINER_MulitHashMapIteratorCallback it, 672 GNUNET_CONTAINER_MultiHashMapIteratorCallback it,
1037 void *it_cls); 673 void *it_cls);
1038 674
1039 675
@@ -1050,7 +686,8 @@ GNUNET_CONTAINER_multihashmap_get_random (
1050 * iterate, 686 * iterate,
1051 * #GNUNET_NO if not. 687 * #GNUNET_NO if not.
1052 */ 688 */
1053typedef int (*GNUNET_CONTAINER_PeerMapIterator) ( 689typedef enum GNUNET_GenericReturnValue
690(*GNUNET_CONTAINER_PeerMapIterator)(
1054 void *cls, 691 void *cls,
1055 const struct GNUNET_PeerIdentity *key, 692 const struct GNUNET_PeerIdentity *key,
1056 void *value); 693 void *value);
@@ -1123,7 +760,7 @@ GNUNET_CONTAINER_multipeermap_get (
1123 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair 760 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
1124 * is not in the map 761 * is not in the map
1125 */ 762 */
1126int 763enum GNUNET_GenericReturnValue
1127GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, 764GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map,
1128 const struct GNUNET_PeerIdentity *key, 765 const struct GNUNET_PeerIdentity *key,
1129 const void *value); 766 const void *value);
@@ -1153,7 +790,7 @@ GNUNET_CONTAINER_multipeermap_remove_all (
1153 * @return #GNUNET_YES if such a value exists, 790 * @return #GNUNET_YES if such a value exists,
1154 * #GNUNET_NO if not 791 * #GNUNET_NO if not
1155 */ 792 */
1156int 793enum GNUNET_GenericReturnValue
1157GNUNET_CONTAINER_multipeermap_contains ( 794GNUNET_CONTAINER_multipeermap_contains (
1158 const struct GNUNET_CONTAINER_MultiPeerMap *map, 795 const struct GNUNET_CONTAINER_MultiPeerMap *map,
1159 const struct GNUNET_PeerIdentity *key); 796 const struct GNUNET_PeerIdentity *key);
@@ -1170,7 +807,7 @@ GNUNET_CONTAINER_multipeermap_contains (
1170 * @return #GNUNET_YES if such a value exists, 807 * @return #GNUNET_YES if such a value exists,
1171 * #GNUNET_NO if not 808 * #GNUNET_NO if not
1172 */ 809 */
1173int 810enum GNUNET_GenericReturnValue
1174GNUNET_CONTAINER_multipeermap_contains_value ( 811GNUNET_CONTAINER_multipeermap_contains_value (
1175 const struct GNUNET_CONTAINER_MultiPeerMap *map, 812 const struct GNUNET_CONTAINER_MultiPeerMap *map,
1176 const struct GNUNET_PeerIdentity *key, 813 const struct GNUNET_PeerIdentity *key,
@@ -1250,9 +887,12 @@ GNUNET_CONTAINER_multipeermap_iterator_create (
1250 * @ingroup hashmap 887 * @ingroup hashmap
1251 * Retrieve the next element from the hash map at the iterator's 888 * Retrieve the next element from the hash map at the iterator's
1252 * position. If there are no elements left, #GNUNET_NO is returned, 889 * position. If there are no elements left, #GNUNET_NO is returned,
1253 * and @a key and @a value are not modified. This operation is only 890 * and @a key and @a value are not modified.
1254 * allowed if no elements have been removed from the multihashmap 891 *
1255 * since the creation of @a iter, and the map has not been destroyed. 892 * This operation is only allowed if no elements have been removed
893 * from the multihashmap since the creation of @a iter, and the map
894 * has not been destroyed.
895 *
1256 * Adding elements may result in repeating or skipping elements. 896 * Adding elements may result in repeating or skipping elements.
1257 * 897 *
1258 * @param iter the iterator to get the next element from 898 * @param iter the iterator to get the next element from
@@ -1261,7 +901,7 @@ GNUNET_CONTAINER_multipeermap_iterator_create (
1261 * @return #GNUNET_YES we returned an element, 901 * @return #GNUNET_YES we returned an element,
1262 * #GNUNET_NO if we are out of elements 902 * #GNUNET_NO if we are out of elements
1263 */ 903 */
1264int 904enum GNUNET_GenericReturnValue
1265GNUNET_CONTAINER_multipeermap_iterator_next ( 905GNUNET_CONTAINER_multipeermap_iterator_next (
1266 struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, 906 struct GNUNET_CONTAINER_MultiPeerMapIterator *iter,
1267 struct GNUNET_PeerIdentity *key, 907 struct GNUNET_PeerIdentity *key,
@@ -1329,7 +969,8 @@ GNUNET_CONTAINER_multipeermap_get_random (
1329 * iterate, 969 * iterate,
1330 * #GNUNET_NO if not. 970 * #GNUNET_NO if not.
1331 */ 971 */
1332typedef int (*GNUNET_CONTAINER_ShortmapIterator) ( 972typedef enum GNUNET_GenericReturnValue
973(*GNUNET_CONTAINER_ShortmapIterator)(
1333 void *cls, 974 void *cls,
1334 const struct GNUNET_ShortHashCode *key, 975 const struct GNUNET_ShortHashCode *key,
1335 void *value); 976 void *value);
@@ -1470,7 +1111,7 @@ GNUNET_CONTAINER_multishortmap_contains_value (
1470 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the 1111 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the
1471 * value already exists 1112 * value already exists
1472 */ 1113 */
1473int 1114enum GNUNET_GenericReturnValue
1474GNUNET_CONTAINER_multishortmap_put ( 1115GNUNET_CONTAINER_multishortmap_put (
1475 struct GNUNET_CONTAINER_MultiShortmap *map, 1116 struct GNUNET_CONTAINER_MultiShortmap *map,
1476 const struct GNUNET_ShortHashCode *key, 1117 const struct GNUNET_ShortHashCode *key,
@@ -1543,7 +1184,7 @@ GNUNET_CONTAINER_multishortmap_iterator_create (
1543 * @return #GNUNET_YES we returned an element, 1184 * @return #GNUNET_YES we returned an element,
1544 * #GNUNET_NO if we are out of elements 1185 * #GNUNET_NO if we are out of elements
1545 */ 1186 */
1546int 1187enum GNUNET_GenericReturnValue
1547GNUNET_CONTAINER_multishortmap_iterator_next ( 1188GNUNET_CONTAINER_multishortmap_iterator_next (
1548 struct GNUNET_CONTAINER_MultiShortmapIterator *iter, 1189 struct GNUNET_CONTAINER_MultiShortmapIterator *iter,
1549 struct GNUNET_ShortHashCode *key, 1190 struct GNUNET_ShortHashCode *key,
@@ -1612,7 +1253,8 @@ GNUNET_CONTAINER_multishortmap_get_random (
1612 * iterate, 1253 * iterate,
1613 * #GNUNET_NO if not. 1254 * #GNUNET_NO if not.
1614 */ 1255 */
1615typedef int (*GNUNET_CONTAINER_MultiUuidmapIteratorCallback) ( 1256typedef enum GNUNET_GenericReturnValue
1257(*GNUNET_CONTAINER_MultiUuidmapIteratorCallback)(
1616 void *cls, 1258 void *cls,
1617 const struct GNUNET_Uuid *key, 1259 const struct GNUNET_Uuid *key,
1618 void *value); 1260 void *value);
@@ -1685,7 +1327,7 @@ GNUNET_CONTAINER_multiuuidmap_get (
1685 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair 1327 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
1686 * is not in the map 1328 * is not in the map
1687 */ 1329 */
1688int 1330enum GNUNET_GenericReturnValue
1689GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map, 1331GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map,
1690 const struct GNUNET_Uuid *key, 1332 const struct GNUNET_Uuid *key,
1691 const void *value); 1333 const void *value);
@@ -1715,7 +1357,7 @@ GNUNET_CONTAINER_multiuuidmap_remove_all (
1715 * @return #GNUNET_YES if such a value exists, 1357 * @return #GNUNET_YES if such a value exists,
1716 * #GNUNET_NO if not 1358 * #GNUNET_NO if not
1717 */ 1359 */
1718int 1360enum GNUNET_GenericReturnValue
1719GNUNET_CONTAINER_multiuuidmap_contains ( 1361GNUNET_CONTAINER_multiuuidmap_contains (
1720 const struct GNUNET_CONTAINER_MultiUuidmap *map, 1362 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1721 const struct GNUNET_Uuid *key); 1363 const struct GNUNET_Uuid *key);
@@ -1732,7 +1374,7 @@ GNUNET_CONTAINER_multiuuidmap_contains (
1732 * @return #GNUNET_YES if such a value exists, 1374 * @return #GNUNET_YES if such a value exists,
1733 * #GNUNET_NO if not 1375 * #GNUNET_NO if not
1734 */ 1376 */
1735int 1377enum GNUNET_GenericReturnValue
1736GNUNET_CONTAINER_multiuuidmap_contains_value ( 1378GNUNET_CONTAINER_multiuuidmap_contains_value (
1737 const struct GNUNET_CONTAINER_MultiUuidmap *map, 1379 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1738 const struct GNUNET_Uuid *key, 1380 const struct GNUNET_Uuid *key,
@@ -1752,7 +1394,7 @@ GNUNET_CONTAINER_multiuuidmap_contains_value (
1752 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the 1394 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the
1753 * value already exists 1395 * value already exists
1754 */ 1396 */
1755int 1397enum GNUNET_GenericReturnValue
1756GNUNET_CONTAINER_multiuuidmap_put ( 1398GNUNET_CONTAINER_multiuuidmap_put (
1757 struct GNUNET_CONTAINER_MultiUuidmap *map, 1399 struct GNUNET_CONTAINER_MultiUuidmap *map,
1758 const struct GNUNET_Uuid *key, 1400 const struct GNUNET_Uuid *key,
@@ -1782,7 +1424,7 @@ GNUNET_CONTAINER_multiuuidmap_size (
1782 * @return the number of key value pairs processed, 1424 * @return the number of key value pairs processed,
1783 * #GNUNET_SYSERR if it aborted iteration 1425 * #GNUNET_SYSERR if it aborted iteration
1784 */ 1426 */
1785int 1427enum GNUNET_GenericReturnValue
1786GNUNET_CONTAINER_multiuuidmap_iterate ( 1428GNUNET_CONTAINER_multiuuidmap_iterate (
1787 struct GNUNET_CONTAINER_MultiUuidmap *map, 1429 struct GNUNET_CONTAINER_MultiUuidmap *map,
1788 GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, 1430 GNUNET_CONTAINER_MultiUuidmapIteratorCallback it,
@@ -1825,7 +1467,7 @@ GNUNET_CONTAINER_multiuuidmap_iterator_create (
1825 * @return #GNUNET_YES we returned an element, 1467 * @return #GNUNET_YES we returned an element,
1826 * #GNUNET_NO if we are out of elements 1468 * #GNUNET_NO if we are out of elements
1827 */ 1469 */
1828int 1470enum GNUNET_GenericReturnValue
1829GNUNET_CONTAINER_multiuuidmap_iterator_next ( 1471GNUNET_CONTAINER_multiuuidmap_iterator_next (
1830 struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, 1472 struct GNUNET_CONTAINER_MultiUuidmapIterator *iter,
1831 struct GNUNET_Uuid *key, 1473 struct GNUNET_Uuid *key,
@@ -1908,9 +1550,11 @@ struct GNUNET_CONTAINER_MultiHashMap32Iterator;
1908 * iterate, 1550 * iterate,
1909 * #GNUNET_NO if not. 1551 * #GNUNET_NO if not.
1910 */ 1552 */
1911typedef int (*GNUNET_CONTAINER_MulitHashMapIterator32Callback) (void *cls, 1553typedef enum GNUNET_GenericReturnValue
1912 uint32_t key, 1554(*GNUNET_CONTAINER_MultiHashMapIterator32Callback)(
1913 void *value); 1555 void *cls,
1556 uint32_t key,
1557 void *value);
1914 1558
1915 1559
1916/** 1560/**
@@ -1978,7 +1622,7 @@ GNUNET_CONTAINER_multihashmap32_get (
1978int 1622int
1979GNUNET_CONTAINER_multihashmap32_iterate ( 1623GNUNET_CONTAINER_multihashmap32_iterate (
1980 struct GNUNET_CONTAINER_MultiHashMap32 *map, 1624 struct GNUNET_CONTAINER_MultiHashMap32 *map,
1981 GNUNET_CONTAINER_MulitHashMapIterator32Callback it, 1625 GNUNET_CONTAINER_MultiHashMapIterator32Callback it,
1982 void *it_cls); 1626 void *it_cls);
1983 1627
1984 1628
@@ -1994,7 +1638,7 @@ GNUNET_CONTAINER_multihashmap32_iterate (
1994 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair 1638 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
1995 * is not in the map 1639 * is not in the map
1996 */ 1640 */
1997int 1641enum GNUNET_GenericReturnValue
1998GNUNET_CONTAINER_multihashmap32_remove ( 1642GNUNET_CONTAINER_multihashmap32_remove (
1999 struct GNUNET_CONTAINER_MultiHashMap32 *map, 1643 struct GNUNET_CONTAINER_MultiHashMap32 *map,
2000 uint32_t key, 1644 uint32_t key,
@@ -2026,7 +1670,7 @@ GNUNET_CONTAINER_multihashmap32_remove_all (
2026 * @return #GNUNET_YES if such a value exists, 1670 * @return #GNUNET_YES if such a value exists,
2027 * #GNUNET_NO if not 1671 * #GNUNET_NO if not
2028 */ 1672 */
2029int 1673enum GNUNET_GenericReturnValue
2030GNUNET_CONTAINER_multihashmap32_contains ( 1674GNUNET_CONTAINER_multihashmap32_contains (
2031 const struct GNUNET_CONTAINER_MultiHashMap32 *map, 1675 const struct GNUNET_CONTAINER_MultiHashMap32 *map,
2032 uint32_t key); 1676 uint32_t key);
@@ -2043,7 +1687,7 @@ GNUNET_CONTAINER_multihashmap32_contains (
2043 * @return #GNUNET_YES if such a value exists, 1687 * @return #GNUNET_YES if such a value exists,
2044 * #GNUNET_NO if not 1688 * #GNUNET_NO if not
2045 */ 1689 */
2046int 1690enum GNUNET_GenericReturnValue
2047GNUNET_CONTAINER_multihashmap32_contains_value ( 1691GNUNET_CONTAINER_multihashmap32_contains_value (
2048 const struct GNUNET_CONTAINER_MultiHashMap32 *map, 1692 const struct GNUNET_CONTAINER_MultiHashMap32 *map,
2049 uint32_t key, 1693 uint32_t key,
@@ -2063,7 +1707,7 @@ GNUNET_CONTAINER_multihashmap32_contains_value (
2063 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the 1707 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the
2064 * value already exists 1708 * value already exists
2065 */ 1709 */
2066int 1710enum GNUNET_GenericReturnValue
2067GNUNET_CONTAINER_multihashmap32_put ( 1711GNUNET_CONTAINER_multihashmap32_put (
2068 struct GNUNET_CONTAINER_MultiHashMap32 *map, 1712 struct GNUNET_CONTAINER_MultiHashMap32 *map,
2069 uint32_t key, 1713 uint32_t key,
@@ -2086,7 +1730,7 @@ int
2086GNUNET_CONTAINER_multihashmap32_get_multiple ( 1730GNUNET_CONTAINER_multihashmap32_get_multiple (
2087 struct GNUNET_CONTAINER_MultiHashMap32 *map, 1731 struct GNUNET_CONTAINER_MultiHashMap32 *map,
2088 uint32_t key, 1732 uint32_t key,
2089 GNUNET_CONTAINER_MulitHashMapIterator32Callback it, 1733 GNUNET_CONTAINER_MultiHashMapIterator32Callback it,
2090 void *it_cls); 1734 void *it_cls);
2091 1735
2092 1736
@@ -2121,7 +1765,7 @@ GNUNET_CONTAINER_multihashmap32_iterator_create (
2121 * @return #GNUNET_YES we returned an element, 1765 * @return #GNUNET_YES we returned an element,
2122 * #GNUNET_NO if we are out of elements 1766 * #GNUNET_NO if we are out of elements
2123 */ 1767 */
2124int 1768enum GNUNET_GenericReturnValue
2125GNUNET_CONTAINER_multihashmap32_iterator_next ( 1769GNUNET_CONTAINER_multihashmap32_iterator_next (
2126 struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, 1770 struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter,
2127 uint32_t *key, 1771 uint32_t *key,
@@ -2568,7 +2212,7 @@ GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap);
2568 * @return #GNUNET_YES if an element is returned, 2212 * @return #GNUNET_YES if an element is returned,
2569 * #GNUNET_NO if the heap is empty. 2213 * #GNUNET_NO if the heap is empty.
2570 */ 2214 */
2571int 2215enum GNUNET_GenericReturnValue
2572GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap, 2216GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap,
2573 void **element, 2217 void **element,
2574 GNUNET_CONTAINER_HeapCostType *cost); 2218 GNUNET_CONTAINER_HeapCostType *cost);
@@ -2608,8 +2252,8 @@ GNUNET_CONTAINER_heap_node_get_cost (
2608 * @return #GNUNET_YES if we should continue to iterate, 2252 * @return #GNUNET_YES if we should continue to iterate,
2609 * #GNUNET_NO if not. 2253 * #GNUNET_NO if not.
2610 */ 2254 */
2611typedef int 2255typedef enum GNUNET_GenericReturnValue
2612(*GNUNET_CONTAINER_HeapIterator) ( 2256(*GNUNET_CONTAINER_HeapIterator)(
2613 void *cls, 2257 void *cls,
2614 struct GNUNET_CONTAINER_HeapNode *node, 2258 struct GNUNET_CONTAINER_HeapNode *node,
2615 void *element, 2259 void *element,
@@ -2704,4 +2348,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_HeapNode *node,
2704 2348
2705/* ifndef GNUNET_CONTAINER_LIB_H */ 2349/* ifndef GNUNET_CONTAINER_LIB_H */
2706#endif 2350#endif
2351
2352/** @} */ /* end of group addition */
2353
2707/* end of gnunet_container_lib.h */ 2354/* end of gnunet_container_lib.h */