#include "gnunet_crypto_lib.h"
#include <extractor.h>
+#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
+/* hack for LE < 0.6.3 */
+#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
+#endif
+
#ifdef __cplusplus
extern "C"
{
typedef int (*GNUNET_HashCodeIterator) (void *cls,
GNUNET_HashCode * next);
+
/**
* Load a bloom-filter from a file.
*
int
k);
+
/**
* Create a bloom filter from raw bits.
*
int
k);
+
/**
* Copy the raw data of this bloomfilter into
* the given data array.
* @param size the size of the given data array
* @return GNUNET_SYSERR if the data array of the wrong size
*/
-int GNUNET_CONTAINER_bloomfilter_get_raw_data (struct
+int GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct
GNUNET_CONTAINER_BloomFilter
*bf, char *data,
size_t size);
+
/**
* Test if an element is in the filter.
* @param e the element
* @param bf the filter
* @return GNUNET_YES if the element is in the filter, GNUNET_NO if not
*/
-int GNUNET_CONTAINER_bloomfilter_test (struct GNUNET_CONTAINER_BloomFilter
+int GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter
*bf, const GNUNET_HashCode * e);
+
/**
* Add an element to the filter
* @param bf the filter
void GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter
*bf, const GNUNET_HashCode * e);
+
/**
* Remove an element from the filter.
* @param bf the filter
void GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter
*bf, const GNUNET_HashCode * e);
+
+/**
+ * Create a copy of a bloomfilter.
+ *
+ * @param bf the filter
+ * @return copy of bf
+ */
+struct GNUNET_CONTAINER_BloomFilter *
+GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter *bf);
+
+
+
/**
* Free the space associcated with a filter
* in memory, flush to drive if needed (do not
void GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter
*bf);
+
+/**
+ * Get size of the bloom filter.
+ *
+ * @param bf the filter
+ * @return number of bytes used for the data of the bloom filter
+ */
+size_t
+GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter
+ *bf);
+
+
/**
* Reset a bloom filter to empty.
* @param bf the filter
int GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
const char *data, size_t size);
+/**
+ * Or the entries of the given raw data array with the
+ * data of the given bloom filter. Assumes that
+ * the size of the data array and the current filter
+ * match.
+ *
+ * @param bf the filter
+ * @param to_or the bloomfilter to or-in
+ * @param size number of bytes in data
+ */
+int
+GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf,
+ const struct GNUNET_CONTAINER_BloomFilter *to_or,
+ size_t size);
+
/**
* Resize a bloom filter. Note that this operation
* is pretty costly. Essentially, the bloom filter
size_t data_len);
+/**
+ * Remove all items in the container.
+ *
+ * @param md metadata to manipulate
+ */
+void
+GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md);
+
+
/**
* Add the current time as the publication date
* to the meta-data.
GNUNET_CONTAINER_MetaData
*md, unsigned char **thumb);
-/**
- * Extract meta-data from a file.
- *
- * @param md metadata to set
- * @param filename name of file to inspect
- * @param extractors plugins to use
- * @return GNUNET_SYSERR on error, otherwise the number
- * of meta-data items obtained
- */
-int
-GNUNET_CONTAINER_meta_data_extract_from_file (struct
- GNUNET_CONTAINER_MetaData
- *md, const char *filename,
- struct EXTRACTOR_PluginList *
- extractors);
/**
* -1 on error (typically: not enough
* space)
*/
-ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct
- GNUNET_CONTAINER_MetaData *md,
- char **target,
- size_t max,
- enum
- GNUNET_CONTAINER_MetaDataSerializationOptions
- opt);
+ssize_t
+GNUNET_CONTAINER_meta_data_serialize (const struct
+ GNUNET_CONTAINER_MetaData *md,
+ char **target,
+ size_t max,
+ enum
+ GNUNET_CONTAINER_MetaDataSerializationOptions
+ opt);
/**
* @param md metadata to inspect
* @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);
+ssize_t
+GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
+ GNUNET_CONTAINER_MetaData
+ *md);
/**
* @return MD on success, NULL on error (i.e.
* bad format)
*/
-struct GNUNET_CONTAINER_MetaData
- *GNUNET_CONTAINER_meta_data_deserialize (const char *input,
- size_t size);
+struct GNUNET_CONTAINER_MetaData *
+GNUNET_CONTAINER_meta_data_deserialize (const char *input,
+ size_t size);
/* ******************************* HashMap **************************** */
* GNUNET_NO if not.
*/
typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls,
- const GNUNET_HashCode * key,
+ const GNUNET_HashCode * key,
void *value);
const GNUNET_HashCode * key);
+/**
+ * Check if the map contains the given value under the given
+ * key.
+ *
+ * @param map the map
+ * @param key the key to test if a value exists for it
+ * @param value value to test for
+ * @return GNUNET_YES if such a value exists,
+ * GNUNET_NO if not
+ */
+int GNUNET_CONTAINER_multihashmap_contains_value (const struct
+ GNUNET_CONTAINER_MultiHashMap
+ *map,
+ const GNUNET_HashCode * key,
+ const void *value);
+
+
/**
* Store a key-value pair in the map.
*
* @param element element to insert
*/
#define GNUNET_CONTAINER_DLL_insert(head,tail,element) do { \
+ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
(element)->next = (head); \
(element)->prev = NULL; \
if ((tail) == NULL) \
(head)->prev = element; \
(head) = (element); } while (0)
+
+/**
+ * Insert an element at the tail of a DLL. Assumes that head, tail and
+ * element are structs with prev and next fields.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param element element to insert
+ */
+#define GNUNET_CONTAINER_DLL_insert_tail(head,tail,element) do { \
+ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
+ (element)->prev = (tail); \
+ (element)->next = NULL; \
+ if ((head) == NULL) \
+ (head) = element; \
+ else \
+ (tail)->next = element; \
+ (tail) = (element); } while (0)
+
+
/**
* Insert an element into a DLL after the given other element. Insert
* at the head if the other element is NULL.
* @param element element to insert
*/
#define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) do { \
+ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
(element)->prev = (other); \
if (NULL == other) \
{ \
(element)->next->prev = (element); } while (0)
+/**
+ * Insert an element into a DLL before the given other element. Insert
+ * at the tail if the other element is NULL.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param other prior element, NULL for insertion at head of DLL
+ * @param element element to insert
+ */
+#define GNUNET_CONTAINER_DLL_insert_before(head,tail,other,element) do { \
+ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
+ (element)->next = (other); \
+ if (NULL == other) \
+ { \
+ (element)->prev = (tail); \
+ (tail) = (element); \
+ } \
+ else \
+ { \
+ (element)->prev = (other)->prev; \
+ (other)->prev = (element); \
+ } \
+ if (NULL == (element)->prev) \
+ (head) = (element); \
+ else \
+ (element)->prev->next = (element); } while (0)
/**
* @param element element to remove
*/
#define GNUNET_CONTAINER_DLL_remove(head,tail,element) do { \
+ GNUNET_assert ( ( (element)->prev != NULL) || ((head) == (element))); \
+ GNUNET_assert ( ( (element)->next != NULL) || ((tail) == (element))); \
if ((element)->prev == NULL) \
(head) = (element)->next; \
else \
if ((element)->next == NULL) \
(tail) = (element)->prev; \
else \
- (element)->next->prev = (element)->prev; } while (0)
+ (element)->next->prev = (element)->prev; \
+ (element)->next = NULL; \
+ (element)->prev = NULL; } while (0)
GNUNET_CONTAINER_heap_get_size (const struct GNUNET_CONTAINER_Heap *heap);
+/**
+ * Get the current cost of the node
+ *
+ * @param node the node to get the cost of
+ * @return cost of the node
+ */
+GNUNET_CONTAINER_HeapCostType
+GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode *node);
+
/**
* Iterator for heap
*
*
*/
void *
-GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap, uint32_t max);
+GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap,
+ uint32_t max);
+
/**
* Perform a random walk of the tree. The walk is biased
/**
* Removes a node from the heap.
*
- * @param heap heap to modify
* @param node node to remove
* @return element data stored at the node, NULL if heap is empty
*/
void *
-GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap,
- struct GNUNET_CONTAINER_HeapNode *node);
+GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node);
/**
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
+ */
+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