More string and buffer functions.
[apps/madmutt.git] / lib-lib / list.c
index 25a6125..c1a7039 100644 (file)
@@ -48,6 +48,32 @@ int string_list_contains(const string_list_t *t, const char *s, const char *any)
     return 0;
 }
 
+void string_list_add(string_list_t **list, const char *str)
+{
+    if (m_strisempty(str))
+        return;
+
+    while (*list) {
+        if (!ascii_strcasecmp(str, (*list)->data))
+            return;
+        list = &(*list)->next;
+    }
+
+    *list = p_new(string_list_t, 1);
+    (*list)->data = m_strdup(str);
+}
+
+void string_list_remove(string_list_t **l, const char *str)
+{
+    while (*l) {
+        if (!ascii_strcasecmp(str, (*l)->data)) {
+            string_list_t *it = string_list_pop(l);
+            string_item_delete(&it);
+        } else {
+            l = &(*l)->next;
+        }
+    }
+}
 
 /* FIXME: b0rken API's, replace that at any cost */
 string_list_t *mutt_add_list_n(string_list_t *head, const void *data, size_t len) {