]> sjero.net Git - wget/blobdiff - src/main.c
Exit with failure if -k is specified and -O is not a regular file.
[wget] / src / main.c
index dddc4b2425df1ad38015472e08d23d9513df42a9..9edec13b67919b4cc942dc3872dc0e39ae6038b7 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.
 
@@ -76,7 +76,7 @@ extern char *compilation_string;
 extern char *system_getrc;
 extern char *link_string;
 /* defined in build_info.c */
-extern char *compiled_features[];
+extern const char *compiled_features[];
 /* Used for --version output in print_version */
 #define MAX_CHARS_PER_LINE      72
 #define TABULATION              4
@@ -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 },
@@ -457,6 +458,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"),
@@ -785,15 +789,8 @@ print_version (void)
   char *env_wgetrc, *user_wgetrc;
   int i;
 
-#ifdef __VMS
-  printf (_("GNU Wget %s built on VMS %s %s.\n\n"),
-   version_string, vms_arch(), vms_vers());
-#else /* def __VMS */
   printf (_("GNU Wget %s built on %s.\n\n"), version_string, OS_TYPE);
-#endif /* def __VMS */
-  /* 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;
@@ -806,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);
@@ -831,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
@@ -875,11 +875,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. */
@@ -1212,6 +1217,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)
+        {
+          printf (_("-k can be used together with -O only if outputting to \
+a regular file.\n"));
+          print_usage ();
+          exit(1);
+        }
     }
 
 #ifdef __VMS