1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] New option --protocol-directories.

This commit is contained in:
hniksic 2003-12-05 19:01:31 -08:00
parent a8155e7bcc
commit 0d0fe50435
6 changed files with 45 additions and 18 deletions

3
NEWS
View File

@ -33,6 +33,9 @@ which might not be what the user wants. The new option
`--preserve-permissions' and the corresponding `.wgetrc' variable can
be used to revert to the old behavior.
** The new option `--protocol-directories' instructs Wget to also use
the protocol name as a directory component of local file names.
** Many options that previously unconditionally set or unset various
flags are now boolean options that can be invoked as either `--OPTION'
or `--no-OPTION'. Options that required an argument "on" or "off"

View File

@ -1,3 +1,11 @@
2003-12-06 Hrvoje Niksic <hniksic@xemacs.org>
* url.c (url_file_name): Respect the setting of
opt.protocol_directories.
* main.c (main): Only check for ret=='?' when longindex is unset.
(option_data): New option --protocol-directories.
2003-12-06 Hrvoje Niksic <hniksic@xemacs.org>
* ftp.c (getftp): Ditto.

View File

@ -181,6 +181,7 @@ static struct {
{ "postfile", &opt.post_file_name, cmd_file },
{ "preservepermissions", &opt.preserve_perm, cmd_boolean },
{ "progress", &opt.progress_type, cmd_spec_progress },
{ "protocoldirectories", &opt.protocol_directories, cmd_boolean },
{ "proxypasswd", &opt.proxy_passwd, cmd_string },
{ "proxyuser", &opt.proxy_user, cmd_string },
{ "quiet", &opt.quiet, cmd_boolean },

View File

@ -216,6 +216,7 @@ struct cmdline_option option_data[] =
{ "post-file", 0, OPT_VALUE, "postfile", -1 },
{ "preserve-permissions", 0, OPT_BOOLEAN, "preservepermissions", -1 },
{ "progress", 0, OPT_VALUE, "progress", -1 },
{ "protocol-directories", 0, OPT_BOOLEAN, "protocoldirectories", -1 },
{ "proxy", 'Y', OPT_BOOLEAN, "useproxy", -1 },
{ "proxy-passwd", 0, OPT_VALUE, "proxypasswd", -1 },
{ "proxy-user", 0, OPT_VALUE, "proxyuser", -1 },
@ -475,6 +476,8 @@ Directories:\n"),
-x, --force-directories force creation of directories.\n"),
N_("\
-nH, --no-host-directories don't create host directories.\n"),
N_("\
--protocol-directories use protocol name in directories.\n"),
N_("\
-P, --directory-prefix=PREFIX save files to PREFIX/...\n"),
N_("\
@ -671,18 +674,21 @@ main (int argc, char *const *argv)
{
int val;
struct cmdline_option *opt;
if (ret == '?')
{
print_usage ();
printf ("\n");
printf (_("Try `%s --help' for more options.\n"), exec_name);
exit (2);
}
/* If LONGINDEX is unchanged, it means RET is referring a short
option. Look it up in the mapping table. */
option. */
if (longindex == -1)
longindex = optmap[ret - 32];
{
if (ret == '?')
{
print_usage ();
printf ("\n");
printf (_("Try `%s --help' for more options.\n"), exec_name);
exit (2);
}
/* Find the short option character in the mapping. */
longindex = optmap[ret - 32];
}
val = long_options[longindex].val;
/* Use the retrieved value to locate the option in the

View File

@ -53,6 +53,7 @@ struct options
int no_dirstruct; /* Do we hate dirstruct? */
int cut_dirs; /* Number of directory components to cut. */
int add_hostdir; /* Do we add hostname directory? */
int protocol_directories; /* Whether to prepend "http"/"ftp" to dirs. */
int noclobber; /* Disables clobbering of existing
data. */
char *dir_prefix; /* The top of directory tree */

View File

@ -54,7 +54,8 @@ extern int errno;
struct scheme_data
{
char *leading_string;
const char *name;
const char *leading_string;
int default_port;
int enabled;
};
@ -62,14 +63,14 @@ struct scheme_data
/* Supported schemes: */
static struct scheme_data supported_schemes[] =
{
{ "http://", DEFAULT_HTTP_PORT, 1 },
{ "http", "http://", DEFAULT_HTTP_PORT, 1 },
#ifdef HAVE_SSL
{ "https://", DEFAULT_HTTPS_PORT, 1 },
{ "https", "https://", DEFAULT_HTTPS_PORT, 1 },
#endif
{ "ftp://", DEFAULT_FTP_PORT, 1 },
{ "ftp", "ftp://", DEFAULT_FTP_PORT, 1 },
/* SCHEME_INVALID */
{ NULL, -1, 0 }
{ NULL, NULL, -1, 0 }
};
/* Forward declarations: */
@ -1578,6 +1579,12 @@ url_file_name (const struct url *u)
directory structure. */
if (opt.dirstruct)
{
if (opt.protocol_directories)
{
if (fnres.tail)
append_char ('/', &fnres);
append_string (supported_schemes[u->scheme].name, &fnres);
}
if (opt.add_hostdir)
{
if (fnres.tail)
@ -1963,10 +1970,10 @@ url_string (const struct url *url, int hide_password)
char *quoted_user = NULL, *quoted_passwd = NULL;
int scheme_port = supported_schemes[url->scheme].default_port;
char *scheme_str = supported_schemes[url->scheme].leading_string;
const char *scheme_str = supported_schemes[url->scheme].leading_string;
int fplen = full_path_length (url);
int brackets_around_host = 0;
int brackets_around_host;
assert (scheme_str != NULL);
@ -1983,8 +1990,9 @@ url_string (const struct url *url, int hide_password)
}
}
if (strchr (url->host, ':'))
brackets_around_host = 1;
/* Numeric IPv6 addresses can contain ':' and need to be quoted with
brackets. */
brackets_around_host = strchr (url->host, ':') != NULL;
size = (strlen (scheme_str)
+ strlen (url->host)