From f48da111b50b817d757e52734e4ee840ba352cd9 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 24 Jul 2005 16:12:11 +0000 Subject: [PATCH] This patch adds an option -D to dump mutt's configuration after all configuration files have been read. Changes against PW's version: (1) curses isn't initialized; (2) variables are dumped to stdout, not to stderr. --- doc/manual.sgml.head | 1 + init.c | 32 ++++++++++++++++++++++++++++++++ main.c | 13 +++++++++++-- protos.h | 1 + 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head index 8b1a68ccc..87be7dc18 100644 --- a/doc/manual.sgml.head +++ b/doc/manual.sgml.head @@ -3062,6 +3062,7 @@ to send messages from the command line as well. -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 --git a/init.c b/init.c index 1910901fe..2e50d4380 100644 --- a/init.c +++ b/init.c @@ -2060,6 +2060,38 @@ int mutt_query_variables (LIST *queries) 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; + } + printf("%s\n", err.data); + } + + FREE (&token.data); + return 0; +} + char *mutt_getnamebyvalue (int val, const struct mapping_t *map) { int i; diff --git a/main.c b/main.c index c979f1d63..5d79b7f3d 100644 --- a/main.c +++ b/main.c @@ -99,6 +99,7 @@ static void mutt_usage (void) "usage: mutt [ -nRyzZ ] [ -e ] [ -F ] [ -m ] [ -f ]\n\ mutt [ -nR ] [ -e ] [ -F ] -Q [ -Q ] [...]\n\ mutt [ -nR ] [ -e ] [ -F ] -A [ -A ] [...]\n\ + mutt [ -nR ] [ -e ] [ -F ] -D\n\ mutt [ -nx ] [ -e ] [ -a ] [ -F ] [ -H ] [ -i ] [ -s ] [ -b ] [ -c ] [ ... ]\n\ mutt [ -n ] [ -e ] [ -F ] -p\n\ mutt -v[v]\n\ @@ -108,6 +109,7 @@ options:\n\ -a \tattach a file to the message\n\ -b
\tspecify a blind carbon-copy (BCC) address\n\ -c
\tspecify a carbon-copy (CC) address\n\ + -D\t\tprint the value of all variables to stderr\n\ -e \tspecify a command to be executed after initialization\n\ -f \tspecify which mailbox to read\n\ -F \tspecify an alternate muttrc file\n\ @@ -517,6 +519,7 @@ int main (int argc, char **argv) int version = 0; int i; int explicit_folder = 0; + int dump_variables = 0; extern char *optarg; extern int optind; @@ -546,7 +549,7 @@ int main (int argc, char **argv) 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 @@ int main (int argc, char **argv) msg->env->cc = rfc822_parse_adrlist (msg->env->cc, optarg); break; + case 'D': + dump_variables = 1; + break; + case 'd': #ifdef DEBUG debuglevel = atoi (optarg); @@ -662,7 +669,7 @@ int main (int argc, char **argv) } /* Check for a batch send. */ - if (!isatty (0) || queries || alias_queries) + if (!isatty (0) || queries || alias_queries || dump_variables) { set_option (OPTNOCURSES); sendflags = SENDBATCH; @@ -682,6 +689,8 @@ int main (int argc, char **argv) if (queries) return mutt_query_variables (queries); + if (dump_variables) + return mutt_dump_variables(); if (alias_queries) { diff --git a/protos.h b/protos.h index 3cda50538..248002b8e 100644 --- a/protos.h +++ b/protos.h @@ -277,6 +277,7 @@ int mutt_compose_attachment (BODY *a); 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); -- 2.40.0