`--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"
+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.
{ "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 },
{ "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 },
-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_("\
{
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
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 */
struct scheme_data
{
- char *leading_string;
+ const char *name;
+ const char *leading_string;
int default_port;
int enabled;
};
/* 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: */
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)
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);
}
}
- 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)