/* 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.
GNU Wget is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
+the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
GNU Wget is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with Wget; if not, write to the Free Software Foundation, Inc.,
-51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+along with Wget. If not, see <http://www.gnu.org/licenses/>.
-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 <config.h>
+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 <stdio.h>
#include <stdlib.h>
#endif /* HAVE_UNISTD_H */
#include <string.h>
#include <signal.h>
-#ifdef HAVE_NLS
+#ifdef ENABLE_NLS
# include <locale.h>
#endif
#include <assert.h>
#include <errno.h>
#include <time.h>
-#include "wget.h"
#include "utils.h"
#include "init.h"
#include "retr.h"
#include "url.h"
#include "progress.h" /* for progress_handle_sigwinch */
#include "convert.h"
+#include "spider.h"
#include "http.h" /* for save_cookies */
-/* On GNU system this will include system-wide getopt.h. */
-#include "getopt.h"
+#include <getopt.h>
#ifndef PATH_SEPARATOR
# define PATH_SEPARATOR '/'
const char *exec_name;
\f
+#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. */
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 */
}
\f
/* Definition of command-line options. */
{ "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 },
{ "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
#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"),
--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_("\
N_("\
--post-file=FILE use the POST method; send contents of FILE.\n"),
N_("\
- --no-content-disposition don't honor Content-Disposition header.\n"),
+ --content-disposition honor the Content-Disposition header when\n\
+ choosing local file names (EXPERIMENTAL).\n"),
"\n",
#ifdef HAVE_SSL
{
printf ("GNU Wget %s\n\n", version_string);
fputs (_("\
-Copyright (C) 2006 Free Software Foundation, Inc.\n"), stdout);
+Copyright (C) 2007 Free Software Foundation, Inc.\n"), stdout);
fputs (_("\
-This program is distributed in the hope that it will be useful,\n\
-but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
-GNU General Public License for more details.\n"), stdout);
+License GPLv3+: GNU GPL version 3 or later\n\
+<http://www.gnu.org/licenses/gpl.html>.\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 <hniksic@xemacs.org>.\n"),
stdout);
- fputs (_("\nCurrently maintained by Mauro Tortonesi <mauro@ferrara.linux.it>.\n"),
+ fputs (_("Currently maintained by Micah Cowan <micah@cowan.name>.\n"),
stdout);
exit (0);
}
\f
-#ifndef TESTING
+
int
-main (int argc, char *const *argv)
+main (int argc, char **argv)
{
char **url, **t;
int i, ret, longindex;
#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. */
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;
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)
{
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. */
int dt;
if ((opt.recursive || opt.page_requisites)
- && (url_scheme (*t) != SCHEME_FTP || opt.use_proxy))
+ && (url_scheme (*t) != SCHEME_FTP || url_uses_proxy (*t)))
{
int old_follow_ftp = opt.follow_ftp;
{
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),