X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Finit.c;h=cf13eacd5521868201900d516f1011f3ac81ec66;hb=5e7f976fa1be6af7b5698972289107747fe37d0e;hp=8000d73cc50919abd7617f021bc49e1d276ef971;hpb=b7c6c35be5930695cc64ef2d54d6f421f8511553;p=wget diff --git a/src/init.c b/src/init.c index 8000d73c..cf13eacd 100644 --- a/src/init.c +++ b/src/init.c @@ -1,6 +1,6 @@ /* Reading/parsing the initialization file. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -17,17 +17,18 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Wget. If not, see . -In addition, as a special exception, the Free Software Foundation -gives permission to link the code of its release of Wget with the -OpenSSL project's "OpenSSL" library (or with modified versions of it -that use the same license as the "OpenSSL" library), and distribute -the linked executables. You must obey the GNU General Public License -in all respects for all of the code used other than "OpenSSL". If you -modify this file, you may extend this exception to your version of the -file, but you are not obligated to do so. If you do not wish to do -so, delete this exception statement from your version. */ +Additional permission under GNU GPL version 3 section 7 -#include +If you modify this program, or any covered work, by linking or +combining it with the OpenSSL project's OpenSSL library (or a +modified version of that library), containing parts covered by the +terms of the OpenSSL or SSLeay licenses, the Free Software Foundation +grants you additional permission to convey the resulting work. +Corresponding Source for a non-source form of such a combination +shall include the source code for the parts of OpenSSL used as well +as that of the covered work. */ + +#include "wget.h" #include #include @@ -42,7 +43,6 @@ so, delete this exception statement from your version. */ #endif #include -#include "wget.h" #include "utils.h" #include "init.h" #include "host.h" @@ -113,6 +113,8 @@ static const struct { { "accept", &opt.accepts, cmd_vector }, { "addhostdir", &opt.add_hostdir, cmd_boolean }, { "alwaysrest", &opt.always_rest, cmd_boolean }, /* deprecated */ + { "authnochallenge", &opt.auth_without_challenge, + cmd_boolean }, { "background", &opt.background, cmd_boolean }, { "backupconverted", &opt.backup_converted, cmd_boolean }, { "backups", &opt.backups, cmd_number }, @@ -367,19 +369,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)) @@ -390,12 +387,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 @@ -536,7 +561,7 @@ initialize (void) xfree (file); return; } - + /* Remove dashes and underscores from S, modifying S in the process. */ @@ -1528,6 +1553,29 @@ cleanup (void) #ifdef TESTING +const char * +test_commands_sorted() +{ + int prev_idx = 0, next_idx = 1; + int command_count = countof (commands) - 1; + int cmp = 0; + while (next_idx <= command_count) + { + cmp = strcasecmp (commands[prev_idx].name, commands[next_idx].name); + if (cmp > 0) + { + mu_assert ("FAILED", false); + break; + } + else + { + prev_idx ++; + next_idx ++; + } + } + return NULL; +} + const char * test_cmd_spec_restrict_file_names() {