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.h1127
1 files changed, 743 insertions, 384 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index fee851e1c..fbfbf2d40 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -84,9 +84,7 @@ GNUNET_try_compression (const char *data,
84 * @return NULL on error, buffer of @a output_size decompressed bytes otherwise 84 * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
85 */ 85 */
86char * 86char *
87GNUNET_decompress (const char *input, 87GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
88 size_t input_size,
89 size_t output_size);
90 88
91 89
92#if HAVE_EXTRACTOR_H 90#if HAVE_EXTRACTOR_H
@@ -101,7 +99,8 @@ GNUNET_decompress (const char *input,
101 * Enumeration defining various sources of keywords. See also 99 * Enumeration defining various sources of keywords. See also
102 * http://dublincore.org/documents/1998/09/dces/ 100 * http://dublincore.org/documents/1998/09/dces/
103 */ 101 */
104enum EXTRACTOR_MetaType { 102enum EXTRACTOR_MetaType
103{
105 EXTRACTOR_METATYPE_RESERVED = 0, 104 EXTRACTOR_METATYPE_RESERVED = 0,
106 EXTRACTOR_METATYPE_MIMETYPE = 1, 105 EXTRACTOR_METATYPE_MIMETYPE = 1,
107 EXTRACTOR_METATYPE_FILENAME = 2, 106 EXTRACTOR_METATYPE_FILENAME = 2,
@@ -131,7 +130,8 @@ enum EXTRACTOR_MetaType {
131/** 130/**
132 * Format in which the extracted meta data is presented. 131 * Format in which the extracted meta data is presented.
133 */ 132 */
134enum EXTRACTOR_MetaFormat { 133enum EXTRACTOR_MetaFormat
134{
135 /** 135 /**
136 * Format is unknown. 136 * Format is unknown.
137 */ 137 */
@@ -173,14 +173,13 @@ enum EXTRACTOR_MetaFormat {
173 * @param data_len number of bytes in @a data 173 * @param data_len number of bytes in @a data
174 * @return 0 to continue extracting, 1 to abort 174 * @return 0 to continue extracting, 1 to abort
175 */ 175 */
176typedef int 176typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
177(*EXTRACTOR_MetaDataProcessor) (void *cls, 177 const char *plugin_name,
178 const char *plugin_name, 178 enum EXTRACTOR_MetaType type,
179 enum EXTRACTOR_MetaType type, 179 enum EXTRACTOR_MetaFormat format,
180 enum EXTRACTOR_MetaFormat format, 180 const char *data_mime_type,
181 const char *data_mime_type, 181 const char *data,
182 const char *data, 182 size_t data_len);
183 size_t data_len);
184 183
185#endif 184#endif
186 185
@@ -190,9 +189,8 @@ typedef int
190#endif 189#endif
191 190
192#ifdef __cplusplus 191#ifdef __cplusplus
193extern "C" 192extern "C" {
194{ 193#if 0 /* keep Emacsens' auto-indent happy */
195#if 0 /* keep Emacsens' auto-indent happy */
196} 194}
197#endif 195#endif
198#endif 196#endif
@@ -216,9 +214,8 @@ struct GNUNET_CONTAINER_BloomFilter;
216 * @return #GNUNET_YES if next was updated 214 * @return #GNUNET_YES if next was updated
217 * #GNUNET_NO if there are no more entries 215 * #GNUNET_NO if there are no more entries
218 */ 216 */
219typedef int 217typedef int (*GNUNET_CONTAINER_HashCodeIterator) (void *cls,
220(*GNUNET_CONTAINER_HashCodeIterator) (void *cls, 218 struct GNUNET_HashCode *next);
221 struct GNUNET_HashCode *next);
222 219
223 220
224/** 221/**
@@ -269,9 +266,10 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data,
269 * @return #GNUNET_SYSERR if the data array of the wrong size 266 * @return #GNUNET_SYSERR if the data array of the wrong size
270 */ 267 */
271int 268int
272GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct GNUNET_CONTAINER_BloomFilter *bf, 269GNUNET_CONTAINER_bloomfilter_get_raw_data (
273 char *data, 270 const struct GNUNET_CONTAINER_BloomFilter *bf,
274 size_t size); 271 char *data,
272 size_t size);
275 273
276 274
277/** 275/**
@@ -283,8 +281,9 @@ GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct GNUNET_CONTAINER_BloomFi
283 * @return #GNUNET_YES if the element is in the filter, #GNUNET_NO if not 281 * @return #GNUNET_YES if the element is in the filter, #GNUNET_NO if not
284 */ 282 */
285int 283int
286GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter *bf, 284GNUNET_CONTAINER_bloomfilter_test (
287 const struct GNUNET_HashCode *e); 285 const struct GNUNET_CONTAINER_BloomFilter *bf,
286 const struct GNUNET_HashCode *e);
288 287
289 288
290/** 289/**
@@ -319,8 +318,8 @@ GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf,
319 * @return copy of bf 318 * @return copy of bf
320 */ 319 */
321struct GNUNET_CONTAINER_BloomFilter * 320struct GNUNET_CONTAINER_BloomFilter *
322GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter *bf); 321GNUNET_CONTAINER_bloomfilter_copy (
323 322 const struct GNUNET_CONTAINER_BloomFilter *bf);
324 323
325 324
326/** 325/**
@@ -342,7 +341,8 @@ GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf);
342 * @return addresses set per element in the bf 341 * @return addresses set per element in the bf
343 */ 342 */
344size_t 343size_t
345GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CONTAINER_BloomFilter *bf); 344GNUNET_CONTAINER_bloomfilter_get_element_addresses (
345 const struct GNUNET_CONTAINER_BloomFilter *bf);
346 346
347 347
348/** 348/**
@@ -353,7 +353,8 @@ GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CONTAINE
353 * @return number of bytes used for the data of the bloom filter 353 * @return number of bytes used for the data of the bloom filter
354 */ 354 */
355size_t 355size_t
356GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter *bf); 356GNUNET_CONTAINER_bloomfilter_get_size (
357 const struct GNUNET_CONTAINER_BloomFilter *bf);
357 358
358 359
359/** 360/**
@@ -380,7 +381,8 @@ GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf);
380 */ 381 */
381int 382int
382GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, 383GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
383 const char *data, size_t size); 384 const char *data,
385 size_t size);
384 386
385 387
386/** 388/**
@@ -394,8 +396,9 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
394 * @return #GNUNET_OK on success 396 * @return #GNUNET_OK on success
395 */ 397 */
396int 398int
397GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf, 399GNUNET_CONTAINER_bloomfilter_or2 (
398 const struct GNUNET_CONTAINER_BloomFilter *to_or); 400 struct GNUNET_CONTAINER_BloomFilter *bf,
401 const struct GNUNET_CONTAINER_BloomFilter *to_or);
399 402
400 403
401/** 404/**
@@ -445,7 +448,8 @@ GNUNET_CONTAINER_meta_data_create (void);
445 * @return duplicate meta-data container 448 * @return duplicate meta-data container
446 */ 449 */
447struct GNUNET_CONTAINER_MetaData * 450struct GNUNET_CONTAINER_MetaData *
448GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData *md); 451GNUNET_CONTAINER_meta_data_duplicate (
452 const struct GNUNET_CONTAINER_MetaData *md);
449 453
450 454
451/** 455/**
@@ -470,8 +474,9 @@ GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
470 * @return #GNUNET_YES if they are equal 474 * @return #GNUNET_YES if they are equal
471 */ 475 */
472int 476int
473GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData *md1, 477GNUNET_CONTAINER_meta_data_test_equal (
474 const struct GNUNET_CONTAINER_MetaData *md2); 478 const struct GNUNET_CONTAINER_MetaData *md1,
479 const struct GNUNET_CONTAINER_MetaData *md2);
475 480
476 481
477/** 482/**
@@ -551,7 +556,8 @@ GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md);
551 * @param md metadata to modify 556 * @param md metadata to modify
552 */ 557 */
553void 558void
554GNUNET_CONTAINER_meta_data_add_publication_date (struct GNUNET_CONTAINER_MetaData *md); 559GNUNET_CONTAINER_meta_data_add_publication_date (
560 struct GNUNET_CONTAINER_MetaData *md);
555 561
556 562
557/** 563/**
@@ -582,8 +588,9 @@ GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
582 * @return NULL if no entry was found 588 * @return NULL if no entry was found
583 */ 589 */
584char * 590char *
585GNUNET_CONTAINER_meta_data_get_by_type (const struct GNUNET_CONTAINER_MetaData *md, 591GNUNET_CONTAINER_meta_data_get_by_type (
586 enum EXTRACTOR_MetaType type); 592 const struct GNUNET_CONTAINER_MetaData *md,
593 enum EXTRACTOR_MetaType type);
587 594
588 595
589/** 596/**
@@ -599,8 +606,9 @@ GNUNET_CONTAINER_meta_data_get_by_type (const struct GNUNET_CONTAINER_MetaData *
599 * otherwise client is responsible for freeing the value! 606 * otherwise client is responsible for freeing the value!
600 */ 607 */
601char * 608char *
602GNUNET_CONTAINER_meta_data_get_first_by_types (const struct GNUNET_CONTAINER_MetaData *md, 609GNUNET_CONTAINER_meta_data_get_first_by_types (
603 ...); 610 const struct GNUNET_CONTAINER_MetaData *md,
611 ...);
604 612
605/** 613/**
606 * @ingroup metadata 614 * @ingroup metadata
@@ -613,9 +621,9 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct GNUNET_CONTAINER_Met
613 * @return number of bytes in thumbnail, 0 if not available 621 * @return number of bytes in thumbnail, 0 if not available
614 */ 622 */
615size_t 623size_t
616GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData *md, 624GNUNET_CONTAINER_meta_data_get_thumbnail (
617 unsigned char **thumb); 625 const struct GNUNET_CONTAINER_MetaData *md,
618 626 unsigned char **thumb);
619 627
620 628
621/** 629/**
@@ -661,10 +669,11 @@ enum GNUNET_CONTAINER_MetaDataSerializationOptions
661 * space) 669 * space)
662 */ 670 */
663ssize_t 671ssize_t
664GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData *md, 672GNUNET_CONTAINER_meta_data_serialize (
665 char **target, 673 const struct GNUNET_CONTAINER_MetaData *md,
666 size_t max, 674 char **target,
667 enum GNUNET_CONTAINER_MetaDataSerializationOptions opt); 675 size_t max,
676 enum GNUNET_CONTAINER_MetaDataSerializationOptions opt);
668 677
669 678
670/** 679/**
@@ -675,7 +684,8 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData *md
675 * @return number of bytes needed for serialization, -1 on error 684 * @return number of bytes needed for serialization, -1 on error
676 */ 685 */
677ssize_t 686ssize_t
678GNUNET_CONTAINER_meta_data_get_serialized_size (const struct GNUNET_CONTAINER_MetaData *md); 687GNUNET_CONTAINER_meta_data_get_serialized_size (
688 const struct GNUNET_CONTAINER_MetaData *md);
679 689
680 690
681/** 691/**
@@ -688,8 +698,7 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct GNUNET_CONTAINER_Me
688 * bad format) 698 * bad format)
689 */ 699 */
690struct GNUNET_CONTAINER_MetaData * 700struct GNUNET_CONTAINER_MetaData *
691GNUNET_CONTAINER_meta_data_deserialize (const char *input, 701GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size);
692 size_t size);
693 702
694 703
695/* ******************************* HashMap **************************** */ 704/* ******************************* HashMap **************************** */
@@ -759,10 +768,10 @@ enum GNUNET_CONTAINER_MultiHashMapOption
759 * iterate, 768 * iterate,
760 * #GNUNET_NO if not. 769 * #GNUNET_NO if not.
761 */ 770 */
762typedef int 771typedef int (*GNUNET_CONTAINER_HashMapIterator) (
763(*GNUNET_CONTAINER_HashMapIterator) (void *cls, 772 void *cls,
764 const struct GNUNET_HashCode *key, 773 const struct GNUNET_HashCode *key,
765 void *value); 774 void *value);
766 775
767 776
768/** 777/**
@@ -782,8 +791,7 @@ typedef int
782 * @return NULL on error 791 * @return NULL on error
783 */ 792 */
784struct GNUNET_CONTAINER_MultiHashMap * 793struct GNUNET_CONTAINER_MultiHashMap *
785GNUNET_CONTAINER_multihashmap_create (unsigned int len, 794GNUNET_CONTAINER_multihashmap_create (unsigned int len, int do_not_copy_keys);
786 int do_not_copy_keys);
787 795
788 796
789/** 797/**
@@ -794,7 +802,8 @@ GNUNET_CONTAINER_multihashmap_create (unsigned int len,
794 * @param map the map 802 * @param map the map
795 */ 803 */
796void 804void
797GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap *map); 805GNUNET_CONTAINER_multihashmap_destroy (
806 struct GNUNET_CONTAINER_MultiHashMap *map);
798 807
799 808
800/** 809/**
@@ -809,8 +818,9 @@ GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap *map
809 * key-value pairs with value NULL 818 * key-value pairs with value NULL
810 */ 819 */
811void * 820void *
812GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap *map, 821GNUNET_CONTAINER_multihashmap_get (
813 const struct GNUNET_HashCode *key); 822 const struct GNUNET_CONTAINER_MultiHashMap *map,
823 const struct GNUNET_HashCode *key);
814 824
815 825
816/** 826/**
@@ -828,7 +838,7 @@ GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap *m
828int 838int
829GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, 839GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
830 const struct GNUNET_HashCode *key, 840 const struct GNUNET_HashCode *key,
831 const void *value); 841 const void *value);
832 842
833/** 843/**
834 * @ingroup hashmap 844 * @ingroup hashmap
@@ -840,8 +850,9 @@ GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
840 * @return number of values removed 850 * @return number of values removed
841 */ 851 */
842int 852int
843GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap *map, 853GNUNET_CONTAINER_multihashmap_remove_all (
844 const struct GNUNET_HashCode *key); 854 struct GNUNET_CONTAINER_MultiHashMap *map,
855 const struct GNUNET_HashCode *key);
845 856
846 857
847/** 858/**
@@ -867,8 +878,9 @@ GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map);
867 * #GNUNET_NO if not 878 * #GNUNET_NO if not
868 */ 879 */
869int 880int
870GNUNET_CONTAINER_multihashmap_contains (const struct GNUNET_CONTAINER_MultiHashMap *map, 881GNUNET_CONTAINER_multihashmap_contains (
871 const struct GNUNET_HashCode * key); 882 const struct GNUNET_CONTAINER_MultiHashMap *map,
883 const struct GNUNET_HashCode *key);
872 884
873 885
874/** 886/**
@@ -883,9 +895,10 @@ GNUNET_CONTAINER_multihashmap_contains (const struct GNUNET_CONTAINER_MultiHashM
883 * #GNUNET_NO if not 895 * #GNUNET_NO if not
884 */ 896 */
885int 897int
886GNUNET_CONTAINER_multihashmap_contains_value (const struct GNUNET_CONTAINER_MultiHashMap *map, 898GNUNET_CONTAINER_multihashmap_contains_value (
887 const struct GNUNET_HashCode *key, 899 const struct GNUNET_CONTAINER_MultiHashMap *map,
888 const void *value); 900 const struct GNUNET_HashCode *key,
901 const void *value);
889 902
890 903
891/** 904/**
@@ -902,11 +915,11 @@ GNUNET_CONTAINER_multihashmap_contains_value (const struct GNUNET_CONTAINER_Mult
902 * value already exists 915 * value already exists
903 */ 916 */
904int 917int
905GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, 918GNUNET_CONTAINER_multihashmap_put (
906 const struct GNUNET_HashCode *key, 919 struct GNUNET_CONTAINER_MultiHashMap *map,
907 void *value, 920 const struct GNUNET_HashCode *key,
908 enum GNUNET_CONTAINER_MultiHashMapOption 921 void *value,
909 opt); 922 enum GNUNET_CONTAINER_MultiHashMapOption opt);
910 923
911/** 924/**
912 * @ingroup hashmap 925 * @ingroup hashmap
@@ -916,7 +929,8 @@ GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map,
916 * @return the number of key value pairs 929 * @return the number of key value pairs
917 */ 930 */
918unsigned int 931unsigned int
919GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap *map); 932GNUNET_CONTAINER_multihashmap_size (
933 const struct GNUNET_CONTAINER_MultiHashMap *map);
920 934
921 935
922/** 936/**
@@ -930,9 +944,10 @@ GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap *
930 * #GNUNET_SYSERR if it aborted iteration 944 * #GNUNET_SYSERR if it aborted iteration
931 */ 945 */
932int 946int
933GNUNET_CONTAINER_multihashmap_iterate (struct GNUNET_CONTAINER_MultiHashMap *map, 947GNUNET_CONTAINER_multihashmap_iterate (
934 GNUNET_CONTAINER_HashMapIterator it, 948 struct GNUNET_CONTAINER_MultiHashMap *map,
935 void *it_cls); 949 GNUNET_CONTAINER_HashMapIterator it,
950 void *it_cls);
936 951
937 952
938/** 953/**
@@ -949,7 +964,8 @@ GNUNET_CONTAINER_multihashmap_iterate (struct GNUNET_CONTAINER_MultiHashMap *map
949 * @return an iterator over the given multihashmap @a map 964 * @return an iterator over the given multihashmap @a map
950 */ 965 */
951struct GNUNET_CONTAINER_MultiHashMapIterator * 966struct GNUNET_CONTAINER_MultiHashMapIterator *
952GNUNET_CONTAINER_multihashmap_iterator_create (const struct GNUNET_CONTAINER_MultiHashMap *map); 967GNUNET_CONTAINER_multihashmap_iterator_create (
968 const struct GNUNET_CONTAINER_MultiHashMap *map);
953 969
954 970
955/** 971/**
@@ -968,9 +984,10 @@ GNUNET_CONTAINER_multihashmap_iterator_create (const struct GNUNET_CONTAINER_Mul
968 * #GNUNET_NO if we are out of elements 984 * #GNUNET_NO if we are out of elements
969 */ 985 */
970int 986int
971GNUNET_CONTAINER_multihashmap_iterator_next (struct GNUNET_CONTAINER_MultiHashMapIterator *iter, 987GNUNET_CONTAINER_multihashmap_iterator_next (
972 struct GNUNET_HashCode *key, 988 struct GNUNET_CONTAINER_MultiHashMapIterator *iter,
973 const void **value); 989 struct GNUNET_HashCode *key,
990 const void **value);
974 991
975 992
976/** 993/**
@@ -980,7 +997,8 @@ GNUNET_CONTAINER_multihashmap_iterator_next (struct GNUNET_CONTAINER_MultiHashMa
980 * @param iter the iterator to destroy 997 * @param iter the iterator to destroy
981 */ 998 */
982void 999void
983GNUNET_CONTAINER_multihashmap_iterator_destroy (struct GNUNET_CONTAINER_MultiHashMapIterator *iter); 1000GNUNET_CONTAINER_multihashmap_iterator_destroy (
1001 struct GNUNET_CONTAINER_MultiHashMapIterator *iter);
984 1002
985 1003
986/** 1004/**
@@ -995,10 +1013,11 @@ GNUNET_CONTAINER_multihashmap_iterator_destroy (struct GNUNET_CONTAINER_MultiHas
995 * #GNUNET_SYSERR if it aborted iteration 1013 * #GNUNET_SYSERR if it aborted iteration
996 */ 1014 */
997int 1015int
998GNUNET_CONTAINER_multihashmap_get_multiple (struct GNUNET_CONTAINER_MultiHashMap *map, 1016GNUNET_CONTAINER_multihashmap_get_multiple (
999 const struct GNUNET_HashCode *key, 1017 struct GNUNET_CONTAINER_MultiHashMap *map,
1000 GNUNET_CONTAINER_HashMapIterator it, 1018 const struct GNUNET_HashCode *key,
1001 void *it_cls); 1019 GNUNET_CONTAINER_HashMapIterator it,
1020 void *it_cls);
1002 1021
1003 1022
1004/** 1023/**
@@ -1013,9 +1032,10 @@ GNUNET_CONTAINER_multihashmap_get_multiple (struct GNUNET_CONTAINER_MultiHashMap
1013 * @return the number of key value pairs processed, zero or one. 1032 * @return the number of key value pairs processed, zero or one.
1014 */ 1033 */
1015unsigned int 1034unsigned int
1016GNUNET_CONTAINER_multihashmap_get_random (const struct GNUNET_CONTAINER_MultiHashMap *map, 1035GNUNET_CONTAINER_multihashmap_get_random (
1017 GNUNET_CONTAINER_HashMapIterator it, 1036 const struct GNUNET_CONTAINER_MultiHashMap *map,
1018 void *it_cls); 1037 GNUNET_CONTAINER_HashMapIterator it,
1038 void *it_cls);
1019 1039
1020 1040
1021/* ***************** Version of Multihashmap for peer identities ****************** */ 1041/* ***************** Version of Multihashmap for peer identities ****************** */
@@ -1031,10 +1051,10 @@ GNUNET_CONTAINER_multihashmap_get_random (const struct GNUNET_CONTAINER_MultiHas
1031 * iterate, 1051 * iterate,
1032 * #GNUNET_NO if not. 1052 * #GNUNET_NO if not.
1033 */ 1053 */
1034typedef int 1054typedef int (*GNUNET_CONTAINER_PeerMapIterator) (
1035(*GNUNET_CONTAINER_PeerMapIterator) (void *cls, 1055 void *cls,
1036 const struct GNUNET_PeerIdentity *key, 1056 const struct GNUNET_PeerIdentity *key,
1037 void *value); 1057 void *value);
1038 1058
1039 1059
1040/** 1060/**
@@ -1060,8 +1080,7 @@ struct GNUNET_CONTAINER_MultiPeerMap;
1060 * @return NULL on error 1080 * @return NULL on error
1061 */ 1081 */
1062struct GNUNET_CONTAINER_MultiPeerMap * 1082struct GNUNET_CONTAINER_MultiPeerMap *
1063GNUNET_CONTAINER_multipeermap_create (unsigned int len, 1083GNUNET_CONTAINER_multipeermap_create (unsigned int len, int do_not_copy_keys);
1064 int do_not_copy_keys);
1065 1084
1066 1085
1067/** 1086/**
@@ -1072,7 +1091,8 @@ GNUNET_CONTAINER_multipeermap_create (unsigned int len,
1072 * @param map the map 1091 * @param map the map
1073 */ 1092 */
1074void 1093void
1075GNUNET_CONTAINER_multipeermap_destroy (struct GNUNET_CONTAINER_MultiPeerMap *map); 1094GNUNET_CONTAINER_multipeermap_destroy (
1095 struct GNUNET_CONTAINER_MultiPeerMap *map);
1076 1096
1077 1097
1078/** 1098/**
@@ -1087,8 +1107,9 @@ GNUNET_CONTAINER_multipeermap_destroy (struct GNUNET_CONTAINER_MultiPeerMap *map
1087 * key-value pairs with value NULL 1107 * key-value pairs with value NULL
1088 */ 1108 */
1089void * 1109void *
1090GNUNET_CONTAINER_multipeermap_get (const struct GNUNET_CONTAINER_MultiPeerMap *map, 1110GNUNET_CONTAINER_multipeermap_get (
1091 const struct GNUNET_PeerIdentity *key); 1111 const struct GNUNET_CONTAINER_MultiPeerMap *map,
1112 const struct GNUNET_PeerIdentity *key);
1092 1113
1093 1114
1094/** 1115/**
@@ -1105,8 +1126,8 @@ GNUNET_CONTAINER_multipeermap_get (const struct GNUNET_CONTAINER_MultiPeerMap *m
1105 */ 1126 */
1106int 1127int
1107GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, 1128GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map,
1108 const struct GNUNET_PeerIdentity * key, 1129 const struct GNUNET_PeerIdentity *key,
1109 const void *value); 1130 const void *value);
1110 1131
1111/** 1132/**
1112 * @ingroup hashmap 1133 * @ingroup hashmap
@@ -1118,8 +1139,9 @@ GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map,
1118 * @return number of values removed 1139 * @return number of values removed
1119 */ 1140 */
1120int 1141int
1121GNUNET_CONTAINER_multipeermap_remove_all (struct GNUNET_CONTAINER_MultiPeerMap *map, 1142GNUNET_CONTAINER_multipeermap_remove_all (
1122 const struct GNUNET_PeerIdentity *key); 1143 struct GNUNET_CONTAINER_MultiPeerMap *map,
1144 const struct GNUNET_PeerIdentity *key);
1123 1145
1124 1146
1125/** 1147/**
@@ -1133,8 +1155,9 @@ GNUNET_CONTAINER_multipeermap_remove_all (struct GNUNET_CONTAINER_MultiPeerMap *
1133 * #GNUNET_NO if not 1155 * #GNUNET_NO if not
1134 */ 1156 */
1135int 1157int
1136GNUNET_CONTAINER_multipeermap_contains (const struct GNUNET_CONTAINER_MultiPeerMap *map, 1158GNUNET_CONTAINER_multipeermap_contains (
1137 const struct GNUNET_PeerIdentity *key); 1159 const struct GNUNET_CONTAINER_MultiPeerMap *map,
1160 const struct GNUNET_PeerIdentity *key);
1138 1161
1139 1162
1140/** 1163/**
@@ -1149,9 +1172,10 @@ GNUNET_CONTAINER_multipeermap_contains (const struct GNUNET_CONTAINER_MultiPeerM
1149 * #GNUNET_NO if not 1172 * #GNUNET_NO if not
1150 */ 1173 */
1151int 1174int
1152GNUNET_CONTAINER_multipeermap_contains_value (const struct GNUNET_CONTAINER_MultiPeerMap *map, 1175GNUNET_CONTAINER_multipeermap_contains_value (
1153 const struct GNUNET_PeerIdentity * key, 1176 const struct GNUNET_CONTAINER_MultiPeerMap *map,
1154 const void *value); 1177 const struct GNUNET_PeerIdentity *key,
1178 const void *value);
1155 1179
1156 1180
1157/** 1181/**
@@ -1168,10 +1192,11 @@ GNUNET_CONTAINER_multipeermap_contains_value (const struct GNUNET_CONTAINER_Mult
1168 * value already exists 1192 * value already exists
1169 */ 1193 */
1170int 1194int
1171GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map, 1195GNUNET_CONTAINER_multipeermap_put (
1172 const struct GNUNET_PeerIdentity *key, 1196 struct GNUNET_CONTAINER_MultiPeerMap *map,
1173 void *value, 1197 const struct GNUNET_PeerIdentity *key,
1174 enum GNUNET_CONTAINER_MultiHashMapOption opt); 1198 void *value,
1199 enum GNUNET_CONTAINER_MultiHashMapOption opt);
1175 1200
1176 1201
1177/** 1202/**
@@ -1182,7 +1207,8 @@ GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map,
1182 * @return the number of key value pairs 1207 * @return the number of key value pairs
1183 */ 1208 */
1184unsigned int 1209unsigned int
1185GNUNET_CONTAINER_multipeermap_size (const struct GNUNET_CONTAINER_MultiPeerMap *map); 1210GNUNET_CONTAINER_multipeermap_size (
1211 const struct GNUNET_CONTAINER_MultiPeerMap *map);
1186 1212
1187 1213
1188/** 1214/**
@@ -1196,9 +1222,10 @@ GNUNET_CONTAINER_multipeermap_size (const struct GNUNET_CONTAINER_MultiPeerMap *
1196 * #GNUNET_SYSERR if it aborted iteration 1222 * #GNUNET_SYSERR if it aborted iteration
1197 */ 1223 */
1198int 1224int
1199GNUNET_CONTAINER_multipeermap_iterate (struct GNUNET_CONTAINER_MultiPeerMap *map, 1225GNUNET_CONTAINER_multipeermap_iterate (
1200 GNUNET_CONTAINER_PeerMapIterator it, 1226 struct GNUNET_CONTAINER_MultiPeerMap *map,
1201 void *it_cls); 1227 GNUNET_CONTAINER_PeerMapIterator it,
1228 void *it_cls);
1202 1229
1203 1230
1204struct GNUNET_CONTAINER_MultiPeerMapIterator; 1231struct GNUNET_CONTAINER_MultiPeerMapIterator;
@@ -1216,7 +1243,8 @@ struct GNUNET_CONTAINER_MultiPeerMapIterator;
1216 * @return an iterator over the given multihashmap @a map 1243 * @return an iterator over the given multihashmap @a map
1217 */ 1244 */
1218struct GNUNET_CONTAINER_MultiPeerMapIterator * 1245struct GNUNET_CONTAINER_MultiPeerMapIterator *
1219GNUNET_CONTAINER_multipeermap_iterator_create (const struct GNUNET_CONTAINER_MultiPeerMap *map); 1246GNUNET_CONTAINER_multipeermap_iterator_create (
1247 const struct GNUNET_CONTAINER_MultiPeerMap *map);
1220 1248
1221 1249
1222/** 1250/**
@@ -1235,9 +1263,10 @@ GNUNET_CONTAINER_multipeermap_iterator_create (const struct GNUNET_CONTAINER_Mul
1235 * #GNUNET_NO if we are out of elements 1263 * #GNUNET_NO if we are out of elements
1236 */ 1264 */
1237int 1265int
1238GNUNET_CONTAINER_multipeermap_iterator_next (struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, 1266GNUNET_CONTAINER_multipeermap_iterator_next (
1239 struct GNUNET_PeerIdentity *key, 1267 struct GNUNET_CONTAINER_MultiPeerMapIterator *iter,
1240 const void **value); 1268 struct GNUNET_PeerIdentity *key,
1269 const void **value);
1241 1270
1242 1271
1243/** 1272/**
@@ -1247,7 +1276,8 @@ GNUNET_CONTAINER_multipeermap_iterator_next (struct GNUNET_CONTAINER_MultiPeerMa
1247 * @param iter the iterator to destroy 1276 * @param iter the iterator to destroy
1248 */ 1277 */
1249void 1278void
1250GNUNET_CONTAINER_multipeermap_iterator_destroy (struct GNUNET_CONTAINER_MultiPeerMapIterator *iter); 1279GNUNET_CONTAINER_multipeermap_iterator_destroy (
1280 struct GNUNET_CONTAINER_MultiPeerMapIterator *iter);
1251 1281
1252 1282
1253/** 1283/**
@@ -1262,10 +1292,11 @@ GNUNET_CONTAINER_multipeermap_iterator_destroy (struct GNUNET_CONTAINER_MultiPee
1262 * #GNUNET_SYSERR if it aborted iteration 1292 * #GNUNET_SYSERR if it aborted iteration
1263 */ 1293 */
1264int 1294int
1265GNUNET_CONTAINER_multipeermap_get_multiple (struct GNUNET_CONTAINER_MultiPeerMap *map, 1295GNUNET_CONTAINER_multipeermap_get_multiple (
1266 const struct GNUNET_PeerIdentity *key, 1296 struct GNUNET_CONTAINER_MultiPeerMap *map,
1267 GNUNET_CONTAINER_PeerMapIterator it, 1297 const struct GNUNET_PeerIdentity *key,
1268 void *it_cls); 1298 GNUNET_CONTAINER_PeerMapIterator it,
1299 void *it_cls);
1269 1300
1270 1301
1271/** 1302/**
@@ -1280,9 +1311,10 @@ GNUNET_CONTAINER_multipeermap_get_multiple (struct GNUNET_CONTAINER_MultiPeerMap
1280 * @return the number of key value pairs processed, zero or one. 1311 * @return the number of key value pairs processed, zero or one.
1281 */ 1312 */
1282unsigned int 1313unsigned int
1283GNUNET_CONTAINER_multipeermap_get_random (const struct GNUNET_CONTAINER_MultiPeerMap *map, 1314GNUNET_CONTAINER_multipeermap_get_random (
1284 GNUNET_CONTAINER_PeerMapIterator it, 1315 const struct GNUNET_CONTAINER_MultiPeerMap *map,
1285 void *it_cls); 1316 GNUNET_CONTAINER_PeerMapIterator it,
1317 void *it_cls);
1286 1318
1287 1319
1288/* ***************** Version of Multihashmap for short hashes ****************** */ 1320/* ***************** Version of Multihashmap for short hashes ****************** */
@@ -1298,10 +1330,10 @@ GNUNET_CONTAINER_multipeermap_get_random (const struct GNUNET_CONTAINER_MultiPee
1298 * iterate, 1330 * iterate,
1299 * #GNUNET_NO if not. 1331 * #GNUNET_NO if not.
1300 */ 1332 */
1301typedef int 1333typedef int (*GNUNET_CONTAINER_ShortmapIterator) (
1302(*GNUNET_CONTAINER_ShortmapIterator) (void *cls, 1334 void *cls,
1303 const struct GNUNET_ShortHashCode *key, 1335 const struct GNUNET_ShortHashCode *key,
1304 void *value); 1336 void *value);
1305 1337
1306 1338
1307/** 1339/**
@@ -1327,8 +1359,7 @@ struct GNUNET_CONTAINER_MultiShortmap;
1327 * @return NULL on error 1359 * @return NULL on error
1328 */ 1360 */
1329struct GNUNET_CONTAINER_MultiShortmap * 1361struct GNUNET_CONTAINER_MultiShortmap *
1330GNUNET_CONTAINER_multishortmap_create (unsigned int len, 1362GNUNET_CONTAINER_multishortmap_create (unsigned int len, int do_not_copy_keys);
1331 int do_not_copy_keys);
1332 1363
1333 1364
1334/** 1365/**
@@ -1339,7 +1370,8 @@ GNUNET_CONTAINER_multishortmap_create (unsigned int len,
1339 * @param map the map 1370 * @param map the map
1340 */ 1371 */
1341void 1372void
1342GNUNET_CONTAINER_multishortmap_destroy (struct GNUNET_CONTAINER_MultiShortmap *map); 1373GNUNET_CONTAINER_multishortmap_destroy (
1374 struct GNUNET_CONTAINER_MultiShortmap *map);
1343 1375
1344 1376
1345/** 1377/**
@@ -1354,8 +1386,9 @@ GNUNET_CONTAINER_multishortmap_destroy (struct GNUNET_CONTAINER_MultiShortmap *m
1354 * key-value pairs with value NULL 1386 * key-value pairs with value NULL
1355 */ 1387 */
1356void * 1388void *
1357GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap *map, 1389GNUNET_CONTAINER_multishortmap_get (
1358 const struct GNUNET_ShortHashCode *key); 1390 const struct GNUNET_CONTAINER_MultiShortmap *map,
1391 const struct GNUNET_ShortHashCode *key);
1359 1392
1360 1393
1361/** 1394/**
@@ -1371,9 +1404,10 @@ GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap
1371 * is not in the map 1404 * is not in the map
1372 */ 1405 */
1373int 1406int
1374GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *map, 1407GNUNET_CONTAINER_multishortmap_remove (
1375 const struct GNUNET_ShortHashCode * key, 1408 struct GNUNET_CONTAINER_MultiShortmap *map,
1376 const void *value); 1409 const struct GNUNET_ShortHashCode *key,
1410 const void *value);
1377 1411
1378/** 1412/**
1379 * @ingroup hashmap 1413 * @ingroup hashmap
@@ -1385,8 +1419,9 @@ GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *ma
1385 * @return number of values removed 1419 * @return number of values removed
1386 */ 1420 */
1387int 1421int
1388GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap *map, 1422GNUNET_CONTAINER_multishortmap_remove_all (
1389 const struct GNUNET_ShortHashCode *key); 1423 struct GNUNET_CONTAINER_MultiShortmap *map,
1424 const struct GNUNET_ShortHashCode *key);
1390 1425
1391 1426
1392/** 1427/**
@@ -1400,8 +1435,9 @@ GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap
1400 * #GNUNET_NO if not 1435 * #GNUNET_NO if not
1401 */ 1436 */
1402int 1437int
1403GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShortmap *map, 1438GNUNET_CONTAINER_multishortmap_contains (
1404 const struct GNUNET_ShortHashCode *key); 1439 const struct GNUNET_CONTAINER_MultiShortmap *map,
1440 const struct GNUNET_ShortHashCode *key);
1405 1441
1406 1442
1407/** 1443/**
@@ -1416,9 +1452,10 @@ GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShor
1416 * #GNUNET_NO if not 1452 * #GNUNET_NO if not
1417 */ 1453 */
1418int 1454int
1419GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_MultiShortmap *map, 1455GNUNET_CONTAINER_multishortmap_contains_value (
1420 const struct GNUNET_ShortHashCode * key, 1456 const struct GNUNET_CONTAINER_MultiShortmap *map,
1421 const void *value); 1457 const struct GNUNET_ShortHashCode *key,
1458 const void *value);
1422 1459
1423 1460
1424/** 1461/**
@@ -1435,10 +1472,11 @@ GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_Mul
1435 * value already exists 1472 * value already exists
1436 */ 1473 */
1437int 1474int
1438GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map, 1475GNUNET_CONTAINER_multishortmap_put (
1439 const struct GNUNET_ShortHashCode *key, 1476 struct GNUNET_CONTAINER_MultiShortmap *map,
1440 void *value, 1477 const struct GNUNET_ShortHashCode *key,
1441 enum GNUNET_CONTAINER_MultiHashMapOption opt); 1478 void *value,
1479 enum GNUNET_CONTAINER_MultiHashMapOption opt);
1442 1480
1443 1481
1444/** 1482/**
@@ -1449,7 +1487,8 @@ GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map,
1449 * @return the number of key value pairs 1487 * @return the number of key value pairs
1450 */ 1488 */
1451unsigned int 1489unsigned int
1452GNUNET_CONTAINER_multishortmap_size (const struct GNUNET_CONTAINER_MultiShortmap *map); 1490GNUNET_CONTAINER_multishortmap_size (
1491 const struct GNUNET_CONTAINER_MultiShortmap *map);
1453 1492
1454 1493
1455/** 1494/**
@@ -1463,9 +1502,10 @@ GNUNET_CONTAINER_multishortmap_size (const struct GNUNET_CONTAINER_MultiShortmap
1463 * #GNUNET_SYSERR if it aborted iteration 1502 * #GNUNET_SYSERR if it aborted iteration
1464 */ 1503 */
1465int 1504int
1466GNUNET_CONTAINER_multishortmap_iterate (struct GNUNET_CONTAINER_MultiShortmap *map, 1505GNUNET_CONTAINER_multishortmap_iterate (
1467 GNUNET_CONTAINER_ShortmapIterator it, 1506 struct GNUNET_CONTAINER_MultiShortmap *map,
1468 void *it_cls); 1507 GNUNET_CONTAINER_ShortmapIterator it,
1508 void *it_cls);
1469 1509
1470 1510
1471struct GNUNET_CONTAINER_MultiShortmapIterator; 1511struct GNUNET_CONTAINER_MultiShortmapIterator;
@@ -1485,7 +1525,8 @@ struct GNUNET_CONTAINER_MultiShortmapIterator;
1485 * @return an iterator over the given multihashmap @a map 1525 * @return an iterator over the given multihashmap @a map
1486 */ 1526 */
1487struct GNUNET_CONTAINER_MultiShortmapIterator * 1527struct GNUNET_CONTAINER_MultiShortmapIterator *
1488GNUNET_CONTAINER_multishortmap_iterator_create (const struct GNUNET_CONTAINER_MultiShortmap *map); 1528GNUNET_CONTAINER_multishortmap_iterator_create (
1529 const struct GNUNET_CONTAINER_MultiShortmap *map);
1489 1530
1490 1531
1491/** 1532/**
@@ -1504,9 +1545,10 @@ GNUNET_CONTAINER_multishortmap_iterator_create (const struct GNUNET_CONTAINER_Mu
1504 * #GNUNET_NO if we are out of elements 1545 * #GNUNET_NO if we are out of elements
1505 */ 1546 */
1506int 1547int
1507GNUNET_CONTAINER_multishortmap_iterator_next (struct GNUNET_CONTAINER_MultiShortmapIterator *iter, 1548GNUNET_CONTAINER_multishortmap_iterator_next (
1508 struct GNUNET_ShortHashCode *key, 1549 struct GNUNET_CONTAINER_MultiShortmapIterator *iter,
1509 const void **value); 1550 struct GNUNET_ShortHashCode *key,
1551 const void **value);
1510 1552
1511 1553
1512/** 1554/**
@@ -1516,7 +1558,8 @@ GNUNET_CONTAINER_multishortmap_iterator_next (struct GNUNET_CONTAINER_MultiShort
1516 * @param iter the iterator to destroy 1558 * @param iter the iterator to destroy
1517 */ 1559 */
1518void 1560void
1519GNUNET_CONTAINER_multishortmap_iterator_destroy (struct GNUNET_CONTAINER_MultiShortmapIterator *iter); 1561GNUNET_CONTAINER_multishortmap_iterator_destroy (
1562 struct GNUNET_CONTAINER_MultiShortmapIterator *iter);
1520 1563
1521 1564
1522/** 1565/**
@@ -1531,10 +1574,11 @@ GNUNET_CONTAINER_multishortmap_iterator_destroy (struct GNUNET_CONTAINER_MultiSh
1531 * #GNUNET_SYSERR if it aborted iteration 1574 * #GNUNET_SYSERR if it aborted iteration
1532 */ 1575 */
1533int 1576int
1534GNUNET_CONTAINER_multishortmap_get_multiple (struct GNUNET_CONTAINER_MultiShortmap *map, 1577GNUNET_CONTAINER_multishortmap_get_multiple (
1535 const struct GNUNET_ShortHashCode *key, 1578 struct GNUNET_CONTAINER_MultiShortmap *map,
1536 GNUNET_CONTAINER_ShortmapIterator it, 1579 const struct GNUNET_ShortHashCode *key,
1537 void *it_cls); 1580 GNUNET_CONTAINER_ShortmapIterator it,
1581 void *it_cls);
1538 1582
1539 1583
1540/** 1584/**
@@ -1549,9 +1593,292 @@ GNUNET_CONTAINER_multishortmap_get_multiple (struct GNUNET_CONTAINER_MultiShortm
1549 * @return the number of key value pairs processed, zero or one. 1593 * @return the number of key value pairs processed, zero or one.
1550 */ 1594 */
1551unsigned int 1595unsigned int
1552GNUNET_CONTAINER_multishortmap_get_random (const struct GNUNET_CONTAINER_MultiShortmap *map, 1596GNUNET_CONTAINER_multishortmap_get_random (
1553 GNUNET_CONTAINER_ShortmapIterator it, 1597 const struct GNUNET_CONTAINER_MultiShortmap *map,
1554 void *it_cls); 1598 GNUNET_CONTAINER_ShortmapIterator it,
1599 void *it_cls);
1600
1601
1602/* ***************** Version of Multihashmap for UUIDs ****************** */
1603
1604
1605/**
1606 * @ingroup hashmap
1607 * Iterator over uuid map entries.
1608 *
1609 * @param cls closure
1610 * @param key current public key
1611 * @param value value in the hash map
1612 * @return #GNUNET_YES if we should continue to
1613 * iterate,
1614 * #GNUNET_NO if not.
1615 */
1616typedef int (*GNUNET_CONTAINER_MultiUuidmapIterator) (
1617 void *cls,
1618 const struct GNUNET_Uuid *key,
1619 void *value);
1620
1621
1622/**
1623 * Hash map from peer identities to values.
1624 */
1625struct GNUNET_CONTAINER_MultiUuidmap;
1626
1627
1628/**
1629 * @ingroup hashmap
1630 * Create a multi peer map (hash map for public keys of peers).
1631 *
1632 * @param len initial size (map will grow as needed)
1633 * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default;
1634 * #GNUNET_YES means that on 'put', the 'key' does not have
1635 * to be copied as the destination of the pointer is
1636 * guaranteed to be life as long as the value is stored in
1637 * the hashmap. This can significantly reduce memory
1638 * consumption, but of course is also a recipie for
1639 * heap corruption if the assumption is not true. Only
1640 * use this if (1) memory use is important in this case and
1641 * (2) you have triple-checked that the invariant holds
1642 * @return NULL on error
1643 */
1644struct GNUNET_CONTAINER_MultiUuidmap *
1645GNUNET_CONTAINER_multiuuidmap_create (unsigned int len, int do_not_copy_keys);
1646
1647
1648/**
1649 * @ingroup hashmap
1650 * Destroy a hash map. Will not free any values
1651 * stored in the hash map!
1652 *
1653 * @param map the map
1654 */
1655void
1656GNUNET_CONTAINER_multiuuidmap_destroy (
1657 struct GNUNET_CONTAINER_MultiUuidmap *map);
1658
1659
1660/**
1661 * @ingroup hashmap
1662 * Given a key find a value in the map matching the key.
1663 *
1664 * @param map the map
1665 * @param key what to look for
1666 * @return NULL if no value was found; note that
1667 * this is indistinguishable from values that just
1668 * happen to be NULL; use "contains" to test for
1669 * key-value pairs with value NULL
1670 */
1671void *
1672GNUNET_CONTAINER_multiuuidmap_get (
1673 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1674 const struct GNUNET_Uuid *key);
1675
1676
1677/**
1678 * @ingroup hashmap
1679 * Remove the given key-value pair from the map. Note that if the
1680 * key-value pair is in the map multiple times, only one of the pairs
1681 * will be removed.
1682 *
1683 * @param map the map
1684 * @param key key of the key-value pair
1685 * @param value value of the key-value pair
1686 * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
1687 * is not in the map
1688 */
1689int
1690GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map,
1691 const struct GNUNET_Uuid *key,
1692 const void *value);
1693
1694/**
1695 * @ingroup hashmap
1696 * Remove all entries for the given key from the map.
1697 * Note that the values would not be "freed".
1698 *
1699 * @param map the map
1700 * @param key identifies values to be removed
1701 * @return number of values removed
1702 */
1703int
1704GNUNET_CONTAINER_multiuuidmap_remove_all (
1705 struct GNUNET_CONTAINER_MultiUuidmap *map,
1706 const struct GNUNET_Uuid *key);
1707
1708
1709/**
1710 * @ingroup hashmap
1711 * Check if the map contains any value under the given
1712 * key (including values that are NULL).
1713 *
1714 * @param map the map
1715 * @param key the key to test if a value exists for it
1716 * @return #GNUNET_YES if such a value exists,
1717 * #GNUNET_NO if not
1718 */
1719int
1720GNUNET_CONTAINER_multiuuidmap_contains (
1721 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1722 const struct GNUNET_Uuid *key);
1723
1724
1725/**
1726 * @ingroup hashmap
1727 * Check if the map contains the given value under the given
1728 * key.
1729 *
1730 * @param map the map
1731 * @param key the key to test if a value exists for it
1732 * @param value value to test for
1733 * @return #GNUNET_YES if such a value exists,
1734 * #GNUNET_NO if not
1735 */
1736int
1737GNUNET_CONTAINER_multiuuidmap_contains_value (
1738 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1739 const struct GNUNET_Uuid *key,
1740 const void *value);
1741
1742
1743/**
1744 * @ingroup hashmap
1745 * Store a key-value pair in the map.
1746 *
1747 * @param map the map
1748 * @param key key to use
1749 * @param value value to use
1750 * @param opt options for put
1751 * @return #GNUNET_OK on success,
1752 * #GNUNET_NO if a value was replaced (with REPLACE)
1753 * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the
1754 * value already exists
1755 */
1756int
1757GNUNET_CONTAINER_multiuuidmap_put (
1758 struct GNUNET_CONTAINER_MultiUuidmap *map,
1759 const struct GNUNET_Uuid *key,
1760 void *value,
1761 enum GNUNET_CONTAINER_MultiHashMapOption opt);
1762
1763
1764/**
1765 * @ingroup hashmap
1766 * Get the number of key-value pairs in the map.
1767 *
1768 * @param map the map
1769 * @return the number of key value pairs
1770 */
1771unsigned int
1772GNUNET_CONTAINER_multiuuidmap_size (
1773 const struct GNUNET_CONTAINER_MultiUuidmap *map);
1774
1775
1776/**
1777 * @ingroup hashmap
1778 * Iterate over all entries in the map.
1779 *
1780 * @param map the map
1781 * @param it function to call on each entry
1782 * @param it_cls extra argument to @a it
1783 * @return the number of key value pairs processed,
1784 * #GNUNET_SYSERR if it aborted iteration
1785 */
1786int
1787GNUNET_CONTAINER_multiuuidmap_iterate (
1788 struct GNUNET_CONTAINER_MultiUuidmap *map,
1789 GNUNET_CONTAINER_MultiUuidmapIterator it,
1790 void *it_cls);
1791
1792
1793struct GNUNET_CONTAINER_MultiUuidmapIterator;
1794
1795
1796/**
1797 * @ingroup hashmap
1798 * Create an iterator for a multihashmap.
1799 * The iterator can be used to retrieve all the elements in the multihashmap
1800 * one by one, without having to handle all elements at once (in contrast to
1801 * #GNUNET_CONTAINER_multiuuidmap_iterate). Note that the iterator can not be
1802 * used anymore if elements have been removed from @a map after the creation of
1803 * the iterator, or 'map' has been destroyed. Adding elements to @a map may
1804 * result in skipped or repeated elements.
1805 *
1806 * @param map the map to create an iterator for
1807 * @return an iterator over the given multihashmap @a map
1808 */
1809struct GNUNET_CONTAINER_MultiUuidmapIterator *
1810GNUNET_CONTAINER_multiuuidmap_iterator_create (
1811 const struct GNUNET_CONTAINER_MultiUuidmap *map);
1812
1813
1814/**
1815 * @ingroup hashmap
1816 * Retrieve the next element from the hash map at the iterator's
1817 * position. If there are no elements left, #GNUNET_NO is returned,
1818 * and @a key and @a value are not modified. This operation is only
1819 * allowed if no elements have been removed from the multihashmap
1820 * since the creation of @a iter, and the map has not been destroyed.
1821 * Adding elements may result in repeating or skipping elements.
1822 *
1823 * @param iter the iterator to get the next element from
1824 * @param key pointer to store the key in, can be NULL
1825 * @param value pointer to store the value in, can be NULL
1826 * @return #GNUNET_YES we returned an element,
1827 * #GNUNET_NO if we are out of elements
1828 */
1829int
1830GNUNET_CONTAINER_multiuuidmap_iterator_next (
1831 struct GNUNET_CONTAINER_MultiUuidmapIterator *iter,
1832 struct GNUNET_Uuid *key,
1833 const void **value);
1834
1835
1836/**
1837 * @ingroup hashmap
1838 * Destroy a multiuuidmap iterator.
1839 *
1840 * @param iter the iterator to destroy
1841 */
1842void
1843GNUNET_CONTAINER_multiuuidmap_iterator_destroy (
1844 struct GNUNET_CONTAINER_MultiUuidmapIterator *iter);
1845
1846
1847/**
1848 * @ingroup hashmap
1849 * Iterate over all entries in the map that match a particular key.
1850 *
1851 * @param map the map
1852 * @param key public key that the entries must correspond to
1853 * @param it function to call on each entry
1854 * @param it_cls extra argument to @a it
1855 * @return the number of key value pairs processed,
1856 * #GNUNET_SYSERR if it aborted iteration
1857 */
1858int
1859GNUNET_CONTAINER_multiuuidmap_get_multiple (
1860 struct GNUNET_CONTAINER_MultiUuidmap *map,
1861 const struct GNUNET_Uuid *key,
1862 GNUNET_CONTAINER_MultiUuidmapIterator it,
1863 void *it_cls);
1864
1865
1866/**
1867 * @ingroup hashmap
1868 * Call @a it on a random value from the map, or not at all
1869 * if the map is empty. Note that this function has linear
1870 * complexity (in the size of the map).
1871 *
1872 * @param map the map
1873 * @param it function to call on a random entry
1874 * @param it_cls extra argument to @a it
1875 * @return the number of key value pairs processed, zero or one.
1876 */
1877unsigned int
1878GNUNET_CONTAINER_multiuuidmap_get_random (
1879 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1880 GNUNET_CONTAINER_MultiUuidmapIterator it,
1881 void *it_cls);
1555 1882
1556 1883
1557/* Version of multihashmap with 32 bit keys */ 1884/* Version of multihashmap with 32 bit keys */
@@ -1582,10 +1909,9 @@ struct GNUNET_CONTAINER_MultiHashMap32Iterator;
1582 * iterate, 1909 * iterate,
1583 * #GNUNET_NO if not. 1910 * #GNUNET_NO if not.
1584 */ 1911 */
1585typedef int 1912typedef int (*GNUNET_CONTAINER_HashMapIterator32) (void *cls,
1586(*GNUNET_CONTAINER_HashMapIterator32) (void *cls, 1913 uint32_t key,
1587 uint32_t key, 1914 void *value);
1588 void *value);
1589 1915
1590 1916
1591/** 1917/**
@@ -1607,7 +1933,8 @@ GNUNET_CONTAINER_multihashmap32_create (unsigned int len);
1607 * @param map the map 1933 * @param map the map
1608 */ 1934 */
1609void 1935void
1610GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashMap32 *map); 1936GNUNET_CONTAINER_multihashmap32_destroy (
1937 struct GNUNET_CONTAINER_MultiHashMap32 *map);
1611 1938
1612 1939
1613/** 1940/**
@@ -1618,8 +1945,8 @@ GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashMap32
1618 * @return the number of key value pairs 1945 * @return the number of key value pairs
1619 */ 1946 */
1620unsigned int 1947unsigned int
1621GNUNET_CONTAINER_multihashmap32_size (const struct 1948GNUNET_CONTAINER_multihashmap32_size (
1622 GNUNET_CONTAINER_MultiHashMap32 *map); 1949 const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1623 1950
1624 1951
1625/** 1952/**
@@ -1634,9 +1961,9 @@ GNUNET_CONTAINER_multihashmap32_size (const struct
1634 * key-value pairs with value NULL 1961 * key-value pairs with value NULL
1635 */ 1962 */
1636void * 1963void *
1637GNUNET_CONTAINER_multihashmap32_get (const struct 1964GNUNET_CONTAINER_multihashmap32_get (
1638 GNUNET_CONTAINER_MultiHashMap32 *map, 1965 const struct GNUNET_CONTAINER_MultiHashMap32 *map,
1639 uint32_t key); 1966 uint32_t key);
1640 1967
1641 1968
1642/** 1969/**
@@ -1650,9 +1977,10 @@ GNUNET_CONTAINER_multihashmap32_get (const struct
1650 * #GNUNET_SYSERR if it aborted iteration 1977 * #GNUNET_SYSERR if it aborted iteration
1651 */ 1978 */
1652int 1979int
1653GNUNET_CONTAINER_multihashmap32_iterate (struct GNUNET_CONTAINER_MultiHashMap32 *map, 1980GNUNET_CONTAINER_multihashmap32_iterate (
1654 GNUNET_CONTAINER_HashMapIterator32 it, 1981 struct GNUNET_CONTAINER_MultiHashMap32 *map,
1655 void *it_cls); 1982 GNUNET_CONTAINER_HashMapIterator32 it,
1983 void *it_cls);
1656 1984
1657 1985
1658/** 1986/**
@@ -1668,9 +1996,10 @@ GNUNET_CONTAINER_multihashmap32_iterate (struct GNUNET_CONTAINER_MultiHashMap32
1668 * is not in the map 1996 * is not in the map
1669 */ 1997 */
1670int 1998int
1671GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMap32 *map, 1999GNUNET_CONTAINER_multihashmap32_remove (
1672 uint32_t key, 2000 struct GNUNET_CONTAINER_MultiHashMap32 *map,
1673 const void *value); 2001 uint32_t key,
2002 const void *value);
1674 2003
1675 2004
1676/** 2005/**
@@ -1683,8 +2012,9 @@ GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMap32 *
1683 * @return number of values removed 2012 * @return number of values removed
1684 */ 2013 */
1685int 2014int
1686GNUNET_CONTAINER_multihashmap32_remove_all (struct GNUNET_CONTAINER_MultiHashMap32 *map, 2015GNUNET_CONTAINER_multihashmap32_remove_all (
1687 uint32_t key); 2016 struct GNUNET_CONTAINER_MultiHashMap32 *map,
2017 uint32_t key);
1688 2018
1689 2019
1690/** 2020/**
@@ -1698,8 +2028,9 @@ GNUNET_CONTAINER_multihashmap32_remove_all (struct GNUNET_CONTAINER_MultiHashMap
1698 * #GNUNET_NO if not 2028 * #GNUNET_NO if not
1699 */ 2029 */
1700int 2030int
1701GNUNET_CONTAINER_multihashmap32_contains (const struct GNUNET_CONTAINER_MultiHashMap32 *map, 2031GNUNET_CONTAINER_multihashmap32_contains (
1702 uint32_t key); 2032 const struct GNUNET_CONTAINER_MultiHashMap32 *map,
2033 uint32_t key);
1703 2034
1704 2035
1705/** 2036/**
@@ -1714,9 +2045,10 @@ GNUNET_CONTAINER_multihashmap32_contains (const struct GNUNET_CONTAINER_MultiHas
1714 * #GNUNET_NO if not 2045 * #GNUNET_NO if not
1715 */ 2046 */
1716int 2047int
1717GNUNET_CONTAINER_multihashmap32_contains_value (const struct GNUNET_CONTAINER_MultiHashMap32 *map, 2048GNUNET_CONTAINER_multihashmap32_contains_value (
1718 uint32_t key, 2049 const struct GNUNET_CONTAINER_MultiHashMap32 *map,
1719 const void *value); 2050 uint32_t key,
2051 const void *value);
1720 2052
1721 2053
1722/** 2054/**
@@ -1733,10 +2065,11 @@ GNUNET_CONTAINER_multihashmap32_contains_value (const struct GNUNET_CONTAINER_Mu
1733 * value already exists 2065 * value already exists
1734 */ 2066 */
1735int 2067int
1736GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32 *map, 2068GNUNET_CONTAINER_multihashmap32_put (
1737 uint32_t key, 2069 struct GNUNET_CONTAINER_MultiHashMap32 *map,
1738 void *value, 2070 uint32_t key,
1739 enum GNUNET_CONTAINER_MultiHashMapOption opt); 2071 void *value,
2072 enum GNUNET_CONTAINER_MultiHashMapOption opt);
1740 2073
1741 2074
1742/** 2075/**
@@ -1751,10 +2084,11 @@ GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32 *map
1751 * #GNUNET_SYSERR if it aborted iteration 2084 * #GNUNET_SYSERR if it aborted iteration
1752 */ 2085 */
1753int 2086int
1754GNUNET_CONTAINER_multihashmap32_get_multiple (struct GNUNET_CONTAINER_MultiHashMap32 *map, 2087GNUNET_CONTAINER_multihashmap32_get_multiple (
1755 uint32_t key, 2088 struct GNUNET_CONTAINER_MultiHashMap32 *map,
1756 GNUNET_CONTAINER_HashMapIterator32 it, 2089 uint32_t key,
1757 void *it_cls); 2090 GNUNET_CONTAINER_HashMapIterator32 it,
2091 void *it_cls);
1758 2092
1759 2093
1760/** 2094/**
@@ -1770,7 +2104,8 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (struct GNUNET_CONTAINER_MultiHashM
1770 * @return an iterator over the given multihashmap map 2104 * @return an iterator over the given multihashmap map
1771 */ 2105 */
1772struct GNUNET_CONTAINER_MultiHashMap32Iterator * 2106struct GNUNET_CONTAINER_MultiHashMap32Iterator *
1773GNUNET_CONTAINER_multihashmap32_iterator_create (const struct GNUNET_CONTAINER_MultiHashMap32 *map); 2107GNUNET_CONTAINER_multihashmap32_iterator_create (
2108 const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1774 2109
1775 2110
1776/** 2111/**
@@ -1788,9 +2123,10 @@ GNUNET_CONTAINER_multihashmap32_iterator_create (const struct GNUNET_CONTAINER_M
1788 * #GNUNET_NO if we are out of elements 2123 * #GNUNET_NO if we are out of elements
1789 */ 2124 */
1790int 2125int
1791GNUNET_CONTAINER_multihashmap32_iterator_next (struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, 2126GNUNET_CONTAINER_multihashmap32_iterator_next (
1792 uint32_t *key, 2127 struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter,
1793 const void **value); 2128 uint32_t *key,
2129 const void **value);
1794 2130
1795 2131
1796/** 2132/**
@@ -1799,7 +2135,8 @@ GNUNET_CONTAINER_multihashmap32_iterator_next (struct GNUNET_CONTAINER_MultiHash
1799 * @param iter the iterator to destroy 2135 * @param iter the iterator to destroy
1800 */ 2136 */
1801void 2137void
1802GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiHashMapIterator *iter); 2138GNUNET_CONTAINER_multihashmap32_iterator_destroy (
2139 struct GNUNET_CONTAINER_MultiHashMapIterator *iter);
1803 2140
1804 2141
1805/* ******************** doubly-linked list *************** */ 2142/* ******************** doubly-linked list *************** */
@@ -1814,16 +2151,19 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1814 * @param tail pointer to the tail of the DLL 2151 * @param tail pointer to the tail of the DLL
1815 * @param element element to insert 2152 * @param element element to insert
1816 */ 2153 */
1817#define GNUNET_CONTAINER_DLL_insert(head,tail,element) do { \ 2154#define GNUNET_CONTAINER_DLL_insert(head, tail, element) \
1818 GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ 2155 do \
1819 GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \ 2156 { \
1820 (element)->next = (head); \ 2157 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1821 (element)->prev = NULL; \ 2158 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1822 if ((tail) == NULL) \ 2159 (element)->next = (head); \
1823 (tail) = element; \ 2160 (element)->prev = NULL; \
1824 else \ 2161 if ((tail) == NULL) \
1825 (head)->prev = element; \ 2162 (tail) = element; \
1826 (head) = (element); } while (0) 2163 else \
2164 (head)->prev = element; \
2165 (head) = (element); \
2166 } while (0)
1827 2167
1828 2168
1829/** 2169/**
@@ -1835,16 +2175,19 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1835 * @param tail pointer to the tail of the DLL 2175 * @param tail pointer to the tail of the DLL
1836 * @param element element to insert 2176 * @param element element to insert
1837 */ 2177 */
1838#define GNUNET_CONTAINER_DLL_insert_tail(head,tail,element) do { \ 2178#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element) \
1839 GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ 2179 do \
1840 GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \ 2180 { \
1841 (element)->prev = (tail); \ 2181 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1842 (element)->next = NULL; \ 2182 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1843 if ((head) == NULL) \ 2183 (element)->prev = (tail); \
1844 (head) = element; \ 2184 (element)->next = NULL; \
1845 else \ 2185 if ((head) == NULL) \
1846 (tail)->next = element; \ 2186 (head) = element; \
1847 (tail) = (element); } while (0) 2187 else \
2188 (tail)->next = element; \
2189 (tail) = (element); \
2190 } while (0)
1848 2191
1849 2192
1850/** 2193/**
@@ -1857,24 +2200,27 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1857 * @param other prior element, NULL for insertion at head of DLL 2200 * @param other prior element, NULL for insertion at head of DLL
1858 * @param element element to insert 2201 * @param element element to insert
1859 */ 2202 */
1860#define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) do { \ 2203#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element) \
1861 GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ 2204 do \
1862 GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \ 2205 { \
1863 (element)->prev = (other); \ 2206 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1864 if (NULL == other) \ 2207 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1865 { \ 2208 (element)->prev = (other); \
1866 (element)->next = (head); \ 2209 if (NULL == other) \
1867 (head) = (element); \ 2210 { \
1868 } \ 2211 (element)->next = (head); \
1869 else \ 2212 (head) = (element); \
1870 { \ 2213 } \
1871 (element)->next = (other)->next; \ 2214 else \
1872 (other)->next = (element); \ 2215 { \
1873 } \ 2216 (element)->next = (other)->next; \
1874 if (NULL == (element)->next) \ 2217 (other)->next = (element); \
1875 (tail) = (element); \ 2218 } \
1876 else \ 2219 if (NULL == (element)->next) \
1877 (element)->next->prev = (element); } while (0) 2220 (tail) = (element); \
2221 else \
2222 (element)->next->prev = (element); \
2223 } while (0)
1878 2224
1879 2225
1880/** 2226/**
@@ -1887,24 +2233,27 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1887 * @param other prior element, NULL for insertion at head of DLL 2233 * @param other prior element, NULL for insertion at head of DLL
1888 * @param element element to insert 2234 * @param element element to insert
1889 */ 2235 */
1890#define GNUNET_CONTAINER_DLL_insert_before(head,tail,other,element) do { \ 2236#define GNUNET_CONTAINER_DLL_insert_before(head, tail, other, element) \
1891 GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ 2237 do \
1892 GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \ 2238 { \
1893 (element)->next = (other); \ 2239 GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1894 if (NULL == other) \ 2240 GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1895 { \ 2241 (element)->next = (other); \
1896 (element)->prev = (tail); \ 2242 if (NULL == other) \
1897 (tail) = (element); \ 2243 { \
1898 } \ 2244 (element)->prev = (tail); \
1899 else \ 2245 (tail) = (element); \
1900 { \ 2246 } \
1901 (element)->prev = (other)->prev; \ 2247 else \
1902 (other)->prev = (element); \ 2248 { \
1903 } \ 2249 (element)->prev = (other)->prev; \
1904 if (NULL == (element)->prev) \ 2250 (other)->prev = (element); \
1905 (head) = (element); \ 2251 } \
1906 else \ 2252 if (NULL == (element)->prev) \
1907 (element)->prev->next = (element); } while (0) 2253 (head) = (element); \
2254 else \
2255 (element)->prev->next = (element); \
2256 } while (0)
1908 2257
1909 2258
1910/** 2259/**
@@ -1921,19 +2270,22 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1921 * @param tail pointer to the tail of the DLL 2270 * @param tail pointer to the tail of the DLL
1922 * @param element element to remove 2271 * @param element element to remove
1923 */ 2272 */
1924#define GNUNET_CONTAINER_DLL_remove(head,tail,element) do { \ 2273#define GNUNET_CONTAINER_DLL_remove(head, tail, element) \
1925 GNUNET_assert ( ( (element)->prev != NULL) || ((head) == (element))); \ 2274 do \
1926 GNUNET_assert ( ( (element)->next != NULL) || ((tail) == (element))); \ 2275 { \
1927 if ((element)->prev == NULL) \ 2276 GNUNET_assert (((element)->prev != NULL) || ((head) == (element))); \
1928 (head) = (element)->next; \ 2277 GNUNET_assert (((element)->next != NULL) || ((tail) == (element))); \
1929 else \ 2278 if ((element)->prev == NULL) \
1930 (element)->prev->next = (element)->next; \ 2279 (head) = (element)->next; \
1931 if ((element)->next == NULL) \ 2280 else \
1932 (tail) = (element)->prev; \ 2281 (element)->prev->next = (element)->next; \
1933 else \ 2282 if ((element)->next == NULL) \
1934 (element)->next->prev = (element)->prev; \ 2283 (tail) = (element)->prev; \
1935 (element)->next = NULL; \ 2284 else \
1936 (element)->prev = NULL; } while (0) 2285 (element)->next->prev = (element)->prev; \
2286 (element)->next = NULL; \
2287 (element)->prev = NULL; \
2288 } while (0)
1937 2289
1938 2290
1939/* ************ Multi-DLL interface, allows DLL elements to be 2291/* ************ Multi-DLL interface, allows DLL elements to be
@@ -1949,16 +2301,19 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1949 * @param tail pointer to the tail of the MDLL 2301 * @param tail pointer to the tail of the MDLL
1950 * @param element element to insert 2302 * @param element element to insert
1951 */ 2303 */
1952#define GNUNET_CONTAINER_MDLL_insert(mdll,head,tail,element) do { \ 2304#define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element) \
1953 GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element))); \ 2305 do \
1954 GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element))); \ 2306 { \
1955 (element)->next_##mdll = (head); \ 2307 GNUNET_assert (((element)->prev_##mdll == NULL) && ((head) != (element))); \
1956 (element)->prev_##mdll = NULL; \ 2308 GNUNET_assert (((element)->next_##mdll == NULL) && ((tail) != (element))); \
1957 if ((tail) == NULL) \ 2309 (element)->next_##mdll = (head); \
1958 (tail) = element; \ 2310 (element)->prev_##mdll = NULL; \
1959 else \ 2311 if ((tail) == NULL) \
1960 (head)->prev_##mdll = element; \ 2312 (tail) = element; \
1961 (head) = (element); } while (0) 2313 else \
2314 (head)->prev_##mdll = element; \
2315 (head) = (element); \
2316 } while (0)
1962 2317
1963 2318
1964/** 2319/**
@@ -1971,16 +2326,19 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1971 * @param tail pointer to the tail of the MDLL 2326 * @param tail pointer to the tail of the MDLL
1972 * @param element element to insert 2327 * @param element element to insert
1973 */ 2328 */
1974#define GNUNET_CONTAINER_MDLL_insert_tail(mdll,head,tail,element) do { \ 2329#define GNUNET_CONTAINER_MDLL_insert_tail(mdll, head, tail, element) \
1975 GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element))); \ 2330 do \
1976 GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element))); \ 2331 { \
1977 (element)->prev_##mdll = (tail); \ 2332 GNUNET_assert (((element)->prev_##mdll == NULL) && ((head) != (element))); \
1978 (element)->next_##mdll = NULL; \ 2333 GNUNET_assert (((element)->next_##mdll == NULL) && ((tail) != (element))); \
1979 if ((head) == NULL) \ 2334 (element)->prev_##mdll = (tail); \
1980 (head) = element; \ 2335 (element)->next_##mdll = NULL; \
1981 else \ 2336 if ((head) == NULL) \
1982 (tail)->next_##mdll = element; \ 2337 (head) = element; \
1983 (tail) = (element); } while (0) 2338 else \
2339 (tail)->next_##mdll = element; \
2340 (tail) = (element); \
2341 } while (0)
1984 2342
1985 2343
1986/** 2344/**
@@ -1994,24 +2352,27 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
1994 * @param other prior element, NULL for insertion at head of MDLL 2352 * @param other prior element, NULL for insertion at head of MDLL
1995 * @param element element to insert 2353 * @param element element to insert
1996 */ 2354 */
1997#define GNUNET_CONTAINER_MDLL_insert_after(mdll,head,tail,other,element) do { \ 2355#define GNUNET_CONTAINER_MDLL_insert_after(mdll, head, tail, other, element) \
1998 GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element))); \ 2356 do \
1999 GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element))); \ 2357 { \
2000 (element)->prev_##mdll = (other); \ 2358 GNUNET_assert (((element)->prev_##mdll == NULL) && ((head) != (element))); \
2001 if (NULL == other) \ 2359 GNUNET_assert (((element)->next_##mdll == NULL) && ((tail) != (element))); \
2002 { \ 2360 (element)->prev_##mdll = (other); \
2003 (element)->next_##mdll = (head); \ 2361 if (NULL == other) \
2004 (head) = (element); \ 2362 { \
2005 } \ 2363 (element)->next_##mdll = (head); \
2006 else \ 2364 (head) = (element); \
2007 { \ 2365 } \
2008 (element)->next_##mdll = (other)->next_##mdll; \ 2366 else \
2009 (other)->next_##mdll = (element); \ 2367 { \
2010 } \ 2368 (element)->next_##mdll = (other)->next_##mdll; \
2011 if (NULL == (element)->next_##mdll) \ 2369 (other)->next_##mdll = (element); \
2012 (tail) = (element); \ 2370 } \
2013 else \ 2371 if (NULL == (element)->next_##mdll) \
2014 (element)->next_##mdll->prev_##mdll = (element); } while (0) 2372 (tail) = (element); \
2373 else \
2374 (element)->next_##mdll->prev_##mdll = (element); \
2375 } while (0)
2015 2376
2016 2377
2017/** 2378/**
@@ -2025,24 +2386,27 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
2025 * @param other prior element, NULL for insertion at head of MDLL 2386 * @param other prior element, NULL for insertion at head of MDLL
2026 * @param element element to insert 2387 * @param element element to insert
2027 */ 2388 */
2028#define GNUNET_CONTAINER_MDLL_insert_before(mdll,head,tail,other,element) do { \ 2389#define GNUNET_CONTAINER_MDLL_insert_before(mdll, head, tail, other, element) \
2029 GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element))); \ 2390 do \
2030 GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element))); \ 2391 { \
2031 (element)->next_##mdll = (other); \ 2392 GNUNET_assert (((element)->prev_##mdll == NULL) && ((head) != (element))); \
2032 if (NULL == other) \ 2393 GNUNET_assert (((element)->next_##mdll == NULL) && ((tail) != (element))); \
2033 { \ 2394 (element)->next_##mdll = (other); \
2034 (element)->prev = (tail); \ 2395 if (NULL == other) \
2035 (tail) = (element); \ 2396 { \
2036 } \ 2397 (element)->prev = (tail); \
2037 else \ 2398 (tail) = (element); \
2038 { \ 2399 } \
2039 (element)->prev_##mdll = (other)->prev_##mdll; \ 2400 else \
2040 (other)->prev_##mdll = (element); \ 2401 { \
2041 } \ 2402 (element)->prev_##mdll = (other)->prev_##mdll; \
2042 if (NULL == (element)->prev_##mdll) \ 2403 (other)->prev_##mdll = (element); \
2043 (head) = (element); \ 2404 } \
2044 else \ 2405 if (NULL == (element)->prev_##mdll) \
2045 (element)->prev_##mdll->next_##mdll = (element); } while (0) 2406 (head) = (element); \
2407 else \
2408 (element)->prev_##mdll->next_##mdll = (element); \
2409 } while (0)
2046 2410
2047 2411
2048/** 2412/**
@@ -2056,20 +2420,22 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
2056 * @param tail pointer to the tail of the MDLL 2420 * @param tail pointer to the tail of the MDLL
2057 * @param element element to remove 2421 * @param element element to remove
2058 */ 2422 */
2059#define GNUNET_CONTAINER_MDLL_remove(mdll,head,tail,element) do { \ 2423#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element) \
2060 GNUNET_assert ( ( (element)->prev_##mdll != NULL) || ((head) == (element))); \ 2424 do \
2061 GNUNET_assert ( ( (element)->next_##mdll != NULL) || ((tail) == (element))); \ 2425 { \
2062 if ((element)->prev_##mdll == NULL) \ 2426 GNUNET_assert (((element)->prev_##mdll != NULL) || ((head) == (element))); \
2063 (head) = (element)->next_##mdll; \ 2427 GNUNET_assert (((element)->next_##mdll != NULL) || ((tail) == (element))); \
2064 else \ 2428 if ((element)->prev_##mdll == NULL) \
2065 (element)->prev_##mdll->next_##mdll = (element)->next_##mdll; \ 2429 (head) = (element)->next_##mdll; \
2066 if ((element)->next_##mdll == NULL) \ 2430 else \
2067 (tail) = (element)->prev_##mdll; \ 2431 (element)->prev_##mdll->next_##mdll = (element)->next_##mdll; \
2068 else \ 2432 if ((element)->next_##mdll == NULL) \
2069 (element)->next_##mdll->prev_##mdll = (element)->prev_##mdll; \ 2433 (tail) = (element)->prev_##mdll; \
2070 (element)->next_##mdll = NULL; \ 2434 else \
2071 (element)->prev_##mdll = NULL; } while (0) 2435 (element)->next_##mdll->prev_##mdll = (element)->prev_##mdll; \
2072 2436 (element)->next_##mdll = NULL; \
2437 (element)->prev_##mdll = NULL; \
2438 } while (0)
2073 2439
2074 2440
2075/** 2441/**
@@ -2085,44 +2451,36 @@ GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiH
2085 * @param[in,out] tail tail of DLL 2451 * @param[in,out] tail tail of DLL
2086 * @param element element to insert 2452 * @param element element to insert
2087 */ 2453 */
2088#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE,comparator,comparator_cls,head,tail,element) do { \ 2454#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, \
2089 if ( (NULL == head) || \ 2455 comparator, \
2090 (0 < comparator (comparator_cls, \ 2456 comparator_cls, \
2091 element, \ 2457 head, \
2092 head)) ) \ 2458 tail, \
2093 { \ 2459 element) \
2094 /* insert at head, element < head */ \ 2460 do \
2095 GNUNET_CONTAINER_DLL_insert (head, \ 2461 { \
2096 tail, \ 2462 if ((NULL == head) || (0 < comparator (comparator_cls, element, head))) \
2097 element); \ 2463 { \
2098 } \ 2464 /* insert at head, element < head */ \
2099 else \ 2465 GNUNET_CONTAINER_DLL_insert (head, tail, element); \
2100 { \ 2466 } \
2101 TYPE *pos; \ 2467 else \
2102 \ 2468 { \
2103 for (pos = head; \ 2469 TYPE *pos; \
2104 NULL != pos; \ 2470 \
2105 pos = pos->next) \ 2471 for (pos = head; NULL != pos; pos = pos->next) \
2106 if (0 < \ 2472 if (0 < comparator (comparator_cls, element, pos)) \
2107 comparator (comparator_cls, \ 2473 break; /* element < pos */ \
2108 element, \ 2474 if (NULL == pos) /* => element > tail */ \
2109 pos)) \ 2475 { \
2110 break; /* element < pos */ \ 2476 GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); \
2111 if (NULL == pos) /* => element > tail */ \ 2477 } \
2112 { \ 2478 else /* prev < element < pos */ \
2113 GNUNET_CONTAINER_DLL_insert_tail (head, \ 2479 { \
2114 tail, \ 2480 GNUNET_CONTAINER_DLL_insert_after (head, tail, pos->prev, element); \
2115 element); \ 2481 } \
2116 } \ 2482 } \
2117 else /* prev < element < pos */ \ 2483 } while (0)
2118 { \
2119 GNUNET_CONTAINER_DLL_insert_after (head, \
2120 tail, \
2121 pos->prev, \
2122 element); \
2123 } \
2124 } \
2125} while (0)
2126 2484
2127 2485
2128/* ******************** Heap *************** */ 2486/* ******************** Heap *************** */
@@ -2236,7 +2594,8 @@ GNUNET_CONTAINER_heap_get_size (const struct GNUNET_CONTAINER_Heap *heap);
2236 * @return cost of the node 2594 * @return cost of the node
2237 */ 2595 */
2238GNUNET_CONTAINER_HeapCostType 2596GNUNET_CONTAINER_HeapCostType
2239GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode *node); 2597GNUNET_CONTAINER_heap_node_get_cost (
2598 const struct GNUNET_CONTAINER_HeapNode *node);
2240 2599
2241 2600
2242/** 2601/**
@@ -2250,11 +2609,11 @@ GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode *nod
2250 * @return #GNUNET_YES if we should continue to iterate, 2609 * @return #GNUNET_YES if we should continue to iterate,
2251 * #GNUNET_NO if not. 2610 * #GNUNET_NO if not.
2252 */ 2611 */
2253typedef int 2612typedef int (*GNUNET_CONTAINER_HeapIterator) (
2254(*GNUNET_CONTAINER_HeapIterator) (void *cls, 2613 void *cls,
2255 struct GNUNET_CONTAINER_HeapNode *node, 2614 struct GNUNET_CONTAINER_HeapNode *node,
2256 void *element, 2615 void *element,
2257 GNUNET_CONTAINER_HeapCostType cost); 2616 GNUNET_CONTAINER_HeapCostType cost);
2258 2617
2259 2618
2260/** 2619/**
@@ -2335,7 +2694,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_HeapNode *node,
2335 GNUNET_CONTAINER_HeapCostType new_cost); 2694 GNUNET_CONTAINER_HeapCostType new_cost);
2336 2695
2337 2696
2338#if 0 /* keep Emacsens' auto-indent happy */ 2697#if 0 /* keep Emacsens' auto-indent happy */
2339{ 2698{
2340#endif 2699#endif
2341#ifdef __cplusplus 2700#ifdef __cplusplus