]> sjero.net Git - wget/blobdiff - src/main.c
Drop the current maintainer line from the version display.
[wget] / src / main.c
index ad39a53b9cdead59612a0ab75cc8ba936d495ab6..fa46eb57d35ef3d072728143219109a87f7a1ed3 100644 (file)
@@ -1,6 +1,6 @@
 /* Command line parsing.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -266,6 +266,7 @@ static struct cmdline_option option_data[] =
     { "timeout", 'T', OPT_VALUE, "timeout", -1 },
     { "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 },
     { "tries", 't', OPT_VALUE, "tries", -1 },
+    { "use-server-timestamps", 0, OPT_BOOLEAN, "useservertimestamps", -1 },
     { "user", 0, OPT_VALUE, "user", -1 },
     { "user-agent", 'U', OPT_VALUE, "useragent", -1 },
     { "verbose", 'v', OPT_BOOLEAN, "verbose", -1 },
@@ -381,9 +382,10 @@ init_switches (void)
 
 /* Print the usage message.  */
 static void
-print_usage (void)
+print_usage (int error)
 {
-  printf (_("Usage: %s [OPTION]... [URL]...\n"), exec_name);
+  fprintf (error ? stderr : stdout, _("Usage: %s [OPTION]... [URL]...\n"),
+           exec_name);
 }
 
 /* Print the help message, describing all the available options.  If
@@ -457,6 +459,9 @@ Download:\n"),
   -N,  --timestamping            don't re-retrieve files unless newer than\n\
                                  local.\n"),
     N_("\
+  --no-use-server-timestamps     don't set the local file's timestamp by\n\
+                                 the one on the server.\n"),
+    N_("\
   -S,  --server-response         print server response.\n"),
     N_("\
        --spider                  don't download anything.\n"),
@@ -687,7 +692,7 @@ Recursive accept/reject:\n"),
 
   printf (_("GNU Wget %s, a non-interactive network retriever.\n"),
           version_string);
-  print_usage ();
+  print_usage (0);
 
   for (i = 0; i < countof (help); i++)
     fputs (_(help[i]), stdout);
@@ -781,14 +786,11 @@ print_version (void)
   const char *locale_title  = _("Locale: ");
   const char *compile_title = _("Compile: ");
   const char *link_title    = _("Link: ");
-  char *line;
   char *env_wgetrc, *user_wgetrc;
   int i;
 
   printf (_("GNU Wget %s built on %s.\n\n"), version_string, OS_TYPE);
-  /* compiled_features is a char*[]. We limit the characters per
-     line to MAX_CHARS_PER_LINE and prefix each line with a constant
-     number of spaces for proper alignment. */
+
   for (i = 0; compiled_features[i] != NULL; )
     {
       int line_length = MAX_CHARS_PER_LINE;
@@ -801,6 +803,7 @@ print_version (void)
       printf ("\n");
     }
   printf ("\n");
+
   /* Handle the case when $WGETRC is unset and $HOME/.wgetrc is
      absent. */
   printf ("%s\n", wgetrc_title);
@@ -826,13 +829,15 @@ print_version (void)
                         MAX_CHARS_PER_LINE);
 #endif /* def ENABLE_NLS */
 
-  format_and_print_line (compile_title,
-                        compilation_string,
-                        MAX_CHARS_PER_LINE);
+  if (compilation_string != NULL)
+    format_and_print_line (compile_title,
+                           compilation_string,
+                           MAX_CHARS_PER_LINE);
 
-  format_and_print_line (link_title,
-                        link_string,
-                        MAX_CHARS_PER_LINE);
+  if (link_string != NULL)
+    format_and_print_line (link_title,
+                           link_string,
+                           MAX_CHARS_PER_LINE);
 
   printf ("\n");
   /* TRANSLATORS: When available, an actual copyright character
@@ -848,8 +853,6 @@ There is NO WARRANTY, to the extent permitted by law.\n"), stdout);
      names such as this one. See en_US.po for reference. */
   fputs (_("\nOriginally written by Hrvoje Niksic <hniksic@xemacs.org>.\n"),
          stdout);
-  fputs (_("Currently maintained by Micah Cowan <micah@cowan.name>.\n"),
-         stdout);
   fputs (_("Please send bug reports and questions to <bug-wget@gnu.org>.\n"),
          stdout);
   exit (0);
@@ -870,11 +873,16 @@ main (int argc, char **argv)
   i18n_initialize ();
 
   /* Construct the name of the executable, without the directory part.  */
+#ifdef __VMS
+  /* On VMS, lose the "dev:[dir]" prefix and the ".EXE;nnn" suffix. */
+  exec_name = vms_basename (argv[0]);
+#else /* def __VMS */
   exec_name = strrchr (argv[0], PATH_SEPARATOR);
   if (!exec_name)
     exec_name = argv[0];
   else
     ++exec_name;
+#endif /* def __VMS [else] */
 
 #ifdef WINDOWS
   /* Drop extension (typically .EXE) from executable filename. */
@@ -898,7 +906,7 @@ main (int argc, char **argv)
         {
           if (ret == '?')
             {
-              print_usage ();
+              print_usage (0);
               printf ("\n");
               printf (_("Try `%s --help' for more options.\n"), exec_name);
               exit (2);
@@ -966,10 +974,12 @@ main (int argc, char **argv)
                   setoptval ("noparent", "1", opt->long_name);
                   break;
                 default:
-                  printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p);
-                  print_usage ();
-                  printf ("\n");
-                  printf (_("Try `%s --help' for more options.\n"), exec_name);
+                  fprintf (stderr, _("%s: illegal option -- `-n%c'\n"),
+                           exec_name, *p);
+                  print_usage (1);
+                  fprintf (stderr, "\n");
+                  fprintf (stderr, _("Try `%s --help' for more options.\n"),
+                           exec_name);
                   exit (1);
                 }
             break;
@@ -1024,22 +1034,23 @@ main (int argc, char **argv)
   /* Sanity checks.  */
   if (opt.verbose && opt.quiet)
     {
-      printf (_("Can't be verbose and quiet at the same time.\n"));
-      print_usage ();
+      fprintf (stderr, _("Can't be verbose and quiet at the same time.\n"));
+      print_usage (1);
       exit (1);
     }
   if (opt.timestamping && opt.noclobber)
     {
-      printf (_("\
+      fprintf (stderr, _("\
 Can't timestamp and not clobber old files at the same time.\n"));
-      print_usage ();
+      print_usage (1);
       exit (1);
     }
 #ifdef ENABLE_IPV6
   if (opt.ipv4_only && opt.ipv6_only)
     {
-      printf (_("Cannot specify both --inet4-only and --inet6-only.\n"));
-      print_usage ();
+      fprintf (stderr,
+               _("Cannot specify both --inet4-only and --inet6-only.\n"));
+      print_usage (1);
       exit (1);
     }
 #endif
@@ -1050,8 +1061,8 @@ Can't timestamp and not clobber old files at the same time.\n"));
         {
           fputs (_("\
 Cannot specify both -k and -O if multiple URLs are given, or in combination\n\
-with -p or -r. See the manual for details.\n\n"), stdout);
-          print_usage ();
+with -p or -r. See the manual for details.\n\n"), stderr);
+          print_usage (1);
           exit (1);
         }
       if (opt.page_requisites
@@ -1071,27 +1082,30 @@ for details.\n\n"));
       if (opt.noclobber && file_exists_p(opt.output_document))
            {
               /* Check if output file exists; if it does, exit. */
-              logprintf (LOG_VERBOSE, _("File `%s' already there; not retrieving.\n"), opt.output_document);
+              logprintf (LOG_VERBOSE,
+                         _("File `%s' already there; not retrieving.\n"),
+                         opt.output_document);
               exit(1);
            }
     }
 
   if (opt.ask_passwd && opt.passwd)
     {
-      printf (_("Cannot specify both --ask-password and --password.\n"));
-      print_usage ();
+      fprintf (stderr,
+               _("Cannot specify both --ask-password and --password.\n"));
+      print_usage (1);
       exit (1);
     }
 
   if (!nurl && !opt.input_filename)
     {
       /* No URL specified.  */
-      printf (_("%s: missing URL\n"), exec_name);
-      print_usage ();
+      fprintf (stderr, _("%s: missing URL\n"), exec_name);
+      print_usage (1);
       printf ("\n");
       /* #### Something nicer should be printed here -- similar to the
          pre-1.5 `--help' page.  */
-      printf (_("Try `%s --help' for more options.\n"), exec_name);
+      fprintf (stderr, _("Try `%s --help' for more options.\n"), exec_name);
       exit (1);
     }
 
@@ -1111,7 +1125,7 @@ for details.\n\n"));
   if (opt.enable_iri || opt.locale || opt.encoding_remote)
     {
       /* sXXXav : be more specific... */
-      printf(_("This version does not have support for IRIs\n"));
+      fprintf (stderr, _("This version does not have support for IRIs\n"));
       exit(1);
     }
 #endif
@@ -1207,6 +1221,13 @@ WARNING: Can't reopen standard output in binary mode;\n\
           if (fstat (fileno (output_stream), &st) == 0 && S_ISREG (st.st_mode))
             output_stream_regular = true;
         }
+      if (!output_stream_regular && opt.convert_links)
+        {
+          fprintf (stderr, _("-k can be used together with -O only if \
+outputting to a regular file.\n"));
+          print_usage (1);
+          exit(1);
+        }
     }
 
 #ifdef __VMS
@@ -1214,13 +1235,9 @@ WARNING: Can't reopen standard output in binary mode;\n\
      any), otherwise according to the current default device.
   */
   if (output_stream == NULL)
-    {
-      set_ods5_dest( "SYS$DISK");
-    }
+    set_ods5_dest( "SYS$DISK");
   else if (output_stream != stdout)
-    {
-      set_ods5_dest( opt.output_document);
-    }
+    set_ods5_dest( opt.output_document);
 #endif /* def __VMS */
 
 #ifdef WINDOWS
@@ -1316,9 +1333,7 @@ WARNING: Can't reopen standard output in binary mode;\n\
 
   /* Print broken links. */
   if (opt.recursive && opt.spider)
-    {
-      print_broken_links();
-    }
+    print_broken_links ();
 
   /* Print the downloaded sum.  */
   if ((opt.recursive || opt.page_requisites