From: Micah Cowan Date: Fri, 16 May 2008 05:36:20 +0000 (-0700) Subject: Merging heads. X-Git-Tag: v1.13~421^2~12^2~22 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=d78cd8d8f8e12d1b71ac19795131d6975abe544b;hp=-c Merging heads. --- d78cd8d8f8e12d1b71ac19795131d6975abe544b diff --combined ChangeLog index 697f2ca6,ad4c460c..1a20b3c6 --- a/ChangeLog +++ b/ChangeLog @@@ -1,7 -1,8 +1,12 @@@ +2008-05-15 Micah Cowan + + * NEWS: Entry for --ask-password. + + 2008-05-14 Joao Ferreira + + * src/main.c, src/http.c, src/ftp.c: -nc is now working in - conjunction with '-O file'. ++ conjunction with '-O file'. + 2008-05-12 Micah Cowan * NEWS: Translations and -N/-O. @@@ -10,45 -11,6 +15,45 @@@ * NEWS: Added documentation for changes made in 1.11.2. +2008-04-30 Steven Schubiger + + * lib/getdelim.c, lib/getline.c, lib/getpass.c, + lib/getpass.h, lib/realloc.c, lib/stdio.h, + lib/stdio.in.h, lib/stdlib.h, lib/stdlib.in.h: Imported + from gnulib. + * m4/eoverflow.m4, m4/extensions.m4, m4/getdelim.m4, + m4/getline.m4, m4/getpass.m4, m4/malloc.m4, m4/realloc.m4, + m4/stdio_h.m4, m4/stdlib_h.m4: Imported from gnulib. + * md5/stdint.h: Imported from gnulib. + + * GNUmakefile: Updated from gnulib. + * lib/Makefile.am, lib/getopt.c, lib/unistd.in.h: Updated + from gnulib. + * m4/gnulib-cache.m4, m4/gnulib-common.m4, m4/gnulib-comp.m4, + m4/include_next.m4, m4/unistd_h.m4: Updated from gnulib. + * md5/Makefile.am, md5/m4/gnulib-cache.m4, md5/m4/gnulib-common.m4, + md5/m4/gnulib-comp.m4, md5/m4/include_next.m4, md5/m4/md5.m4, + md5/m4/stdint.m4, md5/md5.c, md5/md5.h, md5/stdint.in.h, + md5/wchar.in.h: Updated from gnulib. + +2008-04-14 Micah Cowan + + * GNUmakefile, lib/Makefile.am, lib/error.c, lib/error.h, + lib/exitfail.c, lib/exitfail.h, lib/getopt.c, lib/intprops.h, + lib/quote.c, lib/quote.h, lib/quotearg.c, lib/quotearg.h, + lib/stdlib.in.h, lib/strerror.c, lib/string.in.h, + lib/unistd.in.h, lib/wchar.in.h, lib/wctype.in.h, + lib/xalloc-die.c, lib/xalloc.h, lib/xmalloc.c, m4/error.m4, + m4/exitfail.m4, m4/extensions.m4, m4/gnulib-cache.m4, + m4/gnulib-comp.m4, m4/include_next.m4, m4/inline.m4, + m4/mbrtowc.m4, m4/mbstate_t.m4, m4/quote.m4, m4/quotearg.m4, + m4/stdlib_h.m4, m4/strerror.m4, m4/string_h.m4, m4/unistd_h.m4, + m4/wchar.m4, m4/wctype.m4, m4/wint_t.m4, m4/xalloc.m4, + md5/Makefile.am, md5/m4/gnulib-cache.m4, md5/m4/gnulib-comp.m4, + md5/m4/include_next.m4, md5/m4/md5.m4, md5/m4/stdint.m4, + md5/md5.c, md5/md5.h, md5/stdint.in.h, md5/wchar.in.h: Update + from Gnulib, and add the "quote" module. + 2008-03-20 Micah Cowan * ABOUT-NLS: Reinstated, but with a message mentioning that diff --combined src/ChangeLog index c5edf7a3,149bc521..0d4c94b5 --- a/src/ChangeLog +++ b/src/ChangeLog @@@ -1,12 -1,8 +1,17 @@@ + 2008-05-15 Steven Schubiger + + * ftp.c (getftp): Verify that the file actually exists in FTP, by + checking it against the listing. + +2008-05-15 Micah Cowan + + * main.c (prompt_for_password): Use the quote module. + +2008-05-14 Micah Cowan + + * ftp.c (ftp_retrieve_list): Symlinks and other filenames + should be fully quoted. + 2008-05-12 Micah Cowan * main.c (main): Downgrade "-N with -O" to a warning, and switch @@@ -18,21 -14,6 +23,21 @@@ printed on lines that don't display the ETA, in multibyte locales. +2008-04-30 Steven Schubiger + + * main.c (main): New code that handles prompting for passwords + when specified explicitly via command-line option (using gnulib's + getpass-gnu module). + (main): Include the getpass header. + + * init.c: Add "ask-password" to the list of recognized commands. + + * options.h: Add an according boolean member to the options + struct. + + * sysdep.h: Comment the defines __EXTENSIONS__ and _GNU_SOURCE + out, because they're now defined independently by config.h. + 2008-04-27 Rabin Vincent * http.c (http_loop): Fix return for the case where we don't @@@ -101,35 -82,6 +106,35 @@@ * Makefile.am: Move @LIBS@ after other libraries, for better static-linking support. Fixes bug #22143. +2008-04-16 Steven Schubiger + + * ftp.c: Use Gnulib's quote function for printing filenames and + such. + * connect.c: Likewise. + * convert.c: Likewise. + * cookies.c: Likewise. + * ftp-opie.c: Likewise. + * gnutls.c: Likewise. + * init.c: Likewise. + * log.c: Likewise. + * mswindows.c: Likewise. + * openssl.c: Likewise. + * progress.c: Likewise. + * recur.c: Likewise. + * res.c: Likewise. + * utils.c: Likewise. + +2008-04-16 Steven Schubiger + + * sysdep.h: Comment the defines __EXTENSIONS__ and _GNU_SOURCE + out, because they're now defined independently by config.h. + +2008-04-14 Steven Schubiger + + * http.c: Use Gnulib's quote function for printing filenames and + such. + * wget.h: #include "quote.h". + 2008-04-12 Rabin Vincent * mswindows.c (fake_fork_child): Don't create a logfile for diff --combined src/ftp.c index 0ecc6bcb,5bfd2aa8..17df5029 --- a/src/ftp.c +++ b/src/ftp.c @@@ -227,6 -227,8 +227,8 @@@ print_length (wgint size, wgint start, logputs (LOG_VERBOSE, !authoritative ? _(" (unauthoritative)\n") : "\n"); } + static uerr_t ftp_get_listing (struct url *, ccon *, struct fileinfo **); + /* Retrieves a file with denoted parameters through opening an FTP connection to the server. It always closes the data connection, and closes the control connection in case of error. */ @@@ -300,8 -302,7 +302,8 @@@ getftp (struct url *u, wgint *len, wgin con->csock = -1; /* Second: Login with proper USER/PASS sequence. */ - logprintf (LOG_VERBOSE, _("Logging in as %s ... "), escnonprint (user)); + logprintf (LOG_VERBOSE, _("Logging in as %s ... "), + quotearg_style (escape_quoting_style, user)); if (opt.server_response) logputs (LOG_ALWAYS, "\n"); err = ftp_login (csock, logname, passwd); @@@ -546,8 -547,7 +548,8 @@@ Error in server response, closing contr } if (!opt.server_response) - logprintf (LOG_VERBOSE, "==> CWD %s ... ", escnonprint (target)); + logprintf (LOG_VERBOSE, "==> CWD %s ... ", + quotearg_style (escape_quoting_style, target)); err = ftp_cwd (csock, target); /* FTPRERR, WRITEFAILED, FTPNSFOD */ switch (err) @@@ -568,8 -568,8 +570,8 @@@ Error in server response, closing contr return err; case FTPNSFOD: logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("No such directory `%s'.\n\n"), - escnonprint (u->dir)); + logprintf (LOG_NOTQUIET, _("No such directory %s.\n\n"), + quote (u->dir)); fd_close (csock); con->csock = -1; return err; @@@ -590,8 -590,7 +592,8 @@@ if (opt.verbose) { if (!opt.server_response) - logprintf (LOG_VERBOSE, "==> SIZE %s ... ", escnonprint (u->file)); + logprintf (LOG_VERBOSE, "==> SIZE %s ... ", + quotearg_style (escape_quoting_style, u->file)); } err = ftp_size (csock, u->file, len); @@@ -779,12 -778,37 +781,37 @@@ Error in server response, closing contr if (cmd & DO_RETR) { - /* If we're in spider mode, don't really retrieve anything. The - fact that we got to this point should be proof enough that - the file exists, vaguely akin to HTTP's concept of a "HEAD" - request. */ + /* If we're in spider mode, don't really retrieve anything except + the directory listing and verify whether the given "file" exists. */ if (opt.spider) { + bool exists = false; + uerr_t res; + struct fileinfo *f; + res = ftp_get_listing (u, con, &f); + /* Set the DO_RETR command flag again, because it gets unset when + calling ftp_get_listing() and would otherwise cause an assertion + failure earlier on when this function gets repeatedly called + (e.g., when recursing). */ + con->cmd |= DO_RETR; + if (res == RETROK) + { + while (f) + { + if (!strcmp (f->name, u->file)) + { + exists = true; + break; + } + f = f->next; + } + if (!exists) + { + logputs (LOG_VERBOSE, "\n"); + logprintf (LOG_NOTQUIET, _("No such file `%s'.\n"), + escnonprint (u->file)); + } + } fd_close (csock); con->csock = -1; fd_close (dtsock); @@@ -798,8 -822,7 +825,8 @@@ { if (restval) logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_VERBOSE, "==> RETR %s ... ", escnonprint (u->file)); + logprintf (LOG_VERBOSE, "==> RETR %s ... ", + quotearg_style (escape_quoting_style, u->file)); } } @@@ -827,8 -850,8 +854,8 @@@ Error in server response, closing contr return err; case FTPNSFOD: logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("No such file `%s'.\n\n"), - escnonprint (u->file)); + logprintf (LOG_NOTQUIET, _("No such file %s.\n\n"), + quote (u->file)); fd_close (dtsock); fd_close (local_sock); return err; @@@ -874,8 -897,8 +901,8 @@@ Error in server response, closing contr return err; case FTPNSFOD: logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("No such file or directory `%s'.\n\n"), - "."); + logprintf (LOG_NOTQUIET, _("No such file or directory %s.\n\n"), + quote (".")); fd_close (dtsock); fd_close (local_sock); return err; @@@ -1067,8 -1090,7 +1094,8 @@@ char *p = strchr (line, '\0'); while (p > line && (p[-1] == '\n' || p[-1] == '\r')) *--p = '\0'; - logprintf (LOG_ALWAYS, "%s\n", escnonprint (line)); + logprintf (LOG_ALWAYS, "%s\n", + quotearg_style (escape_quoting_style, line)); xfree (line); } fclose (fp); @@@ -1096,10 -1118,12 +1123,12 @@@ ftp_loop_internal (struct url *u, struc if (!con->target) con->target = url_file_name (u); - if (opt.noclobber && file_exists_p (con->target)) + /* If the output_document was given, then this check was already done and + the file didn't exist. Hence the !opt.output_document */ + if (opt.noclobber && !opt.output_document && file_exists_p (con->target)) { logprintf (LOG_VERBOSE, - _("File `%s' already there; not retrieving.\n"), con->target); + _("File %s already there; not retrieving.\n"), quote (con->target)); /* If the file is there, we suppose it's retrieved OK. */ return RETROK; } @@@ -1170,8 -1194,8 +1199,8 @@@ strcpy (tmp, " "); if (count > 1) sprintf (tmp, _("(try:%2d)"), count); - logprintf (LOG_VERBOSE, "--%s-- %s\n %s => `%s'\n", - tms, hurl, tmp, locf); + logprintf (LOG_VERBOSE, "--%s-- %s\n %s => %s\n", + tms, hurl, tmp, quote (locf)); #ifdef WINDOWS ws_changetitle (hurl); #endif @@@ -1239,8 -1263,8 +1268,8 @@@ con->csock = -1; } if (!opt.spider) - logprintf (LOG_VERBOSE, _("%s (%s) - `%s' saved [%s]\n\n"), - tms, tmrate, locf, number_to_static_string (len)); + logprintf (LOG_VERBOSE, _("%s (%s) - %s saved [%s]\n\n"), + tms, tmrate, quote (locf), number_to_static_string (len)); if (!opt.verbose && !opt.quiet) { /* Need to hide the password from the URL. The `if' is here @@@ -1323,7 -1347,7 +1352,7 @@@ ftp_get_listing (struct url *u, ccon *c uf = url_file_name (u); lf = file_merge (uf, LIST_FILENAME); xfree (uf); - DEBUGP ((_("Using `%s' as listing tmp file.\n"), lf)); + DEBUGP ((_("Using %s as listing tmp file.\n"), quote (lf))); con->target = lf; err = ftp_loop_internal (u, NULL, con); @@@ -1337,7 -1361,7 +1366,7 @@@ if (unlink (lf)) logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno)); else - logprintf (LOG_VERBOSE, _("Removed `%s'.\n"), lf); + logprintf (LOG_VERBOSE, _("Removed %s.\n"), quote (lf)); } } else @@@ -1444,15 -1468,15 +1473,15 @@@ ftp_retrieve_list (struct url *u, struc /* Remote file is older, file sizes can be compared and are both equal. */ logprintf (LOG_VERBOSE, _("\ -Remote file no newer than local file `%s' -- not retrieving.\n"), con->target); +Remote file no newer than local file %s -- not retrieving.\n"), quote (con->target)); dlthis = false; } else if (eq_size) { /* Remote file is newer or sizes cannot be matched */ logprintf (LOG_VERBOSE, _("\ -Remote file is newer than local file `%s' -- retrieving.\n\n"), - con->target); +Remote file is newer than local file %s -- retrieving.\n\n"), + quote (con->target)); } else { @@@ -1494,15 -1518,14 +1523,15 @@@ The sizes do not match (local %s) -- re { logprintf (LOG_VERBOSE, _("\ Already have correct symlink %s -> %s\n\n"), - con->target, escnonprint (f->linkto)); + quote (con->target), + quote (f->linkto)); dlthis = false; break; } } } logprintf (LOG_VERBOSE, _("Creating symlink %s -> %s\n"), - con->target, escnonprint (f->linkto)); + quote (con->target), quote (f->linkto)); /* Unlink before creating symlink! */ unlink (con->target); if (symlink (f->linkto, con->target) == -1) @@@ -1511,8 -1534,8 +1540,8 @@@ } /* have f->linkto */ #else /* not HAVE_SYMLINK */ logprintf (LOG_NOTQUIET, - _("Symlinks not supported, skipping symlink `%s'.\n"), - con->target); + _("Symlinks not supported, skipping symlink %s.\n"), + quote (con->target)); #endif /* not HAVE_SYMLINK */ } else /* opt.retr_symlinks */ @@@ -1523,8 -1546,8 +1552,8 @@@ break; case FT_DIRECTORY: if (!opt.recursive) - logprintf (LOG_NOTQUIET, _("Skipping directory `%s'.\n"), - escnonprint (f->name)); + logprintf (LOG_NOTQUIET, _("Skipping directory %s.\n"), + quote (f->name)); break; case FT_PLAINFILE: /* Call the retrieve loop. */ @@@ -1533,7 -1556,7 +1562,7 @@@ break; case FT_UNKNOWN: logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"), - escnonprint (f->name)); + quote (f->name)); break; } /* switch */ @@@ -1638,8 -1661,8 +1667,8 @@@ ftp_retrieve_dirs (struct url *u, struc if (!accdir (newdir)) { logprintf (LOG_VERBOSE, _("\ -Not descending to `%s' as it is excluded/not-included.\n"), - escnonprint (newdir)); +Not descending to %s as it is excluded/not-included.\n"), + quote (newdir)); continue; } @@@ -1703,8 -1726,8 +1732,8 @@@ ftp_retrieve_glob (struct url *u, ccon { if (f->type != FT_DIRECTORY && !acceptable (f->name)) { - logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"), - escnonprint (f->name)); + logprintf (LOG_VERBOSE, _("Rejecting %s.\n"), + quote (f->name)); f = delelement (f, &start); } else @@@ -1717,8 -1740,8 +1746,8 @@@ { if (has_insecure_name_p (f->name)) { - logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"), - escnonprint (f->name)); + logprintf (LOG_VERBOSE, _("Rejecting %s.\n"), + quote (f->name)); f = delelement (f, &start); } else @@@ -1741,8 -1764,7 +1770,8 @@@ if (matchres == -1) { logprintf (LOG_NOTQUIET, _("Error matching %s against %s: %s\n"), - u->file, escnonprint (f->name), strerror (errno)); + u->file, quotearg_style (escape_quoting_style, f->name), + strerror (errno)); break; } if (matchres == FNM_NOMATCH) @@@ -1782,8 -1804,8 +1811,8 @@@ /* No luck. */ /* #### This message SUCKS. We should see what was the reason that nothing was retrieved. */ - logprintf (LOG_VERBOSE, _("No matches on pattern `%s'.\n"), - escnonprint (u->file)); + logprintf (LOG_VERBOSE, _("No matches on pattern %s.\n"), + quote (u->file)); } else /* GLOB_GETONE or GLOB_GETALL */ { @@@ -1848,13 -1870,13 +1877,13 @@@ ftp_loop (struct url *u, int *dt, struc else sz = -1; logprintf (LOG_NOTQUIET, - _("Wrote HTML-ized index to `%s' [%s].\n"), - filename, number_to_static_string (sz)); + _("Wrote HTML-ized index to %s [%s].\n"), + quote (filename), number_to_static_string (sz)); } else logprintf (LOG_NOTQUIET, - _("Wrote HTML-ized index to `%s'.\n"), - filename); + _("Wrote HTML-ized index to %s.\n"), + quote (filename)); } xfree (filename); } diff --combined src/http.c index 0252d342,20f0619a..11dc9cc8 --- a/src/http.c +++ b/src/http.c @@@ -403,13 -403,13 +403,13 @@@ maybe_send_basic_creds (const char *hos else if (basic_authed_hosts && hash_table_contains(basic_authed_hosts, hostname)) { - DEBUGP(("Found `%s' in basic_authed_hosts.\n", hostname)); + DEBUGP(("Found %s in basic_authed_hosts.\n", quote (hostname))); do_challenge = true; } else { - DEBUGP(("Host `%s' has not issued a general basic challenge.\n", - hostname)); + DEBUGP(("Host %s has not issued a general basic challenge.\n", + quote (hostname))); } if (do_challenge) { @@@ -430,7 -430,7 +430,7 @@@ register_basic_auth_host (const char *h if (!hash_table_contains(basic_authed_hosts, hostname)) { hash_table_put (basic_authed_hosts, xstrdup(hostname), NULL); - DEBUGP(("Inserted `%s' into basic_authed_hosts\n", hostname)); + DEBUGP(("Inserted %s into basic_authed_hosts\n", quote (hostname))); } } @@@ -810,8 -810,7 +810,8 @@@ print_response_line(const char *prefix { char *copy; BOUNDED_TO_ALLOCA(b, e, copy); - logprintf (LOG_ALWAYS, "%s%s\n", prefix, escnonprint(copy)); + logprintf (LOG_ALWAYS, "%s%s\n", prefix, + quotearg_style (escape_quoting_style, copy)); } /* Print the server response, line by line, omitting the trailing CRLF @@@ -1545,8 -1544,8 +1545,8 @@@ gethttp (struct url *u, struct http_sta post_data_size = file_size (opt.post_file_name); if (post_data_size == -1) { - logprintf (LOG_NOTQUIET, _("POST data file `%s' missing: %s\n"), - opt.post_file_name, strerror (errno)); + logprintf (LOG_NOTQUIET, _("POST data file %s missing: %s\n"), + quote (opt.post_file_name), strerror (errno)); post_data_size = 0; } } @@@ -1630,8 -1629,7 +1630,8 @@@ sock = pconn.socket; using_ssl = pconn.ssl; logprintf (LOG_VERBOSE, _("Reusing existing connection to %s:%d.\n"), - escnonprint (pconn.host), pconn.port); + quotearg_style (escape_quoting_style, pconn.host), + pconn.port); DEBUGP (("Reusing fd %d.\n", sock)); if (pconn.authorized) /* If the connection is already authorized, the "Basic" @@@ -1643,8 -1641,8 +1643,8 @@@ { request_free (req); logprintf(LOG_NOTQUIET, - _("%s: unable to resolve host address `%s'\n"), - exec_name, relevant->host); + _("%s: unable to resolve host address %s\n"), + exec_name, quote (relevant->host)); return HOSTERR; } } @@@ -1719,7 -1717,7 +1719,7 @@@ { failed_tunnel: logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"), - message ? escnonprint (message) : "?"); + message ? quotearg_style (escape_quoting_style, message) : "?"); xfree_null (message); return CONSSLERR; } @@@ -1797,7 -1795,7 +1797,7 @@@ statcode = resp_status (resp, &message); if (!opt.server_response) logprintf (LOG_VERBOSE, "%2d %s\n", statcode, - message ? escnonprint (message) : ""); + message ? quotearg_style (escape_quoting_style, message) : ""); else { logprintf (LOG_VERBOSE, "\n"); @@@ -1823,12 -1821,13 +1823,13 @@@ /* TODO: perform this check only once. */ if (!hs->existence_checked && file_exists_p (hs->local_file)) { - if (opt.noclobber) + if (opt.noclobber && !opt.output_document) { /* If opt.noclobber is turned on and file already exists, do not - retrieve the file */ + retrieve the file. But if the output_document was given, then this + test was already done and the file didn't exist. Hence the !opt.output_document */ logprintf (LOG_VERBOSE, _("\ -File `%s' already there; not retrieving.\n\n"), hs->local_file); +File %s already there; not retrieving.\n\n"), quote (hs->local_file)); /* If the file is there, we suppose it's retrieved OK. */ *dt |= RETROKF; @@@ -2207,7 -2206,7 +2208,7 @@@ logputs (LOG_VERBOSE, opt.ignore_length ? _("ignored") : _("unspecified")); if (type) - logprintf (LOG_VERBOSE, " [%s]\n", escnonprint (type)); + logprintf (LOG_VERBOSE, " [%s]\n", quotearg_style (escape_quoting_style, type)); else logputs (LOG_VERBOSE, "\n"); } @@@ -2276,8 -2275,8 +2277,8 @@@ /* Print fetch message, if opt.verbose. */ if (opt.verbose) { - logprintf (LOG_NOTQUIET, _("Saving to: `%s'\n"), - HYPHENP (hs->local_file) ? "STDOUT" : hs->local_file); + logprintf (LOG_NOTQUIET, _("Saving to: %s\n"), + HYPHENP (hs->local_file) ? quote ("STDOUT") : quote (hs->local_file)); } /* This confuses the timestamping code that checks for file size. @@@ -2376,13 -2375,14 +2377,14 @@@ http_loop (struct url *u, char **newloc /* TODO: Ick! This code is now in both gethttp and http_loop, and is * screaming for some refactoring. */ - if (got_name && file_exists_p (hstat.local_file) && opt.noclobber) + if (got_name && file_exists_p (hstat.local_file) && opt.noclobber && !opt.output_document) { /* If opt.noclobber is turned on and file already exists, do not - retrieve the file */ + retrieve the file. But if the output_document was given, then this + test was already done and the file didn't exist. Hence the !opt.output_document */ logprintf (LOG_VERBOSE, _("\ -File `%s' already there; not retrieving.\n\n"), - hstat.local_file); +File %s already there; not retrieving.\n\n"), + quote (hstat.local_file)); /* If the file is there, we suppose it's retrieved OK. */ *dt |= RETROKF; @@@ -2510,8 -2510,8 +2512,8 @@@ Spider mode enabled. Check if remote fi case FWRITEERR: case FOPENERR: /* Another fatal error. */ logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"), - hstat.local_file, strerror (errno)); + logprintf (LOG_NOTQUIET, _("Cannot write to %s (%s).\n"), + quote (hstat.local_file), strerror (errno)); case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED: case SSLINITFAILED: case CONTNOTSUPPORTED: /* Fatal errors just return from the function. */ @@@ -2579,8 -2579,7 +2581,8 @@@ Remote file does not exist -- broken li else { logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"), - tms, hstat.statcode, escnonprint (hstat.error)); + tms, hstat.statcode, + quotearg_style (escape_quoting_style, hstat.error)); } logputs (LOG_VERBOSE, "\n"); ret = WRONGCODE; @@@ -2634,8 -2633,8 +2636,8 @@@ Last-modified header invalid -- time-st || hstat.orig_file_size == hstat.contlen) { logprintf (LOG_VERBOSE, _("\ -Server file no newer than local file `%s' -- not retrieving.\n\n"), - hstat.orig_file_name); +Server file no newer than local file %s -- not retrieving.\n\n"), + quote (hstat.orig_file_name)); ret = RETROK; goto exit; } @@@ -2738,8 -2737,8 +2740,8 @@@ Remote file exists.\n\n")) if (*dt & RETROKF) { logprintf (LOG_VERBOSE, - _("%s (%s) - `%s' saved [%s/%s]\n\n"), - tms, tmrate, hstat.local_file, + _("%s (%s) - %s saved [%s/%s]\n\n"), + tms, tmrate, quote (hstat.local_file), number_to_static_string (hstat.len), number_to_static_string (hstat.contlen)); logprintf (LOG_NONVERBOSE, @@@ -2769,8 -2768,8 +2771,8 @@@ if (*dt & RETROKF) { logprintf (LOG_VERBOSE, - _("%s (%s) - `%s' saved [%s]\n\n"), - tms, tmrate, hstat.local_file, + _("%s (%s) - %s saved [%s]\n\n"), + tms, tmrate, quote (hstat.local_file), number_to_static_string (hstat.len)); logprintf (LOG_NONVERBOSE, "%s URL:%s [%s] -> \"%s\" [%d]\n", diff --combined src/main.c index e239b6d0,fdf368a5..159973a0 --- a/src/main.c +++ b/src/main.c @@@ -56,8 -56,6 +56,8 @@@ as that of the covered work. * #include "http.h" /* for save_cookies */ #include +#include +#include #ifndef PATH_SEPARATOR # define PATH_SEPARATOR '/' @@@ -132,7 -130,6 +132,7 @@@ static struct cmdline_option option_dat { { "accept", 'A', OPT_VALUE, "accept", -1 }, { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument }, + { "ask-password", 0, OPT_BOOLEAN, "askpassword", -1 }, { "auth-no-challenge", 0, OPT_BOOLEAN, "authnochallenge", -1 }, { "background", 'b', OPT_BOOLEAN, "background", -1 }, { "backup-converted", 'K', OPT_BOOLEAN, "backupconverted", -1 }, @@@ -475,8 -472,6 +475,8 @@@ Download:\n") --user=USER set both ftp and http user to USER.\n"), N_("\ --password=PASS set both ftp and http password to PASS.\n"), + N_("\ + --ask-password prompt for passwords.\n"), "\n", N_("\ @@@ -678,16 -673,6 +678,16 @@@ secs_to_human_time (double interval return buf; } +static char * +prompt_for_password (void) +{ + if (opt.user) + printf (_("Password for user %s: "), quote (opt.user)); + else + printf (_("Password: ")); + return getpass(""); +} + static void print_version (void) { @@@ -920,15 -905,14 +920,21 @@@ WARNING: timestamping does nothing in c for details.\n\n")); opt.timestamping = false; } + 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); + exit(1); + } } + if (opt.ask_passwd && opt.passwd) + { + printf (_("Cannot specify both --ask-password and --password.\n")); + print_usage (); + exit (1); + } + if (!nurl && !opt.input_filename) { /* No URL specified. */ @@@ -1024,9 -1008,6 +1030,9 @@@ char *filename = NULL, *redirected_URL = NULL; int dt; + if (opt.ask_passwd) + opt.passwd = prompt_for_password (); + if ((opt.recursive || opt.page_requisites) && (url_scheme (*t) != SCHEME_FTP || url_uses_proxy (*t))) {