Code

frontend: Improved parser error reporting.
[sysdb.git] / src / include / utils / llist.h
index 93561906b6056a272f468c9c87187469004b8246..1dddb7e0747391a677ac267f36560b2d385d2a89 100644 (file)
@@ -40,9 +40,6 @@ typedef struct sdb_llist sdb_llist_t;
 struct sdb_llist_iter;
 typedef struct sdb_llist_iter sdb_llist_iter_t;
 
-typedef int (*sdb_llist_cmp_cb)(const sdb_object_t *, const sdb_object_t *);
-typedef int (*sdb_llist_lookup_cb)(const sdb_object_t *, const void *user_data);
-
 /*
  * sdb_llist_create, sdb_llist_destroy:
  * Create and destroy a doubly linked list object.
@@ -56,6 +53,14 @@ sdb_llist_create(void);
 void
 sdb_llist_destroy(sdb_llist_t *list);
 
+/*
+ * sdb_llist_clear:
+ * Remove all elements from the list, releasing the included objects
+ * (decrement the ref-count).
+ */
+void
+sdb_llist_clear(sdb_llist_t *list);
+
 /*
  * sdb_llist_clone:
  * Clone an existing list. The objects stored in the list will not be copied
@@ -117,7 +122,7 @@ sdb_llist_insert(sdb_llist_t *list, sdb_object_t *obj, size_t idx);
  */
 int
 sdb_llist_insert_sorted(sdb_llist_t *list,
-               sdb_object_t *obj, sdb_llist_cmp_cb);
+               sdb_object_t *obj, sdb_object_cmp_cb);
 
 /*
  * sdb_llist_get:
@@ -140,7 +145,7 @@ sdb_llist_get(sdb_llist_t *list, size_t i);
  */
 sdb_object_t *
 sdb_llist_search(sdb_llist_t *list,
-               sdb_llist_lookup_cb lookup, const void *user_data);
+               sdb_object_lookup_cb lookup, const void *user_data);
 
 /*
  * sdb_llist_search_by_name:
@@ -157,9 +162,9 @@ sdb_llist_search_by_name(sdb_llist_t *list, const char *key);
 
 /*
  * sdb_llist_remove:
- * Removes and returns the first matchin element of the list. The ref-count of
- * the item will not be changed, that is, if the element will not be used any
- * further, it should be de-referenced by the caller.
+ * Removes and returns the first matching element of the list. The ref-count
+ * of the item will not be changed, that is, if the element will not be used
+ * any further, it should be de-referenced by the caller.
  *
  * Returns:
  *  - a pointer to the first matching object
@@ -167,7 +172,20 @@ sdb_llist_search_by_name(sdb_llist_t *list, const char *key);
  */
 sdb_object_t *
 sdb_llist_remove(sdb_llist_t *list,
-               sdb_llist_lookup_cb lookup, const void *user_data);
+               sdb_object_lookup_cb lookup, const void *user_data);
+
+/*
+ * sdb_llist_remove_by_name:
+ * Removes and returns the first element whose name matches the specified key.
+ * The ref-count of the item will not be changed, that is, if the element will
+ * not be used any further, it should be de-referenced by the caller.
+ *
+ * Returns:
+ *  - a pointer to the first matching object
+ *  - NULL else
+ */
+sdb_object_t *
+sdb_llist_remove_by_name(sdb_llist_t *list, const char *key);
 
 /*
  * sdb_llist_shift: