rationalize list handling in mutt a bit.
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index f137e35..e215b0c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -529,7 +529,7 @@ static int addr_from_string (struct option_t* dst, const char* val,
                              char* errbuf __attribute__ ((unused)), size_t errlen __attribute__ ((unused))) {
   if (!dst)
     return (0);
-  address_delete ((address_t**) dst->data);
+  address_list_wipe((address_t**) dst->data);
   if (val && *val)
     *((address_t**) dst->data) = rfc822_parse_adrlist (NULL, val);
   return (1);
@@ -626,9 +626,9 @@ int query_quadoption (int opt, const char *prompt)
   /* not reached */
 }
 
-static void add_to_list (LIST ** list, const char *str)
+static void add_to_list (string_list_t ** list, const char *str)
 {
-  LIST *t, *last = NULL;
+  string_list_t *t, *last = NULL;
 
   /* don't add a NULL or empty string to the list */
   if (!str || *str == '\0')
@@ -646,7 +646,7 @@ static void add_to_list (LIST ** list, const char *str)
   }
 
   if (!*list || last) {
-    t = p_new(LIST, 1);
+    t = p_new(string_list_t, 1);
     t->data = m_strdup(str);
     if (last) {
       last->next = t;
@@ -780,12 +780,12 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat)
 }
 
 
