<<< Date Index >>>     <<< Thread Index >>>

For 1.5.10: variable dump patch



Hi all,

As the subject says, this patch adds an option which dumps out the value of
all mutt's variables. There have been a few times on the newsgroup when this
would be useful, and if we ever get a bug tracking system again, it could be
useful for that as well.

The patch is generated against CVS head. Er; Thomas, if you take it, you
probably want to remove the change it makes to PATCHES... :-)

(How's progress going on the BTS, anyway?)

-- 
Paul
diff -urN --exclude='*.o' -x patchlist.c -x mutt -x configure -x tags -x 
'config.*' -x '*.swp' -x '*Makefile' mutt/PATCHES mutt.dump/PATCHES
--- mutt/PATCHES        2002-12-10 18:45:34.000000000 +0000
+++ mutt.dump/PATCHES   2005-03-19 14:45:47.000000000 +0000
@@ -0,0 +1 @@
+patch-1.5.9.pw.dumpvar.1
diff -urN --exclude='*.o' -x patchlist.c -x mutt -x configure -x tags -x 
'config.*' -x '*.swp' -x '*Makefile' mutt/doc/manual.sgml 
mutt.dump/doc/manual.sgml
--- mutt/doc/manual.sgml        2005-03-19 14:25:56.000000000 +0000
+++ mutt.dump/doc/manual.sgml   2005-03-19 14:40:40.000000000 +0000
@@ -3061,6 +3061,7 @@
 -a      attach a file to a message
 -b      specify a blind carbon-copy (BCC) address
 -c      specify a carbon-copy (Cc) address
+-D      print the value of all mutt variables to stderr
 -e      specify a config command to be run after initilization files are read
 -f      specify a mailbox to load
 -F      specify an alternate file to read initialization commands
diff -urN --exclude='*.o' -x patchlist.c -x mutt -x configure -x tags -x 
'config.*' -x '*.swp' -x '*Makefile' mutt/init.c mutt.dump/init.c
--- mutt/init.c 2005-02-13 00:42:33.000000000 +0000
+++ mutt.dump/init.c    2005-03-19 12:30:02.000000000 +0000
@@ -2096,6 +2096,38 @@
   return 0;
 }
 
+/* dump out the value of all the variables we have */
+int mutt_dump_variables (void)
+{
+  int i;
+  
+  char errbuff[STRING];
+  char command[STRING];
+  
+  BUFFER err, token;
+  
+  memset (&err, 0, sizeof (err));
+  memset (&token, 0, sizeof (token));
+  
+  err.data = errbuff;
+  err.dsize = sizeof (errbuff);
+  
+  for (i = 0; MuttVars[i].option; i++)
+  {
+    snprintf (command, sizeof (command), "set ?%s\n", MuttVars[i].option);
+    if (mutt_parse_rc_line (command, &token, &err) == -1)
+    {
+      fprintf (stderr, "%s\n", err.data);
+      FREE (&token.data);
+      return 1;
+    }
+    fprintf(stderr, "%s\n", err.data);
+  }
+  
+  FREE (&token.data);
+  return 0;
+}
+
 char *mutt_getnamebyvalue (int val, const struct mapping_t *map)
 {
   int i;
diff -urN --exclude='*.o' -x patchlist.c -x mutt -x configure -x tags -x 
'config.*' -x '*.swp' -x '*Makefile' mutt/main.c mutt.dump/main.c
--- mutt/main.c 2005-02-13 00:42:33.000000000 +0000
+++ mutt.dump/main.c    2005-03-19 12:30:02.000000000 +0000
@@ -99,6 +99,7 @@
 "usage: mutt [ -nRyzZ ] [ -e <cmd> ] [ -F <file> ] [ -m <type> ] [ -f <file> 
]\n\
        mutt [ -nR ] [ -e <cmd> ] [ -F <file> ] -Q <query> [ -Q <query> ] 
[...]\n\
        mutt [ -nR ] [ -e <cmd> ] [ -F <file> ] -A <alias> [ -A <alias> ] 
[...]\n\
+       mutt [ -nR ] [ -e <cmd> ] [ -F <file> ] -D\n\
        mutt [ -nx ] [ -e <cmd> ] [ -a <file> ] [ -F <file> ] [ -H <file> ] [ 
-i <file> ] [ -s <subj> ] [ -b <addr> ] [ -c <addr> ] <addr> [ ... ]\n\
        mutt [ -n ] [ -e <cmd> ] [ -F <file> ] -p\n\
        mutt -v[v]\n\
@@ -108,6 +109,7 @@
   -a <file>\tattach a file to the message\n\
   -b <address>\tspecify a blind carbon-copy (BCC) address\n\
   -c <address>\tspecify a carbon-copy (CC) address\n\
+  -D\t\tprint the value of all variables to stderr\n\
   -e <command>\tspecify a command to be executed after initialization\n\
   -f <file>\tspecify which mailbox to read\n\
   -F <file>\tspecify an alternate muttrc file\n\
@@ -517,6 +519,7 @@
   int version = 0;
   int i;
   int explicit_folder = 0;
+  int dump_variables = 0;
   extern char *optarg;
   extern int optind;
 
@@ -546,7 +549,7 @@
   memset (Options, 0, sizeof (Options));
   memset (QuadOptions, 0, sizeof (QuadOptions));
   
-  while ((i = getopt (argc, argv, "A:a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != 
EOF)
+  while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != 
EOF)
     switch (i)
     {
       case 'A':
@@ -577,6 +580,10 @@
          msg->env->cc = rfc822_parse_adrlist (msg->env->cc, optarg);
        break;
 
+      case 'D':
+       dump_variables = 1;
+       break;
+
       case 'd':
 #ifdef DEBUG
        debuglevel = atoi (optarg);
@@ -682,6 +689,8 @@
 
   if (queries)
     return mutt_query_variables (queries);
+  if (dump_variables)
+    return mutt_dump_variables();
 
   if (alias_queries)
   {
diff -urN --exclude='*.o' -x patchlist.c -x mutt -x configure -x tags -x 
'config.*' -x '*.swp' -x '*Makefile' mutt/protos.h mutt.dump/protos.h
--- mutt/protos.h       2005-02-03 19:04:39.000000000 +0000
+++ mutt.dump/protos.h  2005-03-19 12:30:02.000000000 +0000
@@ -277,6 +277,7 @@
 int mutt_copy_body (FILE *, BODY **, BODY *);
 int mutt_decode_save_attachment (FILE *, BODY *, char *, int, int);
 int mutt_display_message (HEADER *h);
+int mutt_dump_variables (void);
 int mutt_edit_attachment(BODY *);
 int mutt_edit_message (CONTEXT *, HEADER *);
 int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags);

Attachment: signature.asc
Description: Digital signature