X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fmain.c;h=4c1a70e2ecee982f919bde0d53220dba920ac404;hb=d905504a0af1f808ead87bf6877dafaf6ff6aef8;hp=c3d51ffa48e72eca7943cff2666efba0ce5e5037;hpb=1b79a494a2e628cd6670a5fcd016044dc37174ee;p=wget diff --git a/src/main.c b/src/main.c index c3d51ffa..4c1a70e2 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,6 @@ /* Command line parsing. - Copyright (C) 1996-2006 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -35,7 +36,7 @@ so, delete this exception statement from your version. */ #endif /* HAVE_UNISTD_H */ #include #include -#ifdef HAVE_NLS +#ifdef ENABLE_NLS # include #endif #include @@ -54,8 +55,7 @@ so, delete this exception statement from your version. */ #include "spider.h" #include "http.h" /* for save_cookies */ -/* On GNU system this will include system-wide getopt.h. */ -#include "getopt.h" +#include #ifndef PATH_SEPARATOR # define PATH_SEPARATOR '/' @@ -71,6 +71,7 @@ static void redirect_output_signal (int); const char *exec_name; +#ifndef TESTING /* Initialize I18N/L10N. That amounts to invoking setlocale, and setting up gettext's message catalog using bindtextdomain and textdomain. Does nothing if NLS is disabled or missing. */ @@ -78,14 +79,14 @@ const char *exec_name; static void i18n_initialize (void) { - /* HAVE_NLS implies existence of functions invoked here. */ -#ifdef HAVE_NLS + /* ENABLE_NLS implies existence of functions invoked here. */ +#ifdef ENABLE_NLS /* Set the current locale. */ setlocale (LC_ALL, ""); /* Set the text message domain. */ bindtextdomain ("wget", LOCALEDIR); textdomain ("wget"); -#endif /* HAVE_NLS */ +#endif /* ENABLE_NLS */ } /* Definition of command-line options. */ @@ -189,6 +190,7 @@ static struct cmdline_option option_data[] = { "level", 'l', OPT_VALUE, "reclevel", -1 }, { "limit-rate", 0, OPT_VALUE, "limitrate", -1 }, { "load-cookies", 0, OPT_VALUE, "loadcookies", -1 }, + { "max-redirect", 0, OPT_VALUE, "maxredirect", -1 }, { "mirror", 'm', OPT_BOOLEAN, "mirror", -1 }, { "no", 'n', OPT__NO, NULL, required_argument }, { "no-clobber", 0, OPT_BOOLEAN, "noclobber", -1 }, @@ -242,6 +244,9 @@ static struct cmdline_option option_data[] = { "version", 'V', OPT_FUNCALL, (void *) print_version, no_argument }, { "wait", 'w', OPT_VALUE, "wait", -1 }, { "waitretry", 0, OPT_VALUE, "waitretry", -1 }, +#ifdef MSDOS + { "wdebug", 0, OPT_BOOLEAN, "wdebug", -1 }, +#endif }; #undef WHEN_DEBUG @@ -384,6 +389,10 @@ Logging and input file:\n"), #ifdef ENABLE_DEBUG N_("\ -d, --debug print lots of debugging information.\n"), +#endif +#ifdef MSDOS + N_("\ + --wdebug print Watt-32 debug output.\n"), #endif N_("\ -q, --quiet quiet (no output).\n"), @@ -496,6 +505,8 @@ HTTP options:\n"), --ignore-length ignore `Content-Length' header field.\n"), N_("\ --header=STRING insert STRING among the headers.\n"), + N_("\ + --max-redirect maximum redirections allowed per page.\n"), N_("\ --proxy-user=USER set USER as proxy username.\n"), N_("\ @@ -665,7 +676,8 @@ print_version (void) fputs (_("\ Copyright (C) 2007 Free Software Foundation, Inc.\n"), stdout); fputs (_("\ -License GPLv3+: GNU GPL version 3 or later \n\ +License GPLv3+: GNU GPL version 3 or later\n\ +.\n\ This is free software: you are free to change and redistribute it.\n\ There is NO WARRANTY, to the extent permitted by law.\n"), stdout); fputs (_("\nOriginally written by Hrvoje Niksic .\n"), @@ -675,7 +687,7 @@ There is NO WARRANTY, to the extent permitted by law.\n"), stdout); exit (0); } -#ifndef TESTING + int main (int argc, char *const *argv) { @@ -695,7 +707,7 @@ main (int argc, char *const *argv) #ifdef WINDOWS /* Drop extension (typically .EXE) from executable filename. */ - windows_main (&argc, (char **) argv, (char **) &exec_name); + windows_main ((char **) &exec_name); #endif /* Set option defaults; read the system wgetrc and ~/.wgetrc. */ @@ -799,9 +811,9 @@ main (int argc, char *const *argv) before passing the value to setoptval. */ bool flag = true; if (optarg) - flag = (*optarg == '1' || TOLOWER (*optarg) == 'y' - || (TOLOWER (optarg[0]) == 'o' - && TOLOWER (optarg[1]) == 'n')); + flag = (*optarg == '1' || c_tolower (*optarg) == 'y' + || (c_tolower (optarg[0]) == 'o' + && c_tolower (optarg[1]) == 'n')); setoptval (opt->type == OPT__PARENT ? "noparent" : "noclobber", flag ? "0" : "1", opt->long_name); break; @@ -820,7 +832,10 @@ main (int argc, char *const *argv) interoption dependency checks. */ if (opt.reclevel == 0) - opt.reclevel = INFINITE_RECURSION; /* see recur.h for commentary on this */ + opt.reclevel = INFINITE_RECURSION; /* see recur.h for commentary */ + + if (opt.spider || opt.delete_after) + opt.no_dirstruct = true; if (opt.page_requisites && !opt.recursive) { @@ -887,8 +902,14 @@ Can't timestamp and not clobber old files at the same time.\n")); exit (1); } +#ifdef MSDOS + if (opt.wdebug) + dbug_init(); + sock_init(); +#else if (opt.background) fork_to_background (); +#endif /* Initialize progress. Have to do this after the options are processed so we know where the log file is. */ @@ -1017,7 +1038,7 @@ Can't timestamp and not clobber old files at the same time.\n")); { logprintf (LOG_NOTQUIET, _("FINISHED --%s--\nDownloaded: %d files, %s in %s (%s)\n"), - time_str (time (NULL)), + datetime_str (time (NULL)), opt.numurls, human_readable (total_downloaded_bytes), secs_to_human_time (total_download_time),