]> sjero.net Git - wget/blobdiff - src/main.c
[svn] Improvements/fixes to HTTP Content-Disposition header support.
[wget] / src / main.c
index ecbd88083836ddec0639422850256f69c11d82cc..1f3fb25a2172f90de209b9dc31e6807482611766 100644 (file)
@@ -1,5 +1,5 @@
 /* Command line parsing.
-   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1996-2005 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -14,8 +14,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with Wget; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+along with Wget; if not, write to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
 In addition, as a special exception, the Free Software Foundation
 gives permission to link the code of its release of Wget with the
@@ -36,7 +36,7 @@ so, delete this exception statement from your version.  */
 #endif /* HAVE_UNISTD_H */
 #include <string.h>
 #include <signal.h>
-#if defined(HAVE_NLS) && defined(HAVE_LOCALE_H)
+#ifdef HAVE_NLS
 # include <locale.h>
 #endif
 #include <assert.h>
@@ -64,7 +64,9 @@ struct options opt;
 
 extern char *version_string;
 
+#if defined(SIGHUP) || defined(SIGUSR1)
 static void redirect_output_signal (int);
+#endif
 
 const char *exec_name;
 \f
@@ -141,6 +143,7 @@ static struct cmdline_option option_data[] =
     { "connect-timeout", 0, OPT_VALUE, "connecttimeout", -1 },
     { "continue", 'c', OPT_BOOLEAN, "continue", -1 },
     { "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 },
+    { "content-disposition", 0, OPT_BOOLEAN, "contentdisposition", -1 },
     { "cookies", 0, OPT_BOOLEAN, "cookies", -1 },
     { "cut-dirs", 0, OPT_VALUE, "cutdirs", -1 },
     { WHEN_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 },
@@ -172,6 +175,7 @@ static struct cmdline_option option_data[] =
     { "http-passwd", 0, OPT_VALUE, "httppassword", -1 }, /* deprecated */
     { "http-password", 0, OPT_VALUE, "httppassword", -1 },
     { "http-user", 0, OPT_VALUE, "httpuser", -1 },
+    { "ignore-case", 0, OPT_BOOLEAN, "ignorecase", -1 },
     { "ignore-length", 0, OPT_BOOLEAN, "ignorelength", -1 },
     { "ignore-tags", 0, OPT_VALUE, "ignoretags", -1 },
     { "include-directories", 'I', OPT_VALUE, "includedirectories", -1 },
@@ -444,6 +448,8 @@ Download:\n"),
        --no-dns-cache            disable caching DNS lookups.\n"),
     N_("\
        --restrict-file-names=OS  restrict chars in file names to ones OS allows.\n"),
+    N_("\
+       --ignore-case             ignore case when matching files/directories.\n"),
 #ifdef ENABLE_IPV6
     N_("\
   -4,  --inet4-only              connect only to IPv4 addresses.\n"),
@@ -513,6 +519,8 @@ HTTP options:\n"),
        --post-data=STRING      use the POST method; send STRING as the data.\n"),
     N_("\
        --post-file=FILE        use the POST method; send contents of FILE.\n"),
+    N_("\
+       --no-content-disposition  don't honor Content-Disposition header.\n"),
     "\n",
 
 #ifdef HAVE_SSL
@@ -573,7 +581,7 @@ Recursive download:\n"),
     N_("\
   -K,  --backup-converted   before converting file X, back up as X.orig.\n"),
     N_("\
-  -m,  --mirror             shortcut option equivalent to -r -N -l inf -nr.\n"),
+  -m,  --mirror             shortcut for -N -r -l inf --no-remove-listing.\n"),
     N_("\
   -p,  --page-requisites    get all images, etc. needed to display HTML page.\n"),
     N_("\
@@ -665,6 +673,7 @@ GNU General Public License for more details.\n"), stdout);
   exit (0);
 }
 \f
+#ifndef TESTING
 int
 main (int argc, char *const *argv)
 {
@@ -963,16 +972,18 @@ Can't timestamp and not clobber old files at the same time.\n"));
                   opt.input_filename);
     }
   /* Print the downloaded sum.  */
-  if (opt.recursive || opt.page_requisites
-      || nurl > 1
-      || (opt.input_filename && total_downloaded_bytes != 0))
+  if ((opt.recursive || opt.page_requisites
+       || nurl > 1
+       || (opt.input_filename && total_downloaded_bytes != 0))
+      &&
+      total_downloaded_bytes != 0)
     {
       logprintf (LOG_NOTQUIET,
                 _("FINISHED --%s--\nDownloaded: %d files, %s in %s (%s)\n"),
                 time_str (NULL),
                 opt.numurls,
                 human_readable (total_downloaded_bytes),
-                secs_to_human_time (total_download_time / 1000),
+                secs_to_human_time (total_download_time),
                 retr_rate (total_downloaded_bytes, total_download_time));
       /* Print quota warning, if exceeded.  */
       if (opt.quota && total_downloaded_bytes > opt.quota)
@@ -1000,8 +1011,18 @@ Can't timestamp and not clobber old files at the same time.\n"));
   else
     return 1;
 }
+#endif /* TESTING */
 \f
 #if defined(SIGHUP) || defined(SIGUSR1)
+
+/* So the signal_name check doesn't blow when only one is available. */
+#ifndef SIGHUP
+# define SIGHUP -1
+#endif
+#ifndef SIGUSR1
+# define SIGUSR1 -1
+#endif
+
 /* Hangup signal handler.  When wget receives SIGHUP or SIGUSR1, it
    will proceed operation as usual, trying to write into a log file.
    If that is impossible, the output will be turned off.  */