move list.[hc] into lib-lib.
[apps/madmutt.git] / lib-lib / list.h
diff --git a/lib-lib/list.h b/lib-lib/list.h
new file mode 100644 (file)
index 0000000..1a915b3
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *  MA 02110-1301, USA.
+ *
+ *  Copyright © 2006 Pierre Habouzit
+ */
+
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ */
+
+#ifndef _MUTT_LIST_H
+#define _MUTT_LIST_H
+
+typedef struct list_t {
+    char *data;
+    struct list_t *next;
+} LIST;
+
+#define mutt_new_list() p_new(LIST, 1)
+void mutt_free_list(LIST **);
+
+LIST *mutt_copy_list(LIST *);
+
+/* add an element to a list */
+LIST *mutt_add_list_n(LIST*, const void*, size_t len);
+static inline LIST *mutt_add_list(LIST *head, const char *data) {
+    size_t len = m_strlen(data);
+    return mutt_add_list_n(head, data, len ? len + 1 : 0);
+}
+
+#endif /* !_MUTT_LIST_H */