1 /* Command line parsing.
2 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GNU Wget.
7 GNU Wget is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GNU Wget is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Wget; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 In addition, as a special exception, the Free Software Foundation
22 gives permission to link the code of its release of Wget with the
23 OpenSSL project's "OpenSSL" library (or with modified versions of it
24 that use the same license as the "OpenSSL" library), and distribute
25 the linked executables. You must obey the GNU General Public License
26 in all respects for all of the code used other than "OpenSSL". If you
27 modify this file, you may extend this exception to your version of the
28 file, but you are not obligated to do so. If you do not wish to do
29 so, delete this exception statement from your version. */
37 #endif /* HAVE_UNISTD_H */
38 #include <sys/types.h>
43 #endif /* HAVE_STRING_H */
50 #endif /* HAVE_LOCALE_H */
62 #include "progress.h" /* for progress_handle_sigwinch */
65 # include "gen_sslfunc.h"
68 /* On GNU system this will include system-wide getopt.h. */
71 #ifndef PATH_SEPARATOR
72 # define PATH_SEPARATOR '/'
75 extern char *version_string;
83 extern struct cookie_jar *wget_cookie_jar;
86 void log_init PARAMS ((const char *, int));
87 void log_close PARAMS ((void));
88 void log_request_redirect_output PARAMS ((const char *));
90 static RETSIGTYPE redirect_output_signal PARAMS ((int));
92 const char *exec_name;
94 /* Initialize I18N. The initialization amounts to invoking
95 setlocale(), bindtextdomain() and textdomain().
96 Does nothing if NLS is disabled or missing. */
98 i18n_initialize (void)
100 /* If HAVE_NLS is defined, assume the existence of the three
101 functions invoked here. */
103 /* Set the current locale. */
104 /* Here we use LC_MESSAGES instead of LC_ALL, for two reasons.
105 First, message catalogs are all of I18N Wget uses anyway.
106 Second, setting LC_ALL has a dangerous potential of messing
107 things up. For example, when in a foreign locale, Solaris
108 strptime() fails to handle international dates correctly, which
109 makes http_atotm() malfunction. */
111 setlocale (LC_MESSAGES, "");
112 setlocale (LC_CTYPE, "");
114 setlocale (LC_ALL, "");
116 /* Set the text message domain. */
117 bindtextdomain ("wget", LOCALEDIR);
119 #endif /* HAVE_NLS */
122 /* Print the usage message. */
126 printf (_("Usage: %s [OPTION]... [URL]...\n"), exec_name);
129 /* Print the help message, describing all the available options. If
130 you add an option, be sure to update this list. */
134 printf (_("GNU Wget %s, a non-interactive network retriever.\n"),
137 /* Had to split this in parts, so the #@@#%# Ultrix compiler and cpp
138 don't bitch. Also, it makes translation much easier. */
141 Mandatory arguments to long options are mandatory for short options too.\n\
145 -V, --version display the version of Wget and exit.\n\
146 -h, --help print this help.\n\
147 -b, --background go to background after startup.\n\
148 -e, --execute=COMMAND execute a `.wgetrc\'-style command.\n\
151 Logging and input file:\n\
152 -o, --output-file=FILE log messages to FILE.\n\
153 -a, --append-output=FILE append messages to FILE.\n\
154 -d, --debug print debug output.\n\
155 -q, --quiet quiet (no output).\n\
156 -v, --verbose be verbose (this is the default).\n\
157 -nv, --non-verbose turn off verboseness, without being quiet.\n\
158 -i, --input-file=FILE download URLs found in FILE.\n\
159 -F, --force-html treat input file as HTML.\n\
160 -B, --base=URL prepends URL to relative links in -F -i file.\n\
164 -t, --tries=NUMBER set number of retries to NUMBER (0 unlimits).\n\
165 --retry-connrefused retry even if connection is refused.\n\
166 -O --output-document=FILE write documents to FILE.\n\
167 -nc, --no-clobber don\'t clobber existing files or use .# suffixes.\n\
168 -c, --continue resume getting a partially-downloaded file.\n\
169 --progress=TYPE select progress gauge type.\n\
170 -N, --timestamping don\'t re-retrieve files unless newer than local.\n\
171 -S, --server-response print server response.\n\
172 --spider don\'t download anything.\n\
173 -T, --timeout=SECONDS set the read timeout to SECONDS.\n\
174 -w, --wait=SECONDS wait SECONDS between retrievals.\n\
175 --waitretry=SECONDS wait 1...SECONDS between retries of a retrieval.\n\
176 --random-wait wait from 0...2*WAIT secs between retrievals.\n\
177 -Y, --proxy=on/off turn proxy on or off.\n\
178 -Q, --quota=NUMBER set retrieval quota to NUMBER.\n\
179 --bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local host.\n\
180 --limit-rate=RATE limit download rate to RATE.\n\
181 --dns-cache=off disable caching DNS lookups.\n\
182 --restrict-file-names=OS restrict chars in file names to ones OS allows.\n\
186 -nd, --no-directories don\'t create directories.\n\
187 -x, --force-directories force creation of directories.\n\
188 -nH, --no-host-directories don\'t create host directories.\n\
189 -P, --directory-prefix=PREFIX save files to PREFIX/...\n\
190 --cut-dirs=NUMBER ignore NUMBER remote directory components.\n\
194 --http-user=USER set http user to USER.\n\
195 --http-passwd=PASS set http password to PASS.\n\
196 -C, --cache=on/off (dis)allow server-cached data (normally allowed).\n\
197 -E, --html-extension save all text/html documents with .html extension.\n\
198 --ignore-length ignore `Content-Length\' header field.\n\
199 --header=STRING insert STRING among the headers.\n\
200 --proxy-user=USER set USER as proxy username.\n\
201 --proxy-passwd=PASS set PASS as proxy password.\n\
202 --referer=URL include `Referer: URL\' header in HTTP request.\n\
203 -s, --save-headers save the HTTP headers to file.\n\
204 -U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION.\n\
205 --no-http-keep-alive disable HTTP keep-alive (persistent connections).\n\
206 --cookies=off don't use cookies.\n\
207 --load-cookies=FILE load cookies from FILE before session.\n\
208 --save-cookies=FILE save cookies to FILE after session.\n\
209 --post-data=STRING use the POST method; send STRING as the data.\n\
210 --post-file=FILE use the POST method; send contents of FILE.\n\
214 HTTPS (SSL) options:\n\
215 --sslcertfile=FILE optional client certificate.\n\
216 --sslcertkey=KEYFILE optional keyfile for this certificate.\n\
217 --egd-file=FILE file name of the EGD socket.\n\
218 --sslcadir=DIR dir where hash list of CA's are stured.\n\
219 --sslcafile=FILE file with bundle of CA's\n\
220 --sslcerttype=0/1 Client-Cert type 0=PEM (default) / 1=ASN1 (DER)\n\
221 --sslcheckcert=0/1 Check the server cert agenst given CA\n\
222 --sslprotocol=0-3 choose SSL protocol; 0=automatic,\n\
223 1=SSLv2 2=SSLv3 3=TLSv1\n\
228 -nr, --dont-remove-listing don\'t remove `.listing\' files.\n\
229 -g, --glob=on/off turn file name globbing on or off.\n\
230 --passive-ftp use the \"passive\" transfer mode.\n\
231 --retr-symlinks when recursing, get linked-to files (not dirs).\n\
234 Recursive retrieval:\n\
235 -r, --recursive recursive download.\n\
236 -l, --level=NUMBER maximum recursion depth (inf or 0 for infinite).\n\
237 --delete-after delete files locally after downloading them.\n\
238 -k, --convert-links convert non-relative links to relative.\n\
239 -K, --backup-converted before converting file X, back up as X.orig.\n\
240 -m, --mirror shortcut option equivalent to -r -N -l inf -nr.\n\
241 -p, --page-requisites get all images, etc. needed to display HTML page.\n\
242 --strict-comments turn on strict (SGML) handling of HTML comments.\n\
245 Recursive accept/reject:\n\
246 -A, --accept=LIST comma-separated list of accepted extensions.\n\
247 -R, --reject=LIST comma-separated list of rejected extensions.\n\
248 -D, --domains=LIST comma-separated list of accepted domains.\n\
249 --exclude-domains=LIST comma-separated list of rejected domains.\n\
250 --follow-ftp follow FTP links from HTML documents.\n\
251 --follow-tags=LIST comma-separated list of followed HTML tags.\n\
252 -G, --ignore-tags=LIST comma-separated list of ignored HTML tags.\n\
253 -H, --span-hosts go to foreign hosts when recursive.\n\
254 -L, --relative follow relative links only.\n\
255 -I, --include-directories=LIST list of allowed directories.\n\
256 -X, --exclude-directories=LIST list of excluded directories.\n\
257 -np, --no-parent don\'t ascend to the parent directory.\n\
259 fputs (_("Mail bug reports and suggestions to <bug-wget@gnu.org>.\n"),
264 main (int argc, char *const *argv)
267 int i, c, nurl, status, append_to_log;
269 static struct option long_options[] =
271 /* Options without arguments: */
272 { "background", no_argument, NULL, 'b' },
273 { "backup-converted", no_argument, NULL, 'K' },
274 { "continue", no_argument, NULL, 'c' },
275 { "convert-links", no_argument, NULL, 'k' },
276 { "debug", no_argument, NULL, 'd' },
277 { "delete-after", no_argument, NULL, 136 },
278 { "dont-remove-listing", no_argument, NULL, 149 },
279 { "follow-ftp", no_argument, NULL, 142 },
280 { "force-directories", no_argument, NULL, 'x' },
281 { "force-hier", no_argument, NULL, 'x' }, /* obsolete */
282 { "force-html", no_argument, NULL, 'F'},
283 { "help", no_argument, NULL, 'h' },
284 { "html-extension", no_argument, NULL, 'E' },
285 { "ignore-length", no_argument, NULL, 138 },
286 { "mirror", no_argument, NULL, 'm' },
287 { "no-clobber", no_argument, NULL, 141 },
288 { "no-directories", no_argument, NULL, 147 },
289 { "no-host-directories", no_argument, NULL, 148 },
290 { "no-host-lookup", no_argument, NULL, 150 },
291 { "no-http-keep-alive", no_argument, NULL, 156 },
292 { "no-parent", no_argument, NULL, 133 },
293 { "non-verbose", no_argument, NULL, 146 },
294 { "passive-ftp", no_argument, NULL, 139 },
295 { "page-requisites", no_argument, NULL, 'p' },
296 { "quiet", no_argument, NULL, 'q' },
297 { "random-wait", no_argument, NULL, 165 },
298 { "recursive", no_argument, NULL, 'r' },
299 { "relative", no_argument, NULL, 'L' },
300 { "retr-symlinks", no_argument, NULL, 137 },
301 { "retry-connrefused", no_argument, NULL, 174 },
302 { "save-headers", no_argument, NULL, 's' },
303 { "server-response", no_argument, NULL, 'S' },
304 { "span-hosts", no_argument, NULL, 'H' },
305 { "spider", no_argument, NULL, 132 },
306 { "strict-comments", no_argument, NULL, 177 },
307 { "timestamping", no_argument, NULL, 'N' },
308 { "verbose", no_argument, NULL, 'v' },
309 { "version", no_argument, NULL, 'V' },
311 /* Options accepting an argument: */
312 { "accept", required_argument, NULL, 'A' },
313 { "append-output", required_argument, NULL, 'a' },
314 { "backups", required_argument, NULL, 151 }, /* undocumented */
315 { "base", required_argument, NULL, 'B' },
316 { "bind-address", required_argument, NULL, 155 },
317 { "cache", required_argument, NULL, 'C' },
318 { "cookies", required_argument, NULL, 160 },
319 { "cut-dirs", required_argument, NULL, 145 },
320 { "directory-prefix", required_argument, NULL, 'P' },
321 { "dns-cache", required_argument, NULL, 175 },
322 { "domains", required_argument, NULL, 'D' },
323 { "dot-style", required_argument, NULL, 134 },
324 { "execute", required_argument, NULL, 'e' },
325 { "exclude-directories", required_argument, NULL, 'X' },
326 { "exclude-domains", required_argument, NULL, 140 },
327 { "follow-tags", required_argument, NULL, 153 },
328 { "glob", required_argument, NULL, 'g' },
329 { "header", required_argument, NULL, 131 },
330 { "htmlify", required_argument, NULL, 135 },
331 { "http-passwd", required_argument, NULL, 130 },
332 { "http-user", required_argument, NULL, 129 },
333 { "ignore-tags", required_argument, NULL, 'G' },
334 { "include-directories", required_argument, NULL, 'I' },
335 { "input-file", required_argument, NULL, 'i' },
336 { "level", required_argument, NULL, 'l' },
337 { "limit-rate", required_argument, NULL, 164 },
338 { "load-cookies", required_argument, NULL, 161 },
339 { "no", required_argument, NULL, 'n' },
340 { "output-document", required_argument, NULL, 'O' },
341 { "output-file", required_argument, NULL, 'o' },
342 { "post-data", required_argument, NULL, 167 },
343 { "post-file", required_argument, NULL, 168 },
344 { "progress", required_argument, NULL, 163 },
345 { "proxy", required_argument, NULL, 'Y' },
346 { "proxy-passwd", required_argument, NULL, 144 },
347 { "proxy-user", required_argument, NULL, 143 },
348 { "quota", required_argument, NULL, 'Q' },
349 { "reject", required_argument, NULL, 'R' },
350 { "restrict-file-names", required_argument, NULL, 176 },
351 { "save-cookies", required_argument, NULL, 162 },
352 { "timeout", required_argument, NULL, 'T' },
353 { "tries", required_argument, NULL, 't' },
354 { "user-agent", required_argument, NULL, 'U' },
355 { "referer", required_argument, NULL, 157 },
356 { "use-proxy", required_argument, NULL, 'Y' },
358 { "sslcertfile", required_argument, NULL, 158 },
359 { "sslcertkey", required_argument, NULL, 159 },
360 { "egd-file", required_argument, NULL, 166 },
361 { "sslcadir", required_argument, NULL, 169},
362 { "sslcafile", required_argument, NULL, 170},
363 { "sslcerttype", required_argument, NULL, 171},
364 { "sslcheckcert", required_argument, NULL, 172},
365 { "sslprotocol", required_argument, NULL, 173},
366 #endif /* HAVE_SSL */
367 { "wait", required_argument, NULL, 'w' },
368 { "waitretry", required_argument, NULL, 152 },
376 /* Construct the name of the executable, without the directory part. */
377 exec_name = strrchr (argv[0], PATH_SEPARATOR);
384 windows_main_junk (&argc, (char **) argv, (char **) &exec_name);
387 initialize (); /* sets option defaults; reads the system wgetrc and .wgetrc */
389 /* [Is the order of the option letters significant? If not, they should be
390 alphabetized, like the long_options. The only thing I know for sure is
391 that the options with required arguments must be followed by a ':'.
392 -- Dan Harkless <wget@harkless.org>] */
393 while ((c = getopt_long (argc, argv, "\
394 hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:",
395 long_options, (int *)0)) != EOF)
399 /* Options without arguments: */
401 setval ("spider", "on");
404 setval ("noparent", "on");
407 setval ("deleteafter", "on");
410 setval ("retrsymlinks", "on");
413 setval ("ignorelength", "on");
416 setval ("passiveftp", "on");
419 setval ("noclobber", "on");
422 setval ("followftp", "on");
425 setval ("cutdirs", optarg);
428 setval ("verbose", "off");
431 setval ("dirstruct", "off");
434 setval ("addhostdir", "off");
437 setval ("removelisting", "off");
440 setval ("bindaddress", optarg);
443 setval ("httpkeepalive", "off");
446 setval ("randomwait", "on");
449 setval ("background", "on");
452 setval ("continue", "on");
456 setval ("debug", "on");
457 #else /* not DEBUG */
458 fprintf (stderr, _("%s: debug support not compiled in.\n"),
460 #endif /* not DEBUG */
463 setval ("htmlextension", "on");
466 setval ("forcehtml", "on");
469 setval ("spanhosts", "on");
479 setval ("backupconverted", "on");
482 setval ("convertlinks", "on");
485 setval ("relativeonly", "on");
488 setval ("mirror", "on");
491 setval ("timestamping", "on");
494 setval ("pagerequisites", "on");
497 setval ("serverresponse", "on");
500 setval ("saveheaders", "on");
503 setval ("quiet", "on");
506 setval ("recursive", "on");
509 printf ("GNU Wget %s\n\n", version_string);
511 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.\n"));
513 This program is distributed in the hope that it will be useful,\n\
514 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
515 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
516 GNU General Public License for more details.\n"));
517 printf (_("\nOriginally written by Hrvoje Niksic <hniksic@arsdigita.com>.\n"));
521 setval ("verbose", "on");
524 setval ("dirstruct", "on");
527 setval ("retryconnrefused", "on");
530 setval ("strictcomments", "on");
533 /* Options accepting an argument: */
535 setval ("httpuser", optarg);
538 setval ("httppasswd", optarg);
541 setval ("header", optarg);
544 setval ("dotstyle", optarg);
547 setval ("htmlify", optarg);
550 setval ("excludedomains", optarg);
553 setval ("proxyuser", optarg);
556 setval ("proxypasswd", optarg);
559 setval ("backups", optarg);
562 setval ("waitretry", optarg);
565 setval ("followtags", optarg);
568 setval ("cookies", optarg);
571 setval ("loadcookies", optarg);
574 setval ("savecookies", optarg);
577 setval ("progress", optarg);
580 setval ("limitrate", optarg);
583 setval ("referer", optarg);
587 setval ("sslcertfile", optarg);
590 setval ("sslcertkey", optarg);
593 setval ("egdfile", optarg);
596 setval ("sslcadir", optarg);
599 setval ("sslcafile", optarg);
602 setval ("sslcerttype", optarg);
605 setval ("sslcheckcert", optarg);
608 setval ("sslprotocol", optarg);
610 #endif /* HAVE_SSL */
612 setval ("postdata", optarg);
615 setval ("postfile", optarg);
618 setval ("dnscache", optarg);
621 setval ("restrictfilenames", optarg);
624 setval ("accept", optarg);
627 setval ("logfile", optarg);
631 setval ("base", optarg);
634 setval ("cache", optarg);
637 setval ("domains", optarg);
642 if (parse_line (optarg, &com, &val))
644 if (!setval (com, val))
649 fprintf (stderr, _("%s: %s: invalid command\n"), exec_name,
658 setval ("ignoretags", optarg);
661 setval ("glob", optarg);
664 setval ("includedirectories", optarg);
667 setval ("input", optarg);
670 setval ("reclevel", optarg);
674 /* #### What we really want here is --no-foo. */
677 for (p = optarg; *p; p++)
681 setval ("verbose", "off");
684 setval ("addhostdir", "off");
687 setval ("dirstruct", "off");
690 setval ("noclobber", "on");
693 setval ("removelisting", "off");
696 setval ("noparent", "on");
699 setval ("httpkeepalive", "off");
702 printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p);
705 printf (_("Try `%s --help\' for more options.\n"), exec_name);
711 setval ("outputdocument", optarg);
714 setval ("logfile", optarg);
717 setval ("dirprefix", optarg);
720 setval ("quota", optarg);
723 setval ("reject", optarg);
726 setval ("timeout", optarg);
729 setval ("tries", optarg);
732 setval ("useragent", optarg);
735 setval ("wait", optarg);
738 setval ("excludedirectories", optarg);
741 setval ("useproxy", optarg);
747 printf (_("Try `%s --help' for more options.\n"), exec_name);
753 /* All user options have now been processed, so it's now safe to do
754 interoption dependency checks. */
756 if (opt.reclevel == 0)
757 opt.reclevel = INFINITE_RECURSION; /* see wget.h for commentary on this */
759 if (opt.page_requisites && !opt.recursive)
761 opt.recursive = TRUE;
763 if (!opt.no_dirstruct)
764 opt.dirstruct = TRUE; /* usually handled by cmd_spec_recursive() */
767 if (opt.verbose == -1)
768 opt.verbose = !opt.quiet;
771 if (opt.verbose && opt.quiet)
773 printf (_("Can't be verbose and quiet at the same time.\n"));
777 if (opt.timestamping && opt.noclobber)
780 Can't timestamp and not clobber old files at the same time.\n"));
784 nurl = argc - optind;
785 if (!nurl && !opt.input_filename)
787 /* No URL specified. */
788 printf (_("%s: missing URL\n"), exec_name);
791 /* #### Something nicer should be printed here -- similar to the
792 pre-1.5 `--help' page. */
793 printf (_("Try `%s --help' for more options.\n"), exec_name);
798 fork_to_background ();
800 /* Initialize progress. Have to do this after the options are
801 processed so we know where the log file is. */
803 set_progress_implementation (opt.progress_type);
805 /* Allocate basic pointer. */
806 url = ALLOCA_ARRAY (char *, nurl + 1);
807 /* Fill in the arguments. */
808 for (i = 0; i < nurl; i++, optind++)
810 char *rewritten = rewrite_shorthand_url (argv[optind]);
814 url[i] = xstrdup (argv[optind]);
818 /* Change the title of console window on Windows. #### I think this
819 statement should belong to retrieve_url(). --hniksic. */
821 ws_changetitle (*url, nurl);
824 /* Initialize logging. */
825 log_init (opt.lfilename, append_to_log);
827 DEBUGP (("DEBUG output created by Wget %s on %s.\n\n", version_string,
830 /* Open the output filename if necessary. */
831 if (opt.output_document)
833 if (HYPHENP (opt.output_document))
838 opt.dfp = fopen (opt.output_document, opt.always_rest ? "ab" : "wb");
841 perror (opt.output_document);
844 if (fstat (fileno (opt.dfp), &st) == 0 && S_ISREG (st.st_mode))
845 opt.od_known_regular = 1;
853 /* Setup the signal handler to redirect output when hangup is
856 if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
857 signal(SIGHUP, redirect_output_signal);
858 /* ...and do the same for SIGUSR1. */
859 signal (SIGUSR1, redirect_output_signal);
860 /* Writing to a closed socket normally signals SIGPIPE, and the
861 process exits. What we want is to ignore SIGPIPE and just check
862 for the return value of write(). */
863 signal (SIGPIPE, SIG_IGN);
865 signal (SIGWINCH, progress_handle_sigwinch);
867 #endif /* HAVE_SIGNAL */
870 /* Must call this before resolving any URLs because it has the power
871 to disable `https'. */
875 status = RETROK; /* initialize it, just-in-case */
876 /* Retrieve the URLs from argument list. */
877 for (t = url; *t; t++)
879 char *filename = NULL, *redirected_URL = NULL;
882 if (opt.recursive && url_scheme (*t) != SCHEME_FTP)
883 status = retrieve_tree (*t);
885 status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt);
887 if (opt.delete_after && file_exists_p(filename))
889 DEBUGP (("Removing file due to --delete-after in main():\n"));
890 logprintf (LOG_VERBOSE, _("Removing %s.\n"), filename);
891 if (unlink (filename))
892 logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
895 FREE_MAYBE (redirected_URL);
896 FREE_MAYBE (filename);
899 /* And then from the input file, if any. */
900 if (opt.input_filename)
903 status = retrieve_from_file (opt.input_filename, opt.force_html, &count);
905 logprintf (LOG_NOTQUIET, _("No URLs found in %s.\n"),
908 /* Print the downloaded sum. */
911 || (opt.input_filename && opt.downloaded != 0))
913 logprintf (LOG_NOTQUIET,
914 _("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"),
916 (opt.downloaded_overflow ?
917 "<overflow>" : legible_very_long (opt.downloaded)),
919 /* Print quota warning, if exceeded. */
920 if (downloaded_exceeds_quota ())
921 logprintf (LOG_NOTQUIET,
922 _("Download quota (%s bytes) EXCEEDED!\n"),
923 legible (opt.quota));
926 if (opt.cookies_output && wget_cookie_jar)
927 cookie_jar_save (wget_cookie_jar, opt.cookies_output);
929 if (opt.convert_links && !opt.delete_after)
931 convert_all_links ();
935 for (i = 0; i < nurl; i++)
940 print_malloc_debug_stats ();
942 if (status == RETROK)
949 /* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it
950 will proceed operation as usual, trying to write into a log file.
951 If that is impossible, the output will be turned off.
953 #### It is unsafe to do call libc functions from a signal handler.
954 What we should do is, set a global variable, and have the code in
958 redirect_output_signal (int sig)
960 char *signal_name = (sig == SIGHUP ? "SIGHUP" :
961 (sig == SIGUSR1 ? "SIGUSR1" :
963 log_request_redirect_output (signal_name);
964 progress_schedule_redirect ();
965 signal (sig, redirect_output_signal);
967 #endif /* HAVE_SIGNAL */