2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_container_lib.h
23 * @brief container classes for GNUnet
25 * @author Christian Grothoff
29 #ifndef GNUNET_CONTAINER_LIB_H
30 #define GNUNET_CONTAINER_LIB_H
32 /* add error and config prototypes */
33 #include "gnunet_crypto_lib.h"
34 #include <extractor.h>
39 #if 0 /* keep Emacsens' auto-indent happy */
45 /* ******************* bloomfilter ***************** */
48 * @brief bloomfilter representation (opaque)
50 struct GNUNET_CONTAINER_BloomFilter;
53 * Iterator over HashCodes.
56 * @param next set to the next hash code
57 * @return GNUNET_YES if next was updated
58 * GNUNET_NO if there are no more entries
60 typedef int (*GNUNET_HashCodeIterator) (void *cls,
61 GNUNET_HashCode * next);
64 * Load a bloom-filter from a file.
66 * @param filename the name of the file (or the prefix)
67 * @param size the size of the bloom-filter (number of
68 * bytes of storage space to use)
69 * @param k the number of GNUNET_CRYPTO_hash-functions to apply per
70 * element (number of bits set per element in the set)
71 * @return the bloomfilter
73 struct GNUNET_CONTAINER_BloomFilter *
74 GNUNET_CONTAINER_bloomfilter_load (const
84 * Create a bloom filter from raw bits.
86 * @param data the raw bits in memory (maybe NULL,
87 * in which case all bits should be considered
89 * @param size the size of the bloom-filter (number of
90 * bytes of storage space to use); also size of data
91 * -- unless data is NULL. Must be a power of 2.
92 * @param k the number of GNUNET_CRYPTO_hash-functions to apply per
93 * element (number of bits set per element in the set)
94 * @return the bloomfilter
96 struct GNUNET_CONTAINER_BloomFilter *
97 GNUNET_CONTAINER_bloomfilter_init (const
107 * Copy the raw data of this bloomfilter into
108 * the given data array.
110 * @param data where to write the data
111 * @param size the size of the given data array
112 * @return GNUNET_SYSERR if the data array of the wrong size
114 int GNUNET_CONTAINER_bloomfilter_get_raw_data (struct
115 GNUNET_CONTAINER_BloomFilter
120 * Test if an element is in the filter.
121 * @param e the element
122 * @param bf the filter
123 * @return GNUNET_YES if the element is in the filter, GNUNET_NO if not
125 int GNUNET_CONTAINER_bloomfilter_test (struct GNUNET_CONTAINER_BloomFilter
126 *bf, const GNUNET_HashCode * e);
129 * Add an element to the filter
130 * @param bf the filter
131 * @param e the element
133 void GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter
134 *bf, const GNUNET_HashCode * e);
137 * Remove an element from the filter.
138 * @param bf the filter
139 * @param e the element to remove
141 void GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter
142 *bf, const GNUNET_HashCode * e);
145 * Free the space associcated with a filter
146 * in memory, flush to drive if needed (do not
147 * free the space on the drive)
148 * @param bf the filter
150 void GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter
154 * Reset a bloom filter to empty.
155 * @param bf the filter
157 void GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter
161 * Or the entries of the given raw data array with the
162 * data of the given bloom filter. Assumes that
163 * the size of the data array and the current filter
166 * @param bf the filter
167 * @param data data to OR-in
168 * @param size size of data
169 * @return GNUNET_OK on success
171 int GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
172 const char *data, size_t size);
175 * Resize a bloom filter. Note that this operation
176 * is pretty costly. Essentially, the bloom filter
177 * needs to be completely re-build.
179 * @param bf the filter
180 * @param iterator an iterator over all elements stored in the BF
181 * @param iterator_cls closure for iterator
182 * @param size the new size for the filter
183 * @param k the new number of GNUNET_CRYPTO_hash-function to apply per element
185 void GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter
187 GNUNET_HashCodeIterator iterator,
189 size_t size, unsigned int k);
191 /* ****************** metadata ******************* */
194 * Meta data to associate with a file, directory or namespace.
196 struct GNUNET_CONTAINER_MetaData;
199 * Create a fresh MetaData token.
201 * @return empty meta-data container
203 struct GNUNET_CONTAINER_MetaData *
204 GNUNET_CONTAINER_meta_data_create (void);
207 * Duplicate a MetaData token.
209 * @param md what to duplicate
210 * @return duplicate meta-data container
212 struct GNUNET_CONTAINER_MetaData *
213 GNUNET_CONTAINER_meta_data_duplicate (const struct
214 GNUNET_CONTAINER_MetaData *md);
219 * @param md what to free
222 GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
225 * Test if two MDs are equal. We consider them equal if
226 * the meta types, formats and content match (we do not
227 * include the mime types and plugins names in this
230 * @param md1 first value to check
231 * @param md2 other value to check
232 * @return GNUNET_YES if they are equal
235 GNUNET_CONTAINER_meta_data_test_equal (const struct
236 GNUNET_CONTAINER_MetaData *md1,
238 GNUNET_CONTAINER_MetaData *md2);
244 * @param md metadata to extend
245 * @param plugin_name name of the plugin that produced this value;
246 * special values can be used (i.e. '<zlib>' for zlib being
247 * used in the main libextractor library and yielding
249 * @param type libextractor-type describing the meta data
250 * @param format basic format information about data
251 * @param data_mime_type mime-type of data (not of the original file);
252 * can be NULL (if mime-type is not known)
253 * @param data actual meta-data found
254 * @param data_len number of bytes in data
255 * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists
256 * data_mime_type and plugin_name are not considered for "exists" checks
259 GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
260 const char *plugin_name,
261 enum EXTRACTOR_MetaType type,
262 enum EXTRACTOR_MetaFormat format,
263 const char *data_mime_type,
271 * @param md metadata to manipulate
272 * @param type type of the item to remove
273 * @param data specific value to remove, NULL to remove all
274 * entries of the given type
275 * @param data_len number of bytes in data
276 * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md
279 GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
280 enum EXTRACTOR_MetaType type,
286 * Add the current time as the publication date
289 * @param md metadata to modify
292 GNUNET_CONTAINER_meta_data_add_publication_date (struct
293 GNUNET_CONTAINER_MetaData
298 * Iterate over MD entries.
300 * @param md metadata to inspect
301 * @param iter function to call on each entry
302 * @param iter_cls closure for iterator
303 * @return number of entries
305 int GNUNET_CONTAINER_meta_data_iterate (const struct
306 GNUNET_CONTAINER_MetaData *md,
307 EXTRACTOR_MetaDataProcessor
308 iter, void *iter_cls);
311 * Get the first MD entry of the given type. Caller
312 * is responsible for freeing the return value.
313 * Also, only meta data items that are strings (0-terminated)
314 * are returned by this function.
316 * @param md metadata to inspect
317 * @param type type to look for
318 * @return NULL if no entry was found
321 GNUNET_CONTAINER_meta_data_get_by_type (const struct
322 GNUNET_CONTAINER_MetaData *md,
323 enum EXTRACTOR_MetaType type);
327 * Get the first matching MD entry of the given types. Caller is
328 * responsible for freeing the return value. Also, only meta data
329 * items that are strings (0-terminated) are returned by this
332 * @param md metadata to inspect
333 * @param ... -1-terminated list of types
334 * @return NULL if we do not have any such entry,
335 * otherwise client is responsible for freeing the value!
338 GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
339 GNUNET_CONTAINER_MetaData
343 * Get a thumbnail from the meta-data (if present). Only matches meta
344 * data with mime type "image" and binary format.
346 * @param md metadata to inspect
347 * @param thumb will be set to the thumbnail data. Must be
348 * freed by the caller!
349 * @return number of bytes in thumbnail, 0 if not available
352 GNUNET_CONTAINER_meta_data_get_thumbnail (const struct
353 GNUNET_CONTAINER_MetaData
354 *md, unsigned char **thumb);
357 * Extract meta-data from a file.
359 * @param md metadata to set
360 * @param filename name of file to inspect
361 * @param extractors plugins to use
362 * @return GNUNET_SYSERR on error, otherwise the number
363 * of meta-data items obtained
366 GNUNET_CONTAINER_meta_data_extract_from_file (struct
367 GNUNET_CONTAINER_MetaData
368 *md, const char *filename,
369 struct EXTRACTOR_PluginList *
374 * Options for metadata serialization.
376 enum GNUNET_CONTAINER_MetaDataSerializationOptions
379 * Serialize all of the data.
381 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0,
384 * If not enough space is available, it is acceptable
385 * to only serialize some of the metadata.
387 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1,
390 * Speed is of the essence, do not allow compression.
392 GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2
397 * Serialize meta-data to target.
399 * @param md metadata to serialize
400 * @param target where to write the serialized metadata;
401 * *target can be NULL, in which case memory is allocated
402 * @param max maximum number of bytes available
403 * @param opt is it ok to just write SOME of the
404 * meta-data to match the size constraint,
405 * possibly discarding some data?
406 * @return number of bytes written on success,
407 * -1 on error (typically: not enough
410 ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct
411 GNUNET_CONTAINER_MetaData *md,
415 GNUNET_CONTAINER_MetaDataSerializationOptions
420 * Get the size of the full meta-data in serialized form.
422 * @param md metadata to inspect
423 * @return number of bytes needed for serialization, -1 on error
425 ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
426 GNUNET_CONTAINER_MetaData
431 * Deserialize meta-data. Initializes md.
433 * @param input serialized meta-data.
434 * @param size number of bytes available
435 * @return MD on success, NULL on error (i.e.
438 struct GNUNET_CONTAINER_MetaData
439 *GNUNET_CONTAINER_meta_data_deserialize (const char *input,
443 /* ******************************* HashMap **************************** */
446 * Opaque handle for a HashMap.
448 struct GNUNET_CONTAINER_MultiHashMap;
451 * Options for storing values in the HashMap.
453 enum GNUNET_CONTAINER_MultiHashMapOption
457 * If a value with the given key exists, replace it. Note that the
458 * old value would NOT be freed by replace (the application has to
459 * make sure that this happens if required).
461 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE,
464 * Allow multiple values with the same key.
466 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE,
469 * There must only be one value per key; storing a value should fail
470 * if a value under the same key already exists.
472 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY,
475 * There must only be one value per key, but don't bother checking
476 * if a value already exists (faster than UNIQUE_ONLY; implemented
477 * just like MULTIPLE but this option documents better what is
478 * intended if UNIQUE is what is desired).
480 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
485 * Iterator over hash map entries.
488 * @param key current key code
489 * @param value value in the hash map
490 * @return GNUNET_YES if we should continue to
494 typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls,
495 const GNUNET_HashCode * key,
500 * Create a multi hash map.
502 * @param len initial size (map will grow as needed)
503 * @return NULL on error
505 struct GNUNET_CONTAINER_MultiHashMap
506 *GNUNET_CONTAINER_multihashmap_create (unsigned int len);
510 * Destroy a hash map. Will not free any values
511 * stored in the hash map!
515 void GNUNET_CONTAINER_multihashmap_destroy (struct
516 GNUNET_CONTAINER_MultiHashMap
521 * Given a key find a value in the map matching the key.
524 * @param key what to look for
525 * @return NULL if no value was found; note that
526 * this is indistinguishable from values that just
527 * happen to be NULL; use "contains" to test for
528 * key-value pairs with value NULL
530 void *GNUNET_CONTAINER_multihashmap_get (const struct
531 GNUNET_CONTAINER_MultiHashMap *map,
532 const GNUNET_HashCode * key);
536 * Remove the given key-value pair from the map. Note that if the
537 * key-value pair is in the map multiple times, only one of the pairs
541 * @param key key of the key-value pair
542 * @param value value of the key-value pair
543 * @return GNUNET_YES on success, GNUNET_NO if the key-value pair
546 int GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap
547 *map, const GNUNET_HashCode * key,
551 * Remove all entries for the given key from the map.
552 * Note that the values would not be "freed".
555 * @param key identifies values to be removed
556 * @return number of values removed
558 int GNUNET_CONTAINER_multihashmap_remove_all (struct
559 GNUNET_CONTAINER_MultiHashMap
561 const GNUNET_HashCode * key);
565 * Check if the map contains any value under the given
566 * key (including values that are NULL).
569 * @param key the key to test if a value exists for it
570 * @return GNUNET_YES if such a value exists,
573 int GNUNET_CONTAINER_multihashmap_contains (const struct
574 GNUNET_CONTAINER_MultiHashMap
576 const GNUNET_HashCode * key);
580 * Store a key-value pair in the map.
583 * @param key key to use
584 * @param value value to use
585 * @param opt options for put
586 * @return GNUNET_OK on success,
587 * GNUNET_NO if a value was replaced (with REPLACE)
588 * GNUNET_SYSERR if UNIQUE_ONLY was the option and the
589 * value already exists
591 int GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap
592 *map, const GNUNET_HashCode * key,
595 GNUNET_CONTAINER_MultiHashMapOption
599 * Get the number of key-value pairs in the map.
602 * @return the number of key value pairs
604 unsigned int GNUNET_CONTAINER_multihashmap_size (const struct
605 GNUNET_CONTAINER_MultiHashMap
610 * Iterate over all entries in the map.
613 * @param it function to call on each entry
614 * @param it_cls extra argument to it
615 * @return the number of key value pairs processed,
616 * GNUNET_SYSERR if it aborted iteration
618 int GNUNET_CONTAINER_multihashmap_iterate (const struct
619 GNUNET_CONTAINER_MultiHashMap *map,
620 GNUNET_CONTAINER_HashMapIterator
625 * Iterate over all entries in the map that match a particular key.
628 * @param key key that the entries must correspond to
629 * @param it function to call on each entry
630 * @param it_cls extra argument to it
631 * @return the number of key value pairs processed,
632 * GNUNET_SYSERR if it aborted iteration
634 int GNUNET_CONTAINER_multihashmap_get_multiple (const struct
635 GNUNET_CONTAINER_MultiHashMap
637 const GNUNET_HashCode * key,
638 GNUNET_CONTAINER_HashMapIterator
642 /* ******************** doubly-linked list *************** */
645 * Insert an element at the head of a DLL. Assumes that head, tail and
646 * element are structs with prev and next fields.
648 * @param head pointer to the head of the DLL
649 * @param tail pointer to the tail of the DLL
650 * @param element element to insert
652 #define GNUNET_CONTAINER_DLL_insert(head,tail,element) do { \
653 (element)->next = (head); \
654 (element)->prev = NULL; \
655 if ((tail) == NULL) \
658 (head)->prev = element; \
659 (head) = (element); } while (0)
662 * Insert an element into a DLL after the given other element. Insert
663 * at the head if the other element is NULL.
665 * @param head pointer to the head of the DLL
666 * @param tail pointer to the tail of the DLL
667 * @param other prior element, NULL for insertion at head of DLL
668 * @param element element to insert
670 #define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) do { \
671 (element)->prev = (other); \
674 (element)->next = (head); \
675 (head) = (element); \
679 (element)->next = (other)->next; \
680 (other)->next = (element); \
682 if (NULL == (element)->next) \
683 (tail) = (element); \
685 (element)->next->prev = (element); } while (0)
691 * Remove an element from a DLL. Assumes
692 * that head, tail and element are structs
693 * with prev and next fields.
695 * @param head pointer to the head of the DLL
696 * @param tail pointer to the tail of the DLL
697 * @param element element to remove
699 #define GNUNET_CONTAINER_DLL_remove(head,tail,element) do { \
700 if ((element)->prev == NULL) \
701 (head) = (element)->next; \
703 (element)->prev->next = (element)->next; \
704 if ((element)->next == NULL) \
705 (tail) = (element)->prev; \
707 (element)->next->prev = (element)->prev; } while (0)
711 /* ******************** Heap *************** */
715 * Cost by which elements in a heap can be ordered.
717 typedef uint64_t GNUNET_CONTAINER_HeapCostType;
721 * Heap type, either max or min. Hopefully makes the
722 * implementation more useful.
724 enum GNUNET_CONTAINER_HeapOrder
727 * Heap with the maximum cost at the root.
729 GNUNET_CONTAINER_HEAP_ORDER_MAX,
732 * Heap with the minimum cost at the root.
734 GNUNET_CONTAINER_HEAP_ORDER_MIN
741 struct GNUNET_CONTAINER_Heap;
746 * Handle to a node in a heap.
748 struct GNUNET_CONTAINER_HeapNode;
754 * @param order how should the heap be sorted?
755 * @return handle to the heap
757 struct GNUNET_CONTAINER_Heap *
758 GNUNET_CONTAINER_heap_create (enum GNUNET_CONTAINER_HeapOrder order);
762 * Destroys the heap. Only call on a heap that
765 * @param heap heap to destroy
767 void GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *heap);
771 * Get element stored at root of heap.
773 * @param heap heap to inspect
774 * @return NULL if heap is empty
777 GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap);
781 * Get the current size of the heap
783 * @param heap the heap to get the size of
784 * @return number of elements stored
787 GNUNET_CONTAINER_heap_get_size (const struct GNUNET_CONTAINER_Heap *heap);
794 * @param node internal node of the heap
795 * @param element value stored at the node
796 * @param cost cost associated with the node
797 * @return GNUNET_YES if we should continue to iterate,
800 typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls,
801 struct GNUNET_CONTAINER_HeapNode *node,
803 GNUNET_CONTAINER_HeapCostType cost);
807 * Iterate over all entries in the heap.
809 * @param heap the heap
810 * @param iterator function to call on each entry
811 * @param iterator_cls closure for iterator
814 GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap,
815 GNUNET_CONTAINER_HeapIterator iterator,
820 * Return a *uniform* random element from the heap. Choose a random
821 * number between 0 and heap size and then walk directly to it.
822 * This cost can be between 0 and n, amortized cost of logN.
824 * @param heap heap to choose random element from
825 * @param max how many nodes from the heap to choose from
827 * @return data stored at the chosen random node,
828 * NULL if the heap is empty.
832 GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap, uint32_t max);
835 * Perform a random walk of the tree. The walk is biased
836 * towards elements closer to the root of the tree (since
837 * each walk starts at the root and ends at a random leaf).
838 * The heap internally tracks the current position of the
841 * @param heap heap to walk
842 * @return data stored at the next random node in the walk;
843 * NULL if the tree is empty.
846 GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap);
850 * Inserts a new element into the heap.
852 * @param heap heap to modify
853 * @param element element to insert
854 * @param cost cost for the element
855 * @return node for the new element
857 struct GNUNET_CONTAINER_HeapNode *
858 GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap,
860 GNUNET_CONTAINER_HeapCostType cost);
864 * Remove root of the heap.
866 * @param heap heap to modify
867 * @return element data stored at the root node
870 GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap);
874 * Removes a node from the heap.
876 * @param heap heap to modify
877 * @param node node to remove
878 * @return element data stored at the node, NULL if heap is empty
881 GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap,
882 struct GNUNET_CONTAINER_HeapNode *node);
886 * Updates the cost of any node in the tree
888 * @param heap heap to modify
889 * @param node node for which the cost is to be changed
890 * @param new_cost new cost for the node
893 GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
894 struct GNUNET_CONTAINER_HeapNode *node,
895 GNUNET_CONTAINER_HeapCostType new_cost);
898 /* ******************** Singly linked list *************** */
901 * Possible ways for how data stored in the linked list
902 * might be allocated.
904 enum GNUNET_CONTAINER_SListDisposition
907 * Single-linked list must copy the buffer.
909 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0,
912 * Data is static, no need to copy or free.
914 GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2,
917 * Data is dynamic, do not copy but free when done.
919 GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4
925 * Handle to a singly linked list
927 struct GNUNET_CONTAINER_SList;
930 * Handle to a singly linked list iterator
932 struct GNUNET_CONTAINER_SList_Iterator;
936 * Add a new element to the list
938 * @param disp memory disposition
939 * @param buf payload buffer
940 * @param len length of the buffer
942 void GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l,
943 enum GNUNET_CONTAINER_SListDisposition disp,
944 const void *buf, size_t len);
948 * Append a singly linked list to another
949 * @param dst list to append to
953 GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst, struct GNUNET_CONTAINER_SList *src);
957 * Create a new singly linked list
958 * @return the new list
960 struct GNUNET_CONTAINER_SList *GNUNET_CONTAINER_slist_create (void);
964 * Destroy a singly linked list
965 * @param l the list to be destroyed
967 void GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l);
971 * Return the beginning of a list
974 * @return iterator pointing to the beginning, free using "GNUNET_free"
976 struct GNUNET_CONTAINER_SList_Iterator *
977 GNUNET_CONTAINER_slist_begin(struct GNUNET_CONTAINER_SList *l);
985 void GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l);
989 * Check if a list contains a certain element
991 * @param buf payload buffer to find
992 * @param len length of the payload (number of bytes in buf)
994 int GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l, const void *buf, size_t len);
998 * Count the elements of a list
1000 * @return number of elements in the list
1002 int GNUNET_CONTAINER_slist_count (const struct GNUNET_CONTAINER_SList *l);
1006 * Remove an element from the list
1007 * @param i iterator that points to the element to be removed
1009 void GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i);
1013 * Insert an element into a list at a specific position
1014 * @param before where to insert the new element
1015 * @param disp memory disposition
1016 * @param buf payload buffer
1017 * @param len length of the payload
1019 void GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before,
1020 enum GNUNET_CONTAINER_SListDisposition disp,
1026 * Advance an iterator to the next element
1028 * @return GNUNET_YES on success, GNUNET_NO if the end has been reached
1030 int GNUNET_CONTAINER_slist_next (struct GNUNET_CONTAINER_SList_Iterator *i);
1034 * Check if an iterator points beyond the end of a list
1036 * @return GNUNET_YES if the end has been reached, GNUNET_NO if the iterator
1037 * points to a valid element
1039 int GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i);
1043 * Retrieve the element at a specific position in a list
1046 * @param len set to the payload length
1050 GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i,
1055 * Release an iterator
1058 void GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator *i);
1061 #if 0 /* keep Emacsens' auto-indent happy */
1069 /* ifndef GNUNET_CONTAINER_LIB_H */
1071 /* end of gnunet_container_lib.h */