move list.[hc] into lib-lib.
authorPierre Habouzit <madcoder@debian.org>
Sun, 29 Oct 2006 19:38:59 +0000 (20:38 +0100)
committerPierre Habouzit <madcoder@debian.org>
Sun, 29 Oct 2006 19:38:59 +0000 (20:38 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Makefile.am
crypt-gpgme.c
lib-lib/Makefile.am
lib-lib/list.c [new file with mode: 0644]
lib-lib/list.h [new file with mode: 0644]
list.c [deleted file]
list.h [deleted file]
mutt.h

index 24747a0..fef9893 100644 (file)
@@ -30,14 +30,10 @@ muttng_SOURCES = $(BUILT_SOURCES) \
        alias.c attach.c base64.c browser.c buffy.c \
        charset.c color.c compress.c crypt.c cryptglue.c commands.c complete.c \
        compose.c copy.c curs_lib.c curs_main.c crypt-mod.c crypt-mod.h \
        alias.c attach.c base64.c browser.c buffy.c \
        charset.c color.c compress.c crypt.c cryptglue.c commands.c complete.c \
        compose.c copy.c curs_lib.c curs_main.c crypt-mod.c crypt-mod.h \
-       date.c \
-       edit.c editmsg.c enter.c \
-       flags.c filter.c from.c \
-       getdomain.c \
+       date.c edit.c editmsg.c enter.c \
+       flags.c filter.c from.c getdomain.c \
        handler.c hcache.c hdrline.c headers.c help.c history.c hook.c \
        handler.c hcache.c hdrline.c headers.c help.c history.c hook.c \
-       init.c \
-       keymap.c \
-       lib.c list.c \
+       init.c keymap.c lib.c \
        main.c mbox.c mbyte.c md5c.c menu.c mh.c muttlib.c mutt_idna.c mx.c \
        pager.c parse.c pattern.c postpone.c \
        query.c \
        main.c mbox.c mbyte.c md5c.c menu.c mh.c muttlib.c mutt_idna.c mx.c \
        pager.c parse.c pattern.c postpone.c \
        query.c \
@@ -80,9 +76,7 @@ EXTRA_muttng_SOURCES = \
        account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \
        mutt_tunnel.c smime.c pgp.c pgpinvoke.c pgpkey.c \
        pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
        account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \
        mutt_tunnel.c smime.c pgp.c pgpinvoke.c pgpkey.c \
        pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
-       alias.h browser.h \
-       enter.h \
-       list.h \
+       alias.h browser.h enter.h \
        mbyte.h remailer.h url.h state.h \
        pgppacket.c mutt_idna.h mutt_libesmtp.c \
        crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
        mbyte.h remailer.h url.h state.h \
        pgppacket.c mutt_idna.h mutt_libesmtp.c \
        crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
@@ -91,11 +85,9 @@ EXTRA_muttng_SOURCES = \
 EXTRA_DIST = config.rpath  COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
        configure acconfig.h \
        account.h alias.h attach.h recvattach.h handler.h thread.h \
 EXTRA_DIST = config.rpath  COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
        configure acconfig.h \
        account.h alias.h attach.h recvattach.h handler.h thread.h \
-       buffy.h \
-       charset.h compress.h copy.h crypthash.h \
+       buffy.h charset.h compress.h copy.h crypthash.h \
        dotlock.h functions.h gen_defs \
        enter.h recvattach.h handler.h thread.h \
        dotlock.h functions.h gen_defs \
        enter.h recvattach.h handler.h thread.h \
-       list.h \
        globals.h history.h init.h keymap.h mutt_crypt.h \
        mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
        mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
        globals.h history.h init.h keymap.h mutt_crypt.h \
        mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
        mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
index 0d5cd89..18ca2a5 100644 (file)
@@ -3221,7 +3221,7 @@ static LIST *crypt_add_string_to_hints (LIST * hints, const char *str)
   for (t = strtok (scratch, " ,.:\"()<>\n"); t;
        t = strtok (NULL, " ,.:\"()<>\n")) {
     if (m_strlen(t) > 3)
   for (t = strtok (scratch, " ,.:\"()<>\n"); t;
        t = strtok (NULL, " ,.:\"()<>\n")) {
     if (m_strlen(t) > 3)
-      hints = mutt_add_list (hints, t);
+      hints = mutt_add_list(hints, t);
   }
 
   p_delete(&scratch);
   }
 
   p_delete(&scratch);
index fe73d73..a11995b 100644 (file)
@@ -1,7 +1,7 @@
 noinst_LIBRARIES = liblib.a
 
 noinst_LIBRARIES = liblib.a
 
-liblib_a_SOURCES = mem.h str.h ascii.h buffer.h hash.h                       \
-                         str.c ascii.c buffer.c hash.c
+liblib_a_SOURCES = mem.h str.h ascii.h buffer.h hash.h list.h                \
+                         str.c ascii.c buffer.c hash.c list.c
 
 
-noinst_HEADERS   = mem.h str.h ascii.h buffer.h hash.h
+noinst_HEADERS   = mem.h str.h ascii.h buffer.h hash.h list.h
 
 
diff --git a/lib-lib/list.c b/lib-lib/list.c
new file mode 100644 (file)
index 0000000..74c60c7
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ *  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>
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "mem.h"
+#include "str.h"
+#include "list.h"
+
+LIST *mutt_copy_list(LIST *p) {
+    LIST *t, *r = NULL, *l = NULL;
+
+    for (; p; p = p->next) {
+        t = p_new(LIST, 1);
+        t->data = m_strdup(p->data);
+        t->next = NULL;
+        if (l) {
+            r->next = t;
+            r = r->next;
+        } else {
+            l = r = t;
+        }
+    }
+    return l;
+}
+
+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 = p_new(LIST, 1);
+        tmp = tmp->next;
+    } else {
+        head = tmp = p_new(LIST, 1);
+    }
+
+    tmp->data = p_dup((const char *)data, len);
+    tmp->next = NULL;
+    return head;
+}
+
+void mutt_free_list(LIST **list) {
+    LIST *p;
+
+    if (list) {
+        while (*list) {
+            p = *list;
+            *list = (*list)->next;
+            p_delete(&p->data);
+            p_delete(&p);
+        }
+    }
+}
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 */
diff --git a/list.c b/list.c
deleted file mode 100644 (file)
index 54218b9..0000000
--- a/list.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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 <lib-lib/mem.h>
-#include <lib-lib/str.h>
-
-#include "list.h"
-
-LIST *mutt_copy_list (LIST * p) {
-  LIST *t, *r = NULL, *l = NULL;
-
-  for (; p; p = p->next) {
-    t = p_new(LIST, 1);
-    t->data = m_strdup(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 = m_strlen(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 = p_new(LIST, 1);
-    tmp = tmp->next;
-  } else
-    head = tmp = p_new(LIST, 1);
-
-  tmp->data = p_new(char, 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;
-    p_delete(&p->data);
-    p_delete(&p);
-  }
-}
diff --git a/list.h b/list.h
deleted file mode 100644 (file)
index 11a88b4..0000000
--- a/list.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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() p_new(LIST, 1)
-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 20b04c8..eb23ab5 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -43,9 +43,9 @@
 
 #include <lib-lib/buffer.h>
 #include <lib-lib/hash.h>
 
 #include <lib-lib/buffer.h>
 #include <lib-lib/hash.h>
+#include <lib-lib/list.h>
 
 #include "rfc822.h"
 
 #include "rfc822.h"
-#include "list.h"
 #include "charset.h"
 #include "lib/rx.h"
 
 #include "charset.h"
 #include "lib/rx.h"