-static void remove_from_list (LIST ** l, const char *str)
+static void remove_from_list (string_list_t ** l, const char *str)
 {
-  LIST *p, *last = NULL;
+  string_list_t *p, *last = NULL;
 
   if (m_strcmp("*", str) == 0)
-    mutt_free_list (l);         /* ``unCMD *'' means delete all current entries */
+    string_list_wipe(l);         /* ``unCMD *'' means delete all current entries */
   else {
     p = *l;
     last = NULL;
@@ -927,7 +927,7 @@ static int parse_list (BUFFER * buf, BUFFER * s,
 {
   do {
     mutt_extract_token (buf, s, 0);
-    add_to_list ((LIST **) data, buf->data);
+    add_to_list ((string_list_t **) data, buf->data);
   }
   while (MoreArgs (s));
 
@@ -1057,10 +1057,10 @@ static int parse_unlist (BUFFER * buf, BUFFER * s, unsigned long data,
      * Check for deletion of entire list
      */
     if (m_strcmp(buf->data, "*") == 0) {
-      mutt_free_list ((LIST **) data);
+      string_list_wipe((string_list_t **) data);
       break;
     }
-    remove_from_list ((LIST **) data, buf->data);
+    remove_from_list ((string_list_t **) data, buf->data);
   }
   while (MoreArgs (s));
 
@@ -1092,10 +1092,10 @@ static void _attachments_clean (void) {
   }
 }
 
-static int parse_attach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
+static int parse_attach_list (BUFFER *buf, BUFFER *s, string_list_t **ldata,
                               BUFFER *err __attribute__ ((unused))) {
   ATTACH_MATCH *a;
-  LIST *listp, *lastp;
+  string_list_t *listp, *lastp;
   char *p;
   char *tmpminor;
   int len;
@@ -1149,7 +1149,7 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
     debug_print (5, ("parse_attach_list: added %s/%s [%d]\n",
                      a->major, a->minor, a->major_int));
 
-    listp = p_new(LIST, 1);
+    listp = p_new(string_list_t, 1);
     listp->data = (char *)a;
     listp->next = NULL;
     if (lastp) {
@@ -1165,10 +1165,10 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
   return 0;
 }
 
-static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
+static int parse_unattach_list (BUFFER *buf, BUFFER *s, string_list_t **ldata,
                                 BUFFER *err __attribute__ ((unused))) {
   ATTACH_MATCH *a;
-  LIST *lp, *lastp, *newlp;
+  string_list_t *lp, *lastp, *newlp;
   char *tmp;
   int major;
   char *minor;
@@ -1192,7 +1192,7 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
     major = mutt_check_mime_type(tmp);
 
     /* We must do our own walk here because remove_from_list() will only
-     * remove the LIST->data, not anything pointed to by the LIST->data. */
+     * remove the string_list_t->data, not anything pointed to by the string_list_t->data. */
     lastp = NULL;
     for(lp = *ldata; lp; ) {
       a = (ATTACH_MATCH *)lp->data;
@@ -1228,7 +1228,7 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
   return 0;
 }
 
-static int print_attach_list (LIST *lp, char op, const char *name) {
+static int print_attach_list (string_list_t *lp, char op, const char *name) {
   while (lp) {
     printf("attachments %c%s %s/%s\n", op, name,
            ((ATTACH_MATCH *)lp->data)->major,
@@ -1243,7 +1243,7 @@ static int parse_attachments (BUFFER *buf, BUFFER *s,
                               unsigned long data __attribute__ ((unused)),
                               BUFFER *err) {
   char op, *category;
-  LIST **listp;
+  string_list_t **listp;
 
   mutt_extract_token(buf, s, 0);
   if (!buf->data || *buf->data == '\0') {
@@ -1293,7 +1293,7 @@ static int parse_attachments (BUFFER *buf, BUFFER *s,
 
 static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data __attribute__ ((unused)), BUFFER *err) {
   char op, *p;
-  LIST **listp;
+  string_list_t **listp;
 
   mutt_extract_token(buf, s, 0);
   if (!buf->data || *buf->data == '\0') {
@@ -1396,7 +1396,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s,
         set_option (OPTFORCEREDRAWINDEX);
       }
       else
-        alias_delete(&Aliases);
+        alias_list_wipe(&Aliases);
       break;
     }
     else
@@ -1413,7 +1413,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s,
           else
             Aliases = tmp->next;
           tmp->next = NULL;
-          alias_delete(&tmp);
+          alias_list_wipe(&tmp);
           break;
         }
         last = tmp;
@@ -1457,7 +1457,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s,
   }
   else {
     /* override the previous value */
-    address_delete (&tmp->addr);
+    address_list_wipe(&tmp->addr);
     if (CurrentMenu == MENU_ALIAS)
       set_option (OPTFORCEREDRAWINDEX);
   }
@@ -1496,15 +1496,15 @@ parse_unmy_hdr (BUFFER * buf, BUFFER * s,
                 unsigned long data __attribute__ ((unused)),
                 BUFFER * err __attribute__ ((unused)))
 {
-  LIST *last = NULL;
-  LIST *tmp = UserHeader;
-  LIST *ptr;
+  string_list_t *last = NULL;
+  string_list_t *tmp = UserHeader;
+  string_list_t *ptr;
   size_t l;
 
   do {
     mutt_extract_token (buf, s, 0);
     if (m_strcmp("*", buf->data) == 0)
-      mutt_free_list (&UserHeader);
+      string_list_wipe(&UserHeader);
     else {
       tmp = UserHeader;
       last = NULL;
@@ -1523,7 +1523,7 @@ parse_unmy_hdr (BUFFER * buf, BUFFER * s,
             UserHeader = tmp->next;
           tmp = tmp->next;
           ptr->next = NULL;
-          mutt_free_list (&ptr);
+          string_list_wipe(&ptr);
         }
         else {
           last = tmp;
@@ -1539,7 +1539,7 @@ parse_unmy_hdr (BUFFER * buf, BUFFER * s,
 static int parse_my_hdr (BUFFER * buf, BUFFER * s, unsigned long data __attribute__ ((unused)),
                          BUFFER * err)
 {
-  LIST *tmp;
+  string_list_t *tmp;
   size_t keylen;
   char *p;
 
@@ -1563,11 +1563,11 @@ static int parse_my_hdr (BUFFER * buf, BUFFER * s, unsigned long data __attribut
       if (!tmp->next)
         break;
     }
-    tmp->next = mutt_new_list ();
+    tmp->next = string_item_new();
     tmp = tmp->next;
   }
   else {
-    tmp = mutt_new_list ();
+    tmp = string_item_new();
     UserHeader = tmp;
   }
   tmp->data = buf->data;
@@ -1991,7 +1991,7 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
             r = -1;
             break;
           } else if (DTYPE (option->type) == DT_ADDR)
-            address_delete ((address_t **) option->data);
+            address_list_wipe((address_t **) option->data);
           else if (DTYPE (option->type) == DT_USER)
             /* to unset $user_ means remove */
             hash_delete (ConfigOptions, option->option,
@@ -2515,9 +2515,9 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
 }
 
 /* Implement the -Q command line flag */
-int mutt_query_variables (LIST * queries)
+int mutt_query_variables (string_list_t * queries)
 {
-  LIST *p;
+  string_list_t *p;
 
   char errbuff[STRING];
   char command[STRING];
@@ -2544,7 +2544,7 @@ int mutt_query_variables (LIST * queries)
   return 0;
 }
 
-static int mutt_execute_commands (LIST * p)
+static int mutt_execute_commands (string_list_t * p)
 {
   BUFFER err, token;
   char errstr[SHORT_STRING];
@@ -2564,7 +2564,7 @@ static int mutt_execute_commands (LIST * p)
   return 0;
 }
 
-void mutt_init (int skip_sys_rc, LIST * commands)
+void mutt_init (int skip_sys_rc, string_list_t * commands)
 {
   struct passwd *pw;
   struct utsname utsname;