Rocco Rutte:
[apps/madmutt.git] / main.c
diff --git a/main.c b/main.c
index a6e848f..1d3d349 100644 (file)
--- a/main.c
+++ b/main.c
@@ -25,6 +25,7 @@
 #include "url.h"
 #include "mutt_crypt.h"
 #include "mutt_idna.h"
+#include "xterm.h"
 
 #include "lib/mem.h"
 #include "lib/intl.h"
@@ -63,17 +64,18 @@ Mutt is free software, and you are welcome to redistribute it\n\
 under certain conditions; type `muttng -vv' for details.\n");
 
 static const char *Copyright = N_("\
-Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>\n\
+Copyright (C) 1996-2004 Michael R. Elkins <me@mutt.org>\n\
 Copyright (C) 1996-2002 Brandon Long <blong@fiction.net>\n\
-Copyright (C) 1997-2002 Thomas Roessler <roessler@does-not-exist.org>\n\
-Copyright (C) 1998-2002 Werner Koch <wk@isil.d.shuttle.de>\n\
-Copyright (C) 1999-2002 Brendan Cully <brendan@kublai.com>\n\
+Copyright (C) 1997-2005 Thomas Roessler <roessler@does-not-exist.org>\n\
+Copyright (C) 1998-2005 Werner Koch <wk@isil.d.shuttle.de>\n\
+Copyright (C) 1999-2005 Brendan Cully <brendan@kublai.com>\n\
 Copyright (C) 1999-2002 Tommi Komulainen <Tommi.Komulainen@iki.fi>\n\
 Copyright (C) 2000-2002 Edmund Grimley Evans <edmundo@rano.org>\n\n\
-Parts were written/modified by:\n\
-Andreas Krennmair <ak@synflood.at>\n\
-Nico Golde <nico@ngolde.de>\n\
-Rocco Rutte <pdmef@cs.tu-berlin.de>\n\
+Copyright (C) 2005:\n\
+  Parts were written/modified by:\n\
+     Andreas Krennmair <ak@synflood.at>\n\
+     Nico Golde <nico@ngolde.de>\n\
+     Rocco Rutte <pdmef@cs.tu-berlin.de>\n\
 \n\
 Lots of others not mentioned here contributed lots of code,\n\
 fixes, and suggestions.\n\
@@ -108,6 +110,7 @@ static void mutt_usage (void)
     ("usage: muttng [ -nRyzZ ] [ -e <cmd> ] [ -F <file> ] [ -m <type> ] [ -f <file> ]\n\
        muttng [ -nR ] [ -e <cmd> ] [ -F <file> ] -Q <query> [ -Q <query> ] [...]\n\
        muttng [ -nR ] [ -e <cmd> ] [ -F <file> ] -A <alias> [ -A <alias> ] [...]\n\
+       muttng [ -nR ] [ -e <cmd> ] [ -F <file> ] -D\n\
        muttng [ -nx ] [ -e <cmd> ] [ -a <file> ] [ -F <file> ] [ -H <file> ] [ -i <file> ] [ -s <subj> ] [ -b <addr> ] [ -c <addr> ] <addr> [ ... ]\n\
        muttng [ -n ] [ -e <cmd> ] [ -F <file> ] -p\n\
        muttng -v[v]\n\
@@ -117,6 +120,7 @@ options:\n\
   -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 stdout\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\
@@ -124,6 +128,7 @@ options:\n\
   -G\t\tselect a newsgroup (if compiled with NNTP)\n\
   -H <file>\tspecify a draft file to read header and body from\n\
   -i <file>\tspecify a file which Mutt-ng should include in the body\n\
+  -d <level>\t specify debugging level of Mutt-ng\n\
   -m <type>\tspecify a default mailbox type\n\
   -n\t\tcauses Mutt-ng not to read the system Muttngrc\n\
   -p\t\trecall a postponed message\n\
@@ -227,6 +232,11 @@ static void show_version (void)
          "+USE_INODESORT   "
 #else
          "-USE_INODESORT   "
+#endif
+#if USE_HCACHE
+         "+USE_HCACHE  "
+#else
+         "-USE_HCACHE  "
 #endif
     );
   puts (
@@ -245,11 +255,6 @@ static void show_version (void)
 #else
          "-USE_IMAP  "
 #endif
-#ifdef IMAP_EDIT_THREADS
-         "+IMAP_EDIT_THREADS  "
-#else
-         "-IMAP_EDIT_THREADS  "
-#endif
 #ifdef USE_GSS
          "+USE_GSS  "
 #else
@@ -265,11 +270,6 @@ static void show_version (void)
 #else
          "-USE_GNUTLS  "
 #endif
-#ifdef USE_GNUTLS
-         "+USE_GNUTLS  "
-#else
-         "-USE_GNUTLS  "
-#endif
 #ifdef USE_SASL
          "+USE_SASL  "
 #else
@@ -361,11 +361,6 @@ static void show_version (void)
 #else
          "-BUFFY_SIZE "
 #endif
-#ifdef EXACT_ADDRESS
-         "+EXACT_ADDRESS  "
-#else
-         "-EXACT_ADDRESS  "
-#endif
 #ifdef SUN_ATTACHMENT
          "+SUN_ATTACHMENT  "
 #else
@@ -422,16 +417,6 @@ static void show_version (void)
          "+HAVE_GETADDRINFO  "
 #else
          "-HAVE_GETADDRINFO  "
-#endif
-#if USE_HCACHE
-         "+USE_HCACHE  "
-#else
-         "-USE_HCACHE  "
-#endif
-#if USE_HCACHE
-         "+USE_HCACHE  "
-#else
-         "-USE_HCACHE  "
 #endif
     );
 
@@ -454,6 +439,7 @@ static void show_version (void)
 
   puts (_(ReachingUs));
 
+  puts (_("Mutt-ng is based on the following patches written for mutt:\n"));
   mutt_print_patchlist ();
 
   exit (0);
@@ -519,11 +505,15 @@ 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;
 
+  /* initialize random number for tmp file creation */ 
+  srand ((unsigned int) time (NULL));
+  
   /* sanity check against stupid administrators */
-
+  
   if (getegid () != getgid ()) {
     fprintf (stderr, "%s: I don't want to run with privileges!\n", argv[0]);
     exit (1);
@@ -549,10 +539,10 @@ int main (int argc, char **argv)
 #ifdef USE_NNTP
   while ((i =
           getopt (argc, argv,
-                  "A:a:b:F:f:c:d:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
+                  "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
 #else
   while ((i =
-          getopt (argc, argv, "A:a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
+          getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
 #endif
     switch (i) {
     case 'A':
@@ -591,12 +581,22 @@ int main (int argc, char **argv)
     case 'd':
       debug_setlevel(atoi(optarg));
 #ifdef DEBUG
-      printf (_("Debugging at level %d.\n"), atoi(optarg));
+      if (atoi(optarg) <= DEBUG_MAX_LEVEL && atoi(optarg) >= DEBUG_MIN_LEVEL)
+        printf (_("Debugging at level %d.\n"), atoi(optarg));
+      else {
+        printf(_("Please specify a valid debugging level ("
+                 DEBUG_MIN_LEVEL_S "-" DEBUG_MAX_LEVEL_S ").\n"));
+        return 1;
+      }
 #else
       printf _("DEBUG was not defined during compilation.  Ignored.\n");
 #endif
       break;
 
+    case 'D':
+      dump_variables = 1;
+      break;
+
     case 'e':
       commands = mutt_add_list (commands, optarg);
       break;
@@ -686,7 +686,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;
   }
@@ -706,6 +706,8 @@ int main (int argc, char **argv)
 
   if (queries)
     return mutt_query_variables (queries);
+  if (dump_variables)
+    return (mutt_dump_variables ());
 
   if (alias_queries) {
     int rv = 0;
@@ -805,7 +807,7 @@ int main (int argc, char **argv)
 
     if (infile || bodytext) {
       if (infile) {
-        if (safe_strcmp ("-", infile) == 0)
+        if (mutt_strcmp ("-", infile) == 0)
           fin = stdin;
         else {
           char path[_POSIX_PATH_MAX];
@@ -951,6 +953,8 @@ int main (int argc, char **argv)
                                     M_READONLY : 0, NULL))
         || !explicit_folder) {
       mutt_index_menu ();
+      if (option (OPTXTERMSETTITLES))
+        mutt_xterm_set_title (NONULL (XtermLeave));
       if (Context)
         FREE (&Context);
     }