diff --git a/ChangeLog b/ChangeLog index 407ce64c..8177dc97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-06-14 Xavier Saint + + * configure.ac: Add support for IRIs + 2008-05-29 Micah Cowan * po/*.po: Updated from TP (the 1.11.3 set). diff --git a/configure.ac b/configure.ac index 8100f48b..44f397b9 100644 --- a/configure.ac +++ b/configure.ac @@ -512,6 +512,10 @@ if test "X$iri" != "Xno"; then fi +dnl Needed by src/Makefile.am +AM_CONDITIONAL([IRI_IS_ENABLED], [test "X$iri" != "Xno"]) + + dnl dnl Create output dnl diff --git a/src/ChangeLog b/src/ChangeLog index 9af9267b..ac27e15a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2008-06-14 Xavier Saint + + * iri.c, iri.h : New files. + + * Makefile.am : Add files iri.h and conditional iri.c. + + * build_info.c : Add compiled feature "iri". + + * http.c : include iri.h and parse charset from Content-Type + header. + + * init.c, main.c, options.h : if an options isn't supported + at compiled time, don't get rid off it and show a dummy + message instead if they are used. + 2008-06-13 Micah Cowan * build_info.c: ENABLE_NTLM, not HAVE_NTLM. diff --git a/src/Makefile.am b/src/Makefile.am index c8485cfd..379a9b8c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,10 @@ # Version: @VERSION@ # +if IRI_IS_ENABLED +IRI_OBJ = iri.c +endif + # The following line is losing on some versions of make! DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\" LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBINTL@ @LIBS@ @@ -39,10 +43,10 @@ wget_SOURCES = build_info.c cmpt.c connect.c convert.c cookies.c ftp.c \ ftp-basic.c ftp-ls.c hash.c host.c html-parse.c html-url.c \ http.c init.c log.c main.c netrc.c progress.c ptimer.c \ recur.c res.c retr.c snprintf.c spider.c url.c \ - utils.c \ + utils.c $(IRI_OBJ) \ connect.h convert.h cookies.h \ ftp.h gen-md5.h hash.h host.h html-parse.h \ - http.h http-ntlm.h init.h log.h mswindows.h netrc.h \ + http.h http-ntlm.h init.h iri.h log.h mswindows.h netrc.h \ options.h progress.h ptimer.h recur.h res.h retr.h \ spider.h ssl.h sysdep.h url.h utils.h wget.h nodist_wget_SOURCES = version.c diff --git a/src/build_info.c b/src/build_info.c index 1ac682a7..129bf726 100644 --- a/src/build_info.c +++ b/src/build_info.c @@ -100,6 +100,13 @@ const char* (compiled_features[]) = #else "-gettext", #endif + +#ifdef ENABLE_IRI + "+iri", +#else + "-iri", +#endif + /* sentinel value */ NULL }; diff --git a/src/http.c b/src/http.c index 543165fd..741ed2c0 100644 --- a/src/http.c +++ b/src/http.c @@ -49,6 +49,7 @@ as that of the covered work. */ #include "retr.h" #include "connect.h" #include "netrc.h" +#include "iri.h" #ifdef HAVE_SSL # include "ssl.h" #endif @@ -2040,32 +2041,16 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); char *tmp = strchr (type, ';'); if (tmp) { -#ifdef ENABLE_IRI + /* sXXXav: only needed if IRI support is enabled */ char *tmp2 = tmp + 1; -#endif while (tmp > type && c_isspace (tmp[-1])) --tmp; *tmp = '\0'; -#ifdef ENABLE_IRI - if (opt.enable_iri && *tmp2 != '\0' && - (tmp = strstr (tmp2, "charset=")) != NULL) - { - tmp += 8; - tmp2 = tmp; - - while (*tmp2 && !c_isspace (*tmp2)) - tmp2++; - - if (tmp2 > tmp) - { - *tmp2 = '\0'; - /* sXXXav : check given charset */ - logprintf (LOG_VERBOSE, "HTTP charset: `%s'\n", tmp); - } - } -#endif + /* Try to get remote encoding if needed */ + if (opt.enable_iri && !opt.encoding_remote) + /* xxx = */ parse_charset (tmp2); } } hs->newloc = resp_header_strdup (resp, "Location"); diff --git a/src/init.c b/src/init.c index 167c84fe..a7a4ee01 100644 --- a/src/init.c +++ b/src/init.c @@ -181,15 +181,11 @@ static const struct { { "inet6only", &opt.ipv6_only, cmd_boolean }, #endif { "input", &opt.input_filename, cmd_file }, -#ifdef ENABLE_IRI { "iri", &opt.enable_iri, cmd_boolean }, -#endif { "keepsessioncookies", &opt.keep_session_cookies, cmd_boolean }, { "limitrate", &opt.limit_rate, cmd_bytes }, { "loadcookies", &opt.cookies_input, cmd_file }, -#ifdef ENABLE_IRI { "locale", &opt.locale, cmd_string }, -#endif { "logfile", &opt.lfilename, cmd_file }, { "login", &opt.ftp_user, cmd_string },/* deprecated*/ { "maxredirect", &opt.max_redirect, cmd_number }, @@ -229,9 +225,7 @@ static const struct { { "referer", &opt.referer, cmd_string }, { "reject", &opt.rejects, cmd_vector }, { "relativeonly", &opt.relative_only, cmd_boolean }, -#ifdef ENABLE_IRI { "remoteencoding", &opt.encoding_remote, cmd_string }, -#endif { "removelisting", &opt.remove_listing, cmd_boolean }, { "restrictfilenames", NULL, cmd_spec_restrict_file_names }, { "retrsymlinks", &opt.retr_symlinks, cmd_boolean }, diff --git a/src/iri.c b/src/iri.c new file mode 100644 index 00000000..e4f4622b --- /dev/null +++ b/src/iri.c @@ -0,0 +1,70 @@ +/* IRI related functions. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008 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 3 of the License, or (at +your option) any later version. + +GNU Wget is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . + +Additional permission under GNU GPL version 3 section 7 + +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 +#include +#include + +#include "utils.h" +#include "iri.h" + + +/* Given a string containing "charset=XXX", return the encoding if found, + or NULL otherwise */ +char * +parse_charset (char *str) +{ + char *charset; + + if (!str || !*str) + return NULL; + + str = strcasestr (str, "charset="); + if (!str) + return NULL; + + str += 8; + charset = str; + + /* sXXXav: which chars should be banned ??? */ + while (*charset && !c_isspace (*charset)) + charset++; + + /* sXXXav: could strdupdelim return NULL ? */ + charset = strdupdelim (str, charset); + logprintf (LOG_VERBOSE, "parse_charset: %s\n", quote (charset)); + + return charset; +} + + diff --git a/src/iri.h b/src/iri.h new file mode 100644 index 00000000..d135e868 --- /dev/null +++ b/src/iri.h @@ -0,0 +1,43 @@ +/* Internationalization related declarations. + Copyright (C) 2000, 2007, 2008 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 3 of the License, or +(at your option) any later version. + +GNU Wget is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . + +Additional permission under GNU GPL version 3 section 7 + +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. */ + +#ifndef IRI_H +#define IRI_H + +#ifdef ENABLE_IRI + +char *parse_charset (char *str); + + +#else /* ENABLE_IRI */ + +#define parse_charset(str) /* no-op */ + +#endif /* ENABLE_IRI */ +#endif /* IRI_H */ diff --git a/src/main.c b/src/main.c index 9b449438..8002c1be 100644 --- a/src/main.c +++ b/src/main.c @@ -203,16 +203,12 @@ static struct cmdline_option option_data[] = { "inet6-only", '6', OPT_BOOLEAN, "inet6only", -1 }, #endif { "input-file", 'i', OPT_VALUE, "input", -1 }, -#ifdef ENABLE_IRI { "iri", 0, OPT_BOOLEAN, "iri", -1 }, -#endif { "keep-session-cookies", 0, OPT_BOOLEAN, "keepsessioncookies", -1 }, { "level", 'l', OPT_VALUE, "reclevel", -1 }, { "limit-rate", 0, OPT_VALUE, "limitrate", -1 }, { "load-cookies", 0, OPT_VALUE, "loadcookies", -1 }, -#ifdef ENABLE_IRI { "locale", 0, OPT_VALUE, "locale", -1 }, -#endif { "max-redirect", 0, OPT_VALUE, "maxredirect", -1 }, { "mirror", 'm', OPT_BOOLEAN, "mirror", -1 }, { "no", 'n', OPT__NO, NULL, required_argument }, @@ -246,9 +242,7 @@ static struct cmdline_option option_data[] = { "referer", 0, OPT_VALUE, "referer", -1 }, { "reject", 'R', OPT_VALUE, "reject", -1 }, { "relative", 'L', OPT_BOOLEAN, "relativeonly", -1 }, -#ifdef ENABLE_IRI { "remote-encoding", 0, OPT_VALUE, "remoteencoding", -1}, -#endif { "remove-listing", 0, OPT_BOOLEAN, "removelisting", -1 }, { "restrict-file-names", 0, OPT_BOOLEAN, "restrictfilenames", -1 }, { "retr-symlinks", 0, OPT_BOOLEAN, "retrsymlinks", -1 }, @@ -1085,6 +1079,13 @@ for details.\n\n")); logprintf (LOG_VERBOSE, "Check the locale...\n"); } } +#else + if (opt.enable_iri || opt.locale || opt.encoding_remote) + { + /* sXXXav : be more specific... */ + printf(_("This version does not have support for IRIs\n")); + exit(1); + } #endif if (opt.ask_passwd) diff --git a/src/options.h b/src/options.h index 2927a37c..723f80a1 100644 --- a/src/options.h +++ b/src/options.h @@ -238,11 +238,9 @@ struct options bool auth_without_challenge; /* Issue Basic authentication creds without waiting for a challenge. */ -#ifdef ENABLE_IRI bool enable_iri; char *encoding_remote; char *locale; -#endif }; extern struct options opt;