Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Thu, 11 Aug 2005 10:47:55 +0000 (10:47 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Thu, 11 Aug 2005 10:47:55 +0000 (10:47 +0000)
- move more data structures + protos to dedicated source files

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@386 e385b8ad-14ed-0310-8656-cc95a2468c6d

list.c [new file with mode: 0644]
list.h [new file with mode: 0644]
mutt.h
muttlib.c
send.c

diff --git a/list.c b/list.c
new file mode 100644 (file)
index 0000000..eee8a4f
--- /dev/null
+++ b/list.c
@@ -0,0 +1,72 @@
+/*
+ * 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);
+  }
+}
diff --git a/list.h b/list.h
new file mode 100644 (file)
index 0000000..89916ff
--- /dev/null
+++ b/list.h
@@ -0,0 +1,26 @@
+/*
+ * 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 */
diff --git a/mutt.h b/mutt.h
index bbd1022..35dd081 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -42,6 +42,7 @@
 #include <grp.h>
 
 #include "rfc822.h"
+#include "list.h"
 #include "hash.h"
 #include "charset.h"
 #include "lib/rx.h"
@@ -559,11 +560,6 @@ enum {
 #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;
@@ -572,16 +568,10 @@ typedef struct spam_list_t {
 } 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 *);
 
index bc659a7..723043a 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -215,43 +215,6 @@ void mutt_free_parameter (PARAMETER ** p)
   *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;
diff --git a/send.c b/send.c
index 9f741ed..9fc382f 100644 (file)
--- a/send.c
+++ b/send.c
@@ -369,24 +369,6 @@ static void process_user_header (ENVELOPE * env)
   }
 }
 
-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];