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\
185 -nd --no-directories don\'t create directories.\n\
186 -x, --force-directories force creation of directories.\n\
187 -nH, --no-host-directories don\'t create host directories.\n\
188 -P, --directory-prefix=PREFIX save files to PREFIX/...\n\
189 --cut-dirs=NUMBER ignore NUMBER remote directory components.\n\
193 --http-user=USER set http user to USER.\n\
194 --http-passwd=PASS set http password to PASS.\n\
195 -C, --cache=on/off (dis)allow server-cached data (normally allowed).\n\
196 -E, --html-extension save all text/html documents with .html extension.\n\
197 --ignore-length ignore `Content-Length\' header field.\n\
198 --header=STRING insert STRING among the headers.\n\
199 --proxy-user=USER set USER as proxy username.\n\
200 --proxy-passwd=PASS set PASS as proxy password.\n\
201 --referer=URL include `Referer: URL\' header in HTTP request.\n\
202 -s, --save-headers save the HTTP headers to file.\n\
203 -U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION.\n\
204 --no-http-keep-alive disable HTTP keep-alive (persistent connections).\n\
205 --cookies=off don't use cookies.\n\
206 --load-cookies=FILE load cookies from FILE before session.\n\
207 --save-cookies=FILE save cookies to FILE after session.\n\
208 --post-data=STRING use the POST method; send STRING as the data.\n\
209 --post-file=FILE use the POST method; send contents of FILE.\n\
213 HTTPS (SSL) options:\n\
214 --sslcertfile=FILE optional client certificate.\n\
215 --sslcertkey=KEYFILE optional keyfile for this certificate.\n\
216 --egd-file=FILE file name of the EGD socket.\n\
217 --sslcadir=DIR dir where hash list of CA's are stured.\n\
218 --sslcafile=FILE file with bundle of CA's\n\
219 --sslcerttype=0/1 Client-Cert type 0=PEM (default) / 1=ASN1 (DER)\n\
220 --sslcheckcert=0/1 Check the server cert agenst given CA\n\
221 --sslprotocol=0-3 choose SSL protocol; 0=automatic,\n\
222 1=SSLv2 2=SSLv3 3=TLSv1\n\
227 -nr, --dont-remove-listing don\'t remove `.listing\' files.\n\
228 -g, --glob=on/off turn file name globbing on or off.\n\
229 --passive-ftp use the \"passive\" transfer mode.\n\
230 --retr-symlinks when recursing, get linked-to files (not dirs).\n\
233 Recursive retrieval:\n\
234 -r, --recursive recursive download.\n\
235 -l, --level=NUMBER maximum recursion depth (inf or 0 for infinite).\n\
236 --delete-after delete files locally after downloading them.\n\
237 -k, --convert-links convert non-relative links to relative.\n\
238 -K, --backup-converted before converting file X, back up as X.orig.\n\
239 -m, --mirror shortcut option equivalent to -r -N -l inf -nr.\n\
240 -p, --page-requisites get all images, etc. needed to display HTML page.\n\
243 Recursive accept/reject:\n\
244 -A, --accept=LIST comma-separated list of accepted extensions.\n\
245 -R, --reject=LIST comma-separated list of rejected extensions.\n\
246 -D, --domains=LIST comma-separated list of accepted domains.\n\
247 --exclude-domains=LIST comma-separated list of rejected domains.\n\
248 --follow-ftp follow FTP links from HTML documents.\n\
249 --follow-tags=LIST comma-separated list of followed HTML tags.\n\
250 -G, --ignore-tags=LIST comma-separated list of ignored HTML tags.\n\
251 -H, --span-hosts go to foreign hosts when recursive.\n\
252 -L, --relative follow relative links only.\n\
253 -I, --include-directories=LIST list of allowed directories.\n\
254 -X, --exclude-directories=LIST list of excluded directories.\n\
255 -np, --no-parent don\'t ascend to the parent directory.\n\
257 fputs (_("Mail bug reports and suggestions to <bug-wget@gnu.org>.\n"),
262 main (int argc, char *const *argv)
265 int i, c, nurl, status, append_to_log;
267 static struct option long_options[] =
269 /* Options without arguments: */
270 { "background", no_argument, NULL, 'b' },
271 { "backup-converted", no_argument, NULL, 'K' },
272 { "continue", no_argument, NULL, 'c' },
273 { "convert-links", no_argument, NULL, 'k' },
274 { "debug", no_argument, NULL, 'd' },
275 { "delete-after", no_argument, NULL, 136 },
276 { "dont-remove-listing", no_argument, NULL, 149 },
277 { "follow-ftp", no_argument, NULL, 142 },
278 { "force-directories", no_argument, NULL, 'x' },
279 { "force-hier", no_argument, NULL, 'x' }, /* obsolete */
280 { "force-html", no_argument, NULL, 'F'},
281 { "help", no_argument, NULL, 'h' },
282 { "html-extension", no_argument, NULL, 'E' },
283 { "ignore-length", no_argument, NULL, 138 },
284 { "mirror", no_argument, NULL, 'm' },
285 { "no-clobber", no_argument, NULL, 141 },
286 { "no-directories", no_argument, NULL, 147 },
287 { "no-host-directories", no_argument, NULL, 148 },
288 { "no-host-lookup", no_argument, NULL, 150 },
289 { "no-http-keep-alive", no_argument, NULL, 156 },
290 { "no-parent", no_argument, NULL, 133 },
291 { "non-verbose", no_argument, NULL, 146 },
292 { "passive-ftp", no_argument, NULL, 139 },
293 { "page-requisites", no_argument, NULL, 'p' },
294 { "quiet", no_argument, NULL, 'q' },
295 { "random-wait", no_argument, NULL, 165 },
296 { "recursive", no_argument, NULL, 'r' },
297 { "relative", no_argument, NULL, 'L' },
298 { "retr-symlinks", no_argument, NULL, 137 },
299 { "retry-connrefused", no_argument, NULL, 174 },
300 { "save-headers", no_argument, NULL, 's' },
301 { "server-response", no_argument, NULL, 'S' },
302 { "span-hosts", no_argument, NULL, 'H' },
303 { "spider", no_argument, NULL, 132 },
304 { "timestamping", no_argument, NULL, 'N' },
305 { "verbose", no_argument, NULL, 'v' },
306 { "version", no_argument, NULL, 'V' },
308 /* Options accepting an argument: */
309 { "accept", required_argument, NULL, 'A' },
310 { "append-output", required_argument, NULL, 'a' },
311 { "backups", required_argument, NULL, 151 }, /* undocumented */
312 { "base", required_argument, NULL, 'B' },
313 { "bind-address", required_argument, NULL, 155 },
314 { "cache", required_argument, NULL, 'C' },
315 { "cookies", required_argument, NULL, 160 },
316 { "cut-dirs", required_argument, NULL, 145 },
317 { "directory-prefix", required_argument, NULL, 'P' },
318 { "dns-cache", required_argument, NULL, 175 },
319 { "domains", required_argument, NULL, 'D' },
320 { "dot-style", required_argument, NULL, 134 },
321 { "execute", required_argument, NULL, 'e' },
322 { "exclude-directories", required_argument, NULL, 'X' },
323 { "exclude-domains", required_argument, NULL, 140 },
324 { "follow-tags", required_argument, NULL, 153 },
325 { "glob", required_argument, NULL, 'g' },
326 { "header", required_argument, NULL, 131 },
327 { "htmlify", required_argument, NULL, 135 },
328 { "http-passwd", required_argument, NULL, 130 },
329 { "http-user", required_argument, NULL, 129 },
330 { "ignore-tags", required_argument, NULL, 'G' },
331 { "include-directories", required_argument, NULL, 'I' },
332 { "input-file", required_argument, NULL, 'i' },
333 { "level", required_argument, NULL, 'l' },
334 { "limit-rate", required_argument, NULL, 164 },
335 { "load-cookies", required_argument, NULL, 161 },
336 { "no", required_argument, NULL, 'n' },
337 { "output-document", required_argument, NULL, 'O' },
338 { "output-file", required_argument, NULL, 'o' },
339 { "post-data", required_argument, NULL, 167 },
340 { "post-file", required_argument, NULL, 168 },
341 { "progress", required_argument, NULL, 163 },
342 { "proxy", required_argument, NULL, 'Y' },
343 { "proxy-passwd", required_argument, NULL, 144 },
344 { "proxy-user", required_argument, NULL, 143 },
345 { "quota", required_argument, NULL, 'Q' },
346 { "reject", required_argument, NULL, 'R' },
347 { "save-cookies", required_argument, NULL, 162 },
348 { "timeout", required_argument, NULL, 'T' },
349 { "tries", required_argument, NULL, 't' },
350 { "user-agent", required_argument, NULL, 'U' },
351 { "referer", required_argument, NULL, 157 },
352 { "use-proxy", required_argument, NULL, 'Y' },
354 { "sslcertfile", required_argument, NULL, 158 },
355 { "sslcertkey", required_argument, NULL, 159 },
356 { "egd-file", required_argument, NULL, 166 },
357 { "sslcadir", required_argument, NULL, 169},
358 { "sslcafile", required_argument, NULL, 170},
359 { "sslcerttype", required_argument, NULL, 171},
360 { "sslcheckcert", required_argument, NULL, 172},
361 { "sslprotocol", required_argument, NULL, 173},
362 #endif /* HAVE_SSL */
363 { "wait", required_argument, NULL, 'w' },
364 { "waitretry", required_argument, NULL, 152 },
372 /* Construct the name of the executable, without the directory part. */
373 exec_name = strrchr (argv[0], PATH_SEPARATOR);
380 windows_main_junk (&argc, (char **) argv, (char **) &exec_name);
383 initialize (); /* sets option defaults; reads the system wgetrc and .wgetrc */
385 /* [Is the order of the option letters significant? If not, they should be
386 alphabetized, like the long_options. The only thing I know for sure is
387 that the options with required arguments must be followed by a ':'.
388 -- Dan Harkless <wget@harkless.org>] */
389 while ((c = getopt_long (argc, argv, "\
390 hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:",
391 long_options, (int *)0)) != EOF)
395 /* Options without arguments: */
397 setval ("spider", "on");
400 setval ("noparent", "on");
403 setval ("deleteafter", "on");
406 setval ("retrsymlinks", "on");
409 setval ("ignorelength", "on");
412 setval ("passiveftp", "on");
415 setval ("noclobber", "on");
418 setval ("followftp", "on");
421 setval ("cutdirs", optarg);
424 setval ("verbose", "off");
427 setval ("dirstruct", "off");
430 setval ("addhostdir", "off");
433 setval ("removelisting", "off");
436 setval ("bindaddress", optarg);
439 setval ("httpkeepalive", "off");
442 setval ("randomwait", "on");
445 setval ("background", "on");
448 setval ("continue", "on");
452 setval ("debug", "on");
453 #else /* not DEBUG */
454 fprintf (stderr, _("%s: debug support not compiled in.\n"),
456 #endif /* not DEBUG */
459 setval ("htmlextension", "on");
462 setval ("forcehtml", "on");
465 setval ("spanhosts", "on");
475 setval ("backupconverted", "on");
478 setval ("convertlinks", "on");
481 setval ("relativeonly", "on");
484 setval ("mirror", "on");
487 setval ("timestamping", "on");
490 setval ("pagerequisites", "on");
493 setval ("serverresponse", "on");
496 setval ("saveheaders", "on");
499 setval ("quiet", "on");
502 setval ("recursive", "on");
505 printf ("GNU Wget %s\n\n", version_string);
507 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.\n"));
509 This program is distributed in the hope that it will be useful,\n\
510 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
511 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
512 GNU General Public License for more details.\n"));
513 printf (_("\nOriginally written by Hrvoje Niksic <hniksic@arsdigita.com>.\n"));
517 setval ("verbose", "on");
520 setval ("dirstruct", "on");
523 setval ("retryconnrefused", "on");
526 /* Options accepting an argument: */
528 setval ("httpuser", optarg);
531 setval ("httppasswd", optarg);
534 setval ("header", optarg);
537 setval ("dotstyle", optarg);
540 setval ("htmlify", optarg);
543 setval ("excludedomains", optarg);
546 setval ("proxyuser", optarg);
549 setval ("proxypasswd", optarg);
552 setval ("backups", optarg);
555 setval ("waitretry", optarg);
558 setval ("followtags", optarg);
561 setval ("cookies", optarg);
564 setval ("loadcookies", optarg);
567 setval ("savecookies", optarg);
570 setval ("progress", optarg);
573 setval ("limitrate", optarg);
576 setval ("referer", optarg);
580 setval ("sslcertfile", optarg);
583 setval ("sslcertkey", optarg);
586 setval ("egdfile", optarg);
589 setval ("sslcadir", optarg);
592 setval ("sslcafile", optarg);
595 setval ("sslcerttype", optarg);
598 setval ("sslcheckcert", optarg);
601 setval ("sslprotocol", optarg);
603 #endif /* HAVE_SSL */
605 setval ("postdata", optarg);
608 setval ("postfile", optarg);
611 setval ("dnscache", optarg);
614 setval ("accept", optarg);
617 setval ("logfile", optarg);
621 setval ("base", optarg);
624 setval ("cache", optarg);
627 setval ("domains", optarg);
632 if (parse_line (optarg, &com, &val))
634 if (!setval (com, val))
639 fprintf (stderr, _("%s: %s: invalid command\n"), exec_name,
648 setval ("ignoretags", optarg);
651 setval ("glob", optarg);
654 setval ("includedirectories", optarg);
657 setval ("input", optarg);
660 setval ("reclevel", optarg);
664 /* #### What we really want here is --no-foo. */
667 for (p = optarg; *p; p++)
671 setval ("verbose", "off");
674 setval ("addhostdir", "off");
677 setval ("dirstruct", "off");
680 setval ("noclobber", "on");
683 setval ("removelisting", "off");
686 setval ("noparent", "on");
689 setval ("httpkeepalive", "off");
692 printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p);
695 printf (_("Try `%s --help\' for more options.\n"), exec_name);
701 setval ("outputdocument", optarg);
704 setval ("logfile", optarg);
707 setval ("dirprefix", optarg);
710 setval ("quota", optarg);
713 setval ("reject", optarg);
716 setval ("timeout", optarg);
719 setval ("tries", optarg);
722 setval ("useragent", optarg);
725 setval ("wait", optarg);
728 setval ("excludedirectories", optarg);
731 setval ("useproxy", optarg);
737 printf (_("Try `%s --help' for more options.\n"), exec_name);
743 /* All user options have now been processed, so it's now safe to do
744 interoption dependency checks. */
746 if (opt.reclevel == 0)
747 opt.reclevel = INFINITE_RECURSION; /* see wget.h for commentary on this */
749 if (opt.page_requisites && !opt.recursive)
751 opt.recursive = TRUE;
753 if (!opt.no_dirstruct)
754 opt.dirstruct = TRUE; /* usually handled by cmd_spec_recursive() */
757 if (opt.verbose == -1)
758 opt.verbose = !opt.quiet;
761 if (opt.verbose && opt.quiet)
763 printf (_("Can't be verbose and quiet at the same time.\n"));
767 if (opt.timestamping && opt.noclobber)
770 Can't timestamp and not clobber old files at the same time.\n"));
774 nurl = argc - optind;
775 if (!nurl && !opt.input_filename)
777 /* No URL specified. */
778 printf (_("%s: missing URL\n"), exec_name);
781 /* #### Something nicer should be printed here -- similar to the
782 pre-1.5 `--help' page. */
783 printf (_("Try `%s --help' for more options.\n"), exec_name);
788 fork_to_background ();
790 /* Initialize progress. Have to do this after the options are
791 processed so we know where the log file is. */
793 set_progress_implementation (opt.progress_type);
795 /* Allocate basic pointer. */
796 url = ALLOCA_ARRAY (char *, nurl + 1);
797 /* Fill in the arguments. */
798 for (i = 0; i < nurl; i++, optind++)
800 char *rewritten = rewrite_shorthand_url (argv[optind]);
804 url[i] = xstrdup (argv[optind]);
808 /* Change the title of console window on Windows. #### I think this
809 statement should belong to retrieve_url(). --hniksic. */
811 ws_changetitle (*url, nurl);
814 /* Initialize logging. */
815 log_init (opt.lfilename, append_to_log);
817 DEBUGP (("DEBUG output created by Wget %s on %s.\n\n", version_string,
820 /* Open the output filename if necessary. */
821 if (opt.output_document)
823 if (HYPHENP (opt.output_document))
828 opt.dfp = fopen (opt.output_document, opt.always_rest ? "ab" : "wb");
831 perror (opt.output_document);
834 if (fstat (fileno (opt.dfp), &st) == 0 && S_ISREG (st.st_mode))
835 opt.od_known_regular = 1;
843 /* Setup the signal handler to redirect output when hangup is
846 if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
847 signal(SIGHUP, redirect_output_signal);
848 /* ...and do the same for SIGUSR1. */
849 signal (SIGUSR1, redirect_output_signal);
850 /* Writing to a closed socket normally signals SIGPIPE, and the
851 process exits. What we want is to ignore SIGPIPE and just check
852 for the return value of write(). */
853 signal (SIGPIPE, SIG_IGN);
855 signal (SIGWINCH, progress_handle_sigwinch);
857 #endif /* HAVE_SIGNAL */
860 /* Must call this before resolving any URLs because it has the power
861 to disable `https'. */
865 status = RETROK; /* initialize it, just-in-case */
866 /* Retrieve the URLs from argument list. */
867 for (t = url; *t; t++)
869 char *filename = NULL, *redirected_URL = NULL;
872 if (opt.recursive && url_scheme (*t) != SCHEME_FTP)
873 status = retrieve_tree (*t);
875 status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt);
877 if (opt.delete_after && file_exists_p(filename))
879 DEBUGP (("Removing file due to --delete-after in main():\n"));
880 logprintf (LOG_VERBOSE, _("Removing %s.\n"), filename);
881 if (unlink (filename))
882 logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
885 FREE_MAYBE (redirected_URL);
886 FREE_MAYBE (filename);
889 /* And then from the input file, if any. */
890 if (opt.input_filename)
893 status = retrieve_from_file (opt.input_filename, opt.force_html, &count);
895 logprintf (LOG_NOTQUIET, _("No URLs found in %s.\n"),
898 /* Print the downloaded sum. */
901 || (opt.input_filename && opt.downloaded != 0))
903 logprintf (LOG_NOTQUIET,
904 _("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"),
906 (opt.downloaded_overflow ?
907 "<overflow>" : legible_very_long (opt.downloaded)),
909 /* Print quota warning, if exceeded. */
910 if (downloaded_exceeds_quota ())
911 logprintf (LOG_NOTQUIET,
912 _("Download quota (%s bytes) EXCEEDED!\n"),
913 legible (opt.quota));
916 if (opt.cookies_output && wget_cookie_jar)
917 cookie_jar_save (wget_cookie_jar, opt.cookies_output);
919 if (opt.convert_links && !opt.delete_after)
921 convert_all_links ();
925 for (i = 0; i < nurl; i++)
930 print_malloc_debug_stats ();
932 if (status == RETROK)
939 /* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it
940 will proceed operation as usual, trying to write into a log file.
941 If that is impossible, the output will be turned off.
943 #### It is unsafe to do call libc functions from a signal handler.
944 What we should do is, set a global variable, and have the code in
948 redirect_output_signal (int sig)
950 char *signal_name = (sig == SIGHUP ? "SIGHUP" :
951 (sig == SIGUSR1 ? "SIGUSR1" :
953 log_request_redirect_output (signal_name);
954 progress_schedule_redirect ();
955 signal (sig, redirect_output_signal);
957 #endif /* HAVE_SIGNAL */