X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Furl.c;h=3f4b89920fd2f5d2b37956f3c6f05ba0086051af;hp=f5d621f9064ca4f4d68b8f3117361db9936e1d08;hb=dc9abe478f8175d342f190993d0dc61891a7da8e;hpb=2e2ac6ad2fc90eaf46ae5fee0bc4f61dd97b4284 diff --git a/src/url.c b/src/url.c index f5d621f9..3f4b8992 100644 --- a/src/url.c +++ b/src/url.c @@ -619,7 +619,7 @@ static const char *parse_errors[] = { #define PE_NO_ERROR 0 N_("No error"), #define PE_UNSUPPORTED_SCHEME 1 - N_("Unsupported scheme"), + N_("Unsupported scheme %s"), #define PE_INVALID_HOST_NAME 2 N_("Invalid host name"), #define PE_BAD_PORT_NUMBER 3 @@ -886,11 +886,29 @@ url_parse (const char *url, int *error) /* Return the error message string from ERROR_CODE, which should have been retrieved from url_parse. The error message is translated. */ -const char * -url_error (int error_code) +char * +url_error (const char *url, int error_code) { assert (error_code >= 0 && ((size_t) error_code) < countof (parse_errors)); - return _(parse_errors[error_code]); + + if (error_code == PE_UNSUPPORTED_SCHEME) + { + char *error, *p; + char *scheme = xstrdup (url); + assert (url_has_scheme (url)); + + if ((p = strchr (scheme, ':'))) + *p = '\0'; + if (!strcasecmp (scheme, "https")) + asprintf (&error, _("HTTPS support not compiled in")); + else + asprintf (&error, _(parse_errors[error_code]), quote (scheme)); + xfree (scheme); + + return error; + } + else + return xstrdup (_(parse_errors[error_code])); } /* Split PATH into DIR and FILE. PATH comes from the URL and is @@ -1430,11 +1448,17 @@ url_file_name (const struct url *u) const char *u_file, *u_query; char *fname, *unique; + char *index_filename = "index.html"; /* The default index file is index.html */ fnres.base = NULL; fnres.size = 0; fnres.tail = 0; + /* If an alternative index file was defined, change index_filename */ + if (opt.default_page) + index_filename = opt.default_page; + + /* Start with the directory prefix, if specified. */ if (opt.dir_prefix) append_string (opt.dir_prefix, &fnres); @@ -1476,7 +1500,7 @@ url_file_name (const struct url *u) /* Add the file name. */ if (fnres.tail) append_char ('/', &fnres); - u_file = *u->file ? u->file : "index.html"; + u_file = *u->file ? u->file : index_filename; append_uri_pathel (u_file, u_file + strlen (u_file), false, &fnres); /* Append "?query" to the file name. */