mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
The prefered way is to avoid #ifdef flooding, so take it that way. Introduce iri.c and iri.h for achieving it
This commit is contained in:
parent
1a33947ca0
commit
ed558a83f6
@ -1,3 +1,7 @@
|
|||||||
|
2008-06-14 Xavier Saint <wget@sxav.eu>
|
||||||
|
|
||||||
|
* configure.ac: Add support for IRIs
|
||||||
|
|
||||||
2008-05-29 Micah Cowan <micah@cowan.name>
|
2008-05-29 Micah Cowan <micah@cowan.name>
|
||||||
|
|
||||||
* po/*.po: Updated from TP (the 1.11.3 set).
|
* po/*.po: Updated from TP (the 1.11.3 set).
|
||||||
|
@ -512,6 +512,10 @@ if test "X$iri" != "Xno"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
dnl Needed by src/Makefile.am
|
||||||
|
AM_CONDITIONAL([IRI_IS_ENABLED], [test "X$iri" != "Xno"])
|
||||||
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Create output
|
dnl Create output
|
||||||
dnl
|
dnl
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
2008-06-14 Xavier Saint <wget@sxav.eu>
|
||||||
|
|
||||||
|
* 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 <micah@cowan.name>
|
2008-06-13 Micah Cowan <micah@cowan.name>
|
||||||
|
|
||||||
* build_info.c: ENABLE_NTLM, not HAVE_NTLM.
|
* build_info.c: ENABLE_NTLM, not HAVE_NTLM.
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
# Version: @VERSION@
|
# Version: @VERSION@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
if IRI_IS_ENABLED
|
||||||
|
IRI_OBJ = iri.c
|
||||||
|
endif
|
||||||
|
|
||||||
# The following line is losing on some versions of make!
|
# The following line is losing on some versions of make!
|
||||||
DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\"
|
DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\"
|
||||||
LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBINTL@ @LIBS@
|
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 \
|
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 \
|
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 \
|
recur.c res.c retr.c snprintf.c spider.c url.c \
|
||||||
utils.c \
|
utils.c $(IRI_OBJ) \
|
||||||
connect.h convert.h cookies.h \
|
connect.h convert.h cookies.h \
|
||||||
ftp.h gen-md5.h hash.h host.h html-parse.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 \
|
options.h progress.h ptimer.h recur.h res.h retr.h \
|
||||||
spider.h ssl.h sysdep.h url.h utils.h wget.h
|
spider.h ssl.h sysdep.h url.h utils.h wget.h
|
||||||
nodist_wget_SOURCES = version.c
|
nodist_wget_SOURCES = version.c
|
||||||
|
@ -100,6 +100,13 @@ const char* (compiled_features[]) =
|
|||||||
#else
|
#else
|
||||||
"-gettext",
|
"-gettext",
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_IRI
|
||||||
|
"+iri",
|
||||||
|
#else
|
||||||
|
"-iri",
|
||||||
|
#endif
|
||||||
|
|
||||||
/* sentinel value */
|
/* sentinel value */
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
25
src/http.c
25
src/http.c
@ -49,6 +49,7 @@ as that of the covered work. */
|
|||||||
#include "retr.h"
|
#include "retr.h"
|
||||||
#include "connect.h"
|
#include "connect.h"
|
||||||
#include "netrc.h"
|
#include "netrc.h"
|
||||||
|
#include "iri.h"
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
# include "ssl.h"
|
# include "ssl.h"
|
||||||
#endif
|
#endif
|
||||||
@ -2040,32 +2041,16 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
|
|||||||
char *tmp = strchr (type, ';');
|
char *tmp = strchr (type, ';');
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_IRI
|
/* sXXXav: only needed if IRI support is enabled */
|
||||||
char *tmp2 = tmp + 1;
|
char *tmp2 = tmp + 1;
|
||||||
#endif
|
|
||||||
|
|
||||||
while (tmp > type && c_isspace (tmp[-1]))
|
while (tmp > type && c_isspace (tmp[-1]))
|
||||||
--tmp;
|
--tmp;
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
|
|
||||||
#ifdef ENABLE_IRI
|
/* Try to get remote encoding if needed */
|
||||||
if (opt.enable_iri && *tmp2 != '\0' &&
|
if (opt.enable_iri && !opt.encoding_remote)
|
||||||
(tmp = strstr (tmp2, "charset=")) != NULL)
|
/* xxx = */ parse_charset (tmp2);
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hs->newloc = resp_header_strdup (resp, "Location");
|
hs->newloc = resp_header_strdup (resp, "Location");
|
||||||
|
@ -181,15 +181,11 @@ static const struct {
|
|||||||
{ "inet6only", &opt.ipv6_only, cmd_boolean },
|
{ "inet6only", &opt.ipv6_only, cmd_boolean },
|
||||||
#endif
|
#endif
|
||||||
{ "input", &opt.input_filename, cmd_file },
|
{ "input", &opt.input_filename, cmd_file },
|
||||||
#ifdef ENABLE_IRI
|
|
||||||
{ "iri", &opt.enable_iri, cmd_boolean },
|
{ "iri", &opt.enable_iri, cmd_boolean },
|
||||||
#endif
|
|
||||||
{ "keepsessioncookies", &opt.keep_session_cookies, cmd_boolean },
|
{ "keepsessioncookies", &opt.keep_session_cookies, cmd_boolean },
|
||||||
{ "limitrate", &opt.limit_rate, cmd_bytes },
|
{ "limitrate", &opt.limit_rate, cmd_bytes },
|
||||||
{ "loadcookies", &opt.cookies_input, cmd_file },
|
{ "loadcookies", &opt.cookies_input, cmd_file },
|
||||||
#ifdef ENABLE_IRI
|
|
||||||
{ "locale", &opt.locale, cmd_string },
|
{ "locale", &opt.locale, cmd_string },
|
||||||
#endif
|
|
||||||
{ "logfile", &opt.lfilename, cmd_file },
|
{ "logfile", &opt.lfilename, cmd_file },
|
||||||
{ "login", &opt.ftp_user, cmd_string },/* deprecated*/
|
{ "login", &opt.ftp_user, cmd_string },/* deprecated*/
|
||||||
{ "maxredirect", &opt.max_redirect, cmd_number },
|
{ "maxredirect", &opt.max_redirect, cmd_number },
|
||||||
@ -229,9 +225,7 @@ static const struct {
|
|||||||
{ "referer", &opt.referer, cmd_string },
|
{ "referer", &opt.referer, cmd_string },
|
||||||
{ "reject", &opt.rejects, cmd_vector },
|
{ "reject", &opt.rejects, cmd_vector },
|
||||||
{ "relativeonly", &opt.relative_only, cmd_boolean },
|
{ "relativeonly", &opt.relative_only, cmd_boolean },
|
||||||
#ifdef ENABLE_IRI
|
|
||||||
{ "remoteencoding", &opt.encoding_remote, cmd_string },
|
{ "remoteencoding", &opt.encoding_remote, cmd_string },
|
||||||
#endif
|
|
||||||
{ "removelisting", &opt.remove_listing, cmd_boolean },
|
{ "removelisting", &opt.remove_listing, cmd_boolean },
|
||||||
{ "restrictfilenames", NULL, cmd_spec_restrict_file_names },
|
{ "restrictfilenames", NULL, cmd_spec_restrict_file_names },
|
||||||
{ "retrsymlinks", &opt.retr_symlinks, cmd_boolean },
|
{ "retrsymlinks", &opt.retr_symlinks, cmd_boolean },
|
||||||
|
70
src/iri.c
Normal file
70
src/iri.c
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
43
src/iri.h
Normal file
43
src/iri.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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 */
|
13
src/main.c
13
src/main.c
@ -203,16 +203,12 @@ static struct cmdline_option option_data[] =
|
|||||||
{ "inet6-only", '6', OPT_BOOLEAN, "inet6only", -1 },
|
{ "inet6-only", '6', OPT_BOOLEAN, "inet6only", -1 },
|
||||||
#endif
|
#endif
|
||||||
{ "input-file", 'i', OPT_VALUE, "input", -1 },
|
{ "input-file", 'i', OPT_VALUE, "input", -1 },
|
||||||
#ifdef ENABLE_IRI
|
|
||||||
{ "iri", 0, OPT_BOOLEAN, "iri", -1 },
|
{ "iri", 0, OPT_BOOLEAN, "iri", -1 },
|
||||||
#endif
|
|
||||||
{ "keep-session-cookies", 0, OPT_BOOLEAN, "keepsessioncookies", -1 },
|
{ "keep-session-cookies", 0, OPT_BOOLEAN, "keepsessioncookies", -1 },
|
||||||
{ "level", 'l', OPT_VALUE, "reclevel", -1 },
|
{ "level", 'l', OPT_VALUE, "reclevel", -1 },
|
||||||
{ "limit-rate", 0, OPT_VALUE, "limitrate", -1 },
|
{ "limit-rate", 0, OPT_VALUE, "limitrate", -1 },
|
||||||
{ "load-cookies", 0, OPT_VALUE, "loadcookies", -1 },
|
{ "load-cookies", 0, OPT_VALUE, "loadcookies", -1 },
|
||||||
#ifdef ENABLE_IRI
|
|
||||||
{ "locale", 0, OPT_VALUE, "locale", -1 },
|
{ "locale", 0, OPT_VALUE, "locale", -1 },
|
||||||
#endif
|
|
||||||
{ "max-redirect", 0, OPT_VALUE, "maxredirect", -1 },
|
{ "max-redirect", 0, OPT_VALUE, "maxredirect", -1 },
|
||||||
{ "mirror", 'm', OPT_BOOLEAN, "mirror", -1 },
|
{ "mirror", 'm', OPT_BOOLEAN, "mirror", -1 },
|
||||||
{ "no", 'n', OPT__NO, NULL, required_argument },
|
{ "no", 'n', OPT__NO, NULL, required_argument },
|
||||||
@ -246,9 +242,7 @@ static struct cmdline_option option_data[] =
|
|||||||
{ "referer", 0, OPT_VALUE, "referer", -1 },
|
{ "referer", 0, OPT_VALUE, "referer", -1 },
|
||||||
{ "reject", 'R', OPT_VALUE, "reject", -1 },
|
{ "reject", 'R', OPT_VALUE, "reject", -1 },
|
||||||
{ "relative", 'L', OPT_BOOLEAN, "relativeonly", -1 },
|
{ "relative", 'L', OPT_BOOLEAN, "relativeonly", -1 },
|
||||||
#ifdef ENABLE_IRI
|
|
||||||
{ "remote-encoding", 0, OPT_VALUE, "remoteencoding", -1},
|
{ "remote-encoding", 0, OPT_VALUE, "remoteencoding", -1},
|
||||||
#endif
|
|
||||||
{ "remove-listing", 0, OPT_BOOLEAN, "removelisting", -1 },
|
{ "remove-listing", 0, OPT_BOOLEAN, "removelisting", -1 },
|
||||||
{ "restrict-file-names", 0, OPT_BOOLEAN, "restrictfilenames", -1 },
|
{ "restrict-file-names", 0, OPT_BOOLEAN, "restrictfilenames", -1 },
|
||||||
{ "retr-symlinks", 0, OPT_BOOLEAN, "retrsymlinks", -1 },
|
{ "retr-symlinks", 0, OPT_BOOLEAN, "retrsymlinks", -1 },
|
||||||
@ -1085,6 +1079,13 @@ for details.\n\n"));
|
|||||||
logprintf (LOG_VERBOSE, "Check the locale...\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
|
#endif
|
||||||
|
|
||||||
if (opt.ask_passwd)
|
if (opt.ask_passwd)
|
||||||
|
@ -238,11 +238,9 @@ struct options
|
|||||||
bool auth_without_challenge; /* Issue Basic authentication creds without
|
bool auth_without_challenge; /* Issue Basic authentication creds without
|
||||||
waiting for a challenge. */
|
waiting for a challenge. */
|
||||||
|
|
||||||
#ifdef ENABLE_IRI
|
|
||||||
bool enable_iri;
|
bool enable_iri;
|
||||||
char *encoding_remote;
|
char *encoding_remote;
|
||||||
char *locale;
|
char *locale;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct options opt;
|
extern struct options opt;
|
||||||
|
Loading…
Reference in New Issue
Block a user