X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Finit.c;h=a774061b413a4f1ecd1f98086b2ac4e14ae36238;hb=123f5c39669abc055987d69a311785c861494c87;hp=97976553164c2bb6827c79e430a3ec417f1b1973;hpb=7c46e0f2c1ccc6802765bfb45e192d8f16a0d1e5;p=wget diff --git a/src/init.c b/src/init.c index 97976553..a774061b 100644 --- a/src/init.c +++ b/src/init.c @@ -140,6 +140,7 @@ static const struct { #ifdef ENABLE_DEBUG { "debug", &opt.debug, cmd_boolean }, #endif + { "defaultpage", &opt.default_page, cmd_string}, { "deleteafter", &opt.delete_after, cmd_boolean }, { "dirprefix", &opt.dir_prefix, cmd_directory }, { "dirstruct", NULL, cmd_spec_dirstruct }, @@ -371,19 +372,14 @@ home_dir (void) return home ? xstrdup (home) : NULL; } -/* Return the path to the user's .wgetrc. This is either the value of - `WGETRC' environment variable, or `$HOME/.wgetrc'. - +/* Check the 'WGETRC' environment variable and return the file name + if 'WGETRC' is set and is a valid file. If the `WGETRC' variable exists but the file does not exist, the function will exit(). */ -static char * -wgetrc_file_name (void) +char * +wgetrc_env_file_name (void) { - char *env, *home; - char *file = NULL; - - /* Try the environment. */ - env = getenv ("WGETRC"); + char *env = getenv ("WGETRC"); if (env && *env) { if (!file_exists_p (env)) @@ -394,12 +390,40 @@ wgetrc_file_name (void) } return xstrdup (env); } - - /* If that failed, try $HOME/.wgetrc. */ - home = home_dir (); + return NULL; +} +/* Check for the existance of '$HOME/.wgetrc' and return it's path + if it exists and is set. */ +char * +wgetrc_user_file_name (void) +{ + char *home = home_dir(); + char *file = NULL; if (home) file = aprintf ("%s/.wgetrc", home); xfree_null (home); + if (!file) + return NULL; + if (!file_exists_p (file)) + { + xfree (file); + return NULL; + } + return file; +} +/* Return the path to the user's .wgetrc. This is either the value of + `WGETRC' environment variable, or `$HOME/.wgetrc'. + + Additionally, for windows, look in the directory where wget.exe + resides. */ +char * +wgetrc_file_name (void) +{ + char *file = wgetrc_env_file_name (); + if (file && *file) + return file; + + file = wgetrc_user_file_name (); #ifdef WINDOWS /* Under Windows, if we still haven't found .wgetrc, look for the file @@ -540,7 +564,7 @@ initialize (void) xfree (file); return; } - + /* Remove dashes and underscores from S, modifying S in the process. */ @@ -631,7 +655,7 @@ parse_line (const char *line, char **com, char **val, int *comind) static bool setval_internal (int comind, const char *com, const char *val) { - assert (0 <= comind && comind < countof (commands)); + assert (0 <= comind && ((size_t) comind) < countof (commands)); DEBUGP (("Setting %s (%s) to %s\n", com, commands[comind].name, val)); return commands[comind].action (com, val, commands[comind].place); } @@ -1525,6 +1549,8 @@ cleanup (void) xfree_null (opt.cookies_output); xfree_null (opt.user); xfree_null (opt.passwd); + xfree_null (opt.base_href); + #endif /* DEBUG_MALLOC */ }