mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Implement --config.
This commit is contained in:
parent
b12160ea02
commit
8c7afaf3bb
3
NEWS
3
NEWS
@ -48,6 +48,9 @@ Please send GNU Wget bug reports to <bug-wget@gnu.org>.
|
|||||||
** Use persistent connections with proxies supporting them.
|
** Use persistent connections with proxies supporting them.
|
||||||
|
|
||||||
** Print the total download time as part of the summary for recursive downloads.
|
** Print the total download time as part of the summary for recursive downloads.
|
||||||
|
|
||||||
|
** Now it is possible to specify a different startup configuration file trough
|
||||||
|
the --config option.
|
||||||
|
|
||||||
* Changes in Wget 1.12
|
* Changes in Wget 1.12
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2010-08-08 Reza Snowdon <vivi@mage.me.uk>
|
||||||
|
* wget.texi: Added information about the config option to the
|
||||||
|
'Overview' section and a description of the option in
|
||||||
|
'Logging and Input File Options'.
|
||||||
|
|
||||||
2010-10-26 Giuseppe Scrivano <gscrivano@gnu.org>
|
2010-10-26 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||||
|
|
||||||
* wget.texi (Download Options): Remove unclear statement about the
|
* wget.texi (Download Options): Remove unclear statement about the
|
||||||
|
@ -190,7 +190,9 @@ gauge can be customized to your preferences.
|
|||||||
Most of the features are fully configurable, either through command line
|
Most of the features are fully configurable, either through command line
|
||||||
options, or via the initialization file @file{.wgetrc} (@pxref{Startup
|
options, or via the initialization file @file{.wgetrc} (@pxref{Startup
|
||||||
File}). Wget allows you to define @dfn{global} startup files
|
File}). Wget allows you to define @dfn{global} startup files
|
||||||
(@file{/usr/local/etc/wgetrc} by default) for site settings.
|
(@file{/usr/local/etc/wgetrc} by default) for site settings. You can also
|
||||||
|
specify the location of a startup file with the --config option.
|
||||||
|
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@c man begin FILES
|
@c man begin FILES
|
||||||
@ -524,6 +526,10 @@ presence of a @code{BASE} tag in the @sc{html} input file, with
|
|||||||
For instance, if you specify @samp{http://foo/bar/a.html} for
|
For instance, if you specify @samp{http://foo/bar/a.html} for
|
||||||
@var{URL}, and Wget reads @samp{../baz/b.html} from the input file, it
|
@var{URL}, and Wget reads @samp{../baz/b.html} from the input file, it
|
||||||
would be resolved to @samp{http://foo/baz/b.html}.
|
would be resolved to @samp{http://foo/baz/b.html}.
|
||||||
|
|
||||||
|
@cindex specify config
|
||||||
|
@item --config=@var{FILE}
|
||||||
|
Specify the location of a startup file you wish to use.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node Download Options, Directory Options, Logging and Input File Options, Invoking
|
@node Download Options, Directory Options, Logging and Input File Options, Invoking
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
2010-08-08 Reza Snowdon <vivi@mage.me.uk>
|
||||||
|
|
||||||
|
* main.c (main): inserted 'defaults'.
|
||||||
|
Added additional 'getopt_long' while loop to search and apply a
|
||||||
|
user specified config file before any other options.
|
||||||
|
New variables 'retconf', 'use_userconfig',
|
||||||
|
'confval', 'userrc_ret', 'config_opt'.
|
||||||
|
* init.c: Include stdbool.h.
|
||||||
|
(commands): Added config details.
|
||||||
|
(defaults): Removed static.
|
||||||
|
(wgetrc): Removed static.
|
||||||
|
(initialize): Removed 'defaults ()',
|
||||||
|
changed 'int ok' to 'bool ok'.
|
||||||
|
* options.h: New variable 'choose_config'.
|
||||||
|
* init.h (defaults): exported function.
|
||||||
|
(run_wgetrc): exported function.
|
||||||
|
|
||||||
2010-10-24 Jessica McKellar <jesstess@mit.edu> (tiny change)
|
2010-10-24 Jessica McKellar <jesstess@mit.edu> (tiny change)
|
||||||
|
|
||||||
* main.c (main): Print the total download time as part of the
|
* main.c (main): Print the total download time as part of the
|
||||||
|
12
src/init.c
12
src/init.c
@ -32,6 +32,7 @@ as that of the covered work. */
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -136,6 +137,7 @@ static const struct {
|
|||||||
{ "certificatetype", &opt.cert_type, cmd_cert_type },
|
{ "certificatetype", &opt.cert_type, cmd_cert_type },
|
||||||
{ "checkcertificate", &opt.check_cert, cmd_boolean },
|
{ "checkcertificate", &opt.check_cert, cmd_boolean },
|
||||||
#endif
|
#endif
|
||||||
|
{ "chooseconfig", &opt.choose_config, cmd_file },
|
||||||
{ "connecttimeout", &opt.connect_timeout, cmd_time },
|
{ "connecttimeout", &opt.connect_timeout, cmd_time },
|
||||||
{ "contentdisposition", &opt.content_disposition, cmd_boolean },
|
{ "contentdisposition", &opt.content_disposition, cmd_boolean },
|
||||||
{ "continue", &opt.always_rest, cmd_boolean },
|
{ "continue", &opt.always_rest, cmd_boolean },
|
||||||
@ -291,7 +293,7 @@ command_by_name (const char *cmdname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reset the variables to default values. */
|
/* Reset the variables to default values. */
|
||||||
static void
|
void
|
||||||
defaults (void)
|
defaults (void)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
@ -510,7 +512,7 @@ static bool setval_internal_tilde (int, const char *, const char *);
|
|||||||
/* Initialize variables from a wgetrc file. Returns zero (failure) if
|
/* Initialize variables from a wgetrc file. Returns zero (failure) if
|
||||||
there were errors in the file. */
|
there were errors in the file. */
|
||||||
|
|
||||||
static bool
|
bool
|
||||||
run_wgetrc (const char *file)
|
run_wgetrc (const char *file)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -574,10 +576,7 @@ void
|
|||||||
initialize (void)
|
initialize (void)
|
||||||
{
|
{
|
||||||
char *file, *env_sysrc;
|
char *file, *env_sysrc;
|
||||||
int ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
/* Load the hard-coded defaults. */
|
|
||||||
defaults ();
|
|
||||||
|
|
||||||
/* Run a non-standard system rc file when the according environment
|
/* Run a non-standard system rc file when the according environment
|
||||||
variable has been set. For internal testing purposes only! */
|
variable has been set. For internal testing purposes only! */
|
||||||
@ -1578,6 +1577,7 @@ cleanup (void)
|
|||||||
extern acc_t *netrc_list;
|
extern acc_t *netrc_list;
|
||||||
free_netrc (netrc_list);
|
free_netrc (netrc_list);
|
||||||
}
|
}
|
||||||
|
xfree_null (opt.choose_config);
|
||||||
xfree_null (opt.lfilename);
|
xfree_null (opt.lfilename);
|
||||||
xfree_null (opt.dir_prefix);
|
xfree_null (opt.dir_prefix);
|
||||||
xfree_null (opt.input_filename);
|
xfree_null (opt.input_filename);
|
||||||
|
@ -39,5 +39,7 @@ void run_command (const char *);
|
|||||||
void setoptval (const char *, const char *, const char *);
|
void setoptval (const char *, const char *, const char *);
|
||||||
char *home_dir (void);
|
char *home_dir (void);
|
||||||
void cleanup (void);
|
void cleanup (void);
|
||||||
|
void defaults (void);
|
||||||
|
bool run_wgetrc (const char *file);
|
||||||
|
|
||||||
#endif /* INIT_H */
|
#endif /* INIT_H */
|
||||||
|
43
src/main.c
43
src/main.c
@ -165,6 +165,7 @@ static struct cmdline_option option_data[] =
|
|||||||
{ IF_SSL ("certificate-type"), 0, OPT_VALUE, "certificatetype", -1 },
|
{ IF_SSL ("certificate-type"), 0, OPT_VALUE, "certificatetype", -1 },
|
||||||
{ IF_SSL ("check-certificate"), 0, OPT_BOOLEAN, "checkcertificate", -1 },
|
{ IF_SSL ("check-certificate"), 0, OPT_BOOLEAN, "checkcertificate", -1 },
|
||||||
{ "clobber", 0, OPT__CLOBBER, NULL, optional_argument },
|
{ "clobber", 0, OPT__CLOBBER, NULL, optional_argument },
|
||||||
|
{ "config", 0, OPT_VALUE, "chooseconfig", -1 },
|
||||||
{ "connect-timeout", 0, OPT_VALUE, "connecttimeout", -1 },
|
{ "connect-timeout", 0, OPT_VALUE, "connecttimeout", -1 },
|
||||||
{ "continue", 'c', OPT_BOOLEAN, "continue", -1 },
|
{ "continue", 'c', OPT_BOOLEAN, "continue", -1 },
|
||||||
{ "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 },
|
{ "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 },
|
||||||
@ -441,6 +442,8 @@ Logging and input file:\n"),
|
|||||||
N_("\
|
N_("\
|
||||||
-B, --base=URL resolves HTML input-file links (-i -F)\n\
|
-B, --base=URL resolves HTML input-file links (-i -F)\n\
|
||||||
relative to URL.\n"),
|
relative to URL.\n"),
|
||||||
|
N_("\
|
||||||
|
--config=FILE Specify config file to use.\n"),
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
N_("\
|
N_("\
|
||||||
@ -900,10 +903,46 @@ main (int argc, char **argv)
|
|||||||
windows_main ((char **) &exec_name);
|
windows_main ((char **) &exec_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set option defaults; read the system wgetrc and ~/.wgetrc. */
|
/* Load the hard-coded defaults. */
|
||||||
initialize ();
|
defaults ();
|
||||||
|
|
||||||
init_switches ();
|
init_switches ();
|
||||||
|
|
||||||
|
/* This seperate getopt_long is needed to find the user config
|
||||||
|
and parse it before the other user options. */
|
||||||
|
longindex = -1;
|
||||||
|
int retconf;
|
||||||
|
bool use_userconfig = false;
|
||||||
|
|
||||||
|
while ((retconf = getopt_long (argc, argv,
|
||||||
|
short_options, long_options, &longindex)) != -1)
|
||||||
|
{
|
||||||
|
int confval;
|
||||||
|
bool userrc_ret = true;
|
||||||
|
struct cmdline_option *config_opt;
|
||||||
|
confval = long_options[longindex].val;
|
||||||
|
config_opt = &option_data[confval & ~BOOLEAN_NEG_MARKER];
|
||||||
|
if (strcmp (config_opt->long_name, "config") == 0)
|
||||||
|
{
|
||||||
|
userrc_ret &= run_wgetrc (optarg);
|
||||||
|
use_userconfig = true;
|
||||||
|
}
|
||||||
|
if (!userrc_ret)
|
||||||
|
{
|
||||||
|
printf ("Exiting due to error in %s\n", optarg);
|
||||||
|
exit (2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the user did not specify a config, read the system wgetrc and ~/.wgetrc. */
|
||||||
|
if (use_userconfig == false)
|
||||||
|
initialize ();
|
||||||
|
|
||||||
|
opterr = 0;
|
||||||
|
optind = 0;
|
||||||
|
|
||||||
longindex = -1;
|
longindex = -1;
|
||||||
while ((ret = getopt_long (argc, argv,
|
while ((ret = getopt_long (argc, argv,
|
||||||
short_options, long_options, &longindex)) != -1)
|
short_options, long_options, &longindex)) != -1)
|
||||||
|
@ -58,6 +58,7 @@ struct options
|
|||||||
char *dir_prefix; /* The top of directory tree */
|
char *dir_prefix; /* The top of directory tree */
|
||||||
char *lfilename; /* Log filename */
|
char *lfilename; /* Log filename */
|
||||||
char *input_filename; /* Input filename */
|
char *input_filename; /* Input filename */
|
||||||
|
char *choose_config; /* Specified config file */
|
||||||
bool force_html; /* Is the input file an HTML file? */
|
bool force_html; /* Is the input file an HTML file? */
|
||||||
|
|
||||||
char *default_page; /* Alternative default page (index file) */
|
char *default_page; /* Alternative default page (index file) */
|
||||||
|
Loading…
Reference in New Issue
Block a user