From: Thomas Roessler Date: Thu, 31 Jan 2002 10:18:01 +0000 (+0000) Subject: Add a -Q option to query configuration variables. This is needed to X-Git-Tag: mutt-1-5-1-rel~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c6ad94a3c6e49330eef799652ebb3a5507c54f27;p=mutt Add a -Q option to query configuration variables. This is needed to avoid a separate mutt configuration parser in smime_keys.pl. --- diff --git a/init.c b/init.c index a665a899..4e654b65 100644 --- a/init.c +++ b/init.c @@ -1638,6 +1638,38 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) return 0; } +/* Implement the -Q command line flag */ +int mutt_query_variables (LIST *queries) +{ + LIST *p; + + 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 (p = queries; p; p = p->next) + { + snprintf (command, sizeof (command), "set ?%s\n", p->data); + 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 bbea082b..8d6b5e45 100644 --- a/main.c +++ b/main.c @@ -86,6 +86,7 @@ static void mutt_usage (void) puts _( "usage: mutt [ -nRyzZ ] [ -e ] [ -F ] [ -m ] [ -f ]\n\ + mutt [ -nR ] [ -e ] [ -F ] -Q [ -Q ] [...] mutt [ -nx ] [ -e ] [ -a ] [ -F ] [ -H ] [ -i ] [ -s ] [ -b ] [ -c ] [ ... ]\n\ mutt [ -n ] [ -e ] [ -F ] -p\n\ mutt -v[v]\n\ @@ -102,6 +103,7 @@ options:\n\ -m \tspecify a default mailbox type\n\ -n\t\tcauses Mutt not to read the system Muttrc\n\ -p\t\trecall a postponed message\n\ + -Q \tquery a configuration variable\n\ -R\t\topen mailbox in read-only mode\n\ -s \tspecify a subject (must be in quotes if it has spaces)\n\ -v\t\tshow version and compile-time definitions\n\ @@ -460,6 +462,7 @@ int main (int argc, char **argv) HEADER *msg = NULL; LIST *attach = NULL; LIST *commands = NULL; + LIST *queries = NULL; int sendflags = 0; int flags = 0; int version = 0; @@ -494,7 +497,7 @@ int main (int argc, char **argv) memset (Options, 0, sizeof (Options)); memset (QuadOptions, 0, sizeof (QuadOptions)); - while ((i = getopt (argc, argv, "a:b:F:f:c:d:e:H:s:i:hm:npRvxyzZ")) != EOF) + while ((i = getopt (argc, argv, "a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) switch (i) { case 'a': @@ -556,6 +559,10 @@ int main (int argc, char **argv) sendflags |= SENDPOSTPONED; break; + case 'Q': + queries = mutt_add_list (queries, optarg); + break; + case 'R': flags |= M_RO; /* read-only mode */ break; @@ -603,7 +610,7 @@ int main (int argc, char **argv) } /* Check for a batch send. */ - if (!isatty (0)) + if (!isatty (0) || queries) { set_option (OPTNOCURSES); sendflags = SENDBATCH; @@ -618,6 +625,9 @@ int main (int argc, char **argv) mutt_init (flags & M_NOSYSRC, commands); mutt_free_list (&commands); + if (queries) + return mutt_query_variables (queries); + if (newMagic) mx_set_magic (newMagic); diff --git a/protos.h b/protos.h index 3d3e677f..895e6616 100644 --- a/protos.h +++ b/protos.h @@ -314,6 +314,7 @@ int mutt_pattern_func (int, char *); int mutt_pipe_attachment (FILE *, BODY *, const char *, char *); int mutt_print_attachment (FILE *, BODY *); int mutt_query_complete (char *, size_t); +int mutt_query_variables (LIST *queries); int mutt_save_attachment (FILE *, BODY *, char *, int, HEADER *); void _mutt_save_message (HEADER *, CONTEXT *, int, int, int); int mutt_save_message (HEADER *, int, int, int, int *);