curs_lib.c curs_main.c edit.c editmsg.c enter.c enter_state.h \
envelope.c envelope.h filter.c flags.c format_flags.h from.c getdomain.c group.c \
handler.c hdrline.c header.h headers.c help.c history.c hook.c \
- init.c keymap.c list.h main.c mbox.c mbyte.c mbtable.h \
+ init.c keymap.c main.c mbox.c mbyte.c mbtable.h \
menu.c mh.c muttlib.c mutt_idna.c mutt_sasl_plain.c mutt_socket.c \
mutt_tunnel.c mx.c newsrc.c nntp.c options.h pager.c parameter.c parameter.h \
parse.c pattern.c pattern.h pop.c pop_auth.c pop_lib.c postpone.c \
mutt_curses.h mutt_idna.h mutt_lua.h mutt_menu.h mutt_notmuch.h \
mutt_options.h mutt_regex.h mutt_sasl.h mutt_sasl_plain.h \
mutt_socket.h mutt_ssl.h mutt_tunnel.h mx.h myvar.h nntp.h opcodes.h pager.h \
- pgpewrap.c pop.h protos.h queue.h README.md README.SSL remailer.c remailer.h \
+ pgpewrap.c pop.h protos.h README.md README.SSL remailer.c remailer.h \
rfc1524.h rfc2047.h rfc2231.h rfc3676.h rfc822.h sidebar.h \
sort.h txt2c.c txt2c.sh version.h mutt_tags.h
# libmutt
LIBMUTT= libmutt.a
LIBMUTTOBJS= lib/base64.o lib/buffer.o lib/date.o lib/debug.o lib/exit.o \
- lib/file.o lib/hash.o lib/mapping.o lib/md5.o lib/memory.o \
- lib/message.o lib/sha1.o lib/string.o
+ lib/file.o lib/hash.o lib/list.o lib/mapping.o lib/md5.o \
+ lib/memory.o lib/message.o lib/sha1.o lib/string.o
CLEANFILES+= $(LIBMUTT) $(LIBMUTTOBJS)
MUTTLIBS+= $(LIBMUTT)
ALLOBJS+= $(LIBMUTTOBJS)
rm -f git_ver.h.tmp
hcache/hcversion.h: $(SRCDIR)/mutt.h $(SRCDIR)/address.h \
- $(SRCDIR)/list.h $(SRCDIR)/lib/buffer.h \
+ $(SRCDIR)/lib/list.h $(SRCDIR)/lib/buffer.h \
$(SRCDIR)/parameter.h $(SRCDIR)/body.h \
$(SRCDIR)/envelope.h $(SRCDIR)/header.h \
$(SRCDIR)/hcache/hcachever.sh \
$(PWD)/hcache
( echo '#include "config.h"'; echo '#include "mutt.h"'; \
- echo '#include "address.h"'; echo '#include "list.h"'; \
+ echo '#include "address.h"'; echo '#include "lib/list.h"'; \
echo '#include "lib/buffer.h"'; echo '#include "parameter.h"'; \
echo '#include "body.h"'; echo '#include "envelope.h"'; \
echo '#include "header.h"';) | $(CPP) $(CFLAGS) - | \
#include "charset.h"
#include "envelope.h"
#include "globals.h"
-#include "list.h"
#include "mutt_curses.h"
#include "mutt_idna.h"
#include "options.h"
#include "filter.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_curses.h"
#include "globals.h"
#include "header.h"
#include "keymap.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_curses.h"
#include "envelope.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_curses.h"
#include "globals.h"
#include "header.h"
#include "keymap.h"
-#include "list.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "lib/buffer.h"
#include "lib/memory.h"
#include "envelope.h"
-#include "queue.h"
+#include "lib/queue.h"
#include "rfc822.h"
struct Envelope *mutt_new_envelope(void)
#define _MUTT_ENVELOPE_H
#include <stdbool.h>
-#include "list.h"
+#include "lib/list.h"
/**
* struct Envelope - The header of an email
#include <signal.h>
#include "lib/lib.h"
-#include "list.h"
#include "where.h"
#include "mutt_regex.h"
#include "group.h"
#include "address.h"
#include "globals.h"
-#include "list.h"
#include "protos.h"
#include "rfc822.h"
#include "filter.h"
#include "globals.h"
#include "keymap.h"
-#include "list.h"
#include "mime.h"
#include "mutt_curses.h"
#include "ncrypt/ncrypt.h"
$(top_srcdir)/keymap_defs.h:
+$(MAKE) -C $(top_srcdir) keymap_defs.h
-hcversion.h: $(top_srcdir)/mutt.h $(top_srcdir)/address.h $(top_srcdir)/list.h \
+hcversion.h: $(top_srcdir)/mutt.h $(top_srcdir)/address.h $(top_srcdir)/lib/list.h \
$(top_srcdir)/lib/buffer.h $(top_srcdir)/parameter.h \
$(top_srcdir)/body.h $(top_srcdir)/envelope.h \
$(top_srcdir)/header.h $(srcdir)/hcachever.sh
( echo '#include "config.h"'; echo '#include "mutt.h"'; \
- echo '#include "address.h"'; echo '#include "list.h"'; \
+ echo '#include "address.h"'; echo '#include "lib/list.h"'; \
echo '#include "lib/buffer.h"'; echo '#include "parameter.h"'; \
echo '#include "body.h"'; echo '#include "envelope.h"'; \
echo '#include "header.h"'; \
#include "hcache.h"
#include "hcache/hcversion.h"
#include "header.h"
-#include "list.h"
#include "mbyte.h"
#include "mutt_regex.h"
#include "mutt_tags.h"
#include <stdbool.h>
#include <time.h>
#include "lib/lib.h"
-#include "list.h"
#include "mutt_tags.h"
/**
#include "envelope.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mutt_idna.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "envelope.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mutt_regex.h"
#include "ncrypt/ncrypt.h"
#include "globals.h"
#include "header.h"
#include "imap/imap.h"
-#include "list.h"
#include "mailbox.h"
#include "message.h"
#include "mutt_curses.h"
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
+#include "lib/list.h"
#ifdef USE_HCACHE
#include "hcache/hcache.h"
#endif
-#include "list.h"
struct Account;
struct Buffer;
#include "globals.h"
#include "header.h"
#include "imap/imap.h"
-#include "list.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_socket.h"
#include <stdbool.h>
#include <time.h>
-#include "list.h"
+#include "lib/list.h"
/**
* struct ImapHeaderData - IMAP-specific header data
#include "globals.h"
#include "header.h"
#include "imap/imap.h"
-#include "list.h"
#include "mailbox.h"
#include "message.h"
#include "mutt_socket.h"
#include "header.h"
#include "history.h"
#include "keymap.h"
-#include "list.h"
#include "mailbox.h"
#include "mbtable.h"
#include "mbyte.h"
AUTOMAKE_OPTIONS = 1.6 foreign
-EXTRA_DIST = lib.h base64.h buffer.h date.h debug.h exit.h file.h hash.h mapping.h md5.h memory.h message.h sha1.h string2.h
+EXTRA_DIST = lib.h base64.h buffer.h date.h debug.h exit.h file.h hash.h list.h mapping.h md5.h memory.h message.h queue.h sha1.h string2.h
AM_CPPFLAGS = -I$(top_srcdir)
noinst_LIBRARIES = libmutt.a
-libmutt_a_SOURCES = base64.c buffer.c date.c debug.c exit.c file.c hash.c mapping.c md5.c memory.c message.c sha1.c string.c
+libmutt_a_SOURCES = base64.c buffer.c date.c debug.c exit.c file.c hash.c list.c mapping.c md5.c memory.c message.c sha1.c string.c
* -# @subpage exit
* -# @subpage file
* -# @subpage hash
+ * -# @subpage list
* -# @subpage mapping
* -# @subpage md5
* -# @subpage memory
#include "exit.h"
#include "file.h"
#include "hash.h"
+#include "list.h"
#include "mapping.h"
#include "md5.h"
#include "memory.h"
--- /dev/null
+/**
+ * @file
+ * Singly-linked list type
+ *
+ * @authors
+ * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
+ * Copyright (C) 2017 Pietro Cerutti <gahr@gahr.ch>
+ *
+ * @copyright
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @page list Singly-linked list type
+ *
+ * Singly-linked list of strings.
+ *
+ * | Function | Description
+ * | :----------------------- | :-----------------------------------------
+ * | mutt_list_clear() | Free a list, but NOT its strings
+ * | mutt_list_find() | Find a string in a List
+ * | mutt_list_free() | Free a List AND its strings
+ * | mutt_list_insert_after() | Insert a string after a given ListNode
+ * | mutt_list_insert_head() | Insert a string at the beginning of a List
+ * | mutt_list_insert_tail() | Append a string to the end of a List
+ * | mutt_list_match() | Is the string in the list (see notes)
+ */
+
+#include "config.h"
+#include "list.h"
+#include "memory.h"
+#include "string2.h"
+
+/**
+ * mutt_list_insert_head - Insert a string at the beginning of a List
+ * @param h Head of the List
+ * @param s String to insert
+ * @retval ptr Newly inserted ListNode containing the string
+ */
+struct ListNode *mutt_list_insert_head(struct ListHead *h, char *s)
+{
+ struct ListNode *np = safe_calloc(1, sizeof(struct ListNode));
+ np->data = s;
+ STAILQ_INSERT_HEAD(h, np, entries);
+ return np;
+}
+
+/**
+ * mutt_list_insert_tail - Append a string to the end of a List
+ * @param h Head of the List
+ * @param s String to insert
+ * @retval ptr Newly appended ListNode containing the string
+ */
+struct ListNode *mutt_list_insert_tail(struct ListHead *h, char *s)
+{
+ struct ListNode *np = safe_calloc(1, sizeof(struct ListNode));
+ np->data = s;
+ STAILQ_INSERT_TAIL(h, np, entries);
+ return np;
+}
+
+/**
+ * mutt_list_insert_after - Insert a string after a given ListNode
+ * @param h Head of the List
+ * @parem n ListNode after which the string will be inserted
+ * @param s String to insert
+ * @retval ptr Newly created ListNode containing the string
+ */
+struct ListNode *mutt_list_insert_after(struct ListHead *h, struct ListNode *n, char *s)
+{
+ struct ListNode *np = safe_calloc(1, sizeof(struct ListNode));
+ np->data = s;
+ STAILQ_INSERT_AFTER(h, n, np, entries);
+ return np;
+}
+
+/**
+ * mutt_list_find - Find a string in a List
+ * @param h Head of the List
+ * @param s String to find
+ * @retval ptr ListNode containing the string
+ * @retval NULL if the string isn't found
+ */
+struct ListNode *mutt_list_find(struct ListHead *h, const char *data)
+{
+ struct ListNode *np;
+ STAILQ_FOREACH(np, h, entries)
+ {
+ if (np->data == data || mutt_strcmp(np->data, data) == 0)
+ {
+ return np;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * mutt_list_free - Free a List AND its strings
+ * @param h Head of the List
+ */
+void mutt_list_free(struct ListHead *h)
+{
+ struct ListNode *np = STAILQ_FIRST(h), *next = NULL;
+ while (np)
+ {
+ next = STAILQ_NEXT(np, entries);
+ FREE(&np->data);
+ FREE(&np);
+ np = next;
+ }
+ STAILQ_INIT(h);
+}
+
+/**
+ * mutt_list_clear - Free a list, but NOT its strings
+ * @param h Head of the List
+ *
+ * This can be used when the strings have a different lifetime to the List.
+ */
+void mutt_list_clear(struct ListHead *h)
+{
+ struct ListNode *np = STAILQ_FIRST(h), *next = NULL;
+ while (np)
+ {
+ next = STAILQ_NEXT(np, entries);
+ FREE(&np);
+ np = next;
+ }
+ STAILQ_INIT(h);
+}
+
+/**
+ * mutt_list_match - Is the string in the list (see notes)
+ * @param s String to match
+ * @param h Head of the List
+ * @return true String matches a List item (or List contains "*")
+ *
+ * This is a very specific function. It searches a List of strings looking for
+ * a match. If the list contains a string "*", then it match any input string.
+ *
+ * @note The strings are compared to the length of the List item, e.g.
+ * List: "Red" matches Param: "Redwood", but not the other way around.
+ * @note The case of the strings is ignored.
+ */
+bool mutt_list_match(const char *s, struct ListHead *h)
+{
+ struct ListNode *np;
+ STAILQ_FOREACH(np, h, entries)
+ {
+ if ((*np->data == '*') || (mutt_strncasecmp(s, np->data, strlen(np->data)) == 0))
+ return true;
+ }
+ return false;
+}
--- /dev/null
+/**
+ * @file
+ * Singly-linked list type
+ *
+ * @authors
+ * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
+ * Copyright (C) 2017 Pietro Cerutti <gahr@gahr.ch>
+ *
+ * @copyright
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _LIB_LIST_H
+#define _LIB_LIST_H
+
+#include <string.h>
+#include <stdbool.h>
+#include "lib/queue.h"
+
+/**
+ * struct ListNode - A List node for strings
+ */
+struct ListNode
+{
+ char *data;
+ STAILQ_ENTRY(ListNode) entries;
+};
+
+/**
+ * struct ListHead - A generic list of strings
+ *
+ * The List is stored as a STAILQ.
+ * This means that insertions are quick at the head and tail of the list.
+ */
+STAILQ_HEAD(ListHead, ListNode);
+
+void mutt_list_clear(struct ListHead *h);
+struct ListNode *mutt_list_find(struct ListHead *h, const char *data);
+void mutt_list_free(struct ListHead *h);
+struct ListNode *mutt_list_insert_after(struct ListHead *h, struct ListNode *n, char *s);
+struct ListNode *mutt_list_insert_head(struct ListHead *h, char *s);
+struct ListNode *mutt_list_insert_tail(struct ListHead *h, char *s);
+bool mutt_list_match(const char *s, struct ListHead *h);
+
+#endif /* _LIB_LIST_H */
+++ /dev/null
-/**
- * @file
- * Singly-linked list type
- *
- * @authors
- * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
- *
- * @copyright
- * 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _MUTT_LIST_H
-#define _MUTT_LIST_H
-
-#include <string.h>
-#include "lib/lib.h"
-
-/**
- * New implementation using macros from queue.h
- */
-
-#include "queue.h"
-
-/**
- * struct ListNode - A generic List node
- */
-struct ListNode
-{
- char *data;
- STAILQ_ENTRY(ListNode) entries;
-};
-STAILQ_HEAD(ListHead, ListNode);
-
-static inline struct ListNode* mutt_list_insert_head(struct ListHead *h,
- char *s)
-{
- struct ListNode *np = safe_calloc(1, sizeof(struct ListNode));
- np->data = s;
- STAILQ_INSERT_HEAD(h, np, entries);
- return np;
-}
-
-static inline struct ListNode* mutt_list_insert_tail(struct ListHead *h,
- char *s)
-{
- struct ListNode *np = safe_calloc(1, sizeof(struct ListNode));
- np->data = s;
- STAILQ_INSERT_TAIL(h, np, entries);
- return np;
-}
-
-static inline struct ListNode* mutt_list_insert_after(struct ListHead *h,
- struct ListNode *n,
- char *s)
-{
- struct ListNode *np = safe_calloc(1, sizeof(struct ListNode));
- np->data = s;
- STAILQ_INSERT_AFTER(h, n, np, entries);
- return np;
-}
-
-static inline struct ListNode *mutt_list_find(struct ListHead *h,
- const char *data)
-{
- struct ListNode *np;
- STAILQ_FOREACH(np, h, entries)
- {
- if (np->data == data || mutt_strcmp(np->data, data) == 0)
- {
- return np;
- }
- }
- return NULL;
-}
-
-static inline void mutt_list_free(struct ListHead *h)
-{
- struct ListNode *np = STAILQ_FIRST(h), *next = NULL;
- while (np)
- {
- next = STAILQ_NEXT(np, entries);
- FREE(&np->data);
- FREE(&np);
- np = next;
- }
- STAILQ_INIT(h);
-}
-
-static inline void mutt_list_clear(struct ListHead *h)
-{
- struct ListNode *np = STAILQ_FIRST(h), *next = NULL;
- while (np)
- {
- next = STAILQ_NEXT(np, entries);
- FREE(&np);
- np = next;
- }
- STAILQ_INIT(h);
-}
-
-/**
- * mutt_list_match - Is the string in the list
- * @return true if the header contained in "s" is in list "h"
- */
-static inline bool mutt_list_match(const char *s, struct ListHead *h)
-{
- struct ListNode *np;
- STAILQ_FOREACH(np, h, entries)
- {
- if (*np->data == '*' || mutt_strncasecmp(s, np->data, strlen(np->data)) == 0)
- return true;
- }
- return false;
-}
-
-#endif /* _MUTT_LIST_H */
#include "globals.h"
#include "header.h"
#include "keymap.h"
-#include "list.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_idna.h"
#include "envelope.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mx.h"
#include <regex.h>
#include "lib/lib.h"
#include "options.h"
-#include "queue.h"
+#include "lib/queue.h"
#ifdef USE_SLANG_CURSES
#include <stddef.h>
#include "account.h"
-#include "list.h"
#include "lib/lib.h"
/* logging levels */
#include "lib/string2.h"
#include "globals.h"
#include "mutt_tags.h"
-#include "queue.h"
+#include "lib/queue.h"
/**
* driver_tags_free - Free tags from a header
#include <stdbool.h>
#include <stddef.h>
-#include "queue.h"
+#include "lib/queue.h"
/**
* struct TagNode - LinkedList Tag Element
#include "format_flags.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_curses.h"
#include "globals.h"
#include "header.h"
#include "keymap.h"
-#include "list.h"
#include "mime.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "config.h"
#include "lib/lib.h"
#include "crypt_mod.h"
-#include "queue.h"
+#include "lib/queue.h"
/**
* struct CryptModule - A crypto plugin module
#include "filter.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mime.h"
#include "mutt_curses.h"
#include "mutt_regex.h"
#include "filter.h"
#include "format_flags.h"
#include "globals.h"
-#include "list.h"
#include "mutt_curses.h"
#include "mutt_idna.h"
#include "ncrypt.h"
#include "globals.h"
#include "gnupgparse.h"
#include "keymap.h"
-#include "list.h"
#include "mime.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "envelope.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_regex.h"
#include "globals.h"
#include "group.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
lib/exit.c
lib/file.c
lib/hash.c
+lib/list.c
lib/md5.c
lib/memory.c
lib/message.c
#include "globals.h"
#include "header.h"
#include "keymap.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_menu.h"
#include "globals.h"
#include "header.h"
#include "keymap.h"
-#include "list.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "opcodes.h"
#include "filter.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_curses.h"
#include "format_flags.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "mailbox.h"
#include "mime.h"
#include "mutt_curses.h"
#include "envelope.h"
#include "globals.h"
#include "header.h"
-#include "list.h"
#include "options.h"
#include "protos.h"
#include "sort.h"