]> granicus.if.org Git - mutt/commitdiff
Add a -Q option to query configuration variables. This is needed to
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 31 Jan 2002 10:18:01 +0000 (10:18 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 31 Jan 2002 10:18:01 +0000 (10:18 +0000)
avoid a separate mutt configuration parser in smime_keys.pl.

init.c
main.c
protos.h

diff --git a/init.c b/init.c
index a665a899ea1a222dcaa8f69a27ad76672469ea00..4e654b6587bd9216c5c9b0fa2696d7c187f94de8 100644 (file)
--- 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 bbea082b1302f69ee43fa503cee497683b799d12..8d6b5e4593b94bf1a117249afc08ce0492f0f335 100644 (file)
--- a/main.c
+++ b/main.c
@@ -86,6 +86,7 @@ static void mutt_usage (void)
 
   puts _(
 "usage: mutt [ -nRyzZ ] [ -e <cmd> ] [ -F <file> ] [ -m <type> ] [ -f <file> ]\n\
+       mutt [ -nR ] [ -e <cmd> ] [ -F <file> ] -Q <query> [ -Q <query> ] [...]
        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\
@@ -102,6 +103,7 @@ options:\n\
   -m <type>\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 <variable>\tquery a configuration variable\n\
   -R\t\topen mailbox in read-only mode\n\
   -s <subj>\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);
 
index 3d3e677f0afaaa3b5497a4d1fa1a9ea24d498220..895e66165bf102f18ba092a1918551e4364a4096 100644 (file)
--- 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 *);