-fix
[oweals/gnunet.git] / src / include / gnunet_container_lib.h
index cad85d016b5299f7b5f3ae5636b1e961e43923c5..af64daa82d89d480fcd8b4ec8108b13e0033bdb0 100644 (file)
@@ -239,7 +239,7 @@ struct GNUNET_CONTAINER_MetaData;
 
 /**
  * Create a fresh MetaData token.
- * 
+ *
  * @return empty meta-data container
  */
 struct GNUNET_CONTAINER_MetaData *
@@ -247,7 +247,7 @@ GNUNET_CONTAINER_meta_data_create (void);
 
 /**
  * Duplicate a MetaData token.
- * 
+ *
  * @param md what to duplicate
  * @return duplicate meta-data container
  */
@@ -289,7 +289,7 @@ GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData
  *        used in the main libextractor library and yielding
  *        meta data).
  * @param type libextractor-type describing the meta data
- * @param format basic format information about data 
+ * @param format basic format information about data
  * @param data_mime_type mime-type of data (not of the original file);
  *        can be NULL (if mime-type is not known)
  * @param data actual meta-data found
@@ -999,7 +999,7 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap);
 
 /**
  * Removes a node from the heap.
- * 
+ *
  * @param node node to remove
  * @return element data stored at the node, NULL if heap is empty
  */
@@ -1047,14 +1047,31 @@ enum GNUNET_CONTAINER_SListDisposition
 
 
 /**
- * Handle to a singly linked list  
+ * Handle to a singly linked list
  */
 struct GNUNET_CONTAINER_SList;
 
 /**
- * Handle to a singly linked list iterator 
+ * Handle to a singly linked list iterator
  */
-struct GNUNET_CONTAINER_SList_Iterator;
+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;
+};
+
 
 
 /**
@@ -1113,9 +1130,11 @@ GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l);
  * Return the beginning of a list
  *
  * @param l list
- * @return iterator pointing to the beginning, free using "GNUNET_free"
+ * @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)
  */
-struct GNUNET_CONTAINER_SList_Iterator *
+struct GNUNET_CONTAINER_SList_Iterator
 GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l);
 
 
@@ -1133,12 +1152,28 @@ GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l);
  * @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
  */
 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
+ */
+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