summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am14
-rw-r--r--src/Makefile.in240
-rw-r--r--src/config.h.in247
-rw-r--r--src/connect.c25
-rw-r--r--src/cookies.c72
-rw-r--r--src/css-url.c7
-rw-r--r--src/css-url.h1
-rw-r--r--src/css.c226
-rw-r--r--src/css_.c226
-rw-r--r--src/ftp-ls.c7
-rw-r--r--src/ftp.c80
-rw-r--r--src/gnutls.c12
-rw-r--r--src/hash.c6
-rw-r--r--src/host.c10
-rw-r--r--src/hsts.c29
-rw-r--r--src/html-parse.c8
-rw-r--r--src/html-url.c8
-rw-r--r--src/http-ntlm.c6
-rw-r--r--src/http.c383
-rw-r--r--src/http.h2
-rw-r--r--src/init.c59
-rw-r--r--src/iri.c125
-rw-r--r--src/iri.h7
-rw-r--r--src/log.c125
-rw-r--r--src/log.h1
-rw-r--r--src/main.c161
-rw-r--r--src/metalink.c919
-rw-r--r--src/metalink.h15
-rw-r--r--src/mswindows.c5
-rw-r--r--src/netrc.c6
-rw-r--r--src/openssl.c8
-rw-r--r--src/options.h9
-rw-r--r--src/progress.c5
-rw-r--r--src/recur.c26
-rw-r--r--src/retr.c28
-rw-r--r--src/sysdep.h137
-rw-r--r--src/url.c26
-rw-r--r--src/url.h5
-rw-r--r--src/utils.c69
-rw-r--r--src/utils.h4
-rw-r--r--src/wget.h3
-rw-r--r--src/xattr.c79
-rw-r--r--src/xattr.h45
43 files changed, 2570 insertions, 906 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 050f58e..8a134ff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,9 +39,12 @@ if METALINK_IS_ENABLED
METALINK_OBJ = metalink.c
endif
+if WITH_XATTR
+XATTR_OBJ = xattr.c
+endif
+
# The following line is losing on some versions of make!
DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\"
-LIBS = @LIBICONV@ @LIBINTL@ @LIBS@ $(LIB_CLOCK_GETTIME)
EXTRA_DIST = css.l css.c css_.c build_info.c.in
@@ -50,17 +53,20 @@ wget_SOURCES = connect.c convert.c cookies.c ftp.c \
css_.c css-url.c \
ftp-basic.c ftp-ls.c hash.c host.c hsts.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 spider.c url.c warc.c \
+ recur.c res.c retr.c spider.c url.c warc.c $(XATTR_OBJ) \
utils.c exits.c build_info.c $(IRI_OBJ) $(METALINK_OBJ) \
css-url.h css-tokens.h connect.h convert.h cookies.h \
ftp.h hash.h host.h hsts.h html-parse.h html-url.h \
http.h http-ntlm.h init.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 warc.h utils.h wget.h iri.h \
- exits.h version.h metalink.h
+ exits.h version.h metalink.h xattr.h
nodist_wget_SOURCES = version.c
EXTRA_wget_SOURCES = iri.c
-LDADD = $(LIBOBJS) ../lib/libgnu.a
+LDADD = $(LIBOBJS) ../lib/libgnu.a $(GETADDRINFO_LIB) $(HOSTENT_LIB)\
+ $(INET_NTOP_LIB) $(LIBSOCKET) $(LIB_CLOCK_GETTIME) $(LIB_CRYPTO)\
+ $(LIB_NANOSLEEP) $(LIB_POSIX_SPAWN) $(LIB_SELECT) $(LTLIBICONV) $(LTLIBINTL)\
+ $(LTLIBTHREAD) $(LTLIBUNISTRING) $(SERVENT_LIB)
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
diff --git a/src/Makefile.in b/src/Makefile.in
index 887ca8e..84f45d1 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -127,9 +127,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
$(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \
$(top_srcdir)/m4/arpa_inet_h.m4 \
$(top_srcdir)/m4/asm-underscore.m4 $(top_srcdir)/m4/base32.m4 \
- $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/clock_time.m4 \
- $(top_srcdir)/m4/close.m4 $(top_srcdir)/m4/codeset.m4 \
- $(top_srcdir)/m4/configmake.m4 $(top_srcdir)/m4/dirname.m4 \
+ $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/builtin-expect.m4 \
+ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \
+ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/configmake.m4 \
+ $(top_srcdir)/m4/dirname.m4 \
$(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
$(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \
$(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \
@@ -137,53 +138,65 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
$(top_srcdir)/m4/extern-inline.m4 \
$(top_srcdir)/m4/fatal-signal.m4 $(top_srcdir)/m4/fcntl-o.m4 \
$(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \
- $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/flock.m4 \
- $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fseek.m4 \
+ $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \
+ $(top_srcdir)/m4/flock.m4 $(top_srcdir)/m4/fnmatch.m4 \
+ $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fseek.m4 \
$(top_srcdir)/m4/fseeko.m4 $(top_srcdir)/m4/fstat.m4 \
$(top_srcdir)/m4/ftell.m4 $(top_srcdir)/m4/ftello.m4 \
$(top_srcdir)/m4/futimens.m4 $(top_srcdir)/m4/getaddrinfo.m4 \
$(top_srcdir)/m4/getdelim.m4 $(top_srcdir)/m4/getdtablesize.m4 \
$(top_srcdir)/m4/getline.m4 $(top_srcdir)/m4/getopt.m4 \
- $(top_srcdir)/m4/getpass.m4 $(top_srcdir)/m4/gettext.m4 \
- $(top_srcdir)/m4/gettime.m4 $(top_srcdir)/m4/gettimeofday.m4 \
+ $(top_srcdir)/m4/getpass.m4 $(top_srcdir)/m4/getprogname.m4 \
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gettime.m4 \
+ $(top_srcdir)/m4/gettimeofday.m4 \
$(top_srcdir)/m4/gl-openssl.m4 $(top_srcdir)/m4/glibc21.m4 \
$(top_srcdir)/m4/gnulib-common.m4 \
- $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/hostent.m4 \
+ $(top_srcdir)/m4/gnulib-comp.m4 \
+ $(top_srcdir)/m4/hard-locale.m4 $(top_srcdir)/m4/hostent.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/iconv_h.m4 \
$(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inet_ntop.m4 \
- $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \
- $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/ioctl.m4 \
- $(top_srcdir)/m4/iswblank.m4 $(top_srcdir)/m4/langinfo_h.m4 \
- $(top_srcdir)/m4/largefile.m4 $(top_srcdir)/m4/lib-ld.m4 \
- $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/inline.m4 $(top_srcdir)/m4/intlmacosx.m4 \
+ $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes-pri.m4 \
+ $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \
+ $(top_srcdir)/m4/ioctl.m4 $(top_srcdir)/m4/iswblank.m4 \
+ $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/largefile.m4 \
+ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
+ $(top_srcdir)/m4/lib-prefix.m4 \
$(top_srcdir)/m4/libunistring-base.m4 \
- $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \
- $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \
- $(top_srcdir)/m4/locale_h.m4 $(top_srcdir)/m4/localeconv.m4 \
- $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \
- $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \
- $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/mbchar.m4 \
- $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrtowc.m4 \
- $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbsrtowcs.m4 \
- $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbtowc.m4 \
+ $(top_srcdir)/m4/libunistring-optional.m4 \
+ $(top_srcdir)/m4/libunistring.m4 $(top_srcdir)/m4/limits-h.m4 \
+ $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \
+ $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \
+ $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \
+ $(top_srcdir)/m4/localeconv.m4 $(top_srcdir)/m4/lock.m4 \
+ $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lseek.m4 \
+ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \
+ $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \
+ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \
+ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \
+ $(top_srcdir)/m4/mbtowc.m4 $(top_srcdir)/m4/md4.m4 \
$(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memchr.m4 \
- $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/mkdir.m4 \
- $(top_srcdir)/m4/mkostemp.m4 $(top_srcdir)/m4/mkstemp.m4 \
- $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \
- $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/msvc-inval.m4 \
+ $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/minmax.m4 \
+ $(top_srcdir)/m4/mkdir.m4 $(top_srcdir)/m4/mkostemp.m4 \
+ $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \
+ $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \
+ $(top_srcdir)/m4/msvc-inval.m4 \
$(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \
- $(top_srcdir)/m4/netdb_h.m4 $(top_srcdir)/m4/netinet_in_h.m4 \
+ $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \
+ $(top_srcdir)/m4/netinet_in_h.m4 \
$(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \
$(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/pathmax.m4 \
- $(top_srcdir)/m4/pipe2.m4 $(top_srcdir)/m4/po.m4 \
- $(top_srcdir)/m4/posix_spawn.m4 $(top_srcdir)/m4/printf.m4 \
+ $(top_srcdir)/m4/pipe.m4 $(top_srcdir)/m4/pipe2.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix_spawn.m4 \
+ $(top_srcdir)/m4/printf.m4 \
+ $(top_srcdir)/m4/pthread_rwlock_rdlock.m4 \
$(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \
$(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/rawmemchr.m4 \
- $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/regex.m4 \
- $(top_srcdir)/m4/sched_h.m4 $(top_srcdir)/m4/secure_getenv.m4 \
- $(top_srcdir)/m4/select.m4 $(top_srcdir)/m4/servent.m4 \
- $(top_srcdir)/m4/sha1.m4 $(top_srcdir)/m4/sha256.m4 \
+ $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/sched_h.m4 \
+ $(top_srcdir)/m4/secure_getenv.m4 $(top_srcdir)/m4/select.m4 \
+ $(top_srcdir)/m4/servent.m4 $(top_srcdir)/m4/sha1.m4 \
+ $(top_srcdir)/m4/sha256.m4 $(top_srcdir)/m4/sha512.m4 \
$(top_srcdir)/m4/sig_atomic_t.m4 $(top_srcdir)/m4/sigaction.m4 \
$(top_srcdir)/m4/signal_h.m4 \
$(top_srcdir)/m4/signalblocking.m4 $(top_srcdir)/m4/sigpipe.m4 \
@@ -197,12 +210,13 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
$(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
$(top_srcdir)/m4/strcase.m4 $(top_srcdir)/m4/strchrnul.m4 \
- $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strerror_r.m4 \
- $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strings_h.m4 \
- $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
+ $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
+ $(top_srcdir)/m4/strerror_r.m4 $(top_srcdir)/m4/string_h.m4 \
+ $(top_srcdir)/m4/strings_h.m4 $(top_srcdir)/m4/strndup.m4 \
+ $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strpbrk.m4 \
$(top_srcdir)/m4/strptime.m4 $(top_srcdir)/m4/strtok_r.m4 \
- $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/sys_file_h.m4 \
- $(top_srcdir)/m4/sys_ioctl_h.m4 \
+ $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/symlink.m4 \
+ $(top_srcdir)/m4/sys_file_h.m4 $(top_srcdir)/m4/sys_ioctl_h.m4 \
$(top_srcdir)/m4/sys_select_h.m4 \
$(top_srcdir)/m4/sys_socket_h.m4 \
$(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \
@@ -212,18 +226,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
$(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/timegm.m4 \
$(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \
$(top_srcdir)/m4/tmpdir.m4 $(top_srcdir)/m4/unistd-safer.m4 \
- $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlocked-io.m4 \
- $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \
- $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \
- $(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/vsnprintf.m4 \
- $(top_srcdir)/m4/wait-process.m4 $(top_srcdir)/m4/waitpid.m4 \
- $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/wchar_h.m4 \
- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wcrtomb.m4 \
- $(top_srcdir)/m4/wctype_h.m4 $(top_srcdir)/m4/wcwidth.m4 \
- $(top_srcdir)/m4/wget.m4 $(top_srcdir)/m4/wint_t.m4 \
- $(top_srcdir)/m4/write.m4 $(top_srcdir)/m4/xalloc.m4 \
- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink.m4 \
+ $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/utimbuf.m4 \
+ $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \
+ $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vasprintf.m4 \
+ $(top_srcdir)/m4/vsnprintf.m4 $(top_srcdir)/m4/wait-process.m4 \
+ $(top_srcdir)/m4/waitpid.m4 $(top_srcdir)/m4/warn-on-use.m4 \
+ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \
+ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctype_h.m4 \
+ $(top_srcdir)/m4/wcwidth.m4 $(top_srcdir)/m4/wget.m4 \
+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/write.m4 \
+ $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xsize.m4 \
+ $(top_srcdir)/m4/xstrndup.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -241,16 +255,18 @@ am__libunittest_a_SOURCES_DIST = connect.c convert.c cookies.c ftp.c \
css_.c css-url.c ftp-basic.c ftp-ls.c hash.c host.c hsts.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 spider.c url.c warc.c \
- utils.c exits.c build_info.c iri.c metalink.c css-url.h \
- css-tokens.h connect.h convert.h cookies.h ftp.h hash.h host.h \
- hsts.h html-parse.h html-url.h http.h http-ntlm.h init.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 warc.h utils.h \
- wget.h iri.h exits.h version.h metalink.h test.c test.h
-@IRI_IS_ENABLED_TRUE@am__objects_1 = libunittest_a-iri.$(OBJEXT)
-@METALINK_IS_ENABLED_TRUE@am__objects_2 = \
+ xattr.c utils.c exits.c build_info.c iri.c metalink.c \
+ css-url.h css-tokens.h connect.h convert.h cookies.h ftp.h \
+ hash.h host.h hsts.h html-parse.h html-url.h http.h \
+ http-ntlm.h init.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 warc.h utils.h wget.h iri.h exits.h version.h \
+ metalink.h xattr.h test.c test.h
+@WITH_XATTR_TRUE@am__objects_1 = libunittest_a-xattr.$(OBJEXT)
+@IRI_IS_ENABLED_TRUE@am__objects_2 = libunittest_a-iri.$(OBJEXT)
+@METALINK_IS_ENABLED_TRUE@am__objects_3 = \
@METALINK_IS_ENABLED_TRUE@ libunittest_a-metalink.$(OBJEXT)
-am__objects_3 = libunittest_a-connect.$(OBJEXT) \
+am__objects_4 = libunittest_a-connect.$(OBJEXT) \
libunittest_a-convert.$(OBJEXT) \
libunittest_a-cookies.$(OBJEXT) libunittest_a-ftp.$(OBJEXT) \
libunittest_a-css_.$(OBJEXT) libunittest_a-css-url.$(OBJEXT) \
@@ -265,11 +281,11 @@ am__objects_3 = libunittest_a-connect.$(OBJEXT) \
libunittest_a-ptimer.$(OBJEXT) libunittest_a-recur.$(OBJEXT) \
libunittest_a-res.$(OBJEXT) libunittest_a-retr.$(OBJEXT) \
libunittest_a-spider.$(OBJEXT) libunittest_a-url.$(OBJEXT) \
- libunittest_a-warc.$(OBJEXT) libunittest_a-utils.$(OBJEXT) \
- libunittest_a-exits.$(OBJEXT) \
- libunittest_a-build_info.$(OBJEXT) $(am__objects_1) \
- $(am__objects_2)
-am_libunittest_a_OBJECTS = $(am__objects_3) \
+ libunittest_a-warc.$(OBJEXT) $(am__objects_1) \
+ libunittest_a-utils.$(OBJEXT) libunittest_a-exits.$(OBJEXT) \
+ libunittest_a-build_info.$(OBJEXT) $(am__objects_2) \
+ $(am__objects_3)
+am_libunittest_a_OBJECTS = $(am__objects_4) \
libunittest_a-test.$(OBJEXT) \
libunittest_a-build_info.$(OBJEXT)
nodist_libunittest_a_OBJECTS = libunittest_a-version.$(OBJEXT)
@@ -281,14 +297,16 @@ am__wget_SOURCES_DIST = connect.c convert.c cookies.c ftp.c css_.c \
css-url.c ftp-basic.c ftp-ls.c hash.c host.c hsts.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 spider.c url.c warc.c \
- utils.c exits.c build_info.c iri.c metalink.c css-url.h \
- css-tokens.h connect.h convert.h cookies.h ftp.h hash.h host.h \
- hsts.h html-parse.h html-url.h http.h http-ntlm.h init.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 warc.h utils.h \
- wget.h iri.h exits.h version.h metalink.h
-@IRI_IS_ENABLED_TRUE@am__objects_4 = iri.$(OBJEXT)
-@METALINK_IS_ENABLED_TRUE@am__objects_5 = metalink.$(OBJEXT)
+ xattr.c utils.c exits.c build_info.c iri.c metalink.c \
+ css-url.h css-tokens.h connect.h convert.h cookies.h ftp.h \
+ hash.h host.h hsts.h html-parse.h html-url.h http.h \
+ http-ntlm.h init.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 warc.h utils.h wget.h iri.h exits.h version.h \
+ metalink.h xattr.h
+@WITH_XATTR_TRUE@am__objects_5 = xattr.$(OBJEXT)
+@IRI_IS_ENABLED_TRUE@am__objects_6 = iri.$(OBJEXT)
+@METALINK_IS_ENABLED_TRUE@am__objects_7 = metalink.$(OBJEXT)
am_wget_OBJECTS = connect.$(OBJEXT) convert.$(OBJEXT) \
cookies.$(OBJEXT) ftp.$(OBJEXT) css_.$(OBJEXT) \
css-url.$(OBJEXT) ftp-basic.$(OBJEXT) ftp-ls.$(OBJEXT) \
@@ -297,12 +315,21 @@ am_wget_OBJECTS = connect.$(OBJEXT) convert.$(OBJEXT) \
init.$(OBJEXT) log.$(OBJEXT) main.$(OBJEXT) netrc.$(OBJEXT) \
progress.$(OBJEXT) ptimer.$(OBJEXT) recur.$(OBJEXT) \
res.$(OBJEXT) retr.$(OBJEXT) spider.$(OBJEXT) url.$(OBJEXT) \
- warc.$(OBJEXT) utils.$(OBJEXT) exits.$(OBJEXT) \
- build_info.$(OBJEXT) $(am__objects_4) $(am__objects_5)
+ warc.$(OBJEXT) $(am__objects_5) utils.$(OBJEXT) \
+ exits.$(OBJEXT) build_info.$(OBJEXT) $(am__objects_6) \
+ $(am__objects_7)
nodist_wget_OBJECTS = version.$(OBJEXT)
wget_OBJECTS = $(am_wget_OBJECTS) $(nodist_wget_OBJECTS)
wget_LDADD = $(LDADD)
-wget_DEPENDENCIES = $(LIBOBJS) ../lib/libgnu.a
+am__DEPENDENCIES_1 =
+wget_DEPENDENCIES = $(LIBOBJS) ../lib/libgnu.a $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -497,6 +524,8 @@ GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@
GNULIB_GRANTPT = @GNULIB_GRANTPT@
GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@
GNULIB_ICONV = @GNULIB_ICONV@
+GNULIB_IMAXABS = @GNULIB_IMAXABS@
+GNULIB_IMAXDIV = @GNULIB_IMAXDIV@
GNULIB_INET_NTOP = @GNULIB_INET_NTOP@
GNULIB_INET_PTON = @GNULIB_INET_PTON@
GNULIB_IOCTL = @GNULIB_IOCTL@
@@ -554,6 +583,7 @@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
GNULIB_OPEN = @GNULIB_OPEN@
GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@
GNULIB_PCLOSE = @GNULIB_PCLOSE@
GNULIB_PERROR = @GNULIB_PERROR@
GNULIB_PIPE = @GNULIB_PIPE@
@@ -646,9 +676,11 @@ GNULIB_STRSEP = @GNULIB_STRSEP@
GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
GNULIB_STRSTR = @GNULIB_STRSTR@
GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@
GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
GNULIB_STRTOLL = @GNULIB_STRTOLL@
GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@
GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
GNULIB_SYMLINK = @GNULIB_SYMLINK@
GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
@@ -726,6 +758,7 @@ HAVE_ACCEPT4 = @HAVE_ACCEPT4@
HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@
HAVE_ATOLL = @HAVE_ATOLL@
HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@
HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
HAVE_CHOWN = @HAVE_CHOWN@
HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
@@ -741,10 +774,13 @@ HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN = @HAVE_DECL_GETLOGIN@
HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
HAVE_DECL_GETNAMEINFO = @HAVE_DECL_GETNAMEINFO@
HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@
+HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@
HAVE_DECL_INET_NTOP = @HAVE_DECL_INET_NTOP@
HAVE_DECL_INET_PTON = @HAVE_DECL_INET_PTON@
HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
@@ -760,7 +796,9 @@ HAVE_DECL_STRNCASECMP = @HAVE_DECL_STRNCASECMP@
HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@
HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@
HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
@@ -810,6 +848,7 @@ HAVE_LCHMOD = @HAVE_LCHMOD@
HAVE_LCHOWN = @HAVE_LCHOWN@
HAVE_LIBGNUTLS = @HAVE_LIBGNUTLS@
HAVE_LIBSSL = @HAVE_LIBSSL@
+HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@
HAVE_LINK = @HAVE_LINK@
HAVE_LINKAT = @HAVE_LINKAT@
HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
@@ -855,6 +894,7 @@ HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@
HAVE_PTSNAME = @HAVE_PTSNAME@
HAVE_PTSNAME_R = @HAVE_PTSNAME_R@
HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_QSORT_R = @HAVE_QSORT_R@
HAVE_RAISE = @HAVE_RAISE@
HAVE_RANDOM = @HAVE_RANDOM@
HAVE_RANDOM_H = @HAVE_RANDOM_H@
@@ -903,6 +943,7 @@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
HAVE_SYMLINK = @HAVE_SYMLINK@
HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@
HAVE_SYS_FILE_H = @HAVE_SYS_FILE_H@
HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
HAVE_SYS_IOCTL_H = @HAVE_SYS_IOCTL_H@
@@ -978,6 +1019,8 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@
+INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LDFLAGS = @LDFLAGS@
@@ -996,17 +1039,24 @@ LIBPSL_CFLAGS = @LIBPSL_CFLAGS@
LIBPSL_LIBS = @LIBPSL_LIBS@
LIBPTH = @LIBPTH@
LIBPTH_PREFIX = @LIBPTH_PREFIX@
-LIBS = @LIBICONV@ @LIBINTL@ @LIBS@ $(LIB_CLOCK_GETTIME)
+LIBS = @LIBS@
LIBSOCKET = @LIBSOCKET@
LIBSSL = @LIBSSL@
LIBSSL_PREFIX = @LIBSSL_PREFIX@
LIBTHREAD = @LIBTHREAD@
+LIBUNISTRING = @LIBUNISTRING@
+LIBUNISTRING_PREFIX = @LIBUNISTRING_PREFIX@
+LIBUNISTRING_UNICASE_H = @LIBUNISTRING_UNICASE_H@
+LIBUNISTRING_UNINORM_H = @LIBUNISTRING_UNINORM_H@
+LIBUNISTRING_UNISTR_H = @LIBUNISTRING_UNISTR_H@
LIBUNISTRING_UNITYPES_H = @LIBUNISTRING_UNITYPES_H@
LIBUNISTRING_UNIWIDTH_H = @LIBUNISTRING_UNIWIDTH_H@
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
LIB_CRYPTO = @LIB_CRYPTO@
+LIB_NANOSLEEP = @LIB_NANOSLEEP@
LIB_POSIX_SPAWN = @LIB_POSIX_SPAWN@
LIB_SELECT = @LIB_SELECT@
+LIMITS_H = @LIMITS_H@
LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
LOCALE_FR = @LOCALE_FR@
LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
@@ -1020,6 +1070,7 @@ LTLIBOBJS = @LTLIBOBJS@
LTLIBPTH = @LTLIBPTH@
LTLIBSSL = @LTLIBSSL@
LTLIBTHREAD = @LTLIBTHREAD@
+LTLIBUNISTRING = @LTLIBUNISTRING@
MAKEINFO = @MAKEINFO@
METALINK_CFLAGS = @METALINK_CFLAGS@
METALINK_LIBS = @METALINK_LIBS@
@@ -1036,7 +1087,9 @@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@
+NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@
NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@
NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
NEXT_AS_FIRST_DIRECTIVE_NETDB_H = @NEXT_AS_FIRST_DIRECTIVE_NETDB_H@
NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@
@@ -1067,7 +1120,9 @@ NEXT_FCNTL_H = @NEXT_FCNTL_H@
NEXT_FLOAT_H = @NEXT_FLOAT_H@
NEXT_GETOPT_H = @NEXT_GETOPT_H@
NEXT_ICONV_H = @NEXT_ICONV_H@
+NEXT_INTTYPES_H = @NEXT_INTTYPES_H@
NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LIMITS_H = @NEXT_LIMITS_H@
NEXT_LOCALE_H = @NEXT_LOCALE_H@
NEXT_NETDB_H = @NEXT_NETDB_H@
NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@
@@ -1114,6 +1169,8 @@ POD2MAN = @POD2MAN@
POSUB = @POSUB@
PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PRIPTR_PREFIX = @PRIPTR_PREFIX@
+PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@
PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
PYTHON = @PYTHON@
@@ -1245,7 +1302,9 @@ REPLACE_STRNLEN = @REPLACE_STRNLEN@
REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
REPLACE_STRSTR = @REPLACE_STRSTR@
REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOIMAX = @REPLACE_STRTOIMAX@
REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_STRTOUMAX = @REPLACE_STRTOUMAX@
REPLACE_STRUCT_LCONV = @REPLACE_STRUCT_LCONV@
REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@
REPLACE_SYMLINK = @REPLACE_SYMLINK@
@@ -1289,6 +1348,8 @@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@
SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@
+UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
@@ -1371,23 +1432,28 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@IRI_IS_ENABLED_TRUE@IRI_OBJ = iri.c
@METALINK_IS_ENABLED_TRUE@METALINK_OBJ = metalink.c
+@WITH_XATTR_TRUE@XATTR_OBJ = xattr.c
EXTRA_DIST = css.l css.c css_.c build_info.c.in
wget_SOURCES = connect.c convert.c cookies.c ftp.c \
css_.c css-url.c \
ftp-basic.c ftp-ls.c hash.c host.c hsts.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 spider.c url.c warc.c \
+ recur.c res.c retr.c spider.c url.c warc.c $(XATTR_OBJ) \
utils.c exits.c build_info.c $(IRI_OBJ) $(METALINK_OBJ) \
css-url.h css-tokens.h connect.h convert.h cookies.h \
ftp.h hash.h host.h hsts.h html-parse.h html-url.h \
http.h http-ntlm.h init.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 warc.h utils.h wget.h iri.h \
- exits.h version.h metalink.h
+ exits.h version.h metalink.h xattr.h
nodist_wget_SOURCES = version.c
EXTRA_wget_SOURCES = iri.c
-LDADD = $(LIBOBJS) ../lib/libgnu.a
+LDADD = $(LIBOBJS) ../lib/libgnu.a $(GETADDRINFO_LIB) $(HOSTENT_LIB)\
+ $(INET_NTOP_LIB) $(LIBSOCKET) $(LIB_CLOCK_GETTIME) $(LIB_CRYPTO)\
+ $(LIB_NANOSLEEP) $(LIB_POSIX_SPAWN) $(LIB_SELECT) $(LTLIBICONV) $(LTLIBINTL)\
+ $(LTLIBTHREAD) $(LTLIBUNISTRING) $(SERVENT_LIB)
+
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
ESCAPEQUOTE = sed -e 's/[\\"]/\\&/g' -e 's/\\"/"/' -e 's/\\";$$/";/'
check_LIBRARIES = libunittest.a
@@ -1562,6 +1628,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunittest_a-utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunittest_a-version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunittest_a-warc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunittest_a-xattr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metalink.Po@am__quote@
@@ -1576,6 +1643,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/warc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xattr.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -1955,6 +2023,20 @@ libunittest_a-warc.obj: warc.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunittest_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunittest_a-warc.obj `if test -f 'warc.c'; then $(CYGPATH_W) 'warc.c'; else $(CYGPATH_W) '$(srcdir)/warc.c'; fi`
+libunittest_a-xattr.o: xattr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunittest_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunittest_a-xattr.o -MD -MP -MF $(DEPDIR)/libunittest_a-xattr.Tpo -c -o libunittest_a-xattr.o `test -f 'xattr.c' || echo '$(srcdir)/'`xattr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunittest_a-xattr.Tpo $(DEPDIR)/libunittest_a-xattr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xattr.c' object='libunittest_a-xattr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunittest_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunittest_a-xattr.o `test -f 'xattr.c' || echo '$(srcdir)/'`xattr.c
+
+libunittest_a-xattr.obj: xattr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunittest_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunittest_a-xattr.obj -MD -MP -MF $(DEPDIR)/libunittest_a-xattr.Tpo -c -o libunittest_a-xattr.obj `if test -f 'xattr.c'; then $(CYGPATH_W) 'xattr.c'; else $(CYGPATH_W) '$(srcdir)/xattr.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunittest_a-xattr.Tpo $(DEPDIR)/libunittest_a-xattr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xattr.c' object='libunittest_a-xattr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunittest_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libunittest_a-xattr.obj `if test -f 'xattr.c'; then $(CYGPATH_W) 'xattr.c'; else $(CYGPATH_W) '$(srcdir)/xattr.c'; fi`
+
libunittest_a-utils.o: utils.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libunittest_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libunittest_a-utils.o -MD -MP -MF $(DEPDIR)/libunittest_a-utils.Tpo -c -o libunittest_a-utils.o `test -f 'utils.c' || echo '$(srcdir)/'`utils.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libunittest_a-utils.Tpo $(DEPDIR)/libunittest_a-utils.Po
diff --git a/src/config.h.in b/src/config.h.in
index 8b39c52..b0a7602 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -26,6 +26,9 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
+/* Define to 1 if the C locale may have encoding errors. */
+#undef C_LOCALE_MAYBE_EILSEQ
+
/* Define as the bit index in the word where to find bit 0 of the exponent of
'double'. */
#undef DBL_EXPBIT0_BIT
@@ -58,9 +61,25 @@
/* Define if you want Opie support for FTP compiled in. */
#undef ENABLE_OPIE
+/* Define if you want file meta-data storing into POSIX Extended Attributes
+ compiled in. */
+#undef ENABLE_XATTR
+
/* Define this to 1 if F_DUPFD behavior does not match POSIX */
#undef FCNTL_DUPFD_BUGGY
+/* Define to nothing if C supports flexible array members, and to 1 if it does
+ not. That way, with a declaration like 'struct s { int n; double
+ d[FLEXIBLE_ARRAY_MEMBER]; };', the struct hack can be used with pre-C99
+ compilers. When computing the size of such an object, don't use 'sizeof
+ (struct s)' as it overestimates the size. Use 'offsetof (struct s, d)'
+ instead. Don't use 'offsetof (struct s, d[0])', as this doesn't work with
+ MSVC and with C++ compilers. */
+#undef FLEXIBLE_ARRAY_MEMBER
+
+/* Define to 1 if fopen() fails to recognize a trailing slash. */
+#undef FOPEN_TRAILING_SLASH_BUG
+
/* Define to 1 if the system's ftello function has the Solaris bug. */
#undef FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE
@@ -152,6 +171,9 @@
/* Define to 1 when the gnulib module fcntl should be tested. */
#undef GNULIB_TEST_FCNTL
+/* Define to 1 when the gnulib module fopen should be tested. */
+#undef GNULIB_TEST_FOPEN
+
/* Define to 1 when the gnulib module fseek should be tested. */
#undef GNULIB_TEST_FSEEK
@@ -182,9 +204,6 @@
/* Define to 1 when the gnulib module getline should be tested. */
#undef GNULIB_TEST_GETLINE
-/* Define to 1 when the gnulib module getopt-gnu should be tested. */
-#undef GNULIB_TEST_GETOPT_GNU
-
/* Define to 1 when the gnulib module getpeername should be tested. */
#undef GNULIB_TEST_GETPEERNAME
@@ -200,6 +219,9 @@
/* Define to 1 when the gnulib module iswblank should be tested. */
#undef GNULIB_TEST_ISWBLANK
+/* Define to 1 when the gnulib module link should be tested. */
+#undef GNULIB_TEST_LINK
+
/* Define to 1 when the gnulib module listen should be tested. */
#undef GNULIB_TEST_LISTEN
@@ -242,15 +264,24 @@
/* Define to 1 when the gnulib module mktime should be tested. */
#undef GNULIB_TEST_MKTIME
+/* Define to 1 when the gnulib module nanosleep should be tested. */
+#undef GNULIB_TEST_NANOSLEEP
+
/* Define to 1 when the gnulib module nl_langinfo should be tested. */
#undef GNULIB_TEST_NL_LANGINFO
/* Define to 1 when the gnulib module open should be tested. */
#undef GNULIB_TEST_OPEN
+/* Define to 1 when the gnulib module pipe should be tested. */
+#undef GNULIB_TEST_PIPE
+
/* Define to 1 when the gnulib module pipe2 should be tested. */
#undef GNULIB_TEST_PIPE2
+/* Define to 1 when the gnulib module posix_spawn should be tested. */
+#undef GNULIB_TEST_POSIX_SPAWN
+
/* Define to 1 when the gnulib module posix_spawnattr_destroy should be
tested. */
#undef GNULIB_TEST_POSIX_SPAWNATTR_DESTROY
@@ -296,9 +327,6 @@
/* Define to 1 when the gnulib module rawmemchr should be tested. */
#undef GNULIB_TEST_RAWMEMCHR
-/* Define to 1 when the gnulib module realloc-posix should be tested. */
-#undef GNULIB_TEST_REALLOC_POSIX
-
/* Define to 1 when the gnulib module recv should be tested. */
#undef GNULIB_TEST_RECV
@@ -332,6 +360,9 @@
/* Define to 1 when the gnulib module strchrnul should be tested. */
#undef GNULIB_TEST_STRCHRNUL
+/* Define to 1 when the gnulib module strdup should be tested. */
+#undef GNULIB_TEST_STRDUP
+
/* Define to 1 when the gnulib module strerror should be tested. */
#undef GNULIB_TEST_STRERROR
@@ -344,6 +375,9 @@
/* Define to 1 when the gnulib module strnlen should be tested. */
#undef GNULIB_TEST_STRNLEN
+/* Define to 1 when the gnulib module strpbrk should be tested. */
+#undef GNULIB_TEST_STRPBRK
+
/* Define to 1 when the gnulib module strptime should be tested. */
#undef GNULIB_TEST_STRPTIME
@@ -353,12 +387,18 @@
/* Define to 1 when the gnulib module strtoll should be tested. */
#undef GNULIB_TEST_STRTOLL
+/* Define to 1 when the gnulib module symlink should be tested. */
+#undef GNULIB_TEST_SYMLINK
+
/* Define to 1 when the gnulib module timegm should be tested. */
#undef GNULIB_TEST_TIMEGM
/* Define to 1 when the gnulib module time_r should be tested. */
#undef GNULIB_TEST_TIME_R
+/* Define to 1 when the gnulib module unlink should be tested. */
+#undef GNULIB_TEST_UNLINK
+
/* Define to 1 when the gnulib module vasprintf should be tested. */
#undef GNULIB_TEST_VASPRINTF
@@ -394,6 +434,9 @@
/* Define to 1 if you have the `btowc' function. */
#undef HAVE_BTOWC
+/* Define to 1 if nanosleep mishandles large arguments. */
+#undef HAVE_BUG_BIG_NANOSLEEP
+
/* Define to 1 if you have the `catgets' function. */
#undef HAVE_CATGETS
@@ -558,6 +601,14 @@
don't. */
#undef HAVE_DECL_MEMRCHR
+/* Define to 1 if you have the declaration of `program_invocation_name', and
+ to 0 if you don't. */
+#undef HAVE_DECL_PROGRAM_INVOCATION_NAME
+
+/* Define to 1 if you have the declaration of `program_invocation_short_name',
+ and to 0 if you don't. */
+#undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+
/* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if
you don't. */
#undef HAVE_DECL_PUTCHAR_UNLOCKED
@@ -570,10 +621,17 @@
don't. */
#undef HAVE_DECL_SNPRINTF
-/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
- don't. */
+/* Define to 1 if you have the declaration of `strdup', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRDUP
+
+/* Define to 1, since you should have the declaration of strerror_r. */
#undef HAVE_DECL_STRERROR_R
+/* Define to 1 if you have the declaration of 'strerror_r' in the system
+ include files, or to 0 otherwise. */
+#undef HAVE_DECL_STRERROR_R_ORIG
+
/* Define to 1 if you have the declaration of `strncasecmp', and to 0 if you
don't. */
#undef HAVE_DECL_STRNCASECMP
@@ -610,6 +668,10 @@
don't. */
#undef HAVE_DECL__SNPRINTF
+/* Define to 1 if you have the declaration of `__argv', and to 0 if you don't.
+ */
+#undef HAVE_DECL___ARGV
+
/* Define to 1 if you have the declaration of `__fsetlocking', and to 0 if you
don't. */
#undef HAVE_DECL___FSETLOCKING
@@ -659,6 +721,18 @@
/* Define to 1 if you have the `getdtablesize' function. */
#undef HAVE_GETDTABLESIZE
+/* Define to 1 if you have the `getegid' function. */
+#undef HAVE_GETEGID
+
+/* Define to 1 if you have the `geteuid' function. */
+#undef HAVE_GETEUID
+
+/* Define to 1 if you have the `getexecname' function. */
+#undef HAVE_GETEXECNAME
+
+/* Define to 1 if you have the `getgid' function. */
+#undef HAVE_GETGID
+
/* Define to 1 if you have the `gethostbyname' function. */
#undef HAVE_GETHOSTBYNAME
@@ -671,6 +745,9 @@
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
+/* Define to 1 if you have the `getprogname' function. */
+#undef HAVE_GETPROGNAME
+
/* Define to 1 if you have the `getservbyname' function. */
#undef HAVE_GETSERVBYNAME
@@ -680,6 +757,9 @@
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
+/* Define to 1 if you have the `getuid' function. */
+#undef HAVE_GETUID
+
/* Define to 1 if you have the `gnutls_priority_set_direct' function. */
#undef HAVE_GNUTLS_PRIORITY_SET_DIRECT
@@ -692,12 +772,14 @@
/* Define to 1 if you have the <iconv.h> header file. */
#undef HAVE_ICONV_H
-/* Define to 1 if you have the `inet_ntoa' function. */
-#undef HAVE_INET_NTOA
-
/* Define to 1 if you have the `inet_ntop' function. */
#undef HAVE_INET_NTOP
+/* Define to 1 if the compiler supports one of the keywords 'inline',
+ '__inline__', '__inline' and effectively inlines functions marked as such.
+ */
+#undef HAVE_INLINE
+
/* Define to 1 if the system has the type `int64_t'. */
#undef HAVE_INT64_T
@@ -762,33 +844,33 @@
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
-/* Define to 1 if you have the `nsl' library (-lnsl). */
-#undef HAVE_LIBNSL
-
/* Define if libpcre is available. */
#undef HAVE_LIBPCRE
/* PSL support enabled */
#undef HAVE_LIBPSL
-/* Define to 1 if you have the `rt' library (-lrt). */
-#undef HAVE_LIBRT
-
-/* Define to 1 if you have the `socket' library (-lsocket). */
-#undef HAVE_LIBSOCKET
-
/* Define if you have the libssl library. */
#undef HAVE_LIBSSL
/* Define to 1 if you have the `ssl32' library (-lssl32). */
#undef HAVE_LIBSSL32
+/* Define if you have the libunistring library. */
+#undef HAVE_LIBUNISTRING
+
/* Define if using libuuid. */
#undef HAVE_LIBUUID
/* Define if using zlib. */
#undef HAVE_LIBZ
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have the `link' function. */
+#undef HAVE_LINK
+
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
@@ -838,6 +920,12 @@
/* Define if using metalink. */
#undef HAVE_METALINK
+/* Define to 1 if <limits.h> defines the MIN and MAX macros. */
+#undef HAVE_MINMAX_IN_LIMITS_H
+
+/* Define to 1 if <sys/param.h> defines the MIN and MAX macros. */
+#undef HAVE_MINMAX_IN_SYS_PARAM_H
+
/* Define to 1 if you have the `mkostemp' function. */
#undef HAVE_MKOSTEMP
@@ -854,9 +942,6 @@
concept. */
#undef HAVE_MSVC_INVALID_PARAMETER_HANDLER
-/* Define if you have the nanosleep function. */
-#undef HAVE_NANOSLEEP
-
/* Define to 1 if you have the `nanotime' function. */
#undef HAVE_NANOTIME
@@ -881,6 +966,9 @@
/* Define to 1 if libcrypto is used for SHA256. */
#undef HAVE_OPENSSL_SHA256
+/* Define to 1 if libcrypto is used for SHA512. */
+#undef HAVE_OPENSSL_SHA512
+
/* Define to 1 if you have the `pathconf' function. */
#undef HAVE_PATHCONF
@@ -902,12 +990,19 @@
/* Define to 1 if the system has the type `posix_spawn_file_actions_t'. */
#undef HAVE_POSIX_SPAWN_FILE_ACTIONS_T
+/* Define to 1 if you have the `psl_latest' function. */
+#undef HAVE_PSL_LATEST
+
/* Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE. */
#undef HAVE_PTHREAD_MUTEX_RECURSIVE
/* Define if the POSIX multithreading library has read/write locks. */
#undef HAVE_PTHREAD_RWLOCK
+/* Define if the 'pthread_rwlock_rdlock' function prefers a writer to a
+ reader. */
+#undef HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
+
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
@@ -1101,6 +1196,12 @@
/* Define to 1 if group_member is declared even after undefining macros. */
#undef HAVE_RAW_DECL_GROUP_MEMBER
+/* Define to 1 if imaxabs is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_IMAXABS
+
+/* Define to 1 if imaxdiv is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_IMAXDIV
+
/* Define to 1 if inet_ntop is declared even after undefining macros. */
#undef HAVE_RAW_DECL_INET_NTOP
@@ -1318,6 +1419,9 @@
/* Define to 1 if pwrite is declared even after undefining macros. */
#undef HAVE_RAW_DECL_PWRITE
+/* Define to 1 if qsort_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_QSORT_R
+
/* Define to 1 if random is declared even after undefining macros. */
#undef HAVE_RAW_DECL_RANDOM
@@ -1474,6 +1578,9 @@
/* Define to 1 if strtod is declared even after undefining macros. */
#undef HAVE_RAW_DECL_STRTOD
+/* Define to 1 if strtoimax is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRTOIMAX
+
/* Define to 1 if strtok_r is declared even after undefining macros. */
#undef HAVE_RAW_DECL_STRTOK_R
@@ -1483,6 +1590,9 @@
/* Define to 1 if strtoull is declared even after undefining macros. */
#undef HAVE_RAW_DECL_STRTOULL
+/* Define to 1 if strtoumax is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRTOUMAX
+
/* Define to 1 if strverscmp is declared even after undefining macros. */
#undef HAVE_RAW_DECL_STRVERSCMP
@@ -1636,9 +1746,6 @@
/* Define to 1 if _Exit is declared even after undefining macros. */
#undef HAVE_RAW_DECL__EXIT
-/* Define if the 'realloc' function is POSIX compliant. */
-#undef HAVE_REALLOC_POSIX
-
/* Define to 1 if the system has the type `sa_family_t'. */
#undef HAVE_SA_FAMILY_T
@@ -1741,7 +1848,7 @@
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
-/* Define to 1 if you have the `strerror_r' function. */
+/* Define to 1, since you should have the function strerror_r. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
@@ -1762,6 +1869,9 @@
/* Define to 1 if you have the `strnlen' function. */
#undef HAVE_STRNLEN
+/* Define to 1 if you have the `strpbrk' function. */
+#undef HAVE_STRPBRK
+
/* Define to 1 if you have the `strptime' function. */
#undef HAVE_STRPTIME
@@ -1816,7 +1926,8 @@
/* Define to 1 if `st_birthtim.tv_nsec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC
-/* Define to 1 if the system has the type `struct utimbuf'. */
+/* Define if struct utimbuf is declared -- usually in <utime.h>. Some systems
+ have utime.h but don't declare the struct anywhere. */
#undef HAVE_STRUCT_UTIMBUF
/* Define to 1 if you have the `symlink' function. */
@@ -1825,6 +1936,9 @@
/* Define to 1 if you have the <sys/bitypes.h> header file. */
#undef HAVE_SYS_BITYPES_H
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#undef HAVE_SYS_CDEFS_H
+
/* Define to 1 if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
@@ -1885,6 +1999,9 @@
/* Define to 1 if you have the `towlower' function. */
#undef HAVE_TOWLOWER
+/* Define to 1 if you have the `tzset' function. */
+#undef HAVE_TZSET
+
/* Define to 1 if the system has the type `uint32_t'. */
#undef HAVE_UINT32_T
@@ -1912,6 +2029,9 @@
/* Define if uuid_create is available. */
#undef HAVE_UUID_CREATE
+/* Define if you have a global __progname variable */
+#undef HAVE_VAR___PROGNAME
+
/* Define to 1 if you have the `vasnprintf' function. */
#undef HAVE_VASNPRINTF
@@ -1963,9 +2083,6 @@
/* Define to 1 if you have the `wmempcpy' function. */
#undef HAVE_WMEMPCPY
-/* Define if fnmatch.h can be included. */
-#undef HAVE_WORKING_FNMATCH_H
-
/* Define to 1 if O_NOATIME works. */
#undef HAVE_WORKING_O_NOATIME
@@ -2000,6 +2117,16 @@
/* Define to 1 if you have the `_set_invalid_parameter_handler' function. */
#undef HAVE__SET_INVALID_PARAMETER_HANDLER
+/* Define to 1 if the compiler supports __builtin_expect,
+ and to 2 if <builtins.h> does. */
+#undef HAVE___BUILTIN_EXPECT
+#ifndef HAVE___BUILTIN_EXPECT
+# define __builtin_expect(e, c) (e)
+#elif HAVE___BUILTIN_EXPECT == 2
+# include <builtins.h>
+#endif
+
+
/* Define to 1 if you have the `__fsetlocking' function. */
#undef HAVE___FSETLOCKING
@@ -2041,6 +2168,12 @@
/* Define if the mbrtowc function returns a wrong return value. */
#undef MBRTOWC_RETVAL_BUG
+/* Use GNU style printf and scanf. */
+#ifndef __USE_MINGW_ANSI_STDIO
+# undef __USE_MINGW_ANSI_STDIO
+#endif
+
+
/* Define to 1 if open() fails to recognize a trailing slash. */
#undef OPEN_TRAILING_SLASH_BUG
@@ -2068,6 +2201,9 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
+#undef PRI_MACROS_BROKEN
+
/* Define to the type that is the result of default argument promotions of
type mode_t. */
#undef PROMOTED_MODE_T
@@ -2142,13 +2278,19 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define to 1 if strerror_r returns char *. */
+/* Define to 0, since strerror_r should not return char *. */
#undef STRERROR_R_CHAR_P
+/* Define to 1 if time_t is signed. */
+#undef TIME_T_IS_SIGNED
+
/* Define to 1 if the type of the st_atim member of a struct stat is struct
timespec. */
#undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
+/* Define to 1 if unlink() on a parent directory may succeed */
+#undef UNLINK_PARENT_BUG
+
/* Define to the prefix of C symbols at the assembler and linker level, either
an underscore or empty. */
#undef USER_LABEL_PREFIX
@@ -2178,7 +2320,7 @@
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
-/* Enable general extensions on OS X. */
+/* Enable general extensions on macOS. */
#ifndef _DARWIN_C_SOURCE
# undef _DARWIN_C_SOURCE
#endif
@@ -2186,14 +2328,38 @@
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
-/* Use GNU style printf and scanf. */
-#ifndef __USE_MINGW_ANSI_STDIO
-# undef __USE_MINGW_ANSI_STDIO
-#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
+/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
+#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
+#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
+# undef __STDC_WANT_IEC_60559_BFP_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
+#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
+# undef __STDC_WANT_IEC_60559_DFP_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
+#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
+# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
+#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
+# undef __STDC_WANT_IEC_60559_TYPES_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
+#ifndef __STDC_WANT_LIB_EXT2__
+# undef __STDC_WANT_LIB_EXT2__
+#endif
+/* Enable extensions specified by ISO/IEC 24747:2009. */
+#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
+# undef __STDC_WANT_MATH_SPEC_FUNCS__
+#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
@@ -2309,6 +2475,12 @@
used. */
#undef __GETOPT_PREFIX
+/* Define to 1 if the system <stdint.h> predates C++11. */
+#undef __STDC_CONSTANT_MACROS
+
+/* Define to 1 if the system <stdint.h> predates C++11. */
+#undef __STDC_LIMIT_MACROS
+
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
@@ -2358,6 +2530,7 @@
? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
: (199901L <= __STDC_VERSION__ \
&& !defined __HP_cc \
+ && !defined __PGI \
&& !(defined __SUNPRO_C && __STDC__))) \
&& !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
# define _GL_INLINE inline
diff --git a/src/connect.c b/src/connect.c
index 0704000..7e18171 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -31,6 +31,7 @@ as that of the covered work. */
#include "wget.h"
+#include "exits.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -56,7 +57,7 @@ as that of the covered work. */
#include <sys/time.h>
#ifdef ENABLE_IRI
-#include <idn-free.h>
+#include <idn2.h>
#endif
#include "utils.h"
@@ -283,7 +284,7 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
str = xmalloc (len);
snprintf (str, len, "%s (%s)", name, print);
str[len-1] = '\0';
- idn_free (name);
+ idn2_free (name);
}
logprintf (LOG_VERBOSE, _("Connecting to %s|%s|:%d... "),
@@ -331,8 +332,10 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
if (bufsize < 512)
bufsize = 512; /* avoid pathologically small values */
#ifdef SO_RCVBUF
- setsockopt (sock, SOL_SOCKET, SO_RCVBUF,
- (void *)&bufsize, (socklen_t)sizeof (bufsize));
+ if (setsockopt (sock, SOL_SOCKET, SO_RCVBUF,
+ (void *) &bufsize, (socklen_t) sizeof (bufsize)))
+ logprintf (LOG_NOTQUIET, _("setsockopt SO_RCVBUF failed: %s\n"),
+ strerror (errno));
#endif
/* When we add limit_rate support for writing, which is useful
for POST, we should also set SO_SNDBUF here. */
@@ -471,7 +474,9 @@ bind_local (const ip_address *bind_address, int *port)
return -1;
#ifdef SO_REUSEADDR
- setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, setopt_ptr, setopt_size);
+ if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, setopt_ptr, setopt_size))
+ logprintf (LOG_NOTQUIET, _("setsockopt SO_REUSEADDR failed: %s\n"),
+ strerror (errno));
#endif
xzero (ss);
@@ -689,6 +694,11 @@ select_fd (int fd, double maxtime, int wait_for)
struct timeval tmout;
int result;
+ if (fd >= FD_SETSIZE)
+ {
+ logprintf (LOG_NOTQUIET, _("Too many fds open. Cannot use select on a fd >= %d\n"), FD_SETSIZE);
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
FD_ZERO (&fdset);
FD_SET (fd, &fdset);
if (wait_for & WAIT_FOR_READ)
@@ -731,6 +741,11 @@ test_socket_open (int sock)
struct timeval to;
int ret = 0;
+ if (sock >= FD_SETSIZE)
+ {
+ logprintf (LOG_NOTQUIET, _("Too many fds open. Cannot use select on a fd >= %d\n"), FD_SETSIZE);
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
/* Check if we still have a valid (non-EOF) connection. From Andrew
* Maholski's code in the Unix Socket FAQ. */
diff --git a/src/cookies.c b/src/cookies.c
index 81ecfa5..a250770 100644
--- a/src/cookies.c
+++ b/src/cookies.c
@@ -45,6 +45,7 @@ as that of the covered work. */
#include "wget.h"
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -525,19 +526,51 @@ check_domain_match (const char *cookie_domain, const char *host)
{
#ifdef HAVE_LIBPSL
+ static int init_psl;
+ static const psl_ctx_t *psl;
+
char *cookie_domain_lower = NULL;
char *host_lower = NULL;
- const psl_ctx_t *psl;
int is_acceptable;
- DEBUGP (("cdm: 1"));
- if (!(psl = psl_builtin()))
+ DEBUGP (("cdm: 1\n"));
+ if (!init_psl)
{
- DEBUGP (("\nlibpsl not built with a public suffix list. "
- "Falling back to simple heuristics.\n"));
- goto no_psl;
+ init_psl = 1;
+
+#ifdef HAVE_PSL_LATEST
+ if ((psl = psl_latest (NULL)))
+ goto have_psl;
+
+ DEBUGP (("\nPSL: Failed to load any PSL data. "
+ "Falling back to insecure heuristics.\n"));
+#else
+ if ((psl = psl_builtin ()) && !psl_builtin_outdated ())
+ goto have_psl;
+
+ DEBUGP (("\nPSL: built-in data outdated. "
+ "Trying to load data from %s.\n",
+ quote (psl_builtin_filename ())));
+
+ if ((psl = psl_load_file (psl_builtin_filename ())))
+ goto have_psl;
+
+ DEBUGP (("\nPSL: %s not found or not readable. "
+ "Falling back to built-in data.\n",
+ quote (psl_builtin_filename ())));
+
+ if (!(psl = psl_builtin ()))
+ {
+ DEBUGP (("\nPSL: libpsl not built with a public suffix list. "
+ "Falling back to insecure heuristics.\n"));
+ goto no_psl;
+ }
+#endif
}
+ else if (!psl)
+ goto no_psl;
+have_psl:
if (psl_str_to_utf8lower (cookie_domain, NULL, NULL, &cookie_domain_lower) == PSL_SUCCESS &&
psl_str_to_utf8lower (host, NULL, NULL, &host_lower) == PSL_SUCCESS)
{
@@ -562,13 +595,13 @@ no_psl:
#endif
/* For efficiency make some elementary checks first */
- DEBUGP (("cdm: 2"));
+ DEBUGP (("cdm: 2\n"));
/* For the sake of efficiency, check for exact match first. */
if (0 == strcasecmp (cookie_domain, host))
return true;
- DEBUGP ((" 3"));
+ DEBUGP (("cdm: 3\n"));
/* HOST must match the tail of cookie_domain. */
if (!match_tail (host, cookie_domain, true))
@@ -608,7 +641,7 @@ no_psl:
if (*p == '.')
/* Ignore leading period in this calculation. */
++p;
- DEBUGP ((" 4"));
+ DEBUGP (("cdm: 4\n"));
for (out = 0; !out; p++)
switch (*p)
{
@@ -634,12 +667,12 @@ no_psl:
++ldcl;
}
- DEBUGP ((" 5"));
+ DEBUGP (("cdm: 5\n"));
if (dccount < 2)
return false;
- DEBUGP ((" 6"));
+ DEBUGP (("cdm: 6\n"));
if (dccount == 2)
{
@@ -659,7 +692,7 @@ no_psl:
}
}
- DEBUGP ((" 7"));
+ DEBUGP (("cdm: 7\n"));
/* Don't allow the host "foobar.com" to set a cookie for domain
"bar.com". */
@@ -674,7 +707,7 @@ no_psl:
return false;
}
- DEBUGP ((" 8"));
+ DEBUGP (("cdm: 8\n"));
return true;
}
@@ -1018,7 +1051,7 @@ cookie_header (struct cookie_jar *jar, const char *host,
struct cookie *cookie;
struct weighed_cookie *outgoing;
- int count, i, ocnt;
+ size_t count, i, ocnt;
char *result;
int result_size, pos;
PREPEND_SLASH (path); /* see cookie_handle_set_cookie */
@@ -1032,7 +1065,7 @@ cookie_header (struct cookie_jar *jar, const char *host,
chain_count = find_chains_of_host (jar, host, chains);
/* No cookies for this host. */
- if (!chain_count)
+ if (chain_count <= 0)
return NULL;
cookies_now = time (NULL);
@@ -1043,7 +1076,7 @@ cookie_header (struct cookie_jar *jar, const char *host,
/* Count the number of matching cookies. */
count = 0;
- for (i = 0; i < chain_count; i++)
+ for (i = 0; i < (unsigned) chain_count; i++)
for (cookie = chains[i]; cookie; cookie = cookie->next)
if (cookie_matches_url (cookie, host, port, path, secflag, NULL))
++count;
@@ -1051,12 +1084,14 @@ cookie_header (struct cookie_jar *jar, const char *host,
return NULL; /* no cookies matched */
/* Allocate the array. */
- outgoing = alloca_array (struct weighed_cookie, count);
+ if (count > SIZE_MAX / sizeof (struct weighed_cookie))
+ return NULL; /* unable to process so many cookies */
+ outgoing = xmalloc (count * sizeof (struct weighed_cookie));
/* Fill the array with all the matching cookies from the chains that
match HOST. */
ocnt = 0;
- for (i = 0; i < chain_count; i++)
+ for (i = 0; i < (unsigned) chain_count; i++)
for (cookie = chains[i]; cookie; cookie = cookie->next)
{
int pg;
@@ -1111,6 +1146,7 @@ cookie_header (struct cookie_jar *jar, const char *host,
}
}
result[pos++] = '\0';
+ xfree (outgoing);
assert (pos == result_size);
return result;
}
diff --git a/src/css-url.c b/src/css-url.c
index d56918d..781bbe1 100644
--- a/src/css-url.c
+++ b/src/css-url.c
@@ -59,6 +59,7 @@ extern char *yytext;
extern int yyleng;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern YY_BUFFER_STATE yy_scan_bytes (const char *bytes,int len );
+extern void yy_delete_buffer (YY_BUFFER_STATE b);
extern int yylex (void);
/*
@@ -109,9 +110,10 @@ get_urls_css (struct map_context *ctx, int offset, int buf_length)
int buffer_pos = 0;
int pos, length;
char *uri;
+ YY_BUFFER_STATE b;
/* tell flex to scan from this buffer */
- yy_scan_bytes (ctx->text + offset, buf_length);
+ b = yy_scan_bytes (ctx->text + offset, buf_length);
while((token = yylex()) != CSSEOF)
{
@@ -188,6 +190,9 @@ get_urls_css (struct map_context *ctx, int offset, int buf_length)
}
buffer_pos += yyleng;
}
+
+ yy_delete_buffer(b);
+
DEBUGP (("\n"));
}
diff --git a/src/css-url.h b/src/css-url.h
index 1695901..92ce6b1 100644
--- a/src/css-url.h
+++ b/src/css-url.h
@@ -32,7 +32,6 @@ as that of the covered work. */
#define CSS_URL_H
void get_urls_css (struct map_context *, int, int);
-void get_urls_css (struct map_context *, int, int);
struct urlpos *get_urls_css_file (const char *, const char *);
#endif /* CSS_URL_H */
diff --git a/src/css.c b/src/css.c
index d3e1a03..7c2ae68 100644
--- a/src/css.c
+++ b/src/css.c
@@ -8,8 +8,8 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 39
+#define YY_FLEX_MINOR_VERSION 6
+#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -88,25 +88,13 @@ typedef unsigned int flex_uint32_t;
#endif /* ! FLEXINT_H */
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
+/* TODO: this is always defined, so inline it */
#define yyconst const
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define yynoreturn __attribute__((__noreturn__))
#else
-#define yyconst
+#define yynoreturn
#endif
/* Returned upon end-of-file. */
@@ -142,7 +130,15 @@ typedef unsigned int flex_uint32_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -159,7 +155,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
typedef size_t yy_size_t;
#endif
-extern yy_size_t yyleng;
+extern int yyleng;
extern FILE *yyin, *yyout;
@@ -198,12 +194,12 @@ struct yy_buffer_state
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
- yy_size_t yy_buf_size;
+ int yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- yy_size_t yy_n_chars;
+ int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@@ -226,7 +222,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
-
+
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
@@ -254,7 +250,7 @@ struct yy_buffer_state
/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
@@ -273,11 +269,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
-static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
-yy_size_t yyleng;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int yyleng;
/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
+static char *yy_c_buf_p = NULL;
static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
@@ -302,7 +298,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
@@ -334,12 +330,12 @@ void yyfree (void * );
/* Begin user sect3 */
-#define yywrap() 1
+#define yywrap() (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
@@ -348,19 +344,22 @@ extern int yylineno;
int yylineno = 1;
extern char *yytext;
+#ifdef yytext_ptr
+#undef yytext_ptr
+#endif
#define yytext_ptr yytext
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
+static void yynoreturn yy_fatal_error (yyconst char* msg );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
- yyleng = (size_t) (yy_cp - yy_bp); \
+ yyleng = (int) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
@@ -505,7 +504,7 @@ static yyconst flex_int16_t yy_accept[1153] =
0, 0
} ;
-static yyconst flex_int32_t yy_ec[256] =
+static yyconst YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 4, 5, 1, 1, 1, 1, 1, 1, 1,
@@ -537,7 +536,7 @@ static yyconst flex_int32_t yy_ec[256] =
81, 81, 81, 81, 81
} ;
-static yyconst flex_int32_t yy_meta[82] =
+static yyconst YY_CHAR yy_meta[82] =
{ 0,
1, 2, 3, 3, 3, 2, 4, 5, 4, 4,
4, 5, 6, 4, 4, 4, 4, 7, 4, 4,
@@ -550,7 +549,7 @@ static yyconst flex_int32_t yy_meta[82] =
9
} ;
-static yyconst flex_int16_t yy_base[1307] =
+static yyconst flex_uint16_t yy_base[1307] =
{ 0,
0, 0, 3517,17264, 80, 85, 104, 84, 3459, 81,
17264,17264, 76, 127, 3494, 159, 3501,17264, 200, 82,
@@ -846,7 +845,7 @@ static yyconst flex_int16_t yy_def[1307] =
1152, 1152, 1152, 1152, 1152, 1152
} ;
-static yyconst flex_int16_t yy_nxt[17346] =
+static yyconst flex_uint16_t yy_nxt[17346] =
{ 0,
4, 5, 6, 5, 5, 5, 7, 8, 9, 4,
4, 10, 4, 4, 4, 11, 12, 13, 14, 15,
@@ -4721,7 +4720,7 @@ as that of the covered work. */
#include "css-tokens.h"
-#line 4725 "css.c"
+#line 4724 "css.c"
#define INITIAL 0
@@ -4754,19 +4753,19 @@ void yyset_extra (YY_EXTRA_TYPE user_defined );
FILE *yyget_in (void );
-void yyset_in (FILE * in_str );
+void yyset_in (FILE * _in_str );
FILE *yyget_out (void );
-void yyset_out (FILE * out_str );
+void yyset_out (FILE * _out_str );
-yy_size_t yyget_leng (void );
+ int yyget_leng (void );
char *yyget_text (void );
int yyget_lineno (void );
-void yyset_lineno (int line_number );
+void yyset_lineno (int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -4780,6 +4779,10 @@ extern int yywrap (void );
#endif
#endif
+#ifndef YY_NO_UNPUT
+
+#endif
+
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
@@ -4800,7 +4803,12 @@ static int input (void );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@@ -4808,7 +4816,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -4832,7 +4840,7 @@ static int input (void );
else \
{ \
errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -4887,7 +4895,7 @@ extern int yylex (void);
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
-#define YY_BREAK break;
+#define YY_BREAK /*LINTED*/break;
#endif
#define YY_RULE_SETUP \
@@ -4897,9 +4905,9 @@ extern int yylex (void);
*/
YY_DECL
{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
+ yy_state_type yy_current_state;
+ char *yy_cp, *yy_bp;
+ int yy_act;
if ( !(yy_init) )
{
@@ -4931,9 +4939,9 @@ YY_DECL
#line 83 "css.l"
-#line 4935 "css.c"
+#line 4943 "css.c"
- while ( 1 ) /* loops until end-of-file is reached */
+ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
@@ -4949,7 +4957,7 @@ YY_DECL
yy_match:
do
{
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+ YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@@ -4961,7 +4969,7 @@ yy_match:
if ( yy_current_state >= 1153 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
++yy_cp;
}
while ( yy_current_state != 1152 );
@@ -5224,7 +5232,7 @@ YY_RULE_SETUP
#line 139 "css.l"
ECHO;
YY_BREAK
-#line 5228 "css.c"
+#line 5236 "css.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -5368,9 +5376,9 @@ case YY_STATE_EOF(INITIAL):
*/
static int yy_get_next_buffer (void)
{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
+ char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ char *source = (yytext_ptr);
+ yy_size_t number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@@ -5399,7 +5407,7 @@ static int yy_get_next_buffer (void)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+ number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -5412,7 +5420,7 @@ static int yy_get_next_buffer (void)
else
{
- yy_size_t num_to_read =
+ int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
@@ -5426,7 +5434,7 @@ static int yy_get_next_buffer (void)
if ( b->yy_is_our_buffer )
{
- yy_size_t new_size = b->yy_buf_size * 2;
+ int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@@ -5439,7 +5447,7 @@ static int yy_get_next_buffer (void)
}
else
/* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
+ b->yy_ch_buf = NULL;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
@@ -5481,9 +5489,9 @@ static int yy_get_next_buffer (void)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
@@ -5502,14 +5510,14 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_get_previous_state (void)
{
- register yy_state_type yy_current_state;
- register char *yy_cp;
+ yy_state_type yy_current_state;
+ char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@@ -5521,7 +5529,7 @@ static int yy_get_next_buffer (void)
if ( yy_current_state >= 1153 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
}
return yy_current_state;
@@ -5534,10 +5542,10 @@ static int yy_get_next_buffer (void)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
+ int yy_is_jam;
+ char *yy_cp = (yy_c_buf_p);
- register YY_CHAR yy_c = 1;
+ YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@@ -5549,12 +5557,16 @@ static int yy_get_next_buffer (void)
if ( yy_current_state >= 1153 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
yy_is_jam = (yy_current_state == 1152);
return yy_is_jam ? 0 : yy_current_state;
}
+#ifndef YY_NO_UNPUT
+
+#endif
+
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
@@ -5579,7 +5591,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
+ int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@@ -5603,7 +5615,7 @@ static int yy_get_next_buffer (void)
case EOB_ACT_END_OF_FILE:
{
if ( yywrap( ) )
- return EOF;
+ return 0;
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
@@ -5704,7 +5716,7 @@ static void yy_load_buffer_state (void)
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = size;
+ b->yy_buf_size = (yy_size_t)size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
@@ -5851,7 +5863,7 @@ void yypop_buffer_state (void)
*/
static void yyensure_buffer_stack (void)
{
- yy_size_t num_to_alloc;
+ int num_to_alloc;
if (!(yy_buffer_stack)) {
@@ -5859,15 +5871,15 @@ static void yyensure_buffer_stack (void)
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
- num_to_alloc = 1;
+ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
+
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
+
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
@@ -5876,7 +5888,7 @@ static void yyensure_buffer_stack (void)
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
+ yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
@@ -5896,7 +5908,7 @@ static void yyensure_buffer_stack (void)
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
- * @return the newly allocated buffer state object.
+ * @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
@@ -5906,7 +5918,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
- return 0;
+ return NULL;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
@@ -5915,7 +5927,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
+ b->yy_input_file = NULL;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
@@ -5938,7 +5950,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{
- return yy_scan_bytes(yystr,strlen(yystr) );
+ return yy_scan_bytes(yystr,(int) strlen(yystr) );
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
@@ -5948,7 +5960,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
*
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
@@ -5956,7 +5968,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
+ n = (yy_size_t) _yybytes_len + 2;
buf = (char *) yyalloc(n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -5982,9 +5994,9 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
#define YY_EXIT_FAILURE 2
#endif
-static void yy_fatal_error (yyconst char* msg )
+static void yynoreturn yy_fatal_error (yyconst char* msg )
{
- (void) fprintf( stderr, "%s\n", msg );
+ (void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -6012,7 +6024,7 @@ static void yy_fatal_error (yyconst char* msg )
*/
int yyget_lineno (void)
{
-
+
return yylineno;
}
@@ -6035,7 +6047,7 @@ FILE *yyget_out (void)
/** Get the length of the current token.
*
*/
-yy_size_t yyget_leng (void)
+int yyget_leng (void)
{
return yyleng;
}
@@ -6050,29 +6062,29 @@ char *yyget_text (void)
}
/** Set the current line number.
- * @param line_number
+ * @param _line_number line number
*
*/
-void yyset_lineno (int line_number )
+void yyset_lineno (int _line_number )
{
- yylineno = line_number;
+ yylineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
- * @param in_str A readable stream.
+ * @param _in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
-void yyset_in (FILE * in_str )
+void yyset_in (FILE * _in_str )
{
- yyin = in_str ;
+ yyin = _in_str ;
}
-void yyset_out (FILE * out_str )
+void yyset_out (FILE * _out_str )
{
- yyout = out_str ;
+ yyout = _out_str ;
}
int yyget_debug (void)
@@ -6080,9 +6092,9 @@ int yyget_debug (void)
return yy_flex_debug;
}
-void yyset_debug (int bdebug )
+void yyset_debug (int _bdebug )
{
- yy_flex_debug = bdebug ;
+ yy_flex_debug = _bdebug ;
}
static int yy_init_globals (void)
@@ -6091,10 +6103,10 @@ static int yy_init_globals (void)
* This function is called from yylex_destroy(), so don't allocate here.
*/
- (yy_buffer_stack) = 0;
+ (yy_buffer_stack) = NULL;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
+ (yy_c_buf_p) = NULL;
(yy_init) = 0;
(yy_start) = 0;
@@ -6103,8 +6115,8 @@ static int yy_init_globals (void)
yyin = stdin;
yyout = stdout;
#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
+ yyin = NULL;
+ yyout = NULL;
#endif
/* For future reference: Set errno on error, since we are called by
@@ -6142,7 +6154,8 @@ int yylex_destroy (void)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
- register int i;
+
+ int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
@@ -6151,7 +6164,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
- register int n;
+ int n;
for ( n = 0; s[n]; ++n )
;
@@ -6161,11 +6174,12 @@ static int yy_flex_strlen (yyconst char * s )
void *yyalloc (yy_size_t size )
{
- return (void *) malloc( size );
+ return malloc(size);
}
void *yyrealloc (void * ptr, yy_size_t size )
{
+
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@@ -6173,12 +6187,12 @@ void *yyrealloc (void * ptr, yy_size_t size )
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
- return (void *) realloc( (char *) ptr, size );
+ return realloc(ptr, size);
}
void yyfree (void * ptr )
{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
diff --git a/src/css_.c b/src/css_.c
index 7751492..069adfb 100644
--- a/src/css_.c
+++ b/src/css_.c
@@ -9,8 +9,8 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 39
+#define YY_FLEX_MINOR_VERSION 6
+#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -89,25 +89,13 @@ typedef unsigned int flex_uint32_t;
#endif /* ! FLEXINT_H */
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
+/* TODO: this is always defined, so inline it */
#define yyconst const
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define yynoreturn __attribute__((__noreturn__))
#else
-#define yyconst
+#define yynoreturn
#endif
/* Returned upon end-of-file. */
@@ -143,7 +131,15 @@ typedef unsigned int flex_uint32_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -160,7 +156,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
typedef size_t yy_size_t;
#endif
-extern yy_size_t yyleng;
+extern int yyleng;
extern FILE *yyin, *yyout;
@@ -199,12 +195,12 @@ struct yy_buffer_state
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
- yy_size_t yy_buf_size;
+ int yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- yy_size_t yy_n_chars;
+ int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@@ -227,7 +223,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
-
+
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
@@ -255,7 +251,7 @@ struct yy_buffer_state
/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
@@ -274,11 +270,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
-static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
-yy_size_t yyleng;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int yyleng;
/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
+static char *yy_c_buf_p = NULL;
static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
@@ -303,7 +299,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
@@ -335,12 +331,12 @@ void yyfree (void * );
/* Begin user sect3 */
-#define yywrap() 1
+#define yywrap() (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
@@ -349,19 +345,22 @@ extern int yylineno;
int yylineno = 1;
extern char *yytext;
+#ifdef yytext_ptr
+#undef yytext_ptr
+#endif
#define yytext_ptr yytext
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
+static void yynoreturn yy_fatal_error (yyconst char* msg );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
- yyleng = (size_t) (yy_cp - yy_bp); \
+ yyleng = (int) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
@@ -506,7 +505,7 @@ static yyconst flex_int16_t yy_accept[1153] =
0, 0
} ;
-static yyconst flex_int32_t yy_ec[256] =
+static yyconst YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 4, 5, 1, 1, 1, 1, 1, 1, 1,
@@ -538,7 +537,7 @@ static yyconst flex_int32_t yy_ec[256] =
81, 81, 81, 81, 81
} ;
-static yyconst flex_int32_t yy_meta[82] =
+static yyconst YY_CHAR yy_meta[82] =
{ 0,
1, 2, 3, 3, 3, 2, 4, 5, 4, 4,
4, 5, 6, 4, 4, 4, 4, 7, 4, 4,
@@ -551,7 +550,7 @@ static yyconst flex_int32_t yy_meta[82] =
9
} ;
-static yyconst flex_int16_t yy_base[1307] =
+static yyconst flex_uint16_t yy_base[1307] =
{ 0,
0, 0, 3517,17264, 80, 85, 104, 84, 3459, 81,
17264,17264, 76, 127, 3494, 159, 3501,17264, 200, 82,
@@ -847,7 +846,7 @@ static yyconst flex_int16_t yy_def[1307] =
1152, 1152, 1152, 1152, 1152, 1152
} ;
-static yyconst flex_int16_t yy_nxt[17346] =
+static yyconst flex_uint16_t yy_nxt[17346] =
{ 0,
4, 5, 6, 5, 5, 5, 7, 8, 9, 4,
4, 10, 4, 4, 4, 11, 12, 13, 14, 15,
@@ -4722,7 +4721,7 @@ as that of the covered work. */
#include "css-tokens.h"
-#line 4725 "css.c"
+#line 4724 "css.c"
#define INITIAL 0
@@ -4755,19 +4754,19 @@ void yyset_extra (YY_EXTRA_TYPE user_defined );
FILE *yyget_in (void );
-void yyset_in (FILE * in_str );
+void yyset_in (FILE * _in_str );
FILE *yyget_out (void );
-void yyset_out (FILE * out_str );
+void yyset_out (FILE * _out_str );
-yy_size_t yyget_leng (void );
+ int yyget_leng (void );
char *yyget_text (void );
int yyget_lineno (void );
-void yyset_lineno (int line_number );
+void yyset_lineno (int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -4781,6 +4780,10 @@ extern int yywrap (void );
#endif
#endif
+#ifndef YY_NO_UNPUT
+
+#endif
+
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
@@ -4801,7 +4804,12 @@ static int input (void );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@@ -4809,7 +4817,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -4833,7 +4841,7 @@ static int input (void );
else \
{ \
errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -4888,7 +4896,7 @@ extern int yylex (void);
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
-#define YY_BREAK break;
+#define YY_BREAK /*LINTED*/break;
#endif
#define YY_RULE_SETUP \
@@ -4898,9 +4906,9 @@ extern int yylex (void);
*/
YY_DECL
{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
+ yy_state_type yy_current_state;
+ char *yy_cp, *yy_bp;
+ int yy_act;
if ( !(yy_init) )
{
@@ -4932,9 +4940,9 @@ YY_DECL
#line 83 "css.l"
-#line 4935 "css.c"
+#line 4943 "css.c"
- while ( 1 ) /* loops until end-of-file is reached */
+ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
@@ -4950,7 +4958,7 @@ YY_DECL
yy_match:
do
{
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+ YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@@ -4962,7 +4970,7 @@ yy_match:
if ( yy_current_state >= 1153 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
++yy_cp;
}
while ( yy_current_state != 1152 );
@@ -5225,7 +5233,7 @@ YY_RULE_SETUP
#line 139 "css.l"
ECHO;
YY_BREAK
-#line 5228 "css.c"
+#line 5236 "css.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -5369,9 +5377,9 @@ case YY_STATE_EOF(INITIAL):
*/
static int yy_get_next_buffer (void)
{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
+ char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ char *source = (yytext_ptr);
+ yy_size_t number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@@ -5400,7 +5408,7 @@ static int yy_get_next_buffer (void)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+ number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -5413,7 +5421,7 @@ static int yy_get_next_buffer (void)
else
{
- yy_size_t num_to_read =
+ int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
@@ -5427,7 +5435,7 @@ static int yy_get_next_buffer (void)
if ( b->yy_is_our_buffer )
{
- yy_size_t new_size = b->yy_buf_size * 2;
+ int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@@ -5440,7 +5448,7 @@ static int yy_get_next_buffer (void)
}
else
/* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
+ b->yy_ch_buf = NULL;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
@@ -5482,9 +5490,9 @@ static int yy_get_next_buffer (void)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
@@ -5503,14 +5511,14 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_get_previous_state (void)
{
- register yy_state_type yy_current_state;
- register char *yy_cp;
+ yy_state_type yy_current_state;
+ char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@@ -5522,7 +5530,7 @@ static int yy_get_next_buffer (void)
if ( yy_current_state >= 1153 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
}
return yy_current_state;
@@ -5535,10 +5543,10 @@ static int yy_get_next_buffer (void)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
+ int yy_is_jam;
+ char *yy_cp = (yy_c_buf_p);
- register YY_CHAR yy_c = 1;
+ YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@@ -5550,12 +5558,16 @@ static int yy_get_next_buffer (void)
if ( yy_current_state >= 1153 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
yy_is_jam = (yy_current_state == 1152);
return yy_is_jam ? 0 : yy_current_state;
}
+#ifndef YY_NO_UNPUT
+
+#endif
+
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
@@ -5580,7 +5592,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
+ int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@@ -5604,7 +5616,7 @@ static int yy_get_next_buffer (void)
case EOB_ACT_END_OF_FILE:
{
if ( yywrap( ) )
- return EOF;
+ return 0;
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
@@ -5705,7 +5717,7 @@ static void yy_load_buffer_state (void)
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = size;
+ b->yy_buf_size = (yy_size_t)size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
@@ -5852,7 +5864,7 @@ void yypop_buffer_state (void)
*/
static void yyensure_buffer_stack (void)
{
- yy_size_t num_to_alloc;
+ int num_to_alloc;
if (!(yy_buffer_stack)) {
@@ -5860,15 +5872,15 @@ static void yyensure_buffer_stack (void)
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
- num_to_alloc = 1;
+ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
+
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
+
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
@@ -5877,7 +5889,7 @@ static void yyensure_buffer_stack (void)
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
+ yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
@@ -5897,7 +5909,7 @@ static void yyensure_buffer_stack (void)
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
- * @return the newly allocated buffer state object.
+ * @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
@@ -5907,7 +5919,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
- return 0;
+ return NULL;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
@@ -5916,7 +5928,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
+ b->yy_input_file = NULL;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
@@ -5939,7 +5951,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{
- return yy_scan_bytes(yystr,strlen(yystr) );
+ return yy_scan_bytes(yystr,(int) strlen(yystr) );
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
@@ -5949,7 +5961,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
*
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
@@ -5957,7 +5969,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
+ n = (yy_size_t) _yybytes_len + 2;
buf = (char *) yyalloc(n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -5983,9 +5995,9 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
#define YY_EXIT_FAILURE 2
#endif
-static void yy_fatal_error (yyconst char* msg )
+static void yynoreturn yy_fatal_error (yyconst char* msg )
{
- (void) fprintf( stderr, "%s\n", msg );
+ (void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -6013,7 +6025,7 @@ static void yy_fatal_error (yyconst char* msg )
*/
int yyget_lineno (void)
{
-
+
return yylineno;
}
@@ -6036,7 +6048,7 @@ FILE *yyget_out (void)
/** Get the length of the current token.
*
*/
-yy_size_t yyget_leng (void)
+int yyget_leng (void)
{
return yyleng;
}
@@ -6051,29 +6063,29 @@ char *yyget_text (void)
}
/** Set the current line number.
- * @param line_number
+ * @param _line_number line number
*
*/
-void yyset_lineno (int line_number )
+void yyset_lineno (int _line_number )
{
- yylineno = line_number;
+ yylineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
- * @param in_str A readable stream.
+ * @param _in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
-void yyset_in (FILE * in_str )
+void yyset_in (FILE * _in_str )
{
- yyin = in_str ;
+ yyin = _in_str ;
}
-void yyset_out (FILE * out_str )
+void yyset_out (FILE * _out_str )
{
- yyout = out_str ;
+ yyout = _out_str ;
}
int yyget_debug (void)
@@ -6081,9 +6093,9 @@ int yyget_debug (void)
return yy_flex_debug;
}
-void yyset_debug (int bdebug )
+void yyset_debug (int _bdebug )
{
- yy_flex_debug = bdebug ;
+ yy_flex_debug = _bdebug ;
}
static int yy_init_globals (void)
@@ -6092,10 +6104,10 @@ static int yy_init_globals (void)
* This function is called from yylex_destroy(), so don't allocate here.
*/
- (yy_buffer_stack) = 0;
+ (yy_buffer_stack) = NULL;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
+ (yy_c_buf_p) = NULL;
(yy_init) = 0;
(yy_start) = 0;
@@ -6104,8 +6116,8 @@ static int yy_init_globals (void)
yyin = stdin;
yyout = stdout;
#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
+ yyin = NULL;
+ yyout = NULL;
#endif
/* For future reference: Set errno on error, since we are called by
@@ -6143,7 +6155,8 @@ int yylex_destroy (void)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
- register int i;
+
+ int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
@@ -6152,7 +6165,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
- register int n;
+ int n;
for ( n = 0; s[n]; ++n )
;
@@ -6162,11 +6175,12 @@ static int yy_flex_strlen (yyconst char * s )
void *yyalloc (yy_size_t size )
{
- return (void *) malloc( size );
+ return malloc(size);
}
void *yyrealloc (void * ptr, yy_size_t size )
{
+
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@@ -6174,12 +6188,12 @@ void *yyrealloc (void * ptr, yy_size_t size )
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
- return (void *) realloc( (char *) ptr, size );
+ return realloc(ptr, size);
}
void yyfree (void * ptr )
{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
diff --git a/src/ftp-ls.c b/src/ftp-ls.c
index f8342e2..27addd4 100644
--- a/src/ftp-ls.c
+++ b/src/ftp-ls.c
@@ -167,12 +167,12 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
/*cur.perms = 1023;*/ /* #### What is this? --hniksic */
cur.perms = 0644;
}
- DEBUGP (("implicit perms %0o; ", cur.perms));
+ DEBUGP (("implicit perms %0o; ", (unsigned) cur.perms));
}
else
{
cur.perms = symperms (tok + 1);
- DEBUGP (("perms %0o; ", cur.perms));
+ DEBUGP (("perms %0o; ", (unsigned) cur.perms));
}
error = ignore = 0; /* Erroneous and ignoring entries are
@@ -478,6 +478,7 @@ ftp_parse_winnt_ls (const char *file)
}
/* Now it is possible to determine the position of the first symbol in
filename. */
+ memset(&cur, 0, sizeof (cur));
cur.name = xstrdup(filename);
DEBUGP (("Name: '%s'\n", cur.name));
@@ -931,7 +932,7 @@ ftp_parse_vms_ls (const char *file)
}
}
cur.perms = perms;
- DEBUGP (("Prot. perms = %0o.\n", cur.perms));
+ DEBUGP (("Prot. perms = %0o.\n", (unsigned) cur.perms));
}
else
{
diff --git a/src/ftp.c b/src/ftp.c
index 88a9777..fe09817 100644
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -52,6 +52,9 @@ as that of the covered work. */
#include "recur.h" /* for INFINITE_RECURSION */
#include "warc.h"
#include "c-strcase.h"
+#ifdef ENABLE_XATTR
+#include "xattr.h"
+#endif
#ifdef __VMS
# include "vms.h"
@@ -239,7 +242,7 @@ print_length (wgint size, wgint start, bool authoritative)
static uerr_t ftp_get_listing (struct url *, struct url *, ccon *, struct fileinfo **);
static uerr_t
-get_ftp_greeting(int csock, ccon *con)
+get_ftp_greeting (int csock, ccon *con)
{
uerr_t err = 0;
@@ -356,12 +359,35 @@ getftp (struct url *u, struct url *original_url,
*qtyread = restval;
- user = u->user;
- passwd = u->passwd;
- search_netrc (u->host, (const char **)&user, (const char **)&passwd, 1);
- user = user ? user : (opt.ftp_user ? opt.ftp_user : opt.user);
+ /* Find the username with priority */
+ if (u->user)
+ user = u->user;
+ else if (opt.user && (opt.use_askpass || opt.ask_passwd))
+ user = opt.user;
+ else if (opt.ftp_user)
+ user = opt.ftp_user;
+ else if (opt.user)
+ user = opt.user;
+ else
+ user = NULL;
+
+ /* Find the password with priority */
+ if (u->passwd)
+ passwd = u->passwd;
+ else if (opt.passwd && (opt.use_askpass || opt.ask_passwd))
+ passwd = opt.passwd;
+ else if (opt.ftp_passwd)
+ passwd = opt.ftp_passwd;
+ else if (opt.passwd)
+ passwd = opt.passwd;
+ else
+ passwd = NULL;
+
+ /* Check for ~/.netrc if none of the above match */
+ if (opt.netrc && (!user || !passwd))
+ search_netrc (u->host, (const char **) &user, (const char **) &passwd, 1);
+
if (!user) user = "anonymous";
- passwd = passwd ? passwd : (opt.ftp_passwd ? opt.ftp_passwd : opt.passwd);
if (!passwd) passwd = "-wget@";
dtsock = -1;
@@ -535,10 +561,10 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "done.");
if (!opt.server_response)
- logprintf (LOG_VERBOSE, " ==> PROT %c ... ", prot);
+ logprintf (LOG_VERBOSE, " ==> PROT %c ... ", (int) prot);
if ((err = ftp_prot (csock, prot)) == FTPNOPROT)
{
- logprintf (LOG_NOTQUIET, _("Server did not accept the 'PROT %c' command.\n"), prot);
+ logprintf (LOG_NOTQUIET, _("Server did not accept the 'PROT %c' command.\n"), (int) prot);
return err;
}
if (!opt.server_response)
@@ -872,7 +898,7 @@ Error in server response, closing control connection.\n"));
Unlike the rest of this block, this particular behavior
_is_ VMS-specific, so it gets its own VMS test.
*/
- if ((con->rs == ST_VMS) && (strchr( target, '/') != NULL))
+ if ((con->rs == ST_VMS) && (strchr (target, '/') != NULL))
{
cwd_end = 3;
DEBUGP (("Using extra \"CWD []\" step for VMS server.\n"));
@@ -1188,6 +1214,7 @@ Error in server response, closing control connection.\n"));
if (opt.spider)
{
bool exists = false;
+ bool all_exist = true;
struct fileinfo *f;
uerr_t _res = ftp_get_listing (u, original_url, con, &f);
/* Set the DO_RETR command flag again, because it gets unset when
@@ -1203,6 +1230,8 @@ Error in server response, closing control connection.\n"));
{
exists = true;
break;
+ } else {
+ all_exist = false;
}
f = f->next;
}
@@ -1223,7 +1252,11 @@ Error in server response, closing control connection.\n"));
con->csock = -1;
fd_close (dtsock);
fd_close (local_sock);
- return RETRFINISHED;
+ if (all_exist) {
+ return RETRFINISHED;
+ } else {
+ return FTPNSFOD;
+ }
}
if (opt.verbose)
@@ -1546,6 +1579,11 @@ Error in server response, closing control connection.\n"));
tmrate = retr_rate (rd_size, con->dltime);
total_download_time += con->dltime;
+#ifdef ENABLE_XATTR
+ if (opt.enable_xattr)
+ set_file_metadata (u->url, NULL, fp);
+#endif
+
fd_close (local_sock);
/* Close the local file. */
if (!output_stream || con->cmd & DO_LIST)
@@ -1641,10 +1679,10 @@ Error in server response, closing control connection.\n"));
#ifdef __VMS
char *targ;
- targ = ods_conform( con->target);
+ targ = ods_conform (con->target);
if (targ != con->target)
{
- xfree( con->target);
+ xfree (con->target);
con->target = targ;
}
#endif /* def __VMS */
@@ -1788,7 +1826,7 @@ ftp_loop_internal (struct url *u, struct url *original_url, struct fileinfo *f,
char *tms, *locf;
const char *tmrate = NULL;
uerr_t err;
- struct_stat st;
+ struct stat st;
/* Declare WARC variables. */
bool warc_enabled = (opt.warc_filename != NULL);
@@ -2211,7 +2249,7 @@ ftp_retrieve_list (struct url *u, struct url *original_url,
dlthis = true;
if (opt.timestamping && f->type == FT_PLAINFILE)
{
- struct_stat st;
+ struct stat st;
/* If conversion of HTML files retrieved via FTP is ever implemented,
we'll need to stat() <file>.orig here when -K has been specified.
I'm not implementing it now since files on an FTP server are much
@@ -2274,7 +2312,7 @@ The sizes do not match (local %s) -- retrieving.\n\n"),
_("Invalid name of the symlink, skipping.\n"));
else
{
- struct_stat st;
+ struct stat st;
/* Check whether we already have the correct
symbolic link. */
int rc = lstat (con->target, &st);
@@ -2334,6 +2372,7 @@ Already have correct symlink %s -> %s\n\n"),
}
break;
case FT_UNKNOWN:
+ default:
logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"),
quote (f->name));
break;
@@ -2355,7 +2394,12 @@ Already have correct symlink %s -> %s\n\n"),
(f->type == FT_PLAINFILE) && opt.preserve_perm)
{
if (f->perms)
- chmod (actual_target, f->perms);
+ {
+ if (chmod (actual_target, f->perms))
+ logprintf (LOG_NOTQUIET,
+ _("Failed to set permissions for %s.\n"),
+ actual_target);
+ }
else
DEBUGP (("Unrecognized permissions for %s.\n", actual_target));
}
@@ -2503,7 +2547,7 @@ is_invalid_entry (struct fileinfo *f)
while (cur->next)
{
cur = cur->next;
- if (strcmp(f_name, cur->name) == 0)
+ if (strcmp (f_name, cur->name) == 0)
return true;
}
return false;
@@ -2697,7 +2741,7 @@ ftp_loop (struct url *u, struct url *original_url, char **local_file, int *dt,
{
if (!opt.output_document)
{
- struct_stat st;
+ struct stat st;
wgint sz;
if (stat (filename, &st) == 0)
sz = st.st_size;
diff --git a/src/gnutls.c b/src/gnutls.c
index 185304d..3a79594 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -50,7 +50,7 @@ as that of the covered work. */
#include "hash.h"
#include "ssl.h"
-#include <sys/fcntl.h>
+#include <fcntl.h>
#ifdef WIN32
# include "w32sock.h"
@@ -498,7 +498,7 @@ _do_handshake (gnutls_session_t session, int fd, double timeout)
{
gnutls_alert_description_t alert = gnutls_alert_get (session);
const char *str = gnutls_alert_get_name (alert);
- logprintf (LOG_NOTQUIET, "GnuTLS: received alert [%d]: %s\n",
+ logprintf (LOG_NOTQUIET, "GnuTLS: received alert [%u]: %s\n",
alert, str ? str : "(unknown)");
}
}
@@ -556,7 +556,6 @@ ssl_connect_wget (int fd, const char *hostname, int *continue_session)
xfree(sni_hostname);
}
- gnutls_set_default_priority (session);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, credentials);
#ifndef FD_TO_SOCKET
# define FD_TO_SOCKET(X) (X)
@@ -571,7 +570,8 @@ ssl_connect_wget (int fd, const char *hostname, int *continue_session)
switch (opt.secure_protocol)
{
case secure_protocol_auto:
- err = gnutls_priority_set_direct (session, "NORMAL:%COMPAT:-VERS-SSL3.0", NULL);
+ err = gnutls_set_default_priority (session);
+ gnutls_session_enable_compatibility_mode(session);
break;
case secure_protocol_sslv2:
@@ -599,7 +599,8 @@ ssl_connect_wget (int fd, const char *hostname, int *continue_session)
break;
default:
- logprintf (LOG_NOTQUIET, _("GnuTLS: unimplemented 'secure-protocol' option value %d\n"), opt.secure_protocol);
+ logprintf (LOG_NOTQUIET, _("GnuTLS: unimplemented 'secure-protocol' option value %u\n"),
+ (unsigned) opt.secure_protocol);
logprintf (LOG_NOTQUIET, _("Please report this issue to bug-wget@gnu.org\n"));
abort ();
}
@@ -608,6 +609,7 @@ ssl_connect_wget (int fd, const char *hostname, int *continue_session)
switch (opt.secure_protocol)
{
case secure_protocol_auto:
+ err = gnutls_set_default_priority (session);
break;
case secure_protocol_sslv2:
diff --git a/src/hash.c b/src/hash.c
index 4116ca0..bc74c52 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -283,10 +283,10 @@ hash_table_new (int items,
/* Calculate the size that ensures that the table will store at
least ITEMS keys without the need to resize. */
- size = 1 + items / HASH_MAX_FULLNESS;
+ size = (int) (1 + items / HASH_MAX_FULLNESS);
size = prime_size (size, &ht->prime_offset);
ht->size = size;
- ht->resize_threshold = size * HASH_MAX_FULLNESS;
+ ht->resize_threshold = (int) (size * HASH_MAX_FULLNESS);
/*assert (ht->resize_threshold >= items);*/
ht->cells = xnew_array (struct cell, ht->size);
@@ -394,7 +394,7 @@ grow_hash_table (struct hash_table *ht)
#endif
ht->size = newsize;
- ht->resize_threshold = newsize * HASH_MAX_FULLNESS;
+ ht->resize_threshold = (int) (newsize * HASH_MAX_FULLNESS);
cells = xnew_array (struct cell, newsize);
memset (cells, INVALID_PTR_CHAR, newsize * sizeof (struct cell));
diff --git a/src/host.c b/src/host.c
index 414a294..9f551c7 100644
--- a/src/host.c
+++ b/src/host.c
@@ -58,7 +58,7 @@ as that of the covered work. */
#include <errno.h>
#ifdef ENABLE_IRI
-#include <idn-free.h>
+#include <idn2.h>
#endif
#include "utils.h"
@@ -428,14 +428,12 @@ getaddrinfo_with_timeout (const char *node, const char *service,
const char *
print_address (const ip_address *addr)
{
-#ifdef ENABLE_IPV6
static char buf[64];
+
if (!inet_ntop (addr->family, IP_INADDR_DATA (addr), buf, sizeof buf))
snprintf (buf, sizeof buf, "<error: %s>", strerror (errno));
+
return buf;
-#else
- return inet_ntoa (addr->data.d4);
-#endif
}
/* The following two functions were adapted from glibc's
@@ -852,7 +850,7 @@ lookup_host (const char *host, int flags)
str = xmalloc (len);
snprintf (str, len, "%s (%s)", name, host);
str[len-1] = '\0';
- idn_free (name);
+ idn2_free (name);
}
logprintf (LOG_VERBOSE, _("Resolving %s... "),
diff --git a/src/hsts.c b/src/hsts.c
index 4d748ac..91cc527 100644
--- a/src/hsts.c
+++ b/src/hsts.c
@@ -80,7 +80,6 @@ enum hsts_kh_match {
#define DEFAULT_HTTP_PORT 80
#define DEFAULT_SSL_PORT 443
-#define CHECK_EXPLICIT_PORT(p1, p2) (p1 == 0 || p1 == p2)
#define MAKE_EXPLICIT_PORT(s, p) (s == SCHEME_HTTPS ? (p == DEFAULT_SSL_PORT ? 0 : p) \
: (p == DEFAULT_HTTP_PORT ? 0 : p))
@@ -327,7 +326,8 @@ hsts_store_dump (hsts_store_t store, FILE *fp)
if (fprintf (fp, "%s\t%d\t%d\t%lu\t%lu\n",
kh->host, kh->explicit_port, khi->include_subdomains,
- khi->created, khi->max_age) < 0)
+ (unsigned long) khi->created,
+ (unsigned long) khi->max_age) < 0)
{
logprintf (LOG_ALWAYS, "Could not write the HSTS database correctly.\n");
break;
@@ -343,12 +343,20 @@ hsts_store_dump (hsts_store_t store, FILE *fp)
static bool
hsts_file_access_valid (const char *filename)
{
- struct_stat st;
+ struct stat st;
if (stat (filename, &st) == -1)
return false;
- return !(st.st_mode & S_IWOTH) && S_ISREG (st.st_mode);
+ return
+#ifndef WINDOWS
+ /*
+ * The world-writable concept is a Unix-centric notion.
+ * We bypass this test on Windows.
+ */
+ !(st.st_mode & S_IWOTH) &&
+#endif
+ S_ISREG (st.st_mode);
}
/* HSTS API */
@@ -502,7 +510,7 @@ hsts_store_open (const char *filename)
{
if (hsts_file_access_valid (filename))
{
- struct_stat st;
+ struct stat st;
FILE *fp = fopen (filename, "r");
if (!fp || !hsts_read_database (store, fp, false))
@@ -510,7 +518,8 @@ hsts_store_open (const char *filename)
/* abort! */
hsts_store_close (store);
xfree (store);
- fclose (fp);
+ if (fp)
+ fclose (fp);
goto out;
}
@@ -540,7 +549,7 @@ out:
void
hsts_store_save (hsts_store_t store, const char *filename)
{
- struct_stat st;
+ struct stat st;
FILE *fp = NULL;
int fd = 0;
@@ -790,9 +799,9 @@ test_hsts_read_database (void)
if (fp)
{
fputs ("# dummy comment\n", fp);
- fprintf (fp, "foo.example.com\t0\t1\t%ld\t123\n",(long) created);
- fprintf (fp, "bar.example.com\t0\t0\t%ld\t456\n", (long) created);
- fprintf (fp, "test.example.com\t8080\t0\t%ld\t789\n", (long) created);
+ fprintf (fp, "foo.example.com\t0\t1\t%lu\t123\n",(unsigned long) created);
+ fprintf (fp, "bar.example.com\t0\t0\t%lu\t456\n", (unsigned long) created);
+ fprintf (fp, "test.example.com\t8080\t0\t%lu\t789\n", (unsigned long) created);
fclose (fp);
table = hsts_store_open (file);
diff --git a/src/html-parse.c b/src/html-parse.c
index 42d4bd2..ae436d0 100644
--- a/src/html-parse.c
+++ b/src/html-parse.c
@@ -801,14 +801,6 @@ name_allowed (const struct hash_table *ht, const char *b, const char *e)
} \
} while (0)
-/* Skip non-whitespace, if any. */
-
-#define SKIP_NON_WS(p) do { \
- while (!c_isspace (*p)) { \
- ADVANCE (p); \
- } \
-} while (0)
-
#ifdef STANDALONE
static int tag_backout_count;
#endif
diff --git a/src/html-url.c b/src/html-url.c
index abc916b..98502dd 100644
--- a/src/html-url.c
+++ b/src/html-url.c
@@ -729,8 +729,11 @@ tag_handle_img (int tagid, struct taginfo *tag, struct map_context *ctx) {
srcset + url_end);
struct urlpos *up = append_url (url_text, base_ind + url_start,
url_end - url_start, ctx);
- up->link_inline_p = 1;
- up->link_noquote_html_p = 1;
+ if (up)
+ {
+ up->link_inline_p = 1;
+ up->link_noquote_html_p = 1;
+ }
xfree (url_text);
}
@@ -842,6 +845,7 @@ get_urls_html (const char *file, const char *url, bool *meta_disallow_follow,
if (iri && !iri->content_encoding && meta_charset)
set_content_encoding (iri, meta_charset);
#endif
+ xfree (meta_charset);
DEBUGP (("no-follow in %s: %d\n", file, ctx.nofollow));
if (meta_disallow_follow)
diff --git a/src/http-ntlm.c b/src/http-ntlm.c
index 56c40ae..87f5a37 100644
--- a/src/http-ntlm.c
+++ b/src/http-ntlm.c
@@ -122,7 +122,7 @@ ntlm_input (struct ntlmdata *ntlm, const char *header)
DEBUGP (("Received a type-2 NTLM message.\n"));
- size = base64_decode (header, buffer);
+ size = wget_base64_decode (header, buffer);
if (size < 0)
return false; /* malformed base64 from server */
@@ -411,7 +411,7 @@ ntlm_output (struct ntlmdata *ntlm, const char *user, const char *passwd,
size = 32 + hostlen + domlen;
base64 = (char *) alloca (BASE64_LENGTH (size) + 1);
- base64_encode (ntlmbuf, size, base64);
+ wget_base64_encode (ntlmbuf, size, base64);
output = concat_strings ("NTLM ", base64, (char *) 0);
break;
@@ -584,7 +584,7 @@ ntlm_output (struct ntlmdata *ntlm, const char *user, const char *passwd,
/* convert the binary blob into base64 */
base64 = (char *) alloca (BASE64_LENGTH (size) + 1);
- base64_encode (ntlmbuf, size, base64);
+ wget_base64_encode (ntlmbuf, size, base64);
output = concat_strings ("NTLM ", base64, (char *) 0);
diff --git a/src/http.c b/src/http.c
index 7e60a07..bd1f115 100644
--- a/src/http.c
+++ b/src/http.c
@@ -39,6 +39,7 @@ as that of the covered work. */
#include <errno.h>
#include <time.h>
#include <locale.h>
+#include <fcntl.h>
#include "hash.h"
#include "http.h"
@@ -66,6 +67,9 @@ as that of the covered work. */
# include "metalink.h"
# include "xstrndup.h"
#endif
+#ifdef ENABLE_XATTR
+#include "xattr.h"
+#endif
#ifdef TESTING
#include "test.h"
@@ -341,7 +345,7 @@ request_send (const struct request *req, int fd, FILE *warc_tmp)
/* "\r\n\0" */
size += 3;
- p = request_string = alloca_array (char, size);
+ p = request_string = xmalloc (size);
/* Generate the request. */
@@ -376,8 +380,9 @@ request_send (const struct request *req, int fd, FILE *warc_tmp)
/* Write a copy of the data to the WARC record. */
int warc_tmp_written = fwrite (request_string, 1, size - 1, warc_tmp);
if (warc_tmp_written != size - 1)
- return -2;
+ write_error = -2;
}
+ xfree (request_string);
return write_error;
}
@@ -420,7 +425,7 @@ maybe_send_basic_creds (const char *hostname, const char *user,
do_challenge = true;
}
else if (basic_authed_hosts
- && hash_table_contains(basic_authed_hosts, hostname))
+ && hash_table_contains (basic_authed_hosts, hostname))
{
DEBUGP (("Found %s in basic_authed_hosts.\n", quote (hostname)));
do_challenge = true;
@@ -446,9 +451,9 @@ register_basic_auth_host (const char *hostname)
{
basic_authed_hosts = make_nocase_string_hash_table (1);
}
- if (!hash_table_contains(basic_authed_hosts, hostname))
+ if (!hash_table_contains (basic_authed_hosts, hostname))
{
- hash_table_put (basic_authed_hosts, xstrdup(hostname), NULL);
+ hash_table_put (basic_authed_hosts, xstrdup (hostname), NULL);
DEBUGP (("Inserted %s into basic_authed_hosts\n", quote (hostname)));
}
}
@@ -846,7 +851,7 @@ resp_free (struct response **resp_ref)
caused crashes in UTF-8 locales. */
static void
-print_response_line(const char *prefix, const char *b, const char *e)
+print_response_line (const char *prefix, const char *b, const char *e)
{
char *copy;
BOUNDED_TO_ALLOCA(b, e, copy);
@@ -872,7 +877,7 @@ print_server_response (const struct response *resp, const char *prefix)
--e;
if (b < e && e[-1] == '\r')
--e;
- print_response_line(prefix, b, e);
+ print_response_line (prefix, b, e);
}
}
@@ -1026,18 +1031,18 @@ skip_short_body (int fd, wgint contlen, bool chunked)
or a fragment of a long parameter value
*/
static int
-modify_param_name(param_token *name)
+modify_param_name (param_token *name)
{
const char *delim1 = memchr (name->b, '*', name->e - name->b);
const char *delim2 = memrchr (name->b, '*', name->e - name->b);
int result;
- if(delim1 == NULL)
+ if (delim1 == NULL)
{
result = NOT_RFC2231;
}
- else if(delim1 == delim2)
+ else if (delim1 == delim2)
{
if ((name->e - 1) == delim1)
{
@@ -1155,12 +1160,12 @@ extract_param (const char **source, param_token *name, param_token *value,
}
*source = p;
- param_type = modify_param_name(name);
+ param_type = modify_param_name (name);
if (param_type != NOT_RFC2231)
{
if (param_type == RFC2231_ENCODING && is_url_encoded)
*is_url_encoded = true;
- modify_param_value(value, param_type);
+ modify_param_value (value, param_type);
}
return true;
}
@@ -1175,8 +1180,8 @@ static void
append_value_to_filename (char **filename, param_token const * const value,
bool is_url_encoded)
{
- int original_length = strlen(*filename);
- int new_length = strlen(*filename) + (value->e - value->b);
+ int original_length = strlen (*filename);
+ int new_length = strlen (*filename) + (value->e - value->b);
*filename = xrealloc (*filename, new_length+1);
memcpy (*filename + original_length, value->b, (value->e - value->b));
(*filename)[new_length] = '\0';
@@ -1281,7 +1286,7 @@ parse_strict_transport_security (const char *header, time_t *max_age, bool *incl
{
if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, "max-age"))
{
- xfree(c_max_age);
+ xfree (c_max_age);
c_max_age = strdupdelim (value.b, value.e);
}
else if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, "includeSubDomains"))
@@ -1564,6 +1569,7 @@ struct http_stat
#ifdef HAVE_METALINK
metalink_t *metalink;
#endif
+ bool temporary; /* downloading a temporary file */
};
static void
@@ -1805,7 +1811,7 @@ time_to_rfc1123 (time_t time, char *buf, size_t bufsize)
}
static struct request *
-initialize_request (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
+initialize_request (const struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
bool inhibit_keep_alive, bool *basic_auth_finished,
wgint *body_data_size, char **user, char **passwd, uerr_t *ret)
{
@@ -1869,21 +1875,42 @@ initialize_request (struct url *u, struct http_stat *hs, int *dt, struct url *pr
request_set_header (req, "Accept", "*/*", rel_none);
request_set_header (req, "Accept-Encoding", "identity", rel_none);
- /* Find the username and password for authentication. */
- *user = u->user;
- *passwd = u->passwd;
- search_netrc (u->host, (const char **)user, (const char **)passwd, 0);
- *user = *user ? *user : (opt.http_user ? opt.http_user : opt.user);
- *passwd = *passwd ? *passwd : (opt.http_passwd ? opt.http_passwd : opt.passwd);
+ /* Find the username with priority */
+ if (u->user)
+ *user = u->user;
+ else if (opt.user && (opt.use_askpass || opt.ask_passwd))
+ *user = opt.user;
+ else if (opt.http_user)
+ *user = opt.http_user;
+ else if (opt.user)
+ *user = opt.user;
+ else
+ *user = NULL;
+
+ /* Find the password with priority */
+ if (u->passwd)
+ *passwd = u->passwd;
+ else if (opt.passwd && (opt.use_askpass || opt.ask_passwd))
+ *passwd = opt.passwd;
+ else if (opt.http_passwd)
+ *passwd = opt.http_passwd;
+ else if (opt.passwd)
+ *passwd = opt.passwd;
+ else
+ *passwd = NULL;
+
+ /* Check for ~/.netrc if none of the above match */
+ if (opt.netrc && (!user || !passwd))
+ search_netrc (u->host, (const char **) user, (const char **) passwd, 0);
/* We only do "site-wide" authentication with "global" user/password
* values unless --auth-no-challange has been requested; URL user/password
* info overrides. */
- if (user && *passwd && (!u->user || opt.auth_without_challenge))
+ if (*user && *passwd && (!u->user || opt.auth_without_challenge))
{
/* If this is a host for which we've already received a Basic
* challenge, we'll go ahead and send Basic authentication creds. */
- *basic_auth_finished = maybe_send_basic_creds(u->host, *user, *passwd, req);
+ *basic_auth_finished = maybe_send_basic_creds (u->host, *user, *passwd, req);
}
/* Generate the Host header, HOST:PORT. Take into account that:
@@ -1951,7 +1978,7 @@ initialize_request (struct url *u, struct http_stat *hs, int *dt, struct url *pr
}
static void
-initialize_proxy_configuration (struct url *u, struct request *req,
+initialize_proxy_configuration (const struct url *u, struct request *req,
struct url *proxy, char **proxyauth)
{
char *proxy_user, *proxy_passwd;
@@ -1983,7 +2010,7 @@ initialize_proxy_configuration (struct url *u, struct request *req,
}
static uerr_t
-establish_connection (struct url *u, struct url **conn_ref,
+establish_connection (const struct url *u, const struct url **conn_ref,
struct http_stat *hs, struct url *proxy,
char **proxyauth,
struct request **req_ref, bool *using_ssl,
@@ -1993,7 +2020,7 @@ establish_connection (struct url *u, struct url **conn_ref,
bool host_lookup_failed = false;
int sock = *sock_ref;
struct request *req = *req_ref;
- struct url *conn = *conn_ref;
+ const struct url *conn = *conn_ref;
struct response *resp;
int write_error;
int statcode;
@@ -2004,7 +2031,7 @@ establish_connection (struct url *u, struct url **conn_ref,
proxy is used. The exception is when SSL is in use, in which
case the proxy is nothing but a passthrough to the target
host, registered as a connection to the latter. */
- struct url *relevant = conn;
+ const struct url *relevant = conn;
#ifdef HAVE_SSL
if (u->scheme == SCHEME_HTTPS)
relevant = u;
@@ -2119,7 +2146,7 @@ establish_connection (struct url *u, struct url **conn_ref,
xfree (head);
return HERR;
}
- xfree(hs->message);
+ xfree (hs->message);
hs->message = xstrdup (message);
resp_free (&resp);
xfree (head);
@@ -2168,7 +2195,7 @@ set_file_timestamp (struct http_stat *hs)
char *filename_plus_orig_suffix = alloca (filename_len + sizeof (ORIG_SFX));
bool local_dot_orig_file_exists = false;
char *local_filename = NULL;
- struct_stat st;
+ struct stat st;
if (opt.backup_converted)
/* If -K is specified, we'll act on the assumption that it was specified
@@ -2225,7 +2252,7 @@ set_file_timestamp (struct http_stat *hs)
}
static uerr_t
-check_file_output (struct url *u, struct http_stat *hs,
+check_file_output (const struct url *u, struct http_stat *hs,
struct response *resp, char *hdrval, size_t hdrsize)
{
/* Determine the local filename if needed. Notice that if -O is used
@@ -2254,6 +2281,14 @@ check_file_output (struct url *u, struct http_stat *hs,
xfree (local_file);
}
+ hs->temporary = opt.delete_after || opt.spider || !acceptable (hs->local_file);
+ if (hs->temporary)
+ {
+ char *tmp = aprintf ("%s.tmp", hs->local_file);
+ xfree (hs->local_file);
+ hs->local_file = tmp;
+ }
+
/* TODO: perform this check only once. */
if (!hs->existence_checked && file_exists_p (hs->local_file))
{
@@ -2285,7 +2320,7 @@ check_file_output (struct url *u, struct http_stat *hs,
}
static uerr_t
-check_auth (struct url *u, char *user, char *passwd, struct response *resp,
+check_auth (const struct url *u, char *user, char *passwd, struct response *resp,
struct request *req, bool *ntlm_seen_ref, bool *retry,
bool *basic_auth_finished_ref, bool *auth_finished_ref)
{
@@ -2467,7 +2502,15 @@ open_output_stream (struct http_stat *hs, int count, FILE **fp)
open_id = 22;
*fp = fopen (hs->local_file, "wb", FOPEN_OPT_ARGS);
#else /* def __VMS */
- *fp = fopen (hs->local_file, "wb");
+ if (hs->temporary)
+ {
+ *fp = fdopen (open (hs->local_file, O_BINARY | O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR), "wb");
+ }
+ else
+ {
+ *fp = fopen (hs->local_file, "wb");
+ }
+
#endif /* def __VMS [else] */
}
else
@@ -2533,7 +2576,7 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
metalink_t *metalink = NULL;
metalink_file_t *mfile = xnew0 (metalink_file_t);
const char *val_beg, *val_end;
- int res_count = 0, hash_count = 0, sig_count = 0, i;
+ int res_count = 0, meta_count = 0, hash_count = 0, sig_count = 0, i;
DEBUGP (("Checking for Metalink in HTTP response\n"));
@@ -2546,6 +2589,88 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
/* Begin with 1-element array (for 0-termination). */
mfile->checksums = xnew0 (metalink_checksum_t *);
mfile->resources = xnew0 (metalink_resource_t *);
+ mfile->metaurls = xnew0 (metalink_metaurl_t *);
+
+ /* Process the Content-Type header. */
+ if (resp_header_locate (resp, "Content-Type", 0, &val_beg, &val_end) != -1)
+ {
+ metalink_metaurl_t murl = {0};
+
+ const char *type_beg, *type_end;
+ char *typestr = NULL;
+ char *namestr = NULL;
+ size_t type_len;
+
+ DEBUGP (("Processing Content-Type header...\n"));
+
+ /* Find beginning of type. */
+ type_beg = val_beg;
+ while (type_beg < val_end && c_isspace (*type_beg))
+ type_beg++;
+
+ /* Find end of type. */
+ type_end = type_beg + 1;
+ while (type_end < val_end &&
+ *type_end != ';' &&
+ *type_end != ' ' &&
+ *type_end != '\r' &&
+ *type_end != '\n')
+ type_end++;
+
+ if (type_beg >= val_end || type_end > val_end)
+ {
+ DEBUGP (("Invalid Content-Type header. Ignoring.\n"));
+ goto skip_content_type;
+ }
+
+ type_len = type_end - type_beg;
+ typestr = xstrndup (type_beg, type_len);
+
+ DEBUGP (("Content-Type: %s\n", typestr));
+
+ if (strcmp (typestr, "application/metalink4+xml"))
+ {
+ xfree (typestr);
+ goto skip_content_type;
+ }
+
+ /*
+ Valid ranges for the "pri" attribute are from
+ 1 to 999999. Mirror servers with a lower value of the "pri"
+ attribute have a higher priority, while mirrors with an undefined
+ "pri" attribute are considered to have a value of 999999, which is
+ the lowest priority.
+
+ rfc6249 section 3.1
+ */
+ murl.priority = DEFAULT_PRI;
+
+ murl.mediatype = typestr;
+ typestr = NULL;
+
+ if (opt.content_disposition
+ && resp_header_locate (resp, "Content-Disposition", 0, &val_beg, &val_end) != -1)
+ {
+ find_key_value (val_beg, val_end, "filename", &namestr);
+ murl.name = namestr;
+ namestr = NULL;
+ }
+
+ murl.url = xstrdup (u->url);
+
+ DEBUGP (("URL=%s\n", murl.url));
+ DEBUGP (("MEDIATYPE=%s\n", murl.mediatype));
+ DEBUGP (("NAME=%s\n", murl.name ? murl.name : ""));
+ DEBUGP (("PRIORITY=%d\n", murl.priority));
+
+ /* 1 slot from new resource, 1 slot for null-termination. */
+ mfile->metaurls = xrealloc (mfile->metaurls,
+ sizeof (metalink_metaurl_t *) * (meta_count + 2));
+ mfile->metaurls[meta_count] = xnew0 (metalink_metaurl_t);
+ *mfile->metaurls[meta_count] = murl;
+ meta_count++;
+ }
+skip_content_type:
/* Find all Link headers. */
for (i = 0;
@@ -2606,14 +2731,14 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
DEBUGP (("URL=%s\n", urlstr));
DEBUGP (("rel=%s\n", rel));
+ if (!strcmp (rel, "describedby"))
+ find_key_value (attrs_beg, val_end, "type", &reltype);
+
/* Handle signatures.
Libmetalink only supports one signature per file. Therefore we stop
as soon as we successfully get first supported signature. */
if (sig_count == 0 &&
- !strcmp (rel, "describedby") &&
- find_key_value (attrs_beg, val_end, "type", &reltype) &&
- !strcmp (reltype, "application/pgp-signature")
- )
+ reltype && !strcmp (reltype, "application/pgp-signature"))
{
/* Download the signature to a temporary file. */
FILE *_output_stream = output_stream;
@@ -2779,6 +2904,60 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
res_count++;
}
} /* Handle resource link (rel=duplicate). */
+
+ /* Handle Metalink/XML resources. */
+ else if (reltype && !strcmp (reltype, "application/metalink4+xml"))
+ {
+ metalink_metaurl_t murl = {0};
+ char *pristr;
+
+ /*
+ Valid ranges for the "pri" attribute are from
+ 1 to 999999. Mirror servers with a lower value of the "pri"
+ attribute have a higher priority, while mirrors with an undefined
+ "pri" attribute are considered to have a value of 999999, which is
+ the lowest priority.
+
+ rfc6249 section 3.1
+ */
+ murl.priority = DEFAULT_PRI;
+ if (find_key_value (url_end, val_end, "pri", &pristr))
+ {
+ long pri;
+ char *end_pristr;
+ /* Do not care for errno since 0 is error in this case. */
+ pri = strtol (pristr, &end_pristr, 10);
+ if (end_pristr != pristr + strlen (pristr) ||
+ !VALID_PRI_RANGE (pri))
+ {
+ /* This is against the specification, so let's inform the user. */
+ logprintf (LOG_NOTQUIET,
+ _("Invalid pri value. Assuming %d.\n"),
+ DEFAULT_PRI);
+ }
+ else
+ murl.priority = pri;
+ xfree (pristr);
+ }
+
+ murl.mediatype = xstrdup (reltype);
+
+ DEBUGP (("MEDIATYPE=%s\n", murl.mediatype));
+
+ /* At this point we have validated the new resource. */
+
+ find_key_value (url_end, val_end, "name", &murl.name);
+
+ murl.url = urlstr;
+ urlstr = NULL;
+
+ /* 1 slot from new resource, 1 slot for null-termination. */
+ mfile->metaurls = xrealloc (mfile->metaurls,
+ sizeof (metalink_metaurl_t *) * (meta_count + 2));
+ mfile->metaurls[meta_count] = xnew0 (metalink_metaurl_t);
+ *mfile->metaurls[meta_count] = murl;
+ meta_count++;
+ } /* Handle resource link (rel=describedby). */
else
DEBUGP (("This link header was not used for Metalink\n"));
@@ -2789,8 +2968,9 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
/* Null-terminate resources array. */
mfile->resources[res_count] = 0;
+ mfile->metaurls[meta_count] = 0;
- if (res_count == 0)
+ if (res_count == 0 && meta_count == 0)
{
DEBUGP (("No valid metalink references found.\n"));
goto fail;
@@ -2816,9 +2996,17 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
Therefore we convert: base64 -> binary -> hex. */
const size_t dig_hash_str_len = strlen (dig_hash);
char *bin_hash = alloca (dig_hash_str_len * 3 / 4 + 1);
- size_t hash_bin_len;
+ ssize_t hash_bin_len;
- hash_bin_len = base64_decode (dig_hash, bin_hash);
+ hash_bin_len = wget_base64_decode (dig_hash, bin_hash);
+
+ /* Detect malformed base64 input. */
+ if (hash_bin_len < 0)
+ {
+ xfree (dig_type);
+ xfree (dig_hash);
+ continue;
+ }
/* One slot for me, one for zero-termination. */
mfile->checksums =
@@ -2827,8 +3015,8 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
mfile->checksums[hash_count] = xnew (metalink_checksum_t);
mfile->checksums[hash_count]->type = dig_type;
- mfile->checksums[hash_count]->hash = xmalloc (hash_bin_len * 2 + 1);
- wg_hex_to_string (mfile->checksums[hash_count]->hash, bin_hash, hash_bin_len);
+ mfile->checksums[hash_count]->hash = xmalloc ((size_t)hash_bin_len * 2 + 1);
+ wg_hex_to_string (mfile->checksums[hash_count]->hash, bin_hash, (size_t)hash_bin_len);
xfree (dig_hash);
@@ -2845,7 +3033,7 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
rfc6249 section 6
*/
- if (hash_count == 0)
+ if (res_count && hash_count == 0)
{
logputs (LOG_VERBOSE,
_("Could not find acceptable digest for Metalink resources.\n"
@@ -2856,6 +3044,7 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
/* Metalink data is OK. Now we just need to sort the resources based
on their priorities, preference, and perhaps location. */
stable_sort (mfile->resources, res_count, sizeof (metalink_resource_t *), metalink_res_cmp);
+ stable_sort (mfile->metaurls, meta_count, sizeof (metalink_metaurl_t *), metalink_meta_cmp);
/* Restore sensible preference values (in case someone cares to look). */
for (i = 0; i < res_count; ++i)
@@ -2892,8 +3081,8 @@ fail:
If PROXY is non-NULL, the connection will be made to the proxy
server, and u->url will be requested. */
static uerr_t
-gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
- struct iri *iri, int count)
+gethttp (const struct url *u, struct url *original_url, struct http_stat *hs,
+ int *dt, struct url *proxy, struct iri *iri, int count)
{
struct request *req = NULL;
@@ -2903,7 +3092,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
int statcode;
int write_error;
wgint contlen, contrange;
- struct url *conn;
+ const struct url *conn;
FILE *fp;
int err;
uerr_t retval;
@@ -2997,7 +3186,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
hs->res = -1;
hs->rderrmsg = NULL;
hs->newloc = NULL;
- xfree(hs->remote_time);
+ xfree (hs->remote_time);
hs->error = NULL;
hs->message = NULL;
@@ -3136,7 +3325,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
bool warc_result;
/* Generate a timestamp and uuid for this request. */
- warc_timestamp (warc_timestamp_str, sizeof(warc_timestamp_str));
+ warc_timestamp (warc_timestamp_str, sizeof (warc_timestamp_str));
warc_uuid_str (warc_request_uuid);
/* Create a request record and store it in the WARC file. */
@@ -3182,7 +3371,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
resp = resp_new (head);
/* Check for status line. */
- xfree(message);
+ xfree (message);
statcode = resp_status (resp, &message);
if (statcode < 0)
{
@@ -3211,7 +3400,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
while (_repeat);
}
- xfree(hs->message);
+ xfree (hs->message);
hs->message = xstrdup (message);
if (!opt.server_response)
logprintf (LOG_VERBOSE, "%2d %s\n", statcode,
@@ -3291,6 +3480,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
if (metalink)
{
hs->metalink = metalink_from_http (resp, hs, u);
+ /* Bugfix: hs->local_file is NULL (opt.content_disposition). */
+ if (!hs->local_file && hs->metalink && hs->metalink->origin)
+ hs->local_file = xstrdup (hs->metalink->origin);
xfree (hs->message);
retval = RETR_WITH_METALINK;
CLOSE_FINISH (sock);
@@ -3403,16 +3595,16 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
{
/* process strict transport security */
if (hsts_store_entry (hsts_store, u->scheme, u->host, u->port, max_age, include_subdomains))
- DEBUGP(("Added new HSTS host: %s:%u (max-age: %u, includeSubdomains: %s)\n",
+ DEBUGP(("Added new HSTS host: %s:%u (max-age: %lu, includeSubdomains: %s)\n",
u->host,
- u->port,
- (unsigned int) max_age,
+ (unsigned) u->port,
+ (unsigned long) max_age,
(include_subdomains ? "true" : "false")));
else
- DEBUGP(("Updated HSTS host: %s:%u (max-age: %u, includeSubdomains: %s)\n",
+ DEBUGP(("Updated HSTS host: %s:%u (max-age: %lu, includeSubdomains: %s)\n",
u->host,
- u->port,
- (unsigned int) max_age,
+ (unsigned) u->port,
+ (unsigned long) max_age,
(include_subdomains ? "true" : "false")));
}
}
@@ -3440,7 +3632,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
tmp = parse_charset (tmp2);
if (tmp)
set_content_encoding (iri, tmp);
- xfree(tmp);
+ xfree (tmp);
}
#endif
}
@@ -3646,7 +3838,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
goto cleanup;
}
if ((contrange != 0 && contrange != hs->restval)
- || (H_PARTIAL (statcode) && !contrange))
+ || (H_PARTIAL (statcode) && !contrange && hs->restval))
{
/* The Range request was somehow misunderstood by the server.
Bail out. */
@@ -3754,6 +3946,16 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
goto cleanup;
}
+#ifdef ENABLE_XATTR
+ if (opt.enable_xattr)
+ {
+ if (original_url != u)
+ set_file_metadata (u->url, original_url->url, fp);
+ else
+ set_file_metadata (u->url, NULL, fp);
+ }
+#endif
+
err = read_response_body (hs, sock, fp, contlen, contrange,
chunked_transfer_encoding,
u->url, warc_timestamp_str,
@@ -3783,7 +3985,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
/* The genuine HTTP loop! This is the part where the retrieval is
retried, and retried, and retried, and... */
uerr_t
-http_loop (struct url *u, struct url *original_url, char **newloc,
+http_loop (const struct url *u, struct url *original_url, char **newloc,
char **local_file, const char *referer, int *dt, struct url *proxy,
struct iri *iri)
{
@@ -3796,7 +3998,7 @@ http_loop (struct url *u, struct url *original_url, char **newloc,
uerr_t err, ret = TRYLIMEXC;
time_t tmr = -1; /* remote time-stamp */
struct http_stat hstat; /* HTTP status */
- struct_stat st;
+ struct stat st;
bool send_head_first = true;
bool force_full_retrieve = false;
@@ -3972,7 +4174,7 @@ http_loop (struct url *u, struct url *original_url, char **newloc,
*dt &= ~SEND_NOCACHE;
/* Try fetching the document, or at least its head. */
- err = gethttp (u, &hstat, dt, proxy, iri, count);
+ err = gethttp (u, original_url, &hstat, dt, proxy, iri, count);
/* Time? */
tms = datetime_str (time (NULL));
@@ -4400,7 +4602,10 @@ exit:
if ((ret == RETROK || opt.content_on_error) && local_file)
{
xfree (*local_file);
- *local_file = xstrdup (hstat.local_file);
+ /* Bugfix: Prevent SIGSEGV when hstat.local_file was left NULL
+ (i.e. due to opt.content_disposition). */
+ if (hstat.local_file)
+ *local_file = xstrdup (hstat.local_file);
}
free_hstat (&hstat);
@@ -4546,7 +4751,7 @@ basic_authentication_encode (const char *user, const char *passwd)
sprintf (t1, "%s:%s", user, passwd);
t2 = (char *)alloca (BASE64_LENGTH (len1) + 1);
- base64_encode (t1, len1, t2);
+ wget_base64_encode (t1, len1, t2);
return concat_strings ("Basic ", t2, (char *) 0);
}
@@ -4593,7 +4798,7 @@ digest_authentication_encode (const char *au, const char *user,
{ "algorithm", &algorithm }
};
char cnonce[16] = "";
- char *res;
+ char *res = NULL;
int res_len;
size_t res_size;
param_token name, value;
@@ -4616,29 +4821,22 @@ digest_authentication_encode (const char *au, const char *user,
}
}
- if (qop != NULL && strcmp(qop,"auth"))
+ if (qop && strcmp (qop, "auth"))
{
logprintf (LOG_NOTQUIET, _("Unsupported quality of protection '%s'.\n"), qop);
- xfree (qop); /* force freeing mem and return */
+ xfree (qop); /* force freeing mem and continue */
}
- else if (algorithm != NULL && strcmp (algorithm,"MD5") && strcmp (algorithm,"MD5-sess"))
+ else if (algorithm && strcmp (algorithm,"MD5") && strcmp (algorithm,"MD5-sess"))
{
logprintf (LOG_NOTQUIET, _("Unsupported algorithm '%s'.\n"), algorithm);
- xfree (qop); /* force freeing mem and return */
+ xfree (algorithm); /* force freeing mem and continue */
}
if (!realm || !nonce || !user || !passwd || !path || !method)
{
*auth_err = ATTRMISSING;
-
- xfree (realm);
- xfree (opaque);
- xfree (nonce);
- xfree (qop);
- xfree (algorithm);
-
- return NULL;
- }
+ goto cleanup;
+ }
/* Calculate the digest value. */
{
@@ -4661,7 +4859,8 @@ digest_authentication_encode (const char *au, const char *user,
if (algorithm && !strcmp (algorithm, "MD5-sess"))
{
/* A1BUF = H( H(user ":" realm ":" password) ":" nonce ":" cnonce ) */
- snprintf (cnonce, sizeof (cnonce), "%08x", random_number(INT_MAX));
+ snprintf (cnonce, sizeof (cnonce), "%08x",
+ (unsigned) random_number (INT_MAX));
md5_init_ctx (&ctx);
/* md5_process_bytes (hash, MD5_DIGEST_SIZE, &ctx); */
@@ -4683,12 +4882,13 @@ digest_authentication_encode (const char *au, const char *user,
md5_finish_ctx (&ctx, hash);
dump_hash (a2buf, hash);
- if (qop && !strcmp(qop, "auth"))
+ if (qop && !strcmp (qop, "auth"))
{
/* RFC 2617 Digest Access Authentication */
/* generate random hex string */
if (!*cnonce)
- snprintf(cnonce, sizeof(cnonce), "%08x", random_number(INT_MAX));
+ snprintf (cnonce, sizeof (cnonce), "%08x",
+ (unsigned) random_number (INT_MAX));
/* RESPONSE_DIGEST = H(A1BUF ":" nonce ":" noncecount ":" clientnonce ":" qop ": " A2BUF) */
md5_init_ctx (&ctx);
@@ -4698,9 +4898,9 @@ digest_authentication_encode (const char *au, const char *user,
md5_process_bytes ((unsigned char *)":", 1, &ctx);
md5_process_bytes ((unsigned char *)"00000001", 8, &ctx); /* TODO: keep track of server nonce values */
md5_process_bytes ((unsigned char *)":", 1, &ctx);
- md5_process_bytes ((unsigned char *)cnonce, strlen(cnonce), &ctx);
+ md5_process_bytes ((unsigned char *)cnonce, strlen (cnonce), &ctx);
md5_process_bytes ((unsigned char *)":", 1, &ctx);
- md5_process_bytes ((unsigned char *)qop, strlen(qop), &ctx);
+ md5_process_bytes ((unsigned char *)qop, strlen (qop), &ctx);
md5_process_bytes ((unsigned char *)":", 1, &ctx);
md5_process_bytes ((unsigned char *)a2buf, MD5_DIGEST_SIZE * 2, &ctx);
md5_finish_ctx (&ctx, hash);
@@ -4750,15 +4950,16 @@ digest_authentication_encode (const char *au, const char *user,
if (opaque)
{
- res_len += snprintf(res + res_len, res_size - res_len, ", opaque=\"%s\"", opaque);
+ res_len += snprintf (res + res_len, res_size - res_len, ", opaque=\"%s\"", opaque);
}
if (algorithm)
{
- snprintf(res + res_len, res_size - res_len, ", algorithm=\"%s\"", algorithm);
+ snprintf (res + res_len, res_size - res_len, ", algorithm=\"%s\"", algorithm);
}
}
+cleanup:
xfree (realm);
xfree (opaque);
xfree (nonce);
@@ -4904,7 +5105,7 @@ ensure_extension (struct http_stat *hs, const char *ext, int *dt)
#ifdef TESTING
const char *
-test_parse_range_header(void)
+test_parse_range_header (void)
{
unsigned i;
static const struct {
@@ -4922,8 +5123,10 @@ test_parse_range_header(void)
{ "bytes 1-999/1000", 1, 999, 1000, true },
{ "bytes 42-1233/1234", 42, 1233, 1234, true },
{ "bytes 42-1233/*", 42, 1233, -1, true },
- { "bytes 0-2147483648/2147483649", 0, 2147483648, 2147483649, true },
- { "bytes 2147483648-4294967296/4294967297", 2147483648, 4294967296, 4294967297, true }
+ { "bytes 0-2147483648/2147483649", 0, 2147483648U, 2147483649U, true },
+#if SIZEOF_WGINT >= 8
+ { "bytes 2147483648-4294967296/4294967297", 2147483648U, 4294967296ULL, 4294967297ULL, true },
+#endif
};
wgint firstbyteptr[sizeof(wgint)];
@@ -4949,7 +5152,7 @@ test_parse_range_header(void)
}
const char *
-test_parse_content_disposition(void)
+test_parse_content_disposition (void)
{
unsigned i;
static const struct {
@@ -4971,7 +5174,7 @@ test_parse_content_disposition(void)
filename*1=\"B\"", "AA.ext", true },
};
- for (i = 0; i < countof(test_array); ++i)
+ for (i = 0; i < countof (test_array); ++i)
{
char *filename;
bool res;
diff --git a/src/http.h b/src/http.h
index 71cb0f0..1e8218f 100644
--- a/src/http.h
+++ b/src/http.h
@@ -35,7 +35,7 @@ as that of the covered work. */
struct url;
-uerr_t http_loop (struct url *, struct url *, char **, char **, const char *,
+uerr_t http_loop (const struct url *, struct url *, char **, char **, const char *,
int *, struct url *, struct iri *);
void save_cookies (void);
void http_cleanup (void);
diff --git a/src/init.c b/src/init.c
index d043d83..271bc77 100644
--- a/src/init.c
+++ b/src/init.c
@@ -97,6 +97,8 @@ CMD_DECLARE (cmd_directory);
CMD_DECLARE (cmd_time);
CMD_DECLARE (cmd_vector);
+CMD_DECLARE (cmd_use_askpass);
+
CMD_DECLARE (cmd_spec_dirstruct);
CMD_DECLARE (cmd_spec_header);
CMD_DECLARE (cmd_spec_warc_header);
@@ -210,7 +212,7 @@ static const struct {
{ "header", NULL, cmd_spec_header },
#ifdef HAVE_HSTS
{ "hsts", &opt.hsts, cmd_boolean },
- { "hsts-file", &opt.hsts_file, cmd_file },
+ { "hstsfile", &opt.hsts_file, cmd_file },
#endif
{ "htmlextension", &opt.adjust_extension, cmd_boolean }, /* deprecated */
{ "htmlify", NULL, cmd_spec_htmlify },
@@ -223,7 +225,7 @@ static const struct {
#endif
{ "httpsproxy", &opt.https_proxy, cmd_string },
{ "httpuser", &opt.http_user, cmd_string },
- { "if-modified-since", &opt.if_modified_since, cmd_boolean },
+ { "ifmodifiedsince", &opt.if_modified_since, cmd_boolean },
{ "ignorecase", &opt.ignore_case, cmd_boolean },
{ "ignorelength", &opt.ignore_length, cmd_boolean },
{ "ignoretags", &opt.ignore_tags, cmd_vector },
@@ -234,9 +236,10 @@ static const struct {
#endif
{ "input", &opt.input_filename, cmd_file },
#ifdef HAVE_METALINK
- { "input-metalink", &opt.input_metalink, cmd_file },
+ { "inputmetalink", &opt.input_metalink, cmd_file },
#endif
{ "iri", &opt.enable_iri, cmd_boolean },
+ { "keepbadhash", &opt.keep_badhash, cmd_boolean },
{ "keepsessioncookies", &opt.keep_session_cookies, cmd_boolean },
{ "limitrate", &opt.limit_rate, cmd_bytes },
{ "loadcookies", &opt.cookies_input, cmd_file },
@@ -245,7 +248,8 @@ static const struct {
{ "login", &opt.ftp_user, cmd_string },/* deprecated*/
{ "maxredirect", &opt.max_redirect, cmd_number },
#ifdef HAVE_METALINK
- { "metalink-over-http", &opt.metalink_over_http, cmd_boolean },
+ { "metalinkindex", &opt.metalink_index, cmd_number_inf },
+ { "metalinkoverhttp", &opt.metalink_over_http, cmd_boolean },
#endif
{ "method", &opt.method, cmd_string_uppercase },
{ "mirror", NULL, cmd_spec_mirror },
@@ -267,7 +271,7 @@ static const struct {
{ "postfile", &opt.post_file_name, cmd_file },
{ "preferfamily", NULL, cmd_spec_prefer_family },
#ifdef HAVE_METALINK
- { "preferred-location", &opt.preferred_location, cmd_string },
+ { "preferredlocation", &opt.preferred_location, cmd_string },
#endif
{ "preservepermissions", &opt.preserve_perm, cmd_boolean },
#ifdef HAVE_SSL
@@ -318,6 +322,7 @@ static const struct {
{ "tries", &opt.ntry, cmd_number_inf },
{ "trustservernames", &opt.trustservernames, cmd_boolean },
{ "unlink", &opt.unlink, cmd_boolean },
+ { "useaskpass" , &opt.use_askpass, cmd_use_askpass },
{ "useproxy", &opt.use_proxy, cmd_boolean },
{ "user", &opt.user, cmd_string },
{ "useragent", NULL, cmd_spec_useragent },
@@ -339,6 +344,9 @@ static const struct {
#ifdef USE_WATT32
{ "wdebug", &opt.wdebug, cmd_boolean },
#endif
+#ifdef ENABLE_XATTR
+ { "xattr", &opt.enable_xattr, cmd_boolean },
+#endif
};
/* Look up CMDNAME in the commands[] and return its position in the
@@ -378,6 +386,10 @@ defaults (void)
bit pattern will be the least of the implementors' worries. */
xzero (opt);
+#ifdef HAVE_METALINK
+ opt.metalink_index = -1;
+#endif
+
opt.cookies = true;
opt.verbose = -1;
opt.ntry = 20;
@@ -482,6 +494,12 @@ defaults (void)
/* HSTS is enabled by default */
opt.hsts = true;
#endif
+
+#ifdef ENABLE_XATTR
+ opt.enable_xattr = true;
+#else
+ opt.enable_xattr = false;
+#endif
}
/* Return the user's home directory (strdup-ed), or NULL if none is
@@ -859,6 +877,10 @@ static bool
setval_internal (int comind, const char *com, const char *val)
{
assert (0 <= comind && ((size_t) comind) < countof (commands));
+
+ if ((unsigned) comind >= countof (commands))
+ return NULL;
+
DEBUGP (("Setting %s (%s) to %s\n", com, commands[comind].name, val));
return commands[comind].action (com, val, commands[comind].place);
}
@@ -1371,6 +1393,32 @@ cmd_time (const char *com, const char *val, void *place)
return true;
}
+
+static bool
+cmd_use_askpass (const char *com _GL_UNUSED, const char *val, void *place)
+{
+ const char *env_name = "WGET_ASKPASS";
+ const char *env;
+
+ if (val && *val)
+ return cmd_string (com, val, place);
+
+ env = getenv (env_name);
+ if (!(env && *env))
+ {
+ env_name = "SSH_ASKPASS";
+ env = getenv (env_name);
+ }
+
+ if (!(env && *env))
+ {
+ fprintf (stderr, _("use-askpass requires a string or either environment variable WGET_ASKPASS or SSH_ASKPASS to be set.\n"));
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
+
+ return cmd_string (com, env, place);
+}
+
#ifdef HAVE_SSL
static bool
cmd_cert_type (const char *com, const char *val, void *place)
@@ -1930,6 +1978,7 @@ cleanup (void)
xfree (opt.body_data);
xfree (opt.body_file);
xfree (opt.rejected_log);
+ xfree (opt.use_askpass);
#ifdef HAVE_LIBCARES
#include <ares.h>
diff --git a/src/iri.c b/src/iri.c
index dd156f1..fbde567 100644
--- a/src/iri.c
+++ b/src/iri.c
@@ -33,11 +33,14 @@ as that of the covered work. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <iconv.h>
-#include <stringprep.h>
-#include <idna.h>
-#include <idn-free.h>
+#include <langinfo.h>
#include <errno.h>
+#ifdef HAVE_ICONV
+# include <iconv.h>
+#endif
+#include <idn2.h>
+#include <unicase.h>
+#include <unistr.h>
#include "utils.h"
#include "url.h"
@@ -45,9 +48,6 @@ as that of the covered work. */
#include "c-strcasestr.h"
#include "xstrndup.h"
-/* RFC3987 section 3.1 mandates STD3 ASCII RULES */
-#define IDNA_FLAGS IDNA_USE_STD3_ASCII_RULES
-
/* Note: locale encoding is kept in options struct (opt.locale) */
/* Given a string containing "charset=XXX", return the encoding if found,
@@ -88,10 +88,15 @@ parse_charset (const char *str)
}
/* Find the locale used, or fall back on a default value */
-char *
+const char *
find_locale (void)
{
- return (char *) stringprep_locale_charset ();
+ const char *encoding = nl_langinfo(CODESET);
+
+ if (!encoding || !*encoding)
+ return "ASCII";
+
+ return encoding;
}
/* Basic check of an encoding name. */
@@ -146,7 +151,7 @@ do_conversion (const char *tocode, const char *fromcode, char const *in_org, siz
for (;;)
{
- if (iconv (cd, &in, &inlen, out, &outlen) != (size_t)(-1) &&
+ if (iconv (cd, (ICONV_CONST char **) &in, &inlen, out, &outlen) != (size_t)(-1) &&
iconv (cd, NULL, NULL, out, &outlen) != (size_t)(-1))
{
*out = s;
@@ -159,7 +164,7 @@ do_conversion (const char *tocode, const char *fromcode, char const *in_org, siz
if (!strchr(in_org, '@') && !strchr(*out, '@'))
debug_logprintf ("converted '%s' (%s) -> '%s' (%s)\n", in_org, fromcode, *out, tocode);
else
- debug_logprintf ("%s: logging suppressed, strings may contain password\n", __func__);
+ debug_logprintf ("logging suppressed, strings may contain password\n");
}
return true;
}
@@ -201,7 +206,7 @@ do_conversion (const char *tocode, const char *fromcode, char const *in_org, siz
if (!strchr(in_org, '@') && !strchr(*out, '@'))
debug_logprintf ("converted '%s' (%s) -> '%s' (%s)\n", in_org, fromcode, *out, tocode);
else
- debug_logprintf ("%s: logging suppressed, strings may contain password\n", __func__);
+ debug_logprintf ("logging suppressed, strings may contain password\n");
}
return false;
}
@@ -230,50 +235,6 @@ locale_to_utf8 (const char *str)
return str;
}
-/*
- * Work around a libidn <= 1.30 vulnerability.
- *
- * The function checks for a valid UTF-8 character sequence before
- * passing it to idna_to_ascii_8z().
- *
- * [1] http://lists.gnu.org/archive/html/help-libidn/2015-05/msg00002.html
- * [2] https://lists.gnu.org/archive/html/bug-wget/2015-06/msg00002.html
- * [3] http://curl.haxx.se/mail/lib-2015-06/0143.html
- */
-static bool
-_utf8_is_valid(const char *utf8)
-{
- const unsigned char *s = (const unsigned char *) utf8;
-
- while (*s)
- {
- if ((*s & 0x80) == 0) /* 0xxxxxxx ASCII char */
- s++;
- else if ((*s & 0xE0) == 0xC0) /* 110xxxxx 10xxxxxx */
- {
- if ((s[1] & 0xC0) != 0x80)
- return false;
- s+=2;
- }
- else if ((*s & 0xF0) == 0xE0) /* 1110xxxx 10xxxxxx 10xxxxxx */
- {
- if ((s[1] & 0xC0) != 0x80 || (s[2] & 0xC0) != 0x80)
- return false;
- s+=3;
- }
- else if ((*s & 0xF8) == 0xF0) /* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
- {
- if ((s[1] & 0xC0) != 0x80 || (s[2] & 0xC0) != 0x80 || (s[3] & 0xC0) != 0x80)
- return false;
- s+=4;
- }
- else
- return false;
- }
-
- return true;
-}
-
/* Try to "ASCII encode" UTF-8 host. Return the new domain on success or NULL
on error. */
char *
@@ -282,34 +243,50 @@ idn_encode (const struct iri *i, const char *host)
int ret;
char *ascii_encoded;
char *utf8_encoded = NULL;
+ const char *src;
+#if IDN2_VERSION_NUMBER < 0x00140000
+ uint8_t *lower;
+ size_t len = 0;
+#endif
/* Encode to UTF-8 if not done */
if (!i->utf8_encode)
{
if (!remote_to_utf8 (i, host, &utf8_encoded))
return NULL; /* Nothing to encode or an error occured */
+ src = utf8_encoded;
}
+ else
+ src = host;
- if (!_utf8_is_valid(utf8_encoded ? utf8_encoded : host))
+#if IDN2_VERSION_NUMBER >= 0x00140000
+ /* IDN2_TRANSITIONAL implies input NFC encoding */
+ if ((ret = idn2_lookup_u8 ((uint8_t *) src, (uint8_t **) &ascii_encoded, IDN2_NONTRANSITIONAL)) != IDN2_OK)
{
- logprintf (LOG_VERBOSE, _("Invalid UTF-8 sequence: %s\n"),
- quote(utf8_encoded ? utf8_encoded : host));
+ logprintf (LOG_VERBOSE, _("idn_encode failed (%d): %s\n"), ret,
+ quote (idn2_strerror (ret)));
+ }
+#else
+ /* we need a conversion to lowercase */
+ lower = u8_tolower ((uint8_t *) src, u8_strlen ((uint8_t *) src) + 1, 0, UNINORM_NFKC, NULL, &len);
+ if (!lower)
+ {
+ logprintf (LOG_VERBOSE, _("Failed to convert to lower: %d: %s\n"),
+ errno, quote (src));
xfree (utf8_encoded);
return NULL;
}
- /* Store in ascii_encoded the ASCII UTF-8 NULL terminated string */
- ret = idna_to_ascii_8z (utf8_encoded ? utf8_encoded : host, &ascii_encoded, IDNA_FLAGS);
- xfree (utf8_encoded);
-
- if (ret != IDNA_SUCCESS)
+ if ((ret = idn2_lookup_u8 (lower, (uint8_t **) &ascii_encoded, IDN2_NFC_INPUT)) != IDN2_OK)
{
logprintf (LOG_VERBOSE, _("idn_encode failed (%d): %s\n"), ret,
- quote (idna_strerror (ret)));
- return NULL;
+ quote (idn2_strerror (ret)));
}
- return ascii_encoded;
+ xfree (lower);
+#endif
+
+ return ret == IDN2_OK ? ascii_encoded : NULL;
}
/* Try to decode an "ASCII encoded" host. Return the new domain in the locale
@@ -317,18 +294,24 @@ idn_encode (const struct iri *i, const char *host)
char *
idn_decode (const char *host)
{
+/*
char *new;
int ret;
- ret = idna_to_unicode_8zlz (host, &new, IDNA_FLAGS);
- if (ret != IDNA_SUCCESS)
+ ret = idn2_register_u8 (NULL, host, (uint8_t **) &new, 0);
+ if (ret != IDN2_OK)
{
- logprintf (LOG_VERBOSE, _("idn_decode failed (%d): %s\n"), ret,
- quote (idna_strerror (ret)));
+ logprintf (LOG_VERBOSE, _("idn2_register_u8 failed (%d): %s: %s\n"), ret,
+ quote (idn2_strerror (ret)), host);
return NULL;
}
return new;
+*/
+ /* idn2_register_u8() just works label by label.
+ * That is pretty much overhead for just displaying the original ulabels.
+ * To keep at least the debug output format, return a cloned host. */
+ return xstrdup(host);
}
/* Try to transcode string str from remote encoding to UTF-8. On success, *new
diff --git a/src/iri.h b/src/iri.h
index c350cbf..ba64a27 100644
--- a/src/iri.h
+++ b/src/iri.h
@@ -40,11 +40,10 @@ struct iri {
#ifdef ENABLE_IRI
-# include <idna.h>
-# include <idn-free.h>
+# include <idn2.h>
char *parse_charset (const char *str);
-char *find_locale (void);
+const char *find_locale (void);
bool check_encoding_name (const char *encoding);
const char *locale_to_utf8 (const char *str);
char *idn_encode (const struct iri *i, const char *host);
@@ -66,7 +65,7 @@ extern struct iri dummy_iri;
#define locale_to_utf8(str) (str)
#define idn_encode(a,b) NULL
#define idn_decode(str) NULL
-#define idn_free(str) ((void)0)
+#define idn2_free(str) ((void)0)
#define remote_to_utf8(a,b,c) false
#define iri_new() (&dummy_iri)
#define iri_dup(a) (&dummy_iri)
diff --git a/src/log.c b/src/log.c
index a1338ca..51f30c4 100644
--- a/src/log.c
+++ b/src/log.c
@@ -80,6 +80,18 @@ as that of the covered work. */
logging is inhibited, logfp is set back to NULL. */
static FILE *logfp;
+/* Descriptor of the stdout|stderr */
+static FILE *stdlogfp;
+
+/* Descriptor of the wget.log* file (if created) */
+static FILE *filelogfp;
+
+/* Name of log file */
+static char *logfile;
+
+/* Is interactive shell ? */
+static int shell_is_interactive;
+
/* A second file descriptor pointing to the temporary log file for the
WARC writer. If WARC writing is disabled, this is NULL. */
static FILE *warclogfp;
@@ -611,16 +623,18 @@ log_init (const char *file, bool appendp)
{
if (HYPHENP (file))
{
- logfp = stdout;
+ stdlogfp = stdout;
+ logfp = stdlogfp;
}
else
{
- logfp = fopen (file, appendp ? "a" : "w");
- if (!logfp)
+ filelogfp = fopen (file, appendp ? "a" : "w");
+ if (!filelogfp)
{
fprintf (stderr, "%s: %s: %s\n", exec_name, file, strerror (errno));
exit (WGET_EXIT_GENERIC_ERROR);
}
+ logfp = filelogfp;
}
}
else
@@ -631,7 +645,8 @@ log_init (const char *file, bool appendp)
stderr only if the user actually specifies `-O -'. He says
this inconsistency is harder to document, but is overall
easier on the user. */
- logfp = stderr;
+ stdlogfp = stderr;
+ logfp = stdlogfp;
if (1
#ifdef HAVE_ISATTY
@@ -646,6 +661,11 @@ log_init (const char *file, bool appendp)
save_context_p = true;
}
}
+
+#ifndef WINDOWS
+ /* Initialize this values so we don't have to ask every time we print line */
+ shell_is_interactive = isatty (STDIN_FILENO);
+#endif
}
/* Close LOGFP (only if we opened it, not if it's stderr), inhibit
@@ -880,59 +900,78 @@ log_cleanup (void)
/* When SIGHUP or SIGUSR1 are received, the output is redirected
elsewhere. Such redirection is only allowed once. */
-static enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE;
static const char *redirect_request_signal_name;
-/* Redirect output to `wget-log'. */
+/* Redirect output to `wget-log' or back to stdout/stderr. */
-static void
-redirect_output (void)
+void
+redirect_output (bool to_file, const char *signal_name)
{
- char *logfile;
- logfp = unique_create (DEFAULT_LOGFILE, false, &logfile);
- if (logfp)
+ if (to_file && logfp != filelogfp)
{
- fprintf (stderr, _("\n%s received, redirecting output to %s.\n"),
- redirect_request_signal_name, quote (logfile));
- xfree (logfile);
- /* Dump the context output to the newly opened log. */
- log_dump_context ();
+ if (signal_name)
+ {
+ fprintf (stderr, "\n%s received.", signal_name);
+ }
+ if (!filelogfp)
+ {
+ filelogfp = unique_create (DEFAULT_LOGFILE, false, &logfile);
+ if (filelogfp)
+ {
+ fprintf (stderr, _("\nRedirecting output to %s.\n"),
+ quote (logfile));
+ /* Store signal name to tell wget it's permanent redirect to log file */
+ redirect_request_signal_name = signal_name;
+ logfp = filelogfp;
+ /* Dump the context output to the newly opened log. */
+ log_dump_context ();
+ }
+ else
+ {
+ /* Eek! Opening the alternate log file has failed. Nothing we
+ can do but disable printing completely. */
+ fprintf (stderr, _("%s: %s; disabling logging.\n"),
+ (logfile) ? logfile : DEFAULT_LOGFILE, strerror (errno));
+ inhibit_logging = true;
+ }
+ }
+ else
+ {
+ fprintf (stderr, _("\nRedirecting output to %s.\n"),
+ quote (logfile));
+ logfp = filelogfp;
+ log_dump_context ();
+ }
}
- else
+ else if (!to_file && logfp != stdlogfp)
{
- /* Eek! Opening the alternate log file has failed. Nothing we
- can do but disable printing completely. */
- fprintf (stderr, _("\n%s received.\n"), redirect_request_signal_name);
- fprintf (stderr, _("%s: %s; disabling logging.\n"),
- (logfile) ? logfile : DEFAULT_LOGFILE, strerror (errno));
- inhibit_logging = true;
+ logfp = stdlogfp;
+ log_dump_context ();
}
- save_context_p = false;
}
-/* Check whether a signal handler requested the output to be
- redirected. */
+/* Check whether there's a need to redirect output. */
static void
check_redirect_output (void)
{
- if (redirect_request == RR_REQUESTED)
+#ifndef WINDOWS
+ /* If it was redirected already to log file by SIGHUP, SIGUSR1 or -o parameter,
+ * it was permanent.
+ * If there was no SIGHUP or SIGUSR1 and shell is interactive
+ * we check if process is fg or bg before every line is printed.*/
+ if (!redirect_request_signal_name && shell_is_interactive && !opt.lfilename)
{
- redirect_request = RR_DONE;
- redirect_output ();
+ if (tcgetpgrp (STDIN_FILENO) != getpgrp ())
+ {
+ /* Process backgrounded */
+ redirect_output (true,NULL);
+ }
+ else
+ {
+ /* Process foregrounded */
+ redirect_output (false,NULL);
+ }
}
-}
-
-/* Request redirection at a convenient time. This may be called from
- a signal handler. */
-
-void
-log_request_redirect_output (const char *signal_name)
-{
- if (redirect_request == RR_NONE && save_context_p)
- /* Request output redirection. The request will be processed by
- check_redirect_output(), which is called from entry point log
- functions. */
- redirect_request = RR_REQUESTED;
- redirect_request_signal_name = signal_name;
+#endif /* WINDOWS */
}
diff --git a/src/log.h b/src/log.h
index 0ccc26d..c3b7fec 100644
--- a/src/log.h
+++ b/src/log.h
@@ -52,6 +52,7 @@ void log_init (const char *, bool);
void log_close (void);
void log_cleanup (void);
void log_request_redirect_output (const char *);
+void redirect_output (bool, const char *);
const char *escnonprint (const char *);
const char *escnonprint_uri (const char *);
diff --git a/src/main.c b/src/main.c
index e7d5c66..e393597 100644
--- a/src/main.c
+++ b/src/main.c
@@ -36,6 +36,7 @@ as that of the covered work. */
#include <unistd.h>
#include <string.h>
#include <signal.h>
+#include <spawn.h>
#ifdef ENABLE_NLS
# include <locale.h>
#endif
@@ -60,6 +61,7 @@ as that of the covered work. */
#include "version.h"
#include "c-strcase.h"
#include "dirname.h"
+#include "xmemdup0.h"
#include <getopt.h>
#include <getpass.h>
#include <quote.h>
@@ -130,7 +132,7 @@ redirect_output_signal (int sig)
signal_name = "SIGUSR1";
#endif
- log_request_redirect_output (signal_name);
+ redirect_output (true,signal_name);
progress_schedule_redirect ();
signal (sig, redirect_output_signal);
}
@@ -219,8 +221,8 @@ save_hsts (void)
/* Definition of command-line options. */
-static void _Noreturn print_help (void);
-static void _Noreturn print_version (void);
+_Noreturn static void print_help (void);
+_Noreturn static void print_version (void);
#ifdef HAVE_SSL
# define IF_SSL(x) x
@@ -321,7 +323,7 @@ static struct cmdline_option option_data[] =
{ "host-directories", 0, OPT_BOOLEAN, "addhostdir", -1 },
#ifdef HAVE_HSTS
{ "hsts", 0, OPT_BOOLEAN, "hsts", -1},
- { "hsts-file", 0, OPT_VALUE, "hsts-file", -1 },
+ { "hsts-file", 0, OPT_VALUE, "hstsfile", -1 },
#endif
{ "html-extension", 'E', OPT_BOOLEAN, "adjustextension", -1 }, /* deprecated */
{ "htmlify", 0, OPT_BOOLEAN, "htmlify", -1 },
@@ -340,9 +342,10 @@ static struct cmdline_option option_data[] =
#endif
{ "input-file", 'i', OPT_VALUE, "input", -1 },
#ifdef HAVE_METALINK
- { "input-metalink", 0, OPT_VALUE, "input-metalink", -1 },
+ { "input-metalink", 0, OPT_VALUE, "inputmetalink", -1 },
#endif
{ "iri", 0, OPT_BOOLEAN, "iri", -1 },
+ { "keep-badhash", 0, OPT_BOOLEAN, "keepbadhash", -1 },
{ "keep-session-cookies", 0, OPT_BOOLEAN, "keepsessioncookies", -1 },
{ "level", 'l', OPT_VALUE, "reclevel", -1 },
{ "limit-rate", 0, OPT_VALUE, "limitrate", -1 },
@@ -351,7 +354,8 @@ static struct cmdline_option option_data[] =
{ "rejected-log", 0, OPT_VALUE, "rejectedlog", -1 },
{ "max-redirect", 0, OPT_VALUE, "maxredirect", -1 },
#ifdef HAVE_METALINK
- { "metalink-over-http", 0, OPT_BOOLEAN, "metalink-over-http", -1 },
+ { "metalink-index", 0, OPT_VALUE, "metalinkindex", -1 },
+ { "metalink-over-http", 0, OPT_BOOLEAN, "metalinkoverhttp", -1 },
#endif
{ "method", 0, OPT_VALUE, "method", -1 },
{ "mirror", 'm', OPT_BOOLEAN, "mirror", -1 },
@@ -370,7 +374,7 @@ static struct cmdline_option option_data[] =
{ "post-file", 0, OPT_VALUE, "postfile", -1 },
{ "prefer-family", 0, OPT_VALUE, "preferfamily", -1 },
#ifdef HAVE_METALINK
- { "preferred-location", 0, OPT_VALUE, "preferred-location", -1 },
+ { "preferred-location", 0, OPT_VALUE, "preferredlocation", -1 },
#endif
{ "preserve-permissions", 0, OPT_BOOLEAN, "preservepermissions", -1 },
{ IF_SSL ("private-key"), 0, OPT_VALUE, "privatekey", -1 },
@@ -410,10 +414,11 @@ static struct cmdline_option option_data[] =
{ "strict-comments", 0, OPT_BOOLEAN, "strictcomments", -1 },
{ "timeout", 'T', OPT_VALUE, "timeout", -1 },
{ "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 },
- { "if-modified-since", 0, OPT_BOOLEAN, "if-modified-since", -1 },
+ { "if-modified-since", 0, OPT_BOOLEAN, "ifmodifiedsince", -1 },
{ "tries", 't', OPT_VALUE, "tries", -1 },
{ "unlink", 0, OPT_BOOLEAN, "unlink", -1 },
{ "trust-server-names", 0, OPT_BOOLEAN, "trustservernames", -1 },
+ { "use-askpass", 0, OPT_VALUE, "useaskpass", -1},
{ "use-server-timestamps", 0, OPT_BOOLEAN, "useservertimestamps", -1 },
{ "user", 0, OPT_VALUE, "user", -1 },
{ "user-agent", 'U', OPT_VALUE, "useragent", -1 },
@@ -436,6 +441,9 @@ static struct cmdline_option option_data[] =
#ifdef USE_WATT32
{ "wdebug", 0, OPT_BOOLEAN, "wdebug", -1 },
#endif
+#ifdef ENABLE_XATTR
+ { "xattr", 0, OPT_BOOLEAN, "xattr", -1 },
+#endif
};
#undef IF_SSL
@@ -547,7 +555,7 @@ print_usage (int error)
/* Print the help message, describing all the available options. If
you add an option, be sure to update this list. */
-static void _Noreturn
+_Noreturn static void
print_help (void)
{
/* We split the help text this way to ease translation of individual
@@ -691,6 +699,11 @@ Download:\n"),
N_("\
--ask-password prompt for passwords\n"),
N_("\
+ --use-askpass=COMMAND specify credential handler for requesting \n\
+ username and password. If no COMMAND is \n\
+ specified the WGET_ASKPASS or the SSH_ASKPASS \n\
+ environment variable is used.\n"),
+ N_("\
--no-iri turn off IRI support\n"),
N_("\
--local-encoding=ENC use ENC as the local encoding for IRIs\n"),
@@ -700,10 +713,18 @@ Download:\n"),
--unlink remove file before clobber\n"),
#ifdef HAVE_METALINK
N_("\
+ --keep-badhash keep files with checksum mismatch (append .badhash)\n"),
+ N_("\
+ --metalink-index=NUMBER Metalink application/metalink4+xml metaurl ordinal NUMBER\n"),
+ N_("\
--metalink-over-http use Metalink metadata from HTTP response headers\n"),
N_("\
--preferred-location preferred location for Metalink resources\n"),
#endif
+#ifdef ENABLE_XATTR
+ N_("\
+ --no-xattr turn off storage of metadata in extended file attributes\n"),
+#endif
"\n",
N_("\
@@ -809,7 +830,7 @@ HTTPS (SSL/TLS) options:\n"),
N_("\
--pinnedpubkey=FILE/HASHES Public key (PEM/DER) file, or any number\n\
of base64 encoded sha256 hashes preceded by\n\
- \'sha256//\' and seperated by \';\', to verify\n\
+ \'sha256//\' and separated by \';\', to verify\n\
peer against\n"),
#if defined(HAVE_LIBSSL) || defined(HAVE_LIBSSL32)
N_("\
@@ -1019,6 +1040,103 @@ prompt_for_password (void)
return getpass("");
}
+
+/* Execute external application opt.use_askpass */
+static void
+run_use_askpass (char *question, char **answer)
+{
+ char tmp[1024];
+ pid_t pid;
+ int status;
+ int com[2];
+ ssize_t bytes = 0;
+ char *argv[3], *p;
+ posix_spawn_file_actions_t fa;
+
+ if (pipe (com) == -1)
+ {
+ fprintf (stderr, _("Cannot create pipe\n"));
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
+
+ status = posix_spawn_file_actions_init (&fa);
+ if (status)
+ {
+ fprintf (stderr,
+ _("Error initializing spawn file actions for use-askpass: %d\n"),
+ status);
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
+
+ status = posix_spawn_file_actions_adddup2 (&fa, com[1], STDOUT_FILENO);
+ if (status)
+ {
+ fprintf (stderr,
+ _("Error setting spawn file actions for use-askpass: %d\n"),
+ status);
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
+
+ /* C89 initializer lists must be computable at load time,
+ * thus this explicit initialization. */
+ argv[0] = opt.use_askpass;
+ argv[1] = question;
+ argv[2] = NULL;
+
+ status = posix_spawnp (&pid, opt.use_askpass, &fa, NULL, argv, environ);
+ if (status)
+ {
+ fprintf (stderr, "Error spawning %s: %d\n", opt.use_askpass, status);
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
+
+ /* Parent process reads from child. */
+ close (com[1]);
+ bytes = read (com[0], tmp, sizeof (tmp) - 1);
+ if (bytes <= 0)
+ {
+ fprintf (stderr,
+ _("Error reading response from command \"%s %s\": %s\n"),
+ opt.use_askpass, question, strerror (errno));
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
+
+ /* Make sure there is a trailing 0 */
+ tmp[bytes] = '\0';
+
+ /* Remove a possible new line */
+ if ((p = strpbrk (tmp, "\r\n")))
+ bytes = p - tmp;
+
+ *answer = xmemdup0 (tmp, bytes);
+}
+
+/* set the user name and password*/
+static void
+use_askpass (struct url *u)
+{
+ static char question[1024];
+
+ if (u->user == NULL || u->user[0] == '\0')
+ {
+ snprintf (question, sizeof (question), _("Username for '%s%s': "),
+ scheme_leading_string(u->scheme), u->host);
+ /* Prompt for username */
+ run_use_askpass (question, &u->user);
+ if (opt.recursive)
+ opt.user = xstrdup (u->user);
+ }
+
+ if (u->passwd == NULL || u->passwd[0] == '\0')
+ {
+ snprintf(question, sizeof (question), _("Password for '%s%s@%s': "),
+ scheme_leading_string (u->scheme), u->user, u->host);
+ /* Prompt for password */
+ run_use_askpass (question, &u->passwd);
+ if (opt.recursive)
+ opt.passwd = xstrdup (u->passwd);
+ }
+}
/* Function that prints the line argument while limiting it
to at most line_length. prefix is printed on the first line
and an appropriate number of spaces are added on subsequent
@@ -1080,7 +1198,7 @@ format_and_print_line (const char *prefix, const char *line,
return 0;
}
-static void _Noreturn
+_Noreturn static void
print_version (void)
{
const char *wgetrc_title = _("Wgetrc: ");
@@ -1339,7 +1457,8 @@ main (int argc, char **argv)
append_to_log = true;
break;
case OPT__EXECUTE:
- run_command (optarg);
+ if (optarg) /* check silences static analyzer */
+ run_command (optarg);
break;
case OPT__NO:
{
@@ -1623,7 +1742,7 @@ for details.\n\n"));
else if (opt.method)
{
fprintf (stderr, _("You cannot use --post-data or --post-file along with --method. "
- "--method expects data through --body-data and --body-file options"));
+ "--method expects data through --body-data and --body-file options\n"));
exit (WGET_EXIT_GENERIC_ERROR);
}
}
@@ -1702,6 +1821,16 @@ for details.\n\n"));
exit (WGET_EXIT_GENERIC_ERROR);
}
+ if (opt.use_askpass)
+ {
+ if (opt.use_askpass[0] == '\0')
+ {
+ fprintf (stderr,
+ _("use-askpass requires a string or either environment variable WGET_ASKPASS or SSH_ASKPASS to be set.\n"));
+ exit (WGET_EXIT_GENERIC_ERROR);
+ }
+ }
+
#ifdef USE_WATT32
if (opt.wdebug)
dbug_init();
@@ -1764,7 +1893,7 @@ for details.\n\n"));
}
else
{
- struct_fstat st;
+ struct stat st;
#ifdef __VMS
/* Common fopen() optional arguments:
@@ -1920,6 +2049,10 @@ only if outputting to a regular file.\n"));
}
else
{
+ /* Request credentials if use_askpass is set. */
+ if (opt.use_askpass)
+ use_askpass (url_parsed);
+
if ((opt.recursive || opt.page_requisites)
&& ((url_scheme (*t) != SCHEME_FTP
#ifdef HAVE_SSL
diff --git a/src/metalink.c b/src/metalink.c
index 18f5f5d..904f9f3 100644
--- a/src/metalink.c
+++ b/src/metalink.c
@@ -34,8 +34,16 @@ as that of the covered work. */
#include "retr.h"
#include "exits.h"
#include "utils.h"
+#include "md2.h"
+#include "md4.h"
+#include "md5.h"
+#include "sha1.h"
#include "sha256.h"
+#include "sha512.h"
+#include "dosname.h"
+#include "xmemdup0.h"
#include "xstrndup.h"
+#include "c-strcase.h"
#include <errno.h>
#include <unistd.h> /* For unlink. */
#include <metalink/metalink_parser.h>
@@ -62,7 +70,16 @@ retrieve_from_metalink (const metalink_t* metalink)
bool _output_stream_regular = output_stream_regular;
char *_output_document = opt.output_document;
- DEBUGP (("Retrieving from Metalink\n"));
+ /* metalink file counter */
+ unsigned mfc = 0;
+
+ /* metalink retrieval type */
+ const char *metatpy = metalink->origin ? "Metalink/HTTP" : "Metalink/XML";
+
+ /* metalink mother source */
+ char *metasrc = metalink->origin ? metalink->origin : opt.input_metalink;
+
+ DEBUGP (("Retrieving from Metalink %s\n", quote (metasrc)));
/* No files to download. */
if (!metalink->files)
@@ -80,7 +97,13 @@ retrieve_from_metalink (const metalink_t* metalink)
{
metalink_file_t *mfile = *mfile_ptr;
metalink_resource_t **mres_ptr;
+ char *planname = NULL;
+ char *trsrname = NULL;
char *filename = NULL;
+ char *basename = NULL;
+ char *safename = NULL;
+ char *destname = NULL;
+ bool size_ok = false;
bool hash_ok = false;
uerr_t retr_err = METALINK_MISSING_RESOURCE;
@@ -90,12 +113,263 @@ retrieve_from_metalink (const metalink_t* metalink)
1 -> verified successfully */
char sig_status = 0;
+ bool skip_mfile = false;
+
output_stream = NULL;
+ mfc++;
+
+ /* The directory prefix for opt.metalink_over_http is handled by
+ src/url.c (url_file_name), do not add it a second time. */
+ if (!metalink->origin && opt.dir_prefix && strlen (opt.dir_prefix))
+ planname = aprintf ("%s/%s", opt.dir_prefix, mfile->name);
+ else
+ planname = xstrdup (mfile->name);
+
+ /* With Metalink/HTTP, trust the metalink file name (from cli).
+ With --trust-server-names, trust the Metalink/XML file name,
+ otherwise, use the basename of --input-metalink followed by
+ the metalink file counter as suffix. */
+ if (metalink->origin || opt.trustservernames)
+ {
+ trsrname = xstrdup (mfile->name);
+ }
+ else
+ {
+ trsrname = xstrdup (get_metalink_basename (opt.input_metalink));
+ append_suffix_number (&trsrname, ".#", mfc);
+ }
+
+ /* Add the directory prefix for opt.input_metalink. */
+ if (!metalink->origin && opt.dir_prefix && strlen (opt.dir_prefix))
+ filename = aprintf ("%s/%s", opt.dir_prefix, trsrname);
+ else
+ filename = xstrdup (trsrname);
+
+ /* Enforce libmetalink's metalink_check_safe_path(). */
+ basename = get_metalink_basename (filename);
+ safename = metalink_check_safe_path (filename) ? filename : basename;
+
DEBUGP (("Processing metalink file %s...\n", quote (mfile->name)));
+ DEBUGP (("\n"));
+ DEBUGP ((" %s\n", metatpy));
+ DEBUGP (("\n"));
+ DEBUGP ((" --trust-server-names %s\n", opt.trustservernames ? "true" : "false"));
+ DEBUGP ((" --directory-prefix %s\n", quote (opt.dir_prefix ? opt.dir_prefix : "")));
+ DEBUGP (("\n"));
+ DEBUGP ((" Counted metalink file %u\n", mfc));
+ DEBUGP ((" Planned metalink file %s\n", quote (planname ? planname : "")));
+ DEBUGP ((" Trusted metalink file %s\n", quote (trsrname ? trsrname : "")));
+ DEBUGP ((" Current metalink file %s\n", quote (filename ? filename : "")));
+ DEBUGP ((" Cleaned metalink file %s\n", quote (basename ? basename : "")));
+ DEBUGP ((" Secured metalink file %s\n", quote (safename ? safename : "")));
+ DEBUGP (("\n"));
+
+ /* Verify if the planned metalink file name is safe. */
+ if (!safename || strcmp (planname, safename))
+ {
+ logprintf (LOG_NOTQUIET,
+ _("[--trust-server-names %s, --directory-prefix=%s]\n"),
+ (opt.trustservernames ? "true" : "false"),
+ quote (opt.dir_prefix ? opt.dir_prefix : ""));
+ logprintf (LOG_NOTQUIET,
+ _("Planned metalink file: %s\n"),
+ quote (planname ? planname : ""));
+ logprintf (LOG_NOTQUIET,
+ _("Secured metalink file: %s\n"),
+ quote (safename ? safename : ""));
+ if (!safename)
+ {
+ logprintf (LOG_NOTQUIET,
+ _("Rejecting metalink file. Unsafe name.\n"));
+ xfree (planname);
+ xfree (trsrname);
+ xfree (filename);
+ continue;
+ }
+ }
+
+ /* Process the chosen application/metalink4+xml metaurl. */
+ if (opt.metalink_index >= 0)
+ {
+ int _metalink_index = opt.metalink_index;
+
+ metalink_metaurl_t **murl_ptr;
+ int abs_count = 0, meta_count = 0;
+
+ uerr_t x_retr_err = METALINK_MISSING_RESOURCE;
+
+ opt.metalink_index = -1;
+
+ DEBUGP (("Searching application/metalink4+xml ordinal number %d...\n", _metalink_index));
+
+ if (mfile->metaurls && mfile->metaurls[0])
+ for (murl_ptr = mfile->metaurls; *murl_ptr; murl_ptr++)
+ {
+ metalink_t* metaurl_xml;
+ metalink_error_t meta_err;
+ metalink_metaurl_t *murl = *murl_ptr;
+
+ char *_dir_prefix = opt.dir_prefix;
+ char *_input_metalink = opt.input_metalink;
+
+ char *metafile = NULL;
+ char *metadest = NULL;
+ char *metadir = NULL;
+
+ abs_count++;
+
+ if (strcmp (murl->mediatype, "application/metalink4+xml"))
+ continue;
+
+ meta_count++;
+
+ DEBUGP ((" Ordinal number %d: %s\n", meta_count, quote (murl->url)));
+
+ if (_metalink_index > 0)
+ {
+ if (meta_count < _metalink_index)
+ continue;
+ else if (meta_count > _metalink_index)
+ break;
+ }
+
+ logprintf (LOG_NOTQUIET,
+ _("Processing metaurl %s...\n"), quote (murl->url));
+
+ /* Metalink/XML download file name. */
+ metafile = xstrdup (safename);
+
+ if (opt.trustservernames)
+ replace_metalink_basename (&metafile, murl->name ? murl->name : murl->url);
+ else
+ append_suffix_number (&metafile, ".meta#", meta_count);
+
+ if (!metalink_check_safe_path (metafile))
+ {
+ logprintf (LOG_NOTQUIET,
+ _("Rejecting metaurl file %s. Unsafe name.\n"),
+ quote (metafile));
+ xfree (metafile);
+ if (_metalink_index > 0)
+ break;
+ continue;
+ }
+
+ /* For security reasons, always save metalink metaurl
+ files as new unique files. Keep them on failure. */
+ x_retr_err = fetch_metalink_file (murl->url, false, false,
+ metafile, &metadest);
+
+ /* On failure, try the next metalink metaurl. */
+ if (x_retr_err != RETROK)
+ {
+ logprintf (LOG_VERBOSE,
+ _("Failed to download %s. Skipping metaurl.\n"),
+ quote (metadest ? metadest : metafile));
+ inform_exit_status (x_retr_err);
+ xfree (metadest);
+ xfree (metafile);
+ if (_metalink_index > 0)
+ break;
+ continue;
+ }
+
+ /* Parse Metalink/XML. */
+ meta_err = metalink_parse_file (metadest, &metaurl_xml);
+
+ /* On failure, try the next metalink metaurl. */
+ if (meta_err)
+ {
+ logprintf (LOG_NOTQUIET,
+ _("Unable to parse metaurl file %s.\n"), quote (metadest));
+ x_retr_err = METALINK_PARSE_ERROR;
+ inform_exit_status (x_retr_err);
+ xfree (metadest);
+ xfree (metafile);
+ if (_metalink_index > 0)
+ break;
+ continue;
+ }
+
+ /* We need to sort the resources if preferred location
+ was specified by the user. */
+ if (opt.preferred_location && opt.preferred_location[0])
+ {
+ metalink_file_t **x_mfile_ptr;
+ for (x_mfile_ptr = metaurl_xml->files; *x_mfile_ptr; x_mfile_ptr++)
+ {
+ metalink_resource_t **x_mres_ptr;
+ metalink_file_t *x_mfile = *x_mfile_ptr;
+ size_t mres_count = 0;
+
+ for (x_mres_ptr = x_mfile->resources; *x_mres_ptr; x_mres_ptr++)
+ mres_count++;
+
+ stable_sort (x_mfile->resources,
+ mres_count,
+ sizeof (metalink_resource_t *),
+ metalink_res_cmp);
+ }
+ }
+
+ /* Insert the current "Directory Options". */
+ if (metalink->origin)
+ {
+ /* WARNING: Do not use lib/dirname.c (dir_name) to
+ get the directory name, it may append a dot '.'
+ character to the directory name. */
+ metadir = xstrdup (planname);
+ replace_metalink_basename (&metadir, NULL);
+ }
+ else
+ {
+ metadir = xstrdup (opt.dir_prefix);
+ }
+
+ opt.dir_prefix = metadir;
+ opt.input_metalink = metadest;
+
+ x_retr_err = retrieve_from_metalink (metaurl_xml);
+
+ if (x_retr_err != RETROK)
+ logprintf (LOG_NOTQUIET,
+ _("Could not download all resources from %s.\n"),
+ quote (metadest));
+
+ metalink_delete (metaurl_xml);
+ metaurl_xml = NULL;
+
+ opt.input_metalink = _input_metalink;
+ opt.dir_prefix = _dir_prefix;
+
+ xfree (metadir);
+ xfree (metadest);
+ xfree (metafile);
+
+ break;
+ }
+
+ if (x_retr_err != RETROK)
+ logprintf (LOG_NOTQUIET, _("Metaurls processing returned with error.\n"));
+
+ xfree (destname);
+ xfree (filename);
+ xfree (trsrname);
+ xfree (planname);
+
+ opt.output_document = _output_document;
+ output_stream_regular = _output_stream_regular;
+ output_stream = _output_stream;
+
+ opt.metalink_index = _metalink_index;
+
+ return x_retr_err;
+ }
/* Resources are sorted by priority. */
- for (mres_ptr = mfile->resources; *mres_ptr; mres_ptr++)
+ for (mres_ptr = mfile->resources;
+ *mres_ptr && mfile->checksums && !skip_mfile; mres_ptr++)
{
metalink_resource_t *mres = *mres_ptr;
metalink_checksum_t **mchksum_ptr, *mchksum;
@@ -103,6 +377,8 @@ retrieve_from_metalink (const metalink_t* metalink)
struct url *url;
int url_err;
+ clean_metalink_string (&mres->url);
+
if (!RES_TYPE_SUPPORTED (mres->type))
{
logprintf (LOG_VERBOSE,
@@ -111,19 +387,30 @@ retrieve_from_metalink (const metalink_t* metalink)
continue;
}
- retr_err = METALINK_RETR_ERROR;
-
- /* If output_stream is not NULL, then we have failed on
- previous resource and are retrying. Thus, remove the file. */
- if (output_stream)
+ /* The file is fully downloaded, but some problems were
+ encountered (checksum failure?). The loop had been
+ continued to switch to the next url. */
+ if (output_stream && retr_err == RETROK)
{
+ /* Do not rename/remove a continued file. Skip it. */
+ if (opt.always_rest)
+ {
+ skip_mfile = true;
+ continue;
+ }
+
fclose (output_stream);
output_stream = NULL;
- if (unlink (filename))
- logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
- xfree (filename);
+ badhash_or_remove (destname);
+ xfree (destname);
+ }
+ else if (!output_stream && destname)
+ {
+ xfree (destname);
}
+ retr_err = METALINK_RETR_ERROR;
+
/* Parse our resource URL. */
iri = iri_new ();
set_uri_encoding (iri, opt.locale, true);
@@ -143,22 +430,68 @@ retrieve_from_metalink (const metalink_t* metalink)
/* Avoid recursive Metalink from HTTP headers. */
bool _metalink_http = opt.metalink_over_http;
- /* Assure proper local file name regardless of the URL
- of particular Metalink resource.
- To do that we create the local file here and put
- it as output_stream. We restore the original configuration
- after we are finished with the file. */
- output_stream = unique_create (mfile->name, true, &filename);
+ /* If output_stream is not NULL, then we have failed on
+ previous resource and are retrying. Thus, continue
+ with the next resource. Do not close output_stream
+ while iterating over the resources, or the download
+ progress will be lost. */
+ if (output_stream)
+ {
+ DEBUGP (("Previous resource failed, continue with next resource.\n"));
+ }
+ else
+ {
+ /* Assure proper local file name regardless of the URL
+ of particular Metalink resource.
+ To do that we create the local file here and put
+ it as output_stream. We restore the original configuration
+ after we are finished with the file. */
+ if (opt.always_rest)
+ /* continue previous download */
+ output_stream = fopen (safename, "ab");
+ else
+ /* create a file with an unique name */
+ output_stream = unique_create (safename, true, &destname);
+ }
+
output_stream_regular = true;
- /* Store the real file name for displaying in messages. */
- opt.output_document = filename;
+ /*
+ At this point, if output_stream is NULL, the file
+ couldn't be created/opened.
+
+ This happens when the metalink:file has a "path/file"
+ name format and its directory tree cannot be created:
+ * stdio.h (fopen)
+ * src/utils.c (unique_create)
+
+ RFC5854 requires a proper "path/file" format handling,
+ this can be achieved setting opt.output_document while
+ output_stream is left to NULL:
+ * src/http.c (open_output_stream): If output_stream is
+ NULL, create the opt.output_document "path/file"
+ */
+ if (!destname)
+ destname = xstrdup (safename);
+
+ /* Store the real file name for displaying in messages,
+ and for proper RFC5854 "path/file" handling. */
+ opt.output_document = destname;
opt.metalink_over_http = false;
- DEBUGP (("Storing to %s\n", filename));
+ DEBUGP (("Storing to %s\n", destname));
retr_err = retrieve_url (url, mres->url, NULL, NULL,
NULL, NULL, opt.recursive, iri, false);
opt.metalink_over_http = _metalink_http;
+
+ /*
+ Bug: output_stream is NULL, but retrieve_url() somehow
+ created destname.
+
+ Bugfix: point output_stream to destname if it exists.
+ */
+ if (!output_stream && file_exists_p (destname))
+ output_stream = fopen (destname, "ab");
}
url_free (url);
iri_free (iri);
@@ -168,23 +501,94 @@ retrieve_from_metalink (const metalink_t* metalink)
FILE *local_file;
/* Check the digest. */
- local_file = fopen (filename, "rb");
+ local_file = fopen (destname, "rb");
if (!local_file)
{
logprintf (LOG_NOTQUIET, _("Could not open downloaded file.\n"));
continue;
}
+ size_ok = false;
+ logprintf (LOG_VERBOSE, _("Computing size for %s\n"), quote (destname));
+
+ if (!mfile->size)
+ {
+ size_ok = true;
+ logprintf (LOG_VERBOSE, _("File size not declared. Skipping check.\n"));
+ }
+ else
+ {
+ wgint local_file_size = file_size (destname);
+
+ if (local_file_size == -1)
+ {
+ logprintf (LOG_NOTQUIET, _("Could not get downloaded file's size.\n"));
+ fclose (local_file);
+ local_file = NULL;
+ continue;
+ }
+
+ /* FIXME: what about int64? */
+ DEBUGP (("Declared size: %lld\n", mfile->size));
+ DEBUGP (("Computed size: %lld\n", (long long) local_file_size));
+
+ if (local_file_size != (wgint) mfile->size)
+ {
+ logprintf (LOG_NOTQUIET, _("Size mismatch for file %s.\n"), quote (destname));
+ fclose (local_file);
+ local_file = NULL;
+ continue;
+ }
+ else
+ {
+ size_ok = true;
+ logputs (LOG_VERBOSE, _("Size matches.\n"));
+ }
+ }
+
for (mchksum_ptr = mfile->checksums; *mchksum_ptr; mchksum_ptr++)
{
+ char md2[MD2_DIGEST_SIZE];
+ char md2_txt[2 * MD2_DIGEST_SIZE + 1];
+
+ char md4[MD4_DIGEST_SIZE];
+ char md4_txt[2 * MD4_DIGEST_SIZE + 1];
+
+ char md5[MD5_DIGEST_SIZE];
+ char md5_txt[2 * MD5_DIGEST_SIZE + 1];
+
+ char sha1[SHA1_DIGEST_SIZE];
+ char sha1_txt[2 * SHA1_DIGEST_SIZE + 1];
+
+ char sha224[SHA224_DIGEST_SIZE];
+ char sha224_txt[2 * SHA224_DIGEST_SIZE + 1];
+
char sha256[SHA256_DIGEST_SIZE];
char sha256_txt[2 * SHA256_DIGEST_SIZE + 1];
+ char sha384[SHA384_DIGEST_SIZE];
+ char sha384_txt[2 * SHA384_DIGEST_SIZE + 1];
+
+ char sha512[SHA512_DIGEST_SIZE];
+ char sha512_txt[2 * SHA512_DIGEST_SIZE + 1];
+
+ hash_ok = false;
mchksum = *mchksum_ptr;
/* I have seen both variants... */
- if (strcasecmp (mchksum->type, "sha256")
- && strcasecmp (mchksum->type, "sha-256"))
+ if (c_strcasecmp (mchksum->type, "md2")
+ && c_strcasecmp (mchksum->type, "md4")
+ && c_strcasecmp (mchksum->type, "md5")
+ && c_strcasecmp (mchksum->type, "sha1")
+ && c_strcasecmp (mchksum->type, "sha-1")
+ && c_strcasecmp (mchksum->type, "sha224")
+ && c_strcasecmp (mchksum->type, "sha-224")
+ && c_strcasecmp (mchksum->type, "sha256")
+ && c_strcasecmp (mchksum->type, "sha-256")
+ && c_strcasecmp (mchksum->type, "sha384")
+ && c_strcasecmp (mchksum->type, "sha-384")
+ && c_strcasecmp (mchksum->type, "sha512")
+ && c_strcasecmp (mchksum->type, "sha-512"))
{
DEBUGP (("Ignoring unsupported checksum type %s.\n",
quote (mchksum->type)));
@@ -192,24 +596,90 @@ retrieve_from_metalink (const metalink_t* metalink)
}
logprintf (LOG_VERBOSE, _("Computing checksum for %s\n"),
- quote (mfile->name));
+ quote (destname));
- sha256_stream (local_file, sha256);
- wg_hex_to_string (sha256_txt, sha256, SHA256_DIGEST_SIZE);
DEBUGP (("Declared hash: %s\n", mchksum->hash));
- DEBUGP (("Computed hash: %s\n", sha256_txt));
- if (!strcmp (sha256_txt, mchksum->hash))
+
+ if (c_strcasecmp (mchksum->type, "md2") == 0)
+ {
+ md2_stream (local_file, md2);
+ wg_hex_to_string (md2_txt, md2, MD2_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", md2_txt));
+ if (!strcmp (md2_txt, mchksum->hash))
+ hash_ok = true;
+ }
+ else if (c_strcasecmp (mchksum->type, "md4") == 0)
+ {
+ md4_stream (local_file, md4);
+ wg_hex_to_string (md4_txt, md4, MD4_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", md4_txt));
+ if (!strcmp (md4_txt, mchksum->hash))
+ hash_ok = true;
+ }
+ else if (c_strcasecmp (mchksum->type, "md5") == 0)
+ {
+ md5_stream (local_file, md5);
+ wg_hex_to_string (md5_txt, md5, MD5_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", md5_txt));
+ if (!strcmp (md5_txt, mchksum->hash))
+ hash_ok = true;
+ }
+ else if (c_strcasecmp (mchksum->type, "sha1") == 0
+ || c_strcasecmp (mchksum->type, "sha-1") == 0)
+ {
+ sha1_stream (local_file, sha1);
+ wg_hex_to_string (sha1_txt, sha1, SHA1_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", sha1_txt));
+ if (!strcmp (sha1_txt, mchksum->hash))
+ hash_ok = true;
+ }
+ else if (c_strcasecmp (mchksum->type, "sha224") == 0
+ || c_strcasecmp (mchksum->type, "sha-224") == 0)
+ {
+ sha224_stream (local_file, sha224);
+ wg_hex_to_string (sha224_txt, sha224, SHA224_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", sha224_txt));
+ if (!strcmp (sha224_txt, mchksum->hash))
+ hash_ok = true;
+ }
+ else if (c_strcasecmp (mchksum->type, "sha256") == 0
+ || c_strcasecmp (mchksum->type, "sha-256") == 0)
+ {
+ sha256_stream (local_file, sha256);
+ wg_hex_to_string (sha256_txt, sha256, SHA256_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", sha256_txt));
+ if (!strcmp (sha256_txt, mchksum->hash))
+ hash_ok = true;
+ }
+ else if (c_strcasecmp (mchksum->type, "sha384") == 0
+ || c_strcasecmp (mchksum->type, "sha-384") == 0)
+ {
+ sha384_stream (local_file, sha384);
+ wg_hex_to_string (sha384_txt, sha384, SHA384_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", sha384_txt));
+ if (!strcmp (sha384_txt, mchksum->hash))
+ hash_ok = true;
+ }
+ else if (c_strcasecmp (mchksum->type, "sha512") == 0
+ || c_strcasecmp (mchksum->type, "sha-512") == 0)
+ {
+ sha512_stream (local_file, sha512);
+ wg_hex_to_string (sha512_txt, sha512, SHA512_DIGEST_SIZE);
+ DEBUGP (("Computed hash: %s\n", sha512_txt));
+ if (!strcmp (sha512_txt, mchksum->hash))
+ hash_ok = true;
+ }
+
+ if (hash_ok)
{
logputs (LOG_VERBOSE,
_("Checksum matches.\n"));
- hash_ok = true;
}
else
{
logprintf (LOG_NOTQUIET,
_("Checksum mismatch for file %s.\n"),
- quote (mfile->name));
- hash_ok = false;
+ quote (destname));
}
/* Stop as soon as we checked the supported checksum. */
@@ -226,7 +696,7 @@ retrieve_from_metalink (const metalink_t* metalink)
#ifdef HAVE_GPGME
/* Check the crypto signature.
- Note that the signtures from Metalink in XML will not be
+ Note that the signatures from Metalink in XML will not be
parsed when using libmetalink version older than 0.1.3.
Metalink-over-HTTP is not affected by this problem. */
if (mfile->signature)
@@ -244,7 +714,7 @@ retrieve_from_metalink (const metalink_t* metalink)
gpgme_check_version (NULL);
/* Open data file. */
- fd = open (filename, O_RDONLY);
+ fd = open (destname, O_RDONLY);
if (fd == -1)
{
logputs (LOG_NOTQUIET,
@@ -348,7 +818,7 @@ retrieve_from_metalink (const metalink_t* metalink)
& (GPGME_SIGSUM_VALID | GPGME_SIGSUM_GREEN))
{
logputs (LOG_VERBOSE,
- _("Signature validation suceeded.\n"));
+ _("Signature validation succeeded.\n"));
sig_status = 1;
break;
}
@@ -390,17 +860,30 @@ gpg_skip_verification:
} /* endif RETR_OK. */
} /* Iterate over resources. */
+ if (!mfile->checksums)
+ {
+ logprintf (LOG_NOTQUIET, _("No checksums found.\n"));
+ retr_err = METALINK_CHKSUM_ERROR;
+ }
+
if (retr_err != RETROK)
{
logprintf (LOG_VERBOSE, _("Failed to download %s. Skipping resource.\n"),
- quote (mfile->name));
+ quote (destname ? destname : safename));
+ }
+ else if (!size_ok)
+ {
+ retr_err = METALINK_SIZE_ERROR;
+ logprintf (LOG_NOTQUIET,
+ _("File %s retrieved but size does not match. "
+ "\n"), quote (destname));
}
else if (!hash_ok)
{
retr_err = METALINK_CHKSUM_ERROR;
logprintf (LOG_NOTQUIET,
_("File %s retrieved but checksum does not match. "
- "\n"), quote (mfile->name));
+ "\n"), quote (destname));
}
#ifdef HAVE_GPGME
/* Signature will be only validated if hash check was successful. */
@@ -409,27 +892,28 @@ gpg_skip_verification:
retr_err = METALINK_SIG_ERROR;
logprintf (LOG_NOTQUIET,
_("File %s retrieved but signature does not match. "
- "\n"), quote (mfile->name));
+ "\n"), quote (destname));
}
#endif
last_retr_err = retr_err == RETROK ? last_retr_err : retr_err;
- /* Remove the file if error encountered or if option specified.
+ /* Rename the file if error encountered; remove if option specified.
Note: the file has been downloaded using *_loop. Therefore, it
is not necessary to keep the file for continuated download. */
- if ((retr_err != RETROK || opt.delete_after)
- && filename != NULL && file_exists_p (filename))
+ if (((retr_err != RETROK && !opt.always_rest) || opt.delete_after)
+ && destname != NULL && file_exists_p (destname))
{
- logprintf (LOG_VERBOSE, _("Removing %s.\n"), quote (filename));
- if (unlink (filename))
- logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
+ badhash_or_remove (destname);
}
if (output_stream)
{
fclose (output_stream);
output_stream = NULL;
}
+ xfree (destname);
xfree (filename);
+ xfree (trsrname);
+ xfree (planname);
} /* Iterate over files. */
/* Restore original values. */
@@ -440,6 +924,328 @@ gpg_skip_verification:
return last_retr_err;
}
+/*
+ Replace/remove the basename of a file name.
+
+ The file name is permanently modified.
+
+ Always set NAME to a string, even an empty one.
+
+ Use REF's basename as replacement. If REF is NULL or if it doesn't
+ provide a valid basename candidate, then remove NAME's basename.
+*/
+void
+replace_metalink_basename (char **name, char *ref)
+{
+ int n;
+ char *p, *new, *basename;
+
+ if (!name)
+ return;
+
+ /* Strip old basename. */
+ if (*name)
+ {
+ basename = last_component (*name);
+
+ if (basename == *name)
+ xfree (*name);
+ else
+ *basename = '\0';
+ }
+
+ /* New basename from file name reference. */
+ if (ref)
+ ref = last_component (ref);
+
+ /* Replace the old basename. */
+ new = aprintf ("%s%s", *name ? *name : "", ref ? ref : "");
+ xfree (*name);
+ *name = new;
+
+ /* Remove prefix drive letters if required, i.e. when in w32
+ environments. */
+ p = new;
+ while (p[0] != '\0')
+ {
+ while ((n = FILE_SYSTEM_PREFIX_LEN (p)) > 0)
+ p += n;
+
+ if (p != new)
+ {
+ while (ISSLASH (p[0]))
+ ++p;
+ new = p;
+ continue;
+ }
+
+ break;
+ }
+
+ if (*name != new)
+ {
+ new = xstrdup (new);
+ xfree (*name);
+ *name = new;
+ }
+}
+
+/*
+ Strip the directory components from the given name.
+
+ Return a pointer to the end of the leading directory components.
+ Return NULL if the resulting name is unsafe or invalid.
+
+ Due to security issues posed by saving files with unsafe names, here
+ the use of libmetalink's metalink_check_safe_path() is enforced. If
+ this appears redundant because the given name was already verified,
+ just remember to never underestimate unsafe file names.
+*/
+char *
+get_metalink_basename (char *name)
+{
+ int n;
+ char *basename;
+
+ if (!name)
+ return NULL;
+
+ basename = last_component (name);
+
+ while ((n = FILE_SYSTEM_PREFIX_LEN (basename)) > 0)
+ basename += n;
+
+ return metalink_check_safe_path (basename) ? basename : NULL;
+}
+
+/*
+ Append a separator and a numeric suffix to a string.
+
+ The string is permanently modified.
+*/
+void
+append_suffix_number (char **str, const char *sep, wgint num)
+{
+ char *new, buf[24];
+
+ number_to_string (buf, num);
+ new = aprintf ("%s%s%s", *str ? *str : "", sep ? sep : "", buf);
+ xfree (*str);
+ *str = new;
+}
+
+/*
+ Remove the string's trailing/leading whitespaces and line breaks.
+
+ The string is permanently modified.
+*/
+void
+clean_metalink_string (char **str)
+{
+ int c;
+ size_t len;
+ char *new, *beg, *end;
+
+ if (!str || !*str)
+ return;
+
+ beg = *str;
+
+ while ((c = *beg) && (c == '\n' || c == '\r' || c == '\t' || c == ' '))
+ beg++;
+
+ end = beg;
+
+ /* To not truncate a string containing spaces, search the first '\r'
+ or '\n' which ipotetically marks the end of the string. */
+ while ((c = *end) && (c != '\r') && (c != '\n'))
+ end++;
+
+ /* If we are at the end of the string, search the first legit
+ character going backward. */
+ if (*end == '\0')
+ while ((c = *(end - 1)) && (c == '\n' || c == '\r' || c == '\t' || c == ' '))
+ end--;
+
+ len = end - beg;
+
+ new = xmemdup0 (beg, len);
+ xfree (*str);
+ *str = new;
+}
+
+/*
+ Remove the quotation surrounding a string.
+
+ The string is permanently modified.
+ */
+void
+dequote_metalink_string (char **str)
+{
+ char *new;
+ size_t str_len;
+
+ if (!str || !*str || ((*str)[0] != '\"' && (*str)[0] != '\''))
+ return;
+
+ str_len = strlen (*str); /* current string length */
+
+ /* Verify if the current string is surrounded by quotes. */
+ if (str_len < 2 || (*str)[0] != (*str)[str_len - 1])
+ return;
+
+ /* Dequoted string. */
+ new = xmemdup0 (*str + 1, str_len - 2);
+ xfree (*str);
+ *str = new;
+}
+
+/* Append the suffix ".badhash" to the file NAME, except without
+ overwriting an existing file with that name and suffix. */
+void
+badhash_suffix (char *name)
+{
+ char *bhash, *uname;
+
+ bhash = concat_strings (name, ".badhash", (char *)0);
+ uname = unique_name (bhash, false);
+
+ logprintf (LOG_VERBOSE, _("Renaming %s to %s.\n"),
+ quote_n (0, name), quote_n (1, uname));
+
+ if (link (name, uname))
+ logprintf (LOG_NOTQUIET, "link: %s\n", strerror (errno));
+ else if (unlink (name))
+ logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
+
+ xfree (bhash);
+ xfree (uname);
+}
+
+/* Append the suffix ".badhash" to the file NAME, except without
+ overwriting an existing file with that name and suffix.
+
+ Remove the file NAME if the option --delete-after is specified, or
+ if the option --keep-badhash isn't set. */
+void
+badhash_or_remove (char *name)
+{
+ if (opt.delete_after || !opt.keep_badhash)
+ {
+ logprintf (LOG_VERBOSE, _("Removing %s.\n"), quote (name));
+ if (unlink (name))
+ logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
+ }
+ else
+ {
+ badhash_suffix(name);
+ }
+}
+
+/*
+ Simple file fetch.
+
+ Set DESTNAME to the name of the saved file.
+
+ Resume previous download if RESUME is true. To disable
+ Metalink/HTTP, set METALINK_HTTP to false.
+*/
+uerr_t
+fetch_metalink_file (const char *url_str,
+ bool resume, bool metalink_http,
+ const char *filename, char **destname)
+{
+ FILE *_output_stream = output_stream;
+ bool _output_stream_regular = output_stream_regular;
+ char *_output_document = opt.output_document;
+ bool _metalink_http = opt.metalink_over_http;
+
+ char *local_file = NULL;
+
+ uerr_t retr_err = URLERROR;
+
+ struct iri *iri;
+ struct url *url;
+ int url_err;
+
+ /* Parse the URL. */
+ iri = iri_new ();
+ set_uri_encoding (iri, opt.locale, true);
+ url = url_parse (url_str, &url_err, iri, false);
+
+ if (!url)
+ {
+ char *error = url_error (url_str, url_err);
+ logprintf (LOG_NOTQUIET, "%s: %s.\n", url_str, error);
+ inform_exit_status (retr_err);
+ iri_free (iri);
+ xfree (error);
+ return retr_err;
+ }
+
+ output_stream = NULL;
+
+ if (resume)
+ /* continue previous download */
+ output_stream = fopen (filename, "ab");
+ else
+ /* create a file with an unique name */
+ output_stream = unique_create (filename, true, &local_file);
+
+ output_stream_regular = true;
+
+ /*
+ If output_stream is NULL, the file couldn't be created/opened.
+ This could be due to the impossibility to create a directory tree:
+ * stdio.h (fopen)
+ * src/utils.c (unique_create)
+
+ A call to retrieve_url() can indirectly create a directory tree,
+ when opt.output_document is set to the destination file name and
+ output_stream is left to NULL:
+ * src/http.c (open_output_stream): If output_stream is NULL,
+ create the destination opt.output_document "path/file"
+ */
+ if (!local_file)
+ local_file = xstrdup (filename);
+
+ /* Store the real file name for displaying in messages, and for
+ proper "path/file" handling. */
+ opt.output_document = local_file;
+
+ opt.metalink_over_http = metalink_http;
+
+ DEBUGP (("Storing to %s\n", local_file));
+ retr_err = retrieve_url (url, url_str, NULL, NULL,
+ NULL, NULL, opt.recursive, iri, false);
+
+ if (retr_err == RETROK)
+ {
+ if (destname)
+ *destname = local_file;
+ else
+ xfree (local_file);
+ }
+
+ if (output_stream)
+ {
+ fclose (output_stream);
+ output_stream = NULL;
+ }
+
+ opt.metalink_over_http = _metalink_http;
+ opt.output_document = _output_document;
+ output_stream_regular = _output_stream_regular;
+ output_stream = _output_stream;
+
+ inform_exit_status (retr_err);
+
+ iri_free (iri);
+ url_free (url);
+
+ return retr_err;
+}
+
int metalink_res_cmp (const void* v1, const void* v2)
{
const metalink_resource_t *res1 = *(metalink_resource_t **) v1,
@@ -452,16 +1258,25 @@ int metalink_res_cmp (const void* v1, const void* v2)
{
int cmp = 0;
if (res1->location &&
- !strcasecmp (opt.preferred_location, res1->location))
+ !c_strcasecmp (opt.preferred_location, res1->location))
cmp -= 1;
if (res2->location &&
- !strcasecmp (opt.preferred_location, res2->location))
+ !c_strcasecmp (opt.preferred_location, res2->location))
cmp += 1;
return cmp;
}
return 0;
}
+int metalink_meta_cmp (const void* v1, const void* v2)
+{
+ const metalink_metaurl_t *meta1 = *(metalink_metaurl_t **) v1,
+ *meta2 = *(metalink_metaurl_t **) v2;
+ if (meta1->priority != meta2->priority)
+ return meta1->priority - meta2->priority;
+ return 0;
+}
+
/*
Find value of given key. This is intended for Link header, but will
work with any header that uses ';' as field separator and '=' as key-value
@@ -545,6 +1360,7 @@ find_key_value (const char *start, const char *end, const char *key, char **valu
while (val_end < end && *val_end != ';' && !c_isspace (*val_end))
val_end++;
*value = xstrndup (val_beg, val_end - val_beg);
+ dequote_metalink_string (value);
return true;
}
}
@@ -645,6 +1461,7 @@ find_key_values (const char *start, const char *end, char **key, char **value)
*key = xstrndup (key_start, key_end - key_start);
*value = xstrndup (val_start, val_end - val_start);
+ dequote_metalink_string (value);
/* Skip trailing whitespaces. */
while (val_end < end && c_isspace (*val_end))
@@ -657,10 +1474,10 @@ find_key_values (const char *start, const char *end, char **key, char **value)
const char *
test_find_key_values (void)
{
- static const char *header_data = "key1=val1;key2=val2 ;key3=val3; key4=val4"\
- " ; key5=val5;key6 =val6;key7= val7; "\
- "key8 = val8 ; key9 = val9 "\
- " ,key10= val10,key11,key12=val12";
+ static const char *header_data = "key1=val1;key2=\"val2\" ;key3=val3; key4=val4"\
+ " ; key5=val5;key6 ='val6';key7= val7; "\
+ "key8 = val8 ; key9 = \"val9\" "\
+ " ,key10= 'val10',key11,key12=val12";
static const struct
{
const char *key;
@@ -701,9 +1518,9 @@ test_find_key_values (void)
const char *
test_find_key_value (void)
{
- static const char *header_data = "key1=val1;key2=val2 ;key3=val3; key4=val4"\
- " ; key5=val5;key6 =val6;key7= val7; "\
- "key8 = val8 ; key9 = val9 ";
+ static const char *header_data = "key1=val1;key2=val2 ;key3='val3'; key4=val4"\
+ " ; key5='val5';key6 =val6;key7= \"val7\"; "\
+ "key8 = \"val8\" ; key9 = val9 ";
static const struct
{
const char *key;
diff --git a/src/metalink.h b/src/metalink.h
index e98c210..2a8481d 100644
--- a/src/metalink.h
+++ b/src/metalink.h
@@ -46,6 +46,21 @@ as that of the covered work. */
uerr_t retrieve_from_metalink (const metalink_t *metalink);
int metalink_res_cmp (const void *res1, const void *res2);
+int metalink_meta_cmp (const void* meta1, const void* meta2);
+
+int metalink_check_safe_path (const char *path);
+
+char *last_component (char const *name);
+void replace_metalink_basename (char **name, char *ref);
+char *get_metalink_basename (char *name);
+void append_suffix_number (char **str, const char *sep, wgint num);
+void clean_metalink_string (char **str);
+void dequote_metalink_string (char **str);
+void badhash_suffix (char *name);
+void badhash_or_remove (char *name);
+uerr_t fetch_metalink_file (const char *url_str,
+ bool resume, bool metalink_http,
+ const char *filename, char **destname);
bool find_key_value (const char *start,
const char *end,
diff --git a/src/mswindows.c b/src/mswindows.c
index 9735370..90e6ec4 100644
--- a/src/mswindows.c
+++ b/src/mswindows.c
@@ -53,9 +53,6 @@ as that of the covered work. */
#endif
-/* Defined in log.c. */
-void log_request_redirect_output (const char *);
-
/* Windows version of xsleep in utils.c. */
void
@@ -98,7 +95,7 @@ static void
ws_hangup (const char *reason)
{
fprintf (stderr, _("Continuing in background.\n"));
- log_request_redirect_output (reason);
+ redirect_output (true, reason);
/* Detach process from the current console. Under Windows 9x, if we
were launched from a 16-bit process (which is usually the case;
diff --git a/src/netrc.c b/src/netrc.c
index 02ae1be..47fe9b0 100644
--- a/src/netrc.c
+++ b/src/netrc.c
@@ -75,7 +75,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
#ifdef __VMS
int err;
- struct_stat buf;
+ struct stat buf;
char *path = "SYS$LOGIN:.netrc";
netrc_list = NULL;
@@ -94,7 +94,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
if (home)
{
int err;
- struct_stat buf;
+ struct stat buf;
char *path = (char *)alloca (strlen (home) + 1
+ strlen (NETRC_FILE_NAME) + 1);
sprintf (path, "%s/%s", home, NETRC_FILE_NAME);
@@ -439,7 +439,7 @@ free_netrc(acc_t *l)
int
main (int argc, char **argv)
{
- struct_stat sb;
+ struct stat sb;
char *program_name, *file, *target;
acc_t *head, *a;
diff --git a/src/openssl.c b/src/openssl.c
index c6549ea..0404d2d 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -204,18 +204,20 @@ ssl_init (void)
#endif
SSL_library_init ();
SSL_load_error_strings ();
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
SSLeay_add_all_algorithms ();
SSLeay_add_ssl_algorithms ();
+#endif
switch (opt.secure_protocol)
{
-#ifndef OPENSSL_NO_SSL2
+#if !defined OPENSSL_NO_SSL2 && OPENSSL_VERSION_NUMBER < 0x10100000L
case secure_protocol_sslv2:
meth = SSLv2_client_method ();
break;
#endif
-#ifndef OPENSSL_NO_SSL3
+#ifndef OPENSSL_NO_SSL3_METHOD
case secure_protocol_sslv3:
meth = SSLv3_client_method ();
break;
@@ -583,7 +585,7 @@ ssl_connect_wget (int fd, const char *hostname, int *continue_session)
DEBUGP (("SSL handshake timed out.\n"));
goto timeout;
}
- if (scwt_ctx.result <= 0 || SSL_state(conn) != SSL_ST_OK)
+ if (scwt_ctx.result <= 0 || !SSL_is_init_finished(conn))
goto error;
ctx = xnew0 (struct openssl_transport_context);
diff --git a/src/options.h b/src/options.h
index a8c494b..d713acc 100644
--- a/src/options.h
+++ b/src/options.h
@@ -67,6 +67,7 @@ struct options
char *input_filename; /* Input filename */
#ifdef HAVE_METALINK
char *input_metalink; /* Input metalink file */
+ int metalink_index; /* Metalink application/metalink4+xml metaurl ordinal number. */
bool metalink_over_http; /* Use Metalink if present in HTTP response */
char *preferred_location; /* Preferred location for Metalink resources */
#endif
@@ -127,9 +128,12 @@ struct options
bool warc_keep_log; /* Store the log file in a WARC record. */
char **warc_user_headers; /* User-defined WARC header(s). */
+ bool enable_xattr; /* Store metadata in POSIX extended attributes. */
+
char *user; /* Generic username */
char *passwd; /* Generic password */
bool ask_passwd; /* Ask for password? */
+ char *use_askpass; /* value to use for use-askpass if WGET_ASKPASS is not set */
bool always_rest; /* Always use REST. */
wgint start_pos; /* Start position of a download. */
@@ -243,7 +247,7 @@ struct options
char *pinnedpubkey; /* Public key (PEM/DER) file, or any number
of base64 encoded sha256 hashes preceded by
- \'sha256//\' and seperated by \';\', to verify
+ \'sha256//\' and separated by \';\', to verify
peer against */
char *random_file; /* file with random data to seed the PRNG */
@@ -258,6 +262,7 @@ struct options
bool cookies; /* whether cookies are used. */
char *cookies_input; /* file we're loading the cookies from. */
char *cookies_output; /* file we're saving the cookies to. */
+ bool keep_badhash; /* Keep files with checksum mismatch. */
bool keep_session_cookies; /* whether session cookies should be
saved and loaded. */
@@ -306,7 +311,7 @@ struct options
bool enable_iri;
char *encoding_remote;
- char *locale;
+ const char *locale;
bool trustservernames;
#ifdef __VMS
diff --git a/src/progress.c b/src/progress.c
index c635d19..f44e0ee 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -892,11 +892,6 @@ get_eta (int *bcd)
p += sizeof (s) - 1; \
} while (0)
-/* Use move_to_end (s) to get S to point the end of the string (the
- terminating \0). This is faster than s+=strlen(s), but some people
- are confused when they see strchr (s, '\0') in the code. */
-#define move_to_end(s) s = strchr (s, '\0');
-
static void
create_image (struct bar_progress *bp, double dl_total_time, bool done)
{
diff --git a/src/recur.c b/src/recur.c
index 2b17e72..42b4eb1 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -438,10 +438,15 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi)
struct url *url_parsed = url_parse (url, NULL, i, true);
struct iri *ci;
char *referer_url = url;
- bool strip_auth = (url_parsed != NULL
- && url_parsed->user != NULL);
+ bool strip_auth;
+
assert (url_parsed != NULL);
+ if (!url_parsed)
+ continue;
+
+ strip_auth = (url_parsed && url_parsed->user);
+
/* Strip auth info if present */
if (strip_auth)
referer_url = url_string (url_parsed, URL_AUTH_HIDE);
@@ -451,9 +456,16 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi)
reject_reason r;
if (child->ignore_when_downloading)
- continue;
+ {
+ DEBUGP (("Not following due to 'ignore' flag: %s\n", child->url->url));
+ continue;
+ }
+
if (dash_p_leaf_HTML && !child->link_inline_p)
- continue;
+ {
+ DEBUGP (("Not following due to 'link inline' flag: %s\n", child->url->url));
+ continue;
+ }
r = download_child (child, url_parsed, depth,
start_url_parsed, blacklist, i);
@@ -801,6 +813,12 @@ descend_redirect (const char *redirected, struct url *orig_parsed, int depth,
if (reason == WG_RR_SUCCESS)
blacklist_add (blacklist, upos->url->url);
+ else if (reason == WG_RR_LIST || reason == WG_RR_REGEX)
+ {
+ DEBUGP (("Ignoring decision for redirects, decided to load it.\n"));
+ blacklist_add (blacklist, upos->url->url);
+ reason = WG_RR_SUCCESS;
+ }
else
DEBUGP (("Redirection \"%s\" failed the test.\n", redirected));
diff --git a/src/retr.c b/src/retr.c
index 05668a0..5ba744f 100644
--- a/src/retr.c
+++ b/src/retr.c
@@ -634,7 +634,7 @@ retr_rate (wgint bytes, double secs)
double dlrate = calc_rate (bytes, secs, &units);
/* Use more digits for smaller numbers (regardless of unit used),
e.g. "1022", "247", "12.5", "2.38". */
- sprintf (res, "%.*f %s",
+ snprintf (res, sizeof(res), "%.*f %s",
dlrate >= 99.95 ? 0 : dlrate >= 9.995 ? 1 : 2,
dlrate, !opt.report_bps ? rate_names[units]: rate_names_bits[units]);
@@ -869,7 +869,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
redirects, but a ton of boneheaded webservers and CGIs out
there break the rules and use relative URLs, and popular
browsers are lenient about this, so wget should be too. */
- construced_newloc = uri_merge (url, mynewloc);
+ construced_newloc = uri_merge (url, mynewloc ? mynewloc : "");
xfree (mynewloc);
mynewloc = construced_newloc;
@@ -1147,7 +1147,7 @@ retrieve_from_file (const char *file, bool html, int *count)
Removing file due to --delete-after in retrieve_from_file():\n"));
logprintf (LOG_VERBOSE, _("Removing %s.\n"), filename);
if (unlink (filename))
- logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
+ logprintf (LOG_NOTQUIET, "Failed to unlink %s: (%d) %s\n", filename, errno, strerror (errno));
dt &= ~RETROKF;
}
@@ -1248,9 +1248,9 @@ rotate_backups(const char *fname)
#endif
int maxlen = strlen (fname) + sizeof (SEP) + numdigit (opt.backups) + AVSL;
- char *from = (char *)alloca (maxlen);
- char *to = (char *)alloca (maxlen);
- struct_stat sb;
+ char *from = alloca (maxlen);
+ char *to = alloca (maxlen);
+ struct stat sb;
int i;
if (stat (fname, &sb) == 0)
@@ -1267,17 +1267,21 @@ rotate_backups(const char *fname)
*/
if (i == opt.backups)
{
- sprintf (to, "%s%s%d%s", fname, SEP, i, AVS);
+ snprintf (to, sizeof(to), "%s%s%d%s", fname, SEP, i, AVS);
delete (to);
}
#endif
- sprintf (to, "%s%s%d", fname, SEP, i);
- sprintf (from, "%s%s%d", fname, SEP, i - 1);
- rename (from, to);
+ snprintf (to, maxlen, "%s%s%d", fname, SEP, i);
+ snprintf (from, maxlen, "%s%s%d", fname, SEP, i - 1);
+ if (rename (from, to))
+ logprintf (LOG_NOTQUIET, "Failed to rename %s to %s: (%d) %s\n",
+ from, to, errno, strerror (errno));
}
- sprintf (to, "%s%s%d", fname, SEP, 1);
- rename(fname, to);
+ snprintf (to, maxlen, "%s%s%d", fname, SEP, 1);
+ if (rename(fname, to))
+ logprintf (LOG_NOTQUIET, "Failed to rename %s to %s: (%d) %s\n",
+ fname, to, errno, strerror (errno));
}
static bool no_proxy_match (const char *, const char **);
diff --git a/src/sysdep.h b/src/sysdep.h
index 8da7611..8bc3d93 100644
--- a/src/sysdep.h
+++ b/src/sysdep.h
@@ -35,53 +35,11 @@ as that of the covered work. */
#ifndef SYSDEP_H
#define SYSDEP_H
-/* Testing for __sun is not enough because it's also defined on SunOS. */
-#ifdef __sun
-# ifdef __SVR4
-# define solaris
-# endif
-#endif
-
-#if defined(__INTERIX) && !defined(_ALL_SOURCE)
-# define _ALL_SOURCE
-#endif
-
-/* The "namespace tweaks" below attempt to set a friendly "compilation
- environment" under popular operating systems. Default compilation
- environment often means that some functions that are "extensions"
- are not declared -- `strptime' is one example.
-
- But non-default environments can expose bugs in the system header
- files, crippling compilation in _very_ non-obvious ways. Because
- of that, we define them only on well-tested architectures where we
- know they will work. */
-
-#undef NAMESPACE_TWEAKS
-
-#ifdef solaris
-# define NAMESPACE_TWEAKS
-#endif
-
-#if defined(__linux__) || defined(__GLIBC__)
-# define NAMESPACE_TWEAKS
-#endif
-
-#ifdef NAMESPACE_TWEAKS
-
-#endif /* NAMESPACE_TWEAKS */
-
-
-/* Alloca declaration, based on recommendation in the Autoconf manual.
- These have to be after the above namespace tweaks, but before any
- non-preprocessor code. */
+/* Provided by gnulib on systems that don't have it: */
#include <alloca.h>
-
-/* Must include these, so we can test for the missing stat macros and
- define them as necessary. */
#include <sys/types.h>
#include <sys/stat.h>
-
#include <stdint.h>
#include <inttypes.h>
@@ -95,98 +53,9 @@ as that of the covered work. */
# include "mswindows.h"
#endif
-/* Provided by gnulib on systems that don't have it: */
-# include <stdbool.h>
-
-#ifndef struct_stat
-# define struct_stat struct stat
-#endif
-#ifndef struct_fstat
-# define struct_fstat struct stat
-#endif
-
-#include <intprops.h>
-
-/* For CHAR_BIT, LONG_MAX, etc. */
+#include <stdbool.h>
#include <limits.h>
-
-#ifndef CHAR_BIT
-# define CHAR_BIT 8
-#endif
-
-/* These are defined in cmpt.c if missing, so we must declare
- them. */
-#ifndef HAVE_STRCASECMP
-int strcasecmp ();
-#endif
-#ifndef HAVE_STRNCASECMP
-int strncasecmp ();
-#endif
-#ifndef HAVE_STRPTIME
-char *strptime ();
-#endif
-#ifndef HAVE_TIMEGM
-# include <time.h>
-time_t timegm (struct tm *);
-#endif
-#ifndef HAVE_MEMRCHR
-void *memrchr (const void *, int, size_t);
-#endif
-
-/* These are defined in snprintf.c. It would be nice to have an
- snprintf.h, though. */
-#ifndef HAVE_SNPRINTF
-int snprintf (char *str, size_t count, const char *fmt, ...);
-#endif
-#ifndef HAVE_VSNPRINTF
-#include <stdarg.h>
-int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
-#endif
-
-/* Enable system fnmatch only on systems where fnmatch.h is usable.
- If the fnmatch on your system is buggy, undef this symbol and a
- replacement implementation will be used instead. */
-#ifdef HAVE_WORKING_FNMATCH_H
-# define SYSTEM_FNMATCH
-#endif
-
#include <fnmatch.h>
-
-/* Provide sig_atomic_t if the system doesn't. */
-#ifndef HAVE_SIG_ATOMIC_T
-typedef int sig_atomic_t;
-#endif
-
-/* Provide uint32_t on the platforms that don't define it. Although
- most code should be agnostic about integer sizes, some code really
- does need a 32-bit integral type. Such code should use uint32_t.
- (The exception is gnu-md5.[ch], which uses its own detection for
- portability across platforms.) */
-
-#ifndef HAVE_UINT32_T
-# if SIZEOF_INT == 4
-typedef unsigned int uint32_t;
-# else
-# if SIZEOF_LONG == 4
-typedef unsigned long uint32_t;
-# else
-# if SIZEOF_SHORT == 4
-typedef unsigned short uint32_t;
-# else
- #error "Cannot determine a 32-bit unsigned integer type"
-# endif
-# endif
-# endif
-#endif
-
-/* If uintptr_t isn't defined, simply typedef it to unsigned long. */
-#ifndef HAVE_UINTPTR_T
-typedef unsigned long uintptr_t;
-#endif
-
-/* If intptr_t isn't defined, simply typedef it to long. */
-#ifndef HAVE_INTPTR_T
-typedef long intptr_t;
-#endif
+#include "intprops.h"
#endif /* SYSDEP_H */
diff --git a/src/url.c b/src/url.c
index ec38d6f..c442891 100644
--- a/src/url.c
+++ b/src/url.c
@@ -43,10 +43,10 @@ as that of the covered work. */
#include "host.h" /* for is_valid_ipv6_address */
#include "c-strcase.h"
-#if HAVE_ICONV
-#include <iconv.h>
-#include <langinfo.h>
+#ifdef HAVE_ICONV
+# include <iconv.h>
#endif
+#include <langinfo.h>
#ifdef __VMS
#include "vms.h"
@@ -512,6 +512,12 @@ scheme_disable (enum url_scheme scheme)
supported_schemes[scheme].flags |= scm_disabled;
}
+const char *
+scheme_leading_string (enum url_scheme scheme)
+{
+ return supported_schemes[scheme].leading_string;
+}
+
/* Skip the username and password, if present in the URL. The
function should *not* be called with the complete URL, but with the
portion after the scheme.
@@ -1207,7 +1213,7 @@ url_free (struct url *url)
if (url)
{
if (url->idn_allocated) {
- idn_free (url->host); /* A dummy if !defined(ENABLE_IRI) */
+ idn2_free (url->host); /* A dummy if !defined(ENABLE_IRI) */
url->host = NULL;
}
else
@@ -1236,7 +1242,7 @@ mkalldirs (const char *path)
{
const char *p;
char *t;
- struct_stat st;
+ struct stat st;
int res;
p = path + strlen (path);
@@ -1271,12 +1277,14 @@ mkalldirs (const char *path)
name exists, we just remove it and create the directory
anyway. */
DEBUGP (("Removing %s because of directory danger!\n", t));
- unlink (t);
+ if (unlink (t))
+ logprintf (LOG_NOTQUIET, "Failed to unlink %s (%d): %s\n",
+ t, errno, strerror(errno));
}
}
res = make_directory (t);
if (res != 0)
- logprintf (LOG_NOTQUIET, "%s: %s", t, strerror (errno));
+ logprintf (LOG_NOTQUIET, "%s: %s\n", t, strerror (errno));
xfree (t);
return res;
}
@@ -1540,7 +1548,6 @@ static char *
convert_fname (char *fname)
{
char *converted_fname = fname;
-#if HAVE_ICONV
const char *from_encoding = opt.encoding_remote;
const char *to_encoding = opt.locale;
iconv_t cd;
@@ -1567,7 +1574,7 @@ convert_fname (char *fname)
for (;;)
{
- if (iconv (cd, &fname, &inlen, &s, &outlen) != (size_t)(-1)
+ if (iconv (cd, (ICONV_CONST char **) &fname, &inlen, &s, &outlen) != (size_t)(-1)
&& iconv (cd, NULL, NULL, &s, &outlen) != (size_t)(-1))
{
*(converted_fname + len - outlen - done) = '\0';
@@ -1607,7 +1614,6 @@ convert_fname (char *fname)
}
iconv_close(cd);
-#endif
return converted_fname;
}
diff --git a/src/url.h b/src/url.h
index 7c77737..94d1528 100644
--- a/src/url.h
+++ b/src/url.h
@@ -100,8 +100,8 @@ struct url
char *user;
char *passwd;
- /* 'host' is allocated by idna_to_ascii_8z() via idn_encode().
- * Call 'idn_free()' to free this memory. */
+ /* 'host' is allocated by idn2_lookup_u8() via idn_encode().
+ * Call 'idn2_free()' to free this memory. */
bool idn_allocated;
};
@@ -124,6 +124,7 @@ bool url_has_scheme (const char *);
bool url_valid_scheme (const char *);
int scheme_default_port (enum url_scheme);
void scheme_disable (enum url_scheme);
+const char *scheme_leading_string (enum url_scheme);
char *url_string (const struct url *, enum url_auth_mode);
char *url_file_name (const struct url *, char *);
diff --git a/src/utils.c b/src/utils.c
index b07da9f..db89ae1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -113,7 +113,7 @@ as that of the covered work. */
#include "exits.h"
#include "c-strcase.h"
-static void _Noreturn
+_Noreturn static void
memfatal (const char *context, long attempted_size)
{
/* Make sure we don't try to store part of the log line, and thus
@@ -235,14 +235,20 @@ xstrdup_lower (const char *s)
/* Copy the string formed by two pointers (one on the beginning, other
on the char after the last char) to a new, malloc-ed location.
- 0-terminate it. */
+ 0-terminate it.
+ If both pointers are NULL, the function returns an empty string. */
char *
strdupdelim (const char *beg, const char *end)
{
- char *res = xmalloc (end - beg + 1);
- memcpy (res, beg, end - beg);
- res[end - beg] = '\0';
- return res;
+ if (beg && beg <= end)
+ {
+ char *res = xmalloc (end - beg + 1);
+ memcpy (res, beg, end - beg);
+ res[end - beg] = '\0';
+ return res;
+ }
+
+ return xstrdup("");
}
/* Parse a string containing comma-separated elements, and return a
@@ -292,13 +298,6 @@ sepstring (const char *s)
vsnprintf until the correct size is found. Since Wget also ships a
fallback implementation of vsnprintf, this should be portable. */
-/* Constant is using for limits memory allocation for text buffer.
- Applicable in situation when: vasprintf is not available in the system
- and vsnprintf return -1 when long line is truncated (in old versions of
- glibc and in other system where C99 doesn`t support) */
-
-#define FMT_MAX_LENGTH 1048576
-
char *
aprintf (const char *fmt, ...)
{
@@ -318,6 +317,13 @@ aprintf (const char *fmt, ...)
return str;
#else /* not HAVE_VASPRINTF */
+/* Constant is using for limits memory allocation for text buffer.
+ Applicable in situation when: vasprintf is not available in the system
+ and vsnprintf return -1 when long line is truncated (in old versions of
+ glibc and in other system where C99 doesn`t support) */
+
+#define FMT_MAX_LENGTH 1048576
+
/* vasprintf is unavailable. snprintf into a small buffer and
resize it as necessary. */
int size = 32;
@@ -567,7 +573,7 @@ int
remove_link (const char *file)
{
int err = 0;
- struct_stat st;
+ struct stat st;
if (lstat (file, &st) == 0 && S_ISLNK (st.st_mode))
{
@@ -593,7 +599,7 @@ file_exists_p (const char *filename)
#ifdef HAVE_ACCESS
return access (filename, F_OK) >= 0;
#else
- struct_stat buf;
+ struct stat buf;
return stat (filename, &buf) >= 0;
#endif
}
@@ -603,7 +609,7 @@ file_exists_p (const char *filename)
bool
file_non_directory_p (const char *path)
{
- struct_stat buf;
+ struct stat buf;
/* Use lstat() rather than stat() so that symbolic links pointing to
directories can be identified correctly. */
if (lstat (path, &buf) != 0)
@@ -630,7 +636,7 @@ file_size (const char *filename)
fclose (fp);
return size;
#else
- struct_stat st;
+ struct stat st;
if (stat (filename, &st) < 0)
return -1;
return st.st_size;
@@ -1184,7 +1190,7 @@ wget_read_file (const char *file)
#ifdef HAVE_MMAP
{
- struct_fstat buf;
+ struct stat buf;
if (fstat (fd, &buf) < 0)
goto mmap_lose;
fm->length = buf.st_size;
@@ -1327,7 +1333,7 @@ merge_vecs (char **v1, char **v2)
for (j = 0; v2[j]; j++)
;
/* Reallocate v1. */
- v1 = xrealloc (v1, (i + j + 1) * sizeof (char **));
+ v1 = xrealloc (v1, (i + j + 1) * sizeof (char *));
memcpy (v1 + i, v2, (j + 1) * sizeof (char *));
xfree (v2);
return v1;
@@ -1930,7 +1936,7 @@ random_float (void)
static sigjmp_buf run_with_timeout_env;
-static void _Noreturn
+_Noreturn static void
abort_run_with_timeout (int sig _GL_UNUSED)
{
assert (sig == SIGALRM);
@@ -2045,13 +2051,16 @@ run_with_timeout (double timeout, void (*fun) (void *), void *arg)
return false;
}
- signal (SIGALRM, abort_run_with_timeout);
if (SETJMP (run_with_timeout_env) != 0)
{
/* Longjumped out of FUN with a timeout. */
signal (SIGALRM, SIG_DFL);
return true;
}
+ else
+ {
+ signal (SIGALRM, abort_run_with_timeout);
+ }
alarm_set (timeout);
fun (arg);
@@ -2140,7 +2149,7 @@ xsleep (double seconds)
base64 data. */
size_t
-base64_encode (const void *data, size_t length, char *dest)
+wget_base64_encode (const void *data, size_t length, char *dest)
{
/* Conversion table. */
static const char tbl[64] = {
@@ -2208,7 +2217,7 @@ base64_encode (const void *data, size_t length, char *dest)
This function originates from Free Recode. */
ssize_t
-base64_decode (const char *base64, void *dest)
+wget_base64_decode (const char *base64, void *dest)
{
/* Table of base64 values for first 128 characters. Note that this
assumes ASCII (but so does Wget in other places). */
@@ -2413,17 +2422,17 @@ mergesort_internal (void *base, void *temp, size_t size, size_t from, size_t to,
}
/* Stable sort with interface exactly like standard library's qsort.
- Uses mergesort internally, allocating temporary storage with
- alloca. */
+ Uses mergesort internally. */
void
stable_sort (void *base, size_t nmemb, size_t size,
int (*cmpfun) (const void *, const void *))
{
- if (size > 1)
+ if (nmemb > 1 && size > 1)
{
- void *temp = alloca (nmemb * size * sizeof (void *));
+ void *temp = xmalloc (nmemb * size);
mergesort_internal (base, temp, size, 0, nmemb - 1, cmpfun);
+ xfree(temp);
}
}
@@ -2524,7 +2533,7 @@ wg_hex_to_string (char *str_buffer, const char *hex_buffer, size_t hex_len)
for (i = 0; i < hex_len; i++)
{
/* Each byte takes 2 characters. */
- sprintf (str_buffer + 2 * i, "%02x", hex_buffer[i] & 0xFF);
+ sprintf (str_buffer + 2 * i, "%02x", (unsigned) (hex_buffer[i] & 0xFF));
}
/* Null-terminate result. */
@@ -2588,7 +2597,7 @@ wg_pubkey_pem_to_der (const char *pem, unsigned char **der, size_t *der_len)
base64data = xmalloc (BASE64_LENGTH(stripped_pem_count));
- size = base64_decode (stripped_pem, base64data);
+ size = wget_base64_decode (stripped_pem, base64data);
if (size < 0) {
xfree (base64data); /* malformed base64 from server */
@@ -2651,7 +2660,7 @@ wg_pin_peer_pubkey (const char *pinnedpubkey, const char *pubkey, size_t pubkeyl
end_pos[0] = '\0';
/* decode base64 pinnedpubkey, 8 is length of "sha256//" */
- decoded_hash_length = base64_decode (begin_pos + 8, expectedsha256sumdigest);
+ decoded_hash_length = wget_base64_decode (begin_pos + 8, expectedsha256sumdigest);
/* if valid base64, compare sha256 digests directly */
if (SHA256_DIGEST_SIZE == decoded_hash_length &&
!memcmp (sha256sumdigest, expectedsha256sumdigest, SHA256_DIGEST_SIZE)) {
diff --git a/src/utils.h b/src/utils.h
index f224b73..aaac730 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -140,8 +140,8 @@ void xsleep (double);
/* How many bytes it will take to store LEN bytes in base64. */
#define BASE64_LENGTH(len) (4 * (((len) + 2) / 3))
-size_t base64_encode (const void *, size_t, char *);
-ssize_t base64_decode (const char *, void *);
+size_t wget_base64_encode (const void *, size_t, char *);
+ssize_t wget_base64_decode (const char *, void *);
#ifdef HAVE_LIBPCRE
void *compile_pcre_regex (const char *);
diff --git a/src/wget.h b/src/wget.h
index eacf725..ed57245 100644
--- a/src/wget.h
+++ b/src/wget.h
@@ -361,7 +361,8 @@ typedef enum
TIMECONV_ERR,
METALINK_PARSE_ERROR, METALINK_RETR_ERROR,
METALINK_CHKSUM_ERROR, METALINK_SIG_ERROR, METALINK_MISSING_RESOURCE,
- RETR_WITH_METALINK
+ RETR_WITH_METALINK,
+ METALINK_SIZE_ERROR
} uerr_t;
/* 2005-02-19 SMS.
diff --git a/src/xattr.c b/src/xattr.c
new file mode 100644
index 0000000..f2b208a
--- /dev/null
+++ b/src/xattr.c
@@ -0,0 +1,79 @@
+/* xattr.h -- POSIX Extended Attribute support.
+
+ Copyright (C) 2016 Free Software Foundation, Inc.
+
+ This program 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, or (at your option)
+ any later version.
+
+ This program 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 this program; if not, see <http://www.gnu.org/licenses/>. */
+
+#include "wget.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "log.h"
+#include "xattr.h"
+
+#ifdef USE_XATTR
+
+static int
+write_xattr_metadata (const char *name, const char *value, FILE *fp)
+{
+ int retval = -1;
+
+ if (name && value && fp)
+ {
+ retval = fsetxattr (fileno (fp), name, value, strlen (value), 0);
+ /* FreeBSD's extattr_set_fd returns the length of the extended attribute. */
+ retval = (retval < 0) ? retval : 0;
+ if (retval)
+ DEBUGP (("Failed to set xattr %s.\n", quote(name)));
+ }
+
+ return retval;
+}
+
+#else /* USE_XATTR */
+
+static int
+write_xattr_metadata (const char *name, const char *value, FILE *fp)
+{
+ (void)name;
+ (void)value;
+ (void)fp;
+
+ return 0;
+}
+
+#endif /* USE_XATTR */
+
+int
+set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp)
+{
+ /* Save metadata about where the file came from (requested, final URLs) to
+ * user POSIX Extended Attributes of retrieved file.
+ *
+ * For more details about the user namespace see
+ * [http://freedesktop.org/wiki/CommonExtendedAttributes] and
+ * [http://0pointer.de/lennart/projects/mod_mime_xattr/].
+ */
+ int retval = -1;
+
+ if (!origin_url || !fp)
+ return retval;
+
+ retval = write_xattr_metadata ("user.xdg.origin.url", escnonprint_uri (origin_url), fp);
+ if ((!retval) && referrer_url)
+ retval = write_xattr_metadata ("user.xdg.referrer.url", escnonprint_uri (referrer_url), fp);
+
+ return retval;
+}
diff --git a/src/xattr.h b/src/xattr.h
new file mode 100644
index 0000000..e7ebed8
--- /dev/null
+++ b/src/xattr.h
@@ -0,0 +1,45 @@
+/* xattr.h -- POSIX Extended Attribute function mappings.
+
+ Copyright (C) 2016 Free Software Foundation, Inc.
+
+ This program 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, or (at your option)
+ any later version.
+
+ This program 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 this program; if not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+
+#ifndef _XATTR_H
+#define _XATTR_H
+
+/* Store metadata name/value attributes against fp. */
+int set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp);
+
+#if defined(__linux)
+/* libc on Linux has fsetxattr (5 arguments). */
+# include <sys/xattr.h>
+# define USE_XATTR
+#elif defined(__APPLE__)
+/* libc on OS/X has fsetxattr (6 arguments). */
+# include <sys/xattr.h>
+# define fsetxattr (file, name, buffer, size, flags) \
+ fsetxattr ((file), (name), (buffer), (size), 0, (flags))
+# define USE_XATTR
+#elif defined(__FreeBSD_version) && (__FreeBSD_version > 500000)
+/* FreeBSD */
+# include <sys/types.h>
+# include <sys/extattr.h>
+# define fsetxattr (file, name, buffer, size, flags) \
+ extattr_set_fd ((file), EXTATTR_NAMESPACE_USER, (name), (buffer), (size))
+# define USE_XATTR
+#endif
+
+#endif /* _XATTR_H */