X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fmain.c;h=275605ca58cef7264eff79dcf634ce8d00584158;hb=07f60f19a4ee99ddc343bb51568b0c474e9b853d;hp=8bda521b84069040fad3989579ebfc218cf615f2;hpb=1396b300550d9b5ca3b4b3e4e3776a1456024f73;p=wget diff --git a/src/main.c b/src/main.c index 8bda521b..275605ca 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* Command line parsing. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of Wget. @@ -39,6 +39,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ # include #endif /* HAVE_LOCALE_H */ #endif /* HAVE_NLS */ +#include #define OPTIONS_DEFINED_HERE /* for options.h */ @@ -97,6 +98,20 @@ i18n_initialize (void) textdomain ("wget"); #endif /* HAVE_NLS */ } + +/* It's kosher to declare these here because their interface _has_ to + be void foo(void). */ +void url_init PARAMS ((void)); +void host_init PARAMS ((void)); + +/* This just calls the various initialization functions from the + modules that need one-time initialization. */ +static void +private_initialize (void) +{ + url_init (); + host_init (); +} /* Print the usage message. */ static void @@ -135,20 +150,22 @@ Logging and input file:\n\ -i, --input-file=FILE download URLs found in FILE.\n\ -F, --force-html treat input file as HTML.\n\ -B, --base=URL prepends URL to relative links in -F -i file.\n\ + --sslcertfile=FILE optional client certificate.\n\ + --sslcertkey=KEYFILE optional keyfile for this certificate.\n\ \n"), _("\ Download:\n\ --bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local host.\n\ -t, --tries=NUMBER set number of retries to NUMBER (0 unlimits).\n\ -O --output-document=FILE write documents to FILE.\n\ -nc, --no-clobber don\'t clobber existing files or use .# suffixes.\n\ - -c, --continue restart getting an existing file.\n\ + -c, --continue resume getting a partially-downloaded file.\n\ --dot-style=STYLE set retrieval display style.\n\ -N, --timestamping don\'t retrieve files if older than local.\n\ -S, --server-response print server response.\n\ --spider don\'t download anything.\n\ -T, --timeout=SECONDS set the read timeout to SECONDS.\n\ -w, --wait=SECONDS wait SECONDS between retrievals.\n\ - --waitretry=SECONDS wait 1...SECONDS between retries of a retrieval.\n\ + --waitretry=SECONDS wait 1...SECONDS between retries of a retrieval.\n\ -Y, --proxy=on/off turn proxy on or off.\n\ -Q, --quota=NUMBER set retrieval quota to NUMBER.\n\ \n"), _("\ @@ -233,6 +250,7 @@ main (int argc, char *const *argv) { "no-directories", no_argument, NULL, 19 }, { "no-host-directories", no_argument, NULL, 20 }, { "no-host-lookup", no_argument, NULL, 22 }, + { "no-http-keep-alive", no_argument, NULL, 28 }, { "no-parent", no_argument, NULL, 5 }, { "non-verbose", no_argument, NULL, 18 }, { "passive-ftp", no_argument, NULL, 11 }, @@ -287,12 +305,17 @@ main (int argc, char *const *argv) { "user-agent", required_argument, NULL, 'U' }, { "referer", required_argument, NULL, 129 }, { "use-proxy", required_argument, NULL, 'Y' }, +#ifdef HAVE_SSL + { "sslcertfile", required_argument, NULL, 132}, + { "sslcertkey", required_argument, NULL, 133}, +#endif /* HAVE_SSL */ { "wait", required_argument, NULL, 'w' }, { "waitretry", required_argument, NULL, 24 }, { 0, 0, 0, 0 } }; i18n_initialize (); + private_initialize (); append_to_log = 0; @@ -312,7 +335,7 @@ main (int argc, char *const *argv) /* [Is the order of the option letters significant? If not, they should be alphabetized, like the long_options. The only thing I know for sure is that the options with required arguments must be followed by a ':'. - -- Dan Harkless ] */ + -- Dan Harkless ] */ while ((c = getopt_long (argc, argv, "\ hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:", long_options, (int *)0)) != EOF) @@ -370,6 +393,9 @@ hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:", case 27: setval ("bindaddress", optarg); break; + case 28: + setval ("httpkeepalive", "off"); + break; case 'b': setval ("background", "on"); break; @@ -433,7 +459,7 @@ hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:", case 'V': printf ("GNU Wget %s\n\n", version_string); printf ("%s", _("\ -Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.\n\ +Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.\n\ This program is distributed in the hope that it will be useful,\n\ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ @@ -486,6 +512,14 @@ GNU General Public License for more details.\n")); case 129: setval ("referer", optarg); break; +#ifdef HAVE_SSL + case 132: + setval ("sslcertfile", optarg); + break; + case 133: + setval ("sslcertkey", optarg); + break; +#endif /* HAVE_SSL */ case 'A': setval ("accept", optarg); break; @@ -516,8 +550,8 @@ GNU General Public License for more details.\n")); optarg); exit (1); } - free (com); - free (val); + xfree (com); + xfree (val); } break; case 'G': @@ -564,6 +598,9 @@ GNU General Public License for more details.\n")); case 'p': setval ("noparent", "on"); break; + case 'k': + setval ("httpkeepalive", "off"); + break; default: printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p); print_usage (); @@ -704,12 +741,15 @@ Can't timestamp and not clobber old files at the same time.\n")); opt.dfp = stdout; else { + struct stat st; opt.dfp = fopen (opt.output_document, "wb"); if (opt.dfp == NULL) { perror (opt.output_document); exit (1); } + if (fstat (fileno (opt.dfp), &st) == 0 && S_ISREG (st.st_mode)) + opt.od_known_regular = 1; } } @@ -771,19 +811,25 @@ 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 (opt.downloaded), opt.numurls); + time_str (NULL), + (opt.downloaded_overflow ? + "" : legible_very_long (opt.downloaded)), + opt.numurls); /* Print quota warning, if exceeded. */ - if (opt.quota && opt.downloaded > opt.quota) + if (downloaded_exceeds_quota ()) logprintf (LOG_NOTQUIET, _("Download quota (%s bytes) EXCEEDED!\n"), legible (opt.quota)); } - if (opt.convert_links & !opt.delete_after) + if (opt.convert_links && !opt.delete_after) { convert_all_links (); } log_close (); cleanup (); +#ifdef DEBUG_MALLOC + print_malloc_debug_stats (); +#endif if (status == RETROK) return 0; else