--- /dev/null
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "list.h"
+#include "lib/mem.h"
+#include "lib/str.h"
+
+LIST *mutt_copy_list (LIST * p) {
+ LIST *t, *r = NULL, *l = NULL;
+
+ for (; p; p = p->next) {
+ t = (LIST *) mem_malloc (sizeof (LIST));
+ t->data = str_dup (p->data);
+ t->next = NULL;
+ if (l) {
+ r->next = t;
+ r = r->next;
+ }
+ else
+ l = r = t;
+ }
+ return (l);
+}
+
+
+LIST *mutt_add_list (LIST * head, const char *data) {
+ size_t len = str_len (data);
+ return (mutt_add_list_n (head, data, len ? len + 1 : 0));
+}
+
+LIST *mutt_add_list_n (LIST *head, const void *data, size_t len) {
+ LIST *tmp;
+
+ for (tmp = head; tmp && tmp->next; tmp = tmp->next);
+
+ if (tmp) {
+ tmp->next = mem_malloc (sizeof (LIST));
+ tmp = tmp->next;
+ } else
+ head = tmp = mem_malloc (sizeof (LIST));
+
+ tmp->data = mem_malloc (len);
+ if (len)
+ memcpy (tmp->data, data, len);
+ tmp->next = NULL;
+ return head;
+}
+
+void mutt_free_list (LIST ** list) {
+ LIST *p;
+
+ if (!list)
+ return;
+ while (*list) {
+ p = *list;
+ *list = (*list)->next;
+ mem_free (&p->data);
+ mem_free (&p);
+ }
+}
--- /dev/null
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+#ifndef _MUTT_LIST_H
+#define _MUTT_LIST_H
+
+typedef struct list_t {
+ char *data;
+ struct list_t *next;
+} LIST;
+
+#define mutt_new_list() mem_calloc (1, sizeof (LIST))
+void mutt_free_list (LIST **);
+
+LIST *mutt_copy_list (LIST *);
+
+/* add an element to a list */
+LIST *mutt_add_list (LIST*, const char*);
+LIST *mutt_add_list_n (LIST*, const void*, size_t len);
+
+#endif /* !_MUTT_LIST_H */
#include <grp.h>
#include "rfc822.h"
+#include "list.h"
#include "hash.h"
#include "charset.h"
#include "lib/rx.h"
#define toggle_option(x) mutt_bit_toggle(Options,x)
#define option(x) mutt_bit_isset(Options,x)
-typedef struct list_t {
- char *data;
- struct list_t *next;
-} LIST;
-
typedef struct spam_list_t {
rx_t *rx;
int nmatch;
} SPAM_LIST;
-#define mutt_new_list() mem_calloc (1, sizeof (LIST))
#define mutt_new_spam_list() mem_calloc (1, sizeof (SPAM_LIST))
-void mutt_free_list (LIST **);
void mutt_free_spam_list (SPAM_LIST **);
-LIST *mutt_copy_list (LIST *);
-int mutt_matches_ignore (const char *, LIST *);
-/* add an element to a list */
-LIST *mutt_add_list (LIST*, const char*);
-LIST *mutt_add_list_n (LIST*, const void*, size_t len);
+int mutt_matches_ignore (const char *, LIST *);
void mutt_init (int, LIST *);
*p = 0;
}
-LIST *mutt_add_list (LIST * head, const char *data) {
- size_t len = str_len (data);
- return (mutt_add_list_n (head, data, len ? len + 1 : 0));
-}
-
-LIST *mutt_add_list_n (LIST *head, const void *data, size_t len) {
- LIST *tmp;
-
- for (tmp = head; tmp && tmp->next; tmp = tmp->next);
-
- if (tmp) {
- tmp->next = mem_malloc (sizeof (LIST));
- tmp = tmp->next;
- } else
- head = tmp = mem_malloc (sizeof (LIST));
-
- tmp->data = mem_malloc (len);
- if (len)
- memcpy (tmp->data, data, len);
- tmp->next = NULL;
- return head;
-}
-
-void mutt_free_list (LIST ** list)
-{
- LIST *p;
-
- if (!list)
- return;
- while (*list) {
- p = *list;
- *list = (*list)->next;
- mem_free (&p->data);
- mem_free (&p);
- }
-}
-
HEADER *mutt_dup_header (HEADER * h)
{
HEADER *hnew;
}
}
-LIST *mutt_copy_list (LIST * p)
-{
- LIST *t, *r = NULL, *l = NULL;
-
- for (; p; p = p->next) {
- t = (LIST *) mem_malloc (sizeof (LIST));
- t->data = str_dup (p->data);
- t->next = NULL;
- if (l) {
- r->next = t;
- r = r->next;
- }
- else
- l = r = t;
- }
- return (l);
-}
-
void mutt_forward_intro (FILE * fp, HEADER * cur)
{
char buffer[STRING];