Add option --metalink-file. Add a few interoption availability checks for --metalink-file.

This commit is contained in:
Ilim Ugur 2012-08-12 23:21:02 +03:00
parent 768202bf88
commit 54e5b5d373
4 changed files with 34 additions and 7 deletions

View File

@ -203,6 +203,9 @@ static const struct {
{ "logfile", &opt.lfilename, cmd_file },
{ "login", &opt.ftp_user, cmd_string },/* deprecated*/
{ "maxredirect", &opt.max_redirect, cmd_number },
#ifdef ENABLE_METALINK
{ "metalink", &opt.metalink_file, cmd_file },
#endif
{ "mirror", NULL, cmd_spec_mirror },
{ "netrc", &opt.netrc, cmd_boolean },
{ "noclobber", &opt.noclobber, cmd_boolean },

View File

@ -233,6 +233,9 @@ static struct cmdline_option option_data[] =
{ "load-cookies", 0, OPT_VALUE, "loadcookies", -1 },
{ "local-encoding", 0, OPT_VALUE, "localencoding", -1 },
{ "max-redirect", 0, OPT_VALUE, "maxredirect", -1 },
#ifdef ENABLE_METALINK
{ "metalink-file", 0, OPT_VALUE, "metalink", -1 },
#endif
{ "mirror", 'm', OPT_BOOLEAN, "mirror", -1 },
{ "no", 'n', OPT__NO, NULL, required_argument },
{ "no-clobber", 0, OPT_BOOLEAN, "noclobber", -1 },
@ -538,10 +541,6 @@ Download:\n"),
N_("\
--unlink remove file before clobber.\n"),
"\n",
#ifdef ENABLE_METALINK
N_("\
--verify specify hash type to verify the downloaded files. (Works only with metalink downloads for now)\n"),
#endif
N_("\
Directories:\n"),
N_("\
@ -1335,6 +1334,29 @@ outputting to a regular file.\n"));
}
}
#ifdef ENABLE_METALINK
/* TODO: Add all the options that causes undefined/harmful results when used
with option --metalink-file. */
if(opt.metalink_file)
{
if(opt.output_document)
{
fprintf (stderr, _("-O can not used with --metalink-file.\n"));
exit(1);
}
if(opt.base_href)
{
fprintf (stderr, _("--base can not used with --metalink-file.\n"));
exit(1);
}
if(opt.force_html)
{
fprintf (stderr, _("--force-html can not used with --metalink-file.\n"));
exit(1);
}
}
#endif
#ifdef __VMS
/* Set global ODS5 flag according to the specified destination (if
any), otherwise according to the current default device.

View File

@ -37,6 +37,7 @@ struct options
int ntry; /* Number of tries per URL */
#ifdef ENABLE_METALINK
int n_retries; /* Number of tries per file */
char *metalink_file; /* Metalink filename */
#endif
bool retry_connrefused; /* Treat CONNREFUSED as non-fatal. */
bool background; /* Whether we should work in background. */

View File

@ -1014,9 +1014,7 @@ retrieve_from_file (const char *file, bool html, int *count)
input_file = (char *) file;
#ifdef ENABLE_METALINK
metalink_t *metalink;
if(metalink = metalink_context(input_file))
if(opt.metalink_file)
{
/*GSoC wget*/
char *file_name, **files;
@ -1027,11 +1025,14 @@ retrieve_from_file (const char *file, bool html, int *count)
pthread_t thread;
sem_t retr_sem;
uerr_t status;
metalink_t *metalink;
metalink_file_t* file;
metalink_resource_t* resource;
struct s_thread_ctx *thread_ctx;
struct range *ranges;
metalink = metalink_context(input_file);
thread_ctx = malloc (N_THREADS * (sizeof *thread_ctx));
ranges = malloc (N_THREADS * (sizeof *ranges));
files = malloc (N_THREADS * (sizeof *files));