/*
This file is part of GNUnet.
- (C) 2001-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
*/
struct GNUNET_CONTAINER_BloomFilter;
+
/**
* @ingroup bloomfilter
* Iterator over `struct GNUNET_HashCode`.
* @return #GNUNET_YES if next was updated
* #GNUNET_NO if there are no more entries
*/
-typedef int (*GNUNET_CONTAINER_HashCodeIterator) (void *cls,
- struct GNUNET_HashCode *next);
+typedef int
+(*GNUNET_CONTAINER_HashCodeIterator) (void *cls,
+ struct GNUNET_HashCode *next);
/**
*/
int
GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct GNUNET_CONTAINER_BloomFilter *bf,
- char *data, size_t size);
+ char *data,
+ size_t size);
/**
size_t
GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CONTAINER_BloomFilter *bf);
+
/**
* @ingroup bloomfilter
* Get size of the bloom filter.
GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf,
const struct GNUNET_CONTAINER_BloomFilter *to_or);
+
/**
* @ingroup bloomfilter
* Resize a bloom filter. Note that this operation
void
GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
GNUNET_CONTAINER_HashCodeIterator iterator,
- void *iterator_cls, size_t size,
+ void *iterator_cls,
+ size_t size,
unsigned int k);
*/
struct GNUNET_CONTAINER_MetaData;
+
/**
* @ingroup metadata
* Create a fresh meta data container.
* @return duplicate meta-data container
*/
struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData
- *md);
+GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData *md);
+
/**
* @ingroup metadata
const char *plugin_name,
enum EXTRACTOR_MetaType type,
enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type, const char *data,
+ const char *data_mime_type,
+ const char *data,
size_t data_size);
int
GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
enum EXTRACTOR_MetaType type,
- const char *data, size_t data_size);
+ const char *data,
+ size_t data_size);
/**
* @param md metadata to modify
*/
void
-GNUNET_CONTAINER_meta_data_add_publication_date (struct
- GNUNET_CONTAINER_MetaData *md);
+GNUNET_CONTAINER_meta_data_add_publication_date (struct GNUNET_CONTAINER_MetaData *md);
/**
* @return NULL if no entry was found
*/
char *
-GNUNET_CONTAINER_meta_data_get_by_type (const struct GNUNET_CONTAINER_MetaData
- *md, enum EXTRACTOR_MetaType type);
+GNUNET_CONTAINER_meta_data_get_by_type (const struct GNUNET_CONTAINER_MetaData *md,
+ enum EXTRACTOR_MetaType type);
/**
* otherwise client is responsible for freeing the value!
*/
char *
-GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
- GNUNET_CONTAINER_MetaData *md,
+GNUNET_CONTAINER_meta_data_get_first_by_types (const struct GNUNET_CONTAINER_MetaData *md,
...);
/**
* @return number of bytes in thumbnail, 0 if not available
*/
size_t
-GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData
- *md, unsigned char **thumb);
+GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData *md,
+ unsigned char **thumb);
* space)
*/
ssize_t
-GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
- *md, char **target, size_t max,
- enum
- GNUNET_CONTAINER_MetaDataSerializationOptions
- opt);
+GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData *md,
+ char **target,
+ size_t max,
+ enum GNUNET_CONTAINER_MetaDataSerializationOptions opt);
/**
* @return number of bytes needed for serialization, -1 on error
*/
ssize_t
-GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
- GNUNET_CONTAINER_MetaData *md);
+GNUNET_CONTAINER_meta_data_get_serialized_size (const struct GNUNET_CONTAINER_MetaData *md);
/**
* bad format)
*/
struct GNUNET_CONTAINER_MetaData *
-GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size);
+GNUNET_CONTAINER_meta_data_deserialize (const char *input,
+ size_t size);
/* ******************************* HashMap **************************** */
* iterate,
* #GNUNET_NO if not.
*/
-typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls,
- const struct GNUNET_HashCode *key,
- void *value);
+typedef int
+(*GNUNET_CONTAINER_HashMapIterator) (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value);
/**
const struct GNUNET_HashCode *key);
+/**
+ * @ingroup hashmap
+ * Remove all entries from the map.
+ * Note that the values would not be "freed".
+ *
+ * @param map the map
+ * @return number of values removed
+ */
+unsigned int
+GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map);
+
+
/**
* @ingroup hashmap
* Check if the map contains any value under the given
* @return the number of key value pairs
*/
unsigned int
-GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap
- *map);
+GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap *map);
/**
* #GNUNET_SYSERR if it aborted iteration
*/
int
-GNUNET_CONTAINER_multihashmap_iterate (const struct
- GNUNET_CONTAINER_MultiHashMap *map,
+GNUNET_CONTAINER_multihashmap_iterate (const struct GNUNET_CONTAINER_MultiHashMap *map,
GNUNET_CONTAINER_HashMapIterator it,
void *it_cls);
* #GNUNET_SYSERR if it aborted iteration
*/
int
-GNUNET_CONTAINER_multihashmap_get_multiple (const struct
- GNUNET_CONTAINER_MultiHashMap *map,
- const struct GNUNET_HashCode * key,
+GNUNET_CONTAINER_multihashmap_get_multiple (const struct GNUNET_CONTAINER_MultiHashMap *map,
+ const struct GNUNET_HashCode *key,
GNUNET_CONTAINER_HashMapIterator it,
void *it_cls);
* iterate,
* #GNUNET_NO if not.
*/
-typedef int (*GNUNET_CONTAINER_PeerMapIterator) (void *cls,
- const struct GNUNET_PeerIdentity *key,
- void *value);
+typedef int
+(*GNUNET_CONTAINER_PeerMapIterator) (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value);
struct GNUNET_CONTAINER_MultiPeerMap;
/**
* @ingroup heap
- * Get element stored at root of heap.
+ * Get element stored at the root of @a heap.
*
- * @param heap heap to inspect
- * @return NULL if heap is empty
+ * @param heap Heap to inspect.
+ * @return Element at the root, or NULL if heap is empty.
*/
void *
GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap);
+/**
+ * Get @a element and @a cost stored at the root of @a heap.
+ *
+ * @param[in] heap Heap to inspect.
+ * @param[out] element Root element is returned here.
+ * @param[out] cost Cost of @a element is returned here.
+ * @return #GNUNET_YES if an element is returned,
+ * #GNUNET_NO if the heap is empty.
+ */
+int
+GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap,
+ void **element,
+ GNUNET_CONTAINER_HeapCostType *cost);
+
+
/**
* @ingroup heap
* Get the current size of the heap
GNUNET_CONTAINER_HeapCostType new_cost);
-/* ******************** Singly linked list *************** */
-
-/**
- * Possible ways for how data stored in the linked list
- * might be allocated.
- * @deprecated use DLL macros
- */
-enum GNUNET_CONTAINER_SListDisposition
-{
- /**
- * Single-linked list must copy the buffer.
- * @deprecated use DLL macros
- */
- GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0,
-
- /**
- * Data is static, no need to copy or free.
- * @deprecated use DLL macros
- */
- GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2,
-
- /**
- * Data is dynamic, do not copy but free when done.
- * @deprecated use DLL macros
- */
- GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4
-};
-
-struct GNUNET_CONTAINER_SList_Elem;
-
-
-/**
- * Handle to a singly linked list
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList;
-
-/**
- * Handle to a singly linked list iterator
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList_Iterator
-{
- /**
- * Linked list that we are iterating over.
- */
- struct GNUNET_CONTAINER_SList *list;
-
- /**
- * Last element accessed.
- */
- struct GNUNET_CONTAINER_SList_Elem *last;
-
- /**
- * Current list element.
- */
- struct GNUNET_CONTAINER_SList_Elem *elem;
-};
-
-
-
-/**
- * Add a new element to the list
- * @param l list
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the buffer
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l,
- enum GNUNET_CONTAINER_SListDisposition disp,
- const void *buf, size_t len);
-
-
-/**
- * Add a new element to the end of the list
- * @param l list
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the buffer
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l,
- enum GNUNET_CONTAINER_SListDisposition disp,
- const void *buf, size_t len);
-
-
-/**
- * Append a singly linked list to another
- * @param dst list to append to
- * @param src source
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst,
- struct GNUNET_CONTAINER_SList *src);
-
-
-/**
- * Create a new singly linked list
- * @return the new list
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList *
-GNUNET_CONTAINER_slist_create (void);
-
-
-/**
- * Destroy a singly linked list
- * @param l the list to be destroyed
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Return the beginning of a list
- *
- * @param l list
- * @return iterator pointing to the beginning (by value! Either allocate the
- * structure on the stack, or use GNUNET_malloc() yourself! All other
- * functions do take pointer to this struct though)
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList_Iterator
-GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Clear a list
- *
- * @param l list
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Check if a list contains a certain element
- * @param l list
- * @param buf payload buffer to find
- * @param len length of the payload (number of bytes in buf)
- * @return GNUNET_YES if found, GNUNET_NO otherwise
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l,
- const void *buf, size_t len);
-
-/**
- * Check if a list contains a certain element using 'compare' function
- *
- * @param l list
- * @param buf payload buffer to find
- * @param len length of the payload (number of bytes in buf)
- * @param compare comparison function
- *
- * @return NULL if the 'buf' could not be found, pointer to the
- * list element, if found
- * @deprecated use DLL macros
- */
-void *
-GNUNET_CONTAINER_slist_contains2 (const struct GNUNET_CONTAINER_SList *l,
- const void *buf, size_t len,
- int (*compare)(const void *, const size_t, const void *, const size_t));
-/**
- * Count the elements of a list
- * @param l list
- * @return number of elements in the list
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_count (const struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Remove an element from the list
- * @param i iterator that points to the element to be removed
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i);
-
-
-/**
- * Insert an element into a list at a specific position
- * @param before where to insert the new element
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the payload
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before,
- enum GNUNET_CONTAINER_SListDisposition disp,
- const void *buf, size_t len);
-
-
-/**
- * Advance an iterator to the next element
- * @param i iterator
- * @return GNUNET_YES on success, GNUNET_NO if the end has been reached
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_next (struct GNUNET_CONTAINER_SList_Iterator *i);
-
-
-/**
- * Check if an iterator points beyond the end of a list
- * @param i iterator
- * @return GNUNET_YES if the end has been reached, GNUNET_NO if the iterator
- * points to a valid element
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i);
-
-
-/**
- * Retrieve the element at a specific position in a list
- *
- * @param i iterator
- * @param len set to the payload length
- * @return payload
- * @deprecated use DLL macros
- */
-void *
-GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i,
- size_t *len);
-
-
-/**
- * Release an iterator
- * @param i iterator
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator *i);
-
-
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif