X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fmain.c;h=13f8ad443386f8a89dad87dc4a3e841471e17443;hp=b41277ba841355a66c8f49df7f7632676a206b3d;hb=62864cee6ea9d8073a5c3044ee36dba0a29f89ff;hpb=7585b7019d5909428a477002579366a507e42b58 diff --git a/src/main.c b/src/main.c index b41277ba..13f8ad44 100644 --- a/src/main.c +++ b/src/main.c @@ -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,8 @@ static struct cmdline_option option_data[] = { "timeout", 'T', OPT_VALUE, "timeout", -1 }, { "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 }, { "tries", 't', OPT_VALUE, "tries", -1 }, + { "unlink", 0, OPT_BOOLEAN, "unlink", -1 }, + { "trust-server-names", 0, OPT_BOOLEAN, "trustservernames", -1 }, { "use-server-timestamps", 0, OPT_BOOLEAN, "useservertimestamps", -1 }, { "user", 0, OPT_VALUE, "user", -1 }, { "user-agent", 'U', OPT_VALUE, "useragent", -1 }, @@ -382,9 +384,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 @@ -477,7 +480,7 @@ Download:\n"), N_("\ --waitretry=SECONDS wait 1..SECONDS between retries of a retrieval.\n"), N_("\ - --random-wait wait from 0...2*WAIT secs between retrievals.\n"), + --random-wait wait from 0.5*WAIT...1.5*WAIT secs between retrievals.\n"), N_("\ --no-proxy explicitly turn off proxy.\n"), N_("\ @@ -513,6 +516,8 @@ Download:\n"), --local-encoding=ENC use ENC as the local encoding for IRIs.\n"), N_("\ --remote-encoding=ENC use ENC as the default remote encoding.\n"), + N_("\ + --unlink remove file before clobber.\n"), "\n", N_("\ @@ -679,6 +684,9 @@ Recursive accept/reject:\n"), N_("\ -I, --include-directories=LIST list of allowed directories.\n"), N_("\ + --trust-server-names use the name specified by the redirection\n\ + url last component.\n"), + N_("\ -X, --exclude-directories=LIST list of excluded directories.\n"), N_("\ -np, --no-parent don't ascend to the parent directory.\n"), @@ -691,7 +699,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); @@ -785,7 +793,6 @@ 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; @@ -853,8 +860,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 .\n"), stdout); - fputs (_("Currently maintained by Micah Cowan .\n"), - stdout); fputs (_("Please send bug reports and questions to .\n"), stdout); exit (0); @@ -867,7 +872,7 @@ main (int argc, char **argv) { char **url, **t; int i, ret, longindex; - int nurl, status; + int nurl; bool append_to_log = false; program_name = argv[0]; @@ -908,7 +913,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); @@ -976,10 +981,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; @@ -1034,22 +1041,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 @@ -1060,8 +1068,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 @@ -1081,27 +1089,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); } @@ -1121,7 +1132,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 @@ -1217,6 +1228,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 @@ -1224,13 +1242,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 @@ -1257,7 +1271,6 @@ WARNING: Can't reopen standard output in binary mode;\n\ signal (SIGWINCH, progress_handle_sigwinch); #endif - status = RETROK; /* initialize it, just-in-case */ /* Retrieve the URLs from argument list. */ for (t = url; *t; t++) { @@ -1277,7 +1290,6 @@ WARNING: Can't reopen standard output in binary mode;\n\ char *error = url_error (*t, url_err); logprintf (LOG_NOTQUIET, "%s: %s.\n",*t, error); xfree (error); - status = URLERROR; } else { @@ -1290,14 +1302,14 @@ WARNING: Can't reopen standard output in binary mode;\n\ if (url_scheme (*t) == SCHEME_FTP) opt.follow_ftp = 1; - status = retrieve_tree (url_parsed, NULL); + retrieve_tree (url_parsed, NULL); opt.follow_ftp = old_follow_ftp; } else { - status = retrieve_url (url_parsed, *t, &filename, &redirected_URL, - NULL, &dt, opt.recursive, iri, true); + retrieve_url (url_parsed, *t, &filename, &redirected_URL, NULL, + &dt, opt.recursive, iri, true); } if (opt.delete_after && file_exists_p(filename)) @@ -1318,7 +1330,7 @@ WARNING: Can't reopen standard output in binary mode;\n\ if (opt.input_filename) { int count; - status = retrieve_from_file (opt.input_filename, opt.force_html, &count); + retrieve_from_file (opt.input_filename, opt.force_html, &count); if (!count) logprintf (LOG_NOTQUIET, _("No URLs found in %s.\n"), opt.input_filename); @@ -1326,9 +1338,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