Rocco Rutte:
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index 7ffb37c..0d7bbbe 100644 (file)
--- a/init.c
+++ b/init.c
@@ -21,7 +21,7 @@
 #include "mutt_crypt.h"
 #include "mutt_idna.h"
 
-#if defined(USE_SSL) || defined(USE_NSS) || defined(USE_GNUTLS)
+#if defined(USE_SSL) || defined(USE_GNUTLS)
 #include "mutt_ssl.h"
 #endif
 
@@ -32,6 +32,7 @@
 #include "lib/intl.h"
 #include "lib/str.h"
 #include "lib/rx.h"
+#include "lib/list.h"
 #include "lib/debug.h"
 
 #include <ctype.h>
@@ -428,6 +429,8 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat)
 
   /* Being first is a special case. */
   spam = *list;
+  if (!spam)
+    return 0;
   if (spam->rx && !mutt_strcmp (spam->rx->pattern, pat)) {
     *list = spam->next;
     rx_free (&spam->rx);
@@ -1937,6 +1940,26 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
                   "reverse-" : "",
                   (*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" :
                   "", p);
+      } 
+      else if (DTYPE (MuttVars[idx].type) == DT_MAGIC) {
+        char *p;
+        switch (DefaultMagic) {
+          case M_MBOX:
+            p = "mbox";
+            break;
+          case M_MMDF:
+            p = "MMDF";
+            break;
+          case M_MH:
+            p = "MH";
+          break;
+          case M_MAILDIR:
+            p = "Maildir";
+            break;
+          default:
+            p = "unknown";
+        }
+        strfcpy (tmp, p, sizeof (tmp));
       }
       else if (DTYPE (MuttVars[idx].type) == DT_BOOL)
         strfcpy (tmp, option (MuttVars[idx].data) ? "yes" : "no",
@@ -2325,3 +2348,50 @@ int mutt_get_hook_type (const char *name)
       return c->data;
   return 0;
 }
+
+static int opt_cmp (const void* a, const void* b) {
+  return (mutt_strcmp ((*(struct option_t**) a)->option,
+                       (*(struct option_t**) b)->option));
+}
+
+/* dump out the value of all the variables we have */
+int mutt_dump_variables (void) {
+  int i;
+
+  char errbuff[STRING];
+  char command[STRING];
+  list2_t* tmp = NULL;
+
+  BUFFER err, token;
+
+  memset (&err, 0, sizeof (err));
+  memset (&token, 0, sizeof (token));
+
+  err.data = errbuff;
+  err.dsize = sizeof (errbuff);
+
+  /* get all non-synonyms into list... */
+  for (i = 0; MuttVars[i].option; i++) {
+    if (MuttVars[i].type == DT_SYN)
+      continue;
+    list_push_back (&tmp, &MuttVars[i]);
+  }
+  if (!list_empty(tmp)) {
+    /* ...and dump list sorted */
+    qsort (tmp->data, tmp->length, sizeof (void*), opt_cmp);
+    for (i = 0; i < tmp->length; i++) {
+      snprintf (command, sizeof (command), "set ?%s\n",
+                ((struct option_t*) tmp->data[i])->option);
+      if (mutt_parse_rc_line (command, &token, &err) == -1) {
+        fprintf (stderr, "%s\n", err.data);
+        FREE (&token.data);
+        list_del (&tmp, NULL);
+        return 1;
+      }
+      printf("%s\n", err.data);
+    }
+  }
+  FREE (&token.data);
+  list_del (&tmp, NULL);
+  return 0;
+}