X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fmain.c;h=0be2c90c49e5e643a51bff330ab6554bf19fdfa1;hb=8f935cf74ce95a631788fb8a4cce4114df935a78;hp=951dc04b4ba8a6fd5593e7699c862f179e7d6996;hpb=489452a23a072949937733016062fcf5a16fce72;p=wget diff --git a/src/main.c b/src/main.c index 951dc04b..0be2c90c 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* Command line parsing. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -61,7 +61,6 @@ extern int errno; #include "retr.h" #include "recur.h" #include "host.h" -#include "cookies.h" #include "url.h" #include "progress.h" /* for progress_handle_sigwinch */ #include "convert.h" @@ -158,7 +157,12 @@ struct cmdline_option option_data[] = { "backups", 0, OPT_BOOLEAN, "backups", -1 }, { "base", 'B', OPT_VALUE, "base", -1 }, { "bind-address", 0, OPT_VALUE, "bindaddress", -1 }, + { IF_SSL ("ca-certificate"), 0, OPT_VALUE, "cacertificate", -1 }, + { IF_SSL ("ca-directory"), 0, OPT_VALUE, "cadirectory", -1 }, { "cache", 0, OPT_BOOLEAN, "cache", -1 }, + { IF_SSL ("certificate"), 0, OPT_VALUE, "certificate", -1 }, + { IF_SSL ("certificate-type"), 0, OPT_VALUE, "certificatetype", -1 }, + { IF_SSL ("check-certificate"), 0, OPT_BOOLEAN, "checkcertificate", -1 }, { "clobber", 0, OPT__CLOBBER, NULL, optional_argument }, { "connect-timeout", 0, OPT_VALUE, "connecttimeout", -1 }, { "continue", 'c', OPT_BOOLEAN, "continue", -1 }, @@ -182,6 +186,7 @@ struct cmdline_option option_data[] = { "follow-tags", 0, OPT_VALUE, "followtags", -1 }, { "force-directories", 'x', OPT_BOOLEAN, "dirstruct", -1 }, { "force-html", 'F', OPT_BOOLEAN, "forcehtml", -1 }, + { "ftp-passwd", 0, OPT_VALUE, "ftppasswd", -1 }, { "glob", 0, OPT_BOOLEAN, "glob", -1 }, { "header", 0, OPT_VALUE, "header", -1 }, { "help", 'h', OPT_FUNCALL, (void *)print_help, no_argument }, @@ -214,14 +219,19 @@ struct cmdline_option option_data[] = { "passive-ftp", 0, OPT_BOOLEAN, "passiveftp", -1 }, { "post-data", 0, OPT_VALUE, "postdata", -1 }, { "post-file", 0, OPT_VALUE, "postfile", -1 }, + { "prefer-family", 0, OPT_VALUE, "preferfamily", -1 }, { "preserve-permissions", 0, OPT_BOOLEAN, "preservepermissions", -1 }, + { IF_SSL ("private-key"), 0, OPT_VALUE, "privatekey", -1 }, + { IF_SSL ("private-key-type"), 0, OPT_VALUE, "privatekeytype", -1 }, { "progress", 0, OPT_VALUE, "progress", -1 }, { "protocol-directories", 0, OPT_BOOLEAN, "protocoldirectories", -1 }, - { "proxy", 'Y', OPT_BOOLEAN, "useproxy", -1 }, + { "proxy", 0, OPT_BOOLEAN, "useproxy", -1 }, + { "proxy__compat", 'Y', OPT_VALUE, "useproxy", -1 }, /* back-compatible */ { "proxy-passwd", 0, OPT_VALUE, "proxypasswd", -1 }, { "proxy-user", 0, OPT_VALUE, "proxyuser", -1 }, { "quiet", 'q', OPT_BOOLEAN, "quiet", -1 }, { "quota", 'Q', OPT_VALUE, "quota", -1 }, + { "random-file", 0, OPT_VALUE, "randomfile", -1 }, { "random-wait", 0, OPT_BOOLEAN, "randomwait", -1 }, { "read-timeout", 0, OPT_VALUE, "readtimeout", -1 }, { "recursive", 'r', OPT_BOOLEAN, "recursive", -1 }, @@ -234,21 +244,14 @@ struct cmdline_option option_data[] = { "retry-connrefused", 0, OPT_BOOLEAN, "retryconnrefused", -1 }, { "save-cookies", 0, OPT_VALUE, "savecookies", -1 }, { "save-headers", 0, OPT_BOOLEAN, "saveheaders", -1 }, + { IF_SSL ("secure-protocol"), 0, OPT_VALUE, "secureprotocol", -1 }, { "server-response", 'S', OPT_BOOLEAN, "serverresponse", -1 }, { "span-hosts", 'H', OPT_BOOLEAN, "spanhosts", -1 }, { "spider", 0, OPT_BOOLEAN, "spider", -1 }, - { IF_SSL ("sslcadir"), 0, OPT_VALUE, "sslcadir", -1 }, - { IF_SSL ("sslcafile"), 0, OPT_VALUE, "sslcafile", -1 }, - { IF_SSL ("sslcertfile"), 0, OPT_VALUE, "sslcertfile", -1 }, - { IF_SSL ("sslcertkey"), 0, OPT_VALUE, "sslcertkey", -1 }, - { IF_SSL ("sslcerttype"), 0, OPT_VALUE, "sslcerttype", -1 }, - { IF_SSL ("sslcheckcert"), 0, OPT_VALUE, "sslcheckcert", -1 }, - { IF_SSL ("sslprotocol"), 0, OPT_VALUE, "sslprotocol", -1 }, { "strict-comments", 0, OPT_BOOLEAN, "strictcomments", -1 }, { "timeout", 'T', OPT_VALUE, "timeout", -1 }, { "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 }, { "tries", 't', OPT_VALUE, "tries", -1 }, - { "use-proxy", 'Y', OPT_BOOLEAN, "useproxy", -1 }, { "user-agent", 'U', OPT_VALUE, "useragent", -1 }, { "verbose", 'v', OPT_BOOLEAN, "verbose", -1 }, { "verbose", 0, OPT_BOOLEAN, "verbose", -1 }, @@ -324,9 +327,11 @@ init_switches (void) *p++ = ':'; break; case OPT_BOOLEAN: - /* Don't specify optional arguments for boolean short - options. They are evil because they prevent combining of - short options. */ + /* Specify an optional argument for long options, so that + --option=off works the same as --no-option, for + compatibility with pre-1.10 Wget. However, don't specify + optional arguments short-option booleans because they + prevent combining of short options. */ longopt->has_arg = optional_argument; /* For Boolean options, add the "--no-FOO" variant, which is identical to "--foo", except it has opposite meaning and @@ -465,6 +470,9 @@ Download:\n"), -4, --inet4-only connect only to IPv4 addresses.\n"), N_("\ -6, --inet6-only connect only to IPv6 addresses.\n"), + N_("\ + --prefer-family=FAMILY connect first to addresses of specified family,\n\ + one of IPv6, IPv4, or none.\n"), #endif "\n", @@ -526,24 +534,28 @@ HTTP options:\n"), #ifdef HAVE_SSL N_("\ -HTTPS (SSL) options:\n"), +HTTPS (SSL/TLS) options:\n"), + N_("\ + --secure-protocol=PR choose SSL protocol, one of auto, SSLv2, SSLv3,\n\ + and TLSv1.\n"), N_("\ - --sslcertfile=FILE optional client certificate.\n"), + --no-check-certificate don't validate the server's certificate.\n"), N_("\ - --sslcertkey=KEYFILE optional keyfile for this certificate.\n"), + --certificate=FILE client certificate file.\n"), N_("\ - --egd-file=FILE file name of the EGD socket.\n"), + --certificate-type=TYPE client certificate type, PEM or ASN1.\n"), N_("\ - --sslcadir=DIR dir where hash list of CA's are stored.\n"), + --private-key=FILE private key file.\n"), N_("\ - --sslcafile=FILE file with bundle of CA's.\n"), + --private-key-type=TYPE private key type, PEM or ASN1.\n"), N_("\ - --sslcerttype=0/1 Client-Cert type 0=PEM (default) / 1=ASN1 (DER).\n"), + --ca-certificate=FILE file with the bundle of CA's.\n"), N_("\ - --sslcheckcert=0/1 Check the server cert against given CA.\n"), + --ca-directory=DIR directory where hash list of CA's is stored.\n"), N_("\ - --sslprotocol=0-3 choose SSL protocol; 0=automatic,\n\ - 1=SSLv2 2=SSLv3 3=TLSv1.\n"), + --random-file=FILE file with random data for seeding the SSL PRNG.\n"), + N_("\ + --egd-file=FILE file naming the EGD socket with random data.\n"), "\n", #endif /* HAVE_SSL */ @@ -554,7 +566,7 @@ FTP options:\n"), N_("\ --no-glob turn off FTP file name globbing.\n"), N_("\ - --passive-ftp use the \"passive\" transfer mode.\n"), + --no-passive-ftp disable the \"passive\" transfer mode.\n"), N_("\ --retr-symlinks when recursing, get linked-to files (not dir).\n"), N_("\ @@ -621,9 +633,6 @@ Recursive accept/reject:\n"), for (i = 0; i < countof (help); i++) fputs (_(help[i]), stdout); -#ifdef WINDOWS - ws_help (exec_name); -#endif exit (0); } @@ -632,7 +641,7 @@ print_version (void) { printf ("GNU Wget %s\n\n", version_string); fputs (_("\ -Copyright (C) 2003 Free Software Foundation, Inc.\n"), stdout); +Copyright (C) 2005 Free Software Foundation, Inc.\n"), stdout); fputs (_("\ This program is distributed in the hope that it will be useful,\n\ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ @@ -661,7 +670,8 @@ main (int argc, char *const *argv) ++exec_name; #ifdef WINDOWS - windows_main_junk (&argc, (char **) argv, (char **) &exec_name); + /* Drop extension (typically .EXE) from executable filename. */ + windows_main (&argc, (char **) argv, (char **) &exec_name); #endif /* Set option defaults; read the system wgetrc and ~/.wgetrc. */ @@ -713,7 +723,7 @@ main (int argc, char *const *argv) break; case OPT_FUNCALL: { - void (*func) PARAMS ((void)) = opt->data; + void (*func) PARAMS ((void)) = (void (*) PARAMS ((void))) opt->data; func (); } break; @@ -784,7 +794,7 @@ main (int argc, char *const *argv) interoption dependency checks. */ if (opt.reclevel == 0) - opt.reclevel = INFINITE_RECURSION; /* see wget.h for commentary on this */ + opt.reclevel = INFINITE_RECURSION; /* see recur.h for commentary on this */ if (opt.page_requisites && !opt.recursive) { @@ -855,12 +865,6 @@ Can't timestamp and not clobber old files at the same time.\n")); } url[i] = NULL; - /* Change the title of console window on Windows. #### I think this - statement should belong to retrieve_url(). --hniksic. */ -#ifdef WINDOWS - ws_changetitle (*url, nurl); -#endif - /* Initialize logging. */ log_init (opt.lfilename, append_to_log); @@ -877,7 +881,7 @@ Can't timestamp and not clobber old files at the same time.\n")); output_stream = stdout; else { - struct stat st; + struct_stat st; output_stream = fopen (opt.output_document, opt.always_rest ? "ab" : "wb"); if (output_stream == NULL) @@ -951,17 +955,17 @@ Can't timestamp and not clobber old files at the same time.\n")); { logprintf (LOG_NOTQUIET, _("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"), - time_str (NULL), legible_large_int (total_downloaded_bytes), + time_str (NULL), with_thousand_seps_large (total_downloaded_bytes), opt.numurls); /* Print quota warning, if exceeded. */ if (opt.quota && total_downloaded_bytes > opt.quota) logprintf (LOG_NOTQUIET, _("Download quota (%s bytes) EXCEEDED!\n"), - legible (opt.quota)); + with_thousand_seps_large (opt.quota)); } - if (opt.cookies_output && wget_cookie_jar) - cookie_jar_save (wget_cookie_jar, opt.cookies_output); + if (opt.cookies_output) + save_cookies (); if (opt.convert_links && !opt.delete_after) convert_all_links ();