diff -urN wget-1.10.2/configure wget-1.10.2_new/configure --- wget-1.10.2/configure 2005-10-13 11:22:29.000000000 +0200 +++ wget-1.10.2_new/configure 2006-06-27 12:03:10.000000000 +0200 @@ -309,7 +309,7 @@ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION PACKAGE build build_cpu build_vendor build_os host host_cpu host_vendor host_os OPIE_OBJ SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP exeext U ANSI2KNR ALLOCA GETOPT_OBJ HAVE_LIBSSL LIBSSL LTLIBSSL SSL_OBJ NTLM_OBJ MD5_OBJ MSGFMT XGETTEXT GMSGFMT CATALOGS CATOBJEXT DATADIRNAME GMOFILES INSTOBJEXT INTLLIBS POFILES HAVE_NLS USE_NLS MAKEINFO PERL POD2MAN COMMENT_IF_NO_POD2MAN LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION PACKAGE build build_cpu build_vendor build_os host host_cpu host_vendor host_os OPIE_OBJ SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP exeext ALLOCA GETOPT_OBJ HAVE_LIBGNUTLS LIBGNUTLS LTLIBGNUTLS HAVE_LIBSSL LIBSSL LTLIBSSL SSL_OBJ NTLM_OBJ MD5_OBJ MSGFMT XGETTEXT GMSGFMT CATALOGS CATOBJEXT DATADIRNAME GMOFILES INSTOBJEXT INTLLIBS POFILES HAVE_NLS USE_NLS MAKEINFO PERL POD2MAN COMMENT_IF_NO_POD2MAN LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -858,6 +858,8 @@ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-ssl disable SSL autodetection --with-gnu-ld assume the C compiler uses GNU ld default=no + --with-libgnutls-prefix[=DIR] search for libgnutls in DIR/include and DIR/lib + --without-libgnutls-prefix don't search for libgnutls in includedir and libdir --with-libssl-prefix[=DIR] search for libssl in DIR/include and DIR/lib --without-libssl-prefix don't search for libssl in includedir and libdir @@ -961,7 +963,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd $ac_popdir + cd "$ac_popdir" done fi @@ -1334,27 +1336,6 @@ -# serial 1 - -# @defmac AC_PROG_CC_STDC -# @maindex PROG_CC_STDC -# @ovindex CC -# If the C compiler in not in ANSI C mode by default, try to add an option -# to output variable @code{CC} to make it so. This macro tries various -# options that select ANSI C on some system or another. It considers the -# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and -# handles function prototypes correctly. -# -# If you use this macro, you should check after calling it whether the C -# compiler has been set to accept ANSI C; if not, the shell variable -# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source -# code in ANSI C, you can make an un-ANSIfied copy of it by using the -# program @code{ansi2knr}, which comes with Ghostscript. -# @end defmac - - - - @@ -1386,6 +1367,7 @@ # serial 1 + # lib-ld.m4 serial 3 (gettext-0.13) @@ -1571,7 +1553,7 @@ wget_need_md5=yes esac if test x"$ENABLE_OPIE" = xyes; then - OPIE_OBJ='ftp-opie$o' + OPIE_OBJ='ftp-opie.o' fi @@ -2257,8 +2239,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2316,8 +2297,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2433,8 +2413,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2488,8 +2467,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2534,8 +2512,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2579,8 +2556,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2900,92 +2876,9 @@ -echo "$as_me:$LINENO: checking for ${CC-cc} option to accept ANSI C" >&5 -echo $ECHO_N "checking for ${CC-cc} option to accept ANSI C... $ECHO_C" >&6 -if test "${am_cv_prog_cc_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - am_cv_prog_cc_stdc=no -ac_save_CC="$CC" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Aa -D_HPUX_SOURCE -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -do - CC="$ac_save_CC $ac_arg" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if !defined(__STDC__) -choke me -#endif -/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */ -#ifdef _SEQUENT_ -# include -# include -#endif - -int -main () -{ - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - am_cv_prog_cc_stdc="$ac_arg"; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -CC="$ac_save_CC" - -fi - -echo "$as_me:$LINENO: result: $am_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$am_cv_prog_cc_stdc" >&6 -case "x$am_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $am_cv_prog_cc_stdc" ;; -esac - - if test -n "$auto_cflags"; then if test -n "$GCC"; then - CFLAGS="$CFLAGS -O2 -Wall -Wno-implicit" + CFLAGS="$CFLAGS -O2 -Wall" else case "$host_os" in *hpux*) CFLAGS="$CFLAGS +O3" ;; @@ -3076,8 +2969,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3137,8 +3029,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3210,8 +3101,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3242,27 +3132,26 @@ fi -echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 -if test "${ac_cv_c_bigendian+set}" = set; then + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - # See if sys/param.h defines the BYTE_ORDER macro. -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include +#include +#include +#include +#include int main () { -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros -#endif ; return 0; @@ -3277,8 +3166,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3290,124 +3178,61 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - # It does; now see whether it defined to BIG_ENDIAN or not. -cat >conftest.$ac_ext <<_ACEOF + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include - -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif +#include - ; - return 0; -} _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_bigendian=yes +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest* -ac_cv_c_bigendian=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -# It does not; compile a test program. -if test "$cross_compiling" = yes; then - # try to guess the endianness by grepping values into an object file - ac_cv_c_bigendian=unknown +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; -void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; -void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } -int -main () -{ - _ascii (); _ebcdic (); - ; - return 0; -} +#include + _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then - ac_cv_c_bigendian=yes -fi -if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi -fi +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest* fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3415,17 +3240,28 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long l; - char c[sizeof (long)]; - } u; - u.l = 1; - exit (u.c[sizeof (long) - 1] == 1); + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); } _ACEOF rm -f conftest$ac_exeext @@ -3439,87 +3275,63 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_c_bigendian=no + : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -ac_cv_c_bigendian=yes +ac_cv_header_stdc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6 -case $ac_cv_c_bigendian in - yes) +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF -#define WORDS_BIGENDIAN 1 -_ACEOF - ;; - no) - ;; - *) - { { echo "$as_me:$LINENO: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&5 -echo "$as_me: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} - { (exit 1); exit 1; }; } ;; -esac - -echo "$as_me:$LINENO: checking for function prototypes" >&5 -echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6 -if test "$ac_cv_prog_cc_stdc" != no; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - -cat >>confdefs.h <<\_ACEOF -#define PROTOTYPES 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define __PROTOTYPES 1 +#define STDC_HEADERS 1 _ACEOF -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 fi -if test x"$am_cv_prog_cc_stdc" != xno; then : - - -else - U=_ - - ANSI2KNR=./ansi2knr - -fi +# Check whether --enable-largefile or --disable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval="$enable_largefile" +fi; +if test "$enable_largefile" != no; then -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then + echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 +echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include -#include -#include - +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; int main () { @@ -3528,7 +3340,7 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext + rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? @@ -3537,8 +3349,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3550,154 +3361,83 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_header_stdc=yes + break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_header_stdc=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +rm -f conftest.err conftest.$ac_objext + CC="$CC -n32" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - : + ac_cv_sys_largefile_CC=' -n32'; break else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi fi +rm -f conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_file_offset_bits+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else + while :; do + ac_cv_sys_file_offset_bits=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ -#include <$ac_header> + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -3708,8 +3448,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3721,52 +3460,107 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" + break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF - -fi - -done - - - - -for ac_header in sys/types.h sys/stat.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_file_offset_bits=64; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 +if test "$ac_cv_sys_file_offset_bits" != no; then + +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF + +fi +rm -f conftest* + echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 +echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_large_files+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF + while :; do + ac_cv_sys_large_files=no + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -3777,8 +3571,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3790,108 +3583,81 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_header_compiler=yes + break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include <$ac_header> +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_large_files=1; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +echo "${ECHO_T}$ac_cv_sys_large_files" >&6 +if test "$ac_cv_sys_large_files" != no; then -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files _ACEOF fi +rm -f conftest* +fi -done +# On IRIX 5.3, sys/types and inttypes.h are conflicting. @@ -3899,28 +3665,25 @@ -for ac_header in string.h strings.h stdarg.h limits.h unistd.h sys/time.h + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + #include <$ac_header> _ACEOF rm -f conftest.$ac_objext @@ -3932,8 +3695,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3945,103 +3707,20 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_header_compiler=yes + eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no +eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -4049,33 +3728,28 @@ done - - - - -for ac_header in termios.h sys/ioctl.h sys/select.h utime.h sys/utime.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then +echo "$as_me:$LINENO: checking for off_t" >&5 +echo $ECHO_N "checking for off_t... $ECHO_C" >&6 +if test "${ac_cv_type_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -#include <$ac_header> +int +main () +{ +if ((off_t *) 0) + return 0; +if (sizeof (off_t)) + return 0; + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -4086,8 +3760,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4099,129 +3772,30 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_header_compiler=yes + ac_cv_type_off_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no +ac_cv_type_off_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - fi +echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6 -done - - - - - - -for ac_header in stdint.h inttypes.h signal.h setjmp.h pwd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then +echo "$as_me:$LINENO: checking size of off_t" >&5 +echo $ECHO_N "checking size of off_t... $ECHO_C" >&6 +if test "${ac_cv_sizeof_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 + if test "$ac_cv_type_off_t" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4229,7 +3803,15 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -#include <$ac_header> +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -4240,285 +3822,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 -echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 -if test "${ac_cv_header_time+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include - -int -main () -{ -if ((struct tm *) 0) -return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_time=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_time=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 -echo "${ECHO_T}$ac_cv_header_time" >&6 -if test $ac_cv_header_time = yes; then - -cat >>confdefs.h <<\_ACEOF -#define TIME_WITH_SYS_TIME 1 -_ACEOF - -fi - - -echo "$as_me:$LINENO: checking for short" >&5 -echo $ECHO_N "checking for short... $ECHO_C" >&6 -if test "${ac_cv_type_short+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((short *) 0) - return 0; -if (sizeof (short)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_short=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_short=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 -echo "${ECHO_T}$ac_cv_type_short" >&6 - -echo "$as_me:$LINENO: checking size of short" >&5 -echo $ECHO_N "checking size of short... $ECHO_C" >&6 -if test "${ac_cv_sizeof_short+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$ac_cv_type_short" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (short))) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4542,7 +3846,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -4558,8 +3862,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4599,7 +3902,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (short))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) < 0)]; test_array [0] = 0 ; @@ -4615,8 +3918,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4640,7 +3942,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (short))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= $ac_mid)]; test_array [0] = 0 ; @@ -4656,8 +3958,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4705,7 +4006,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -4721,8 +4022,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4744,19 +4044,17 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_short=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 +?*) ac_cv_sizeof_off_t=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (short), 77 +echo "$as_me: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF @@ -4766,8 +4064,8 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (short)); } -unsigned long ulongval () { return (long) (sizeof (short)); } +long longval () { return (long) (sizeof (off_t)); } +unsigned long ulongval () { return (long) (sizeof (off_t)); } #include #include int @@ -4777,17 +4075,17 @@ FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (short))) < 0) + if (((long) (sizeof (off_t))) < 0) { long i = longval (); - if (i != ((long) (sizeof (short)))) + if (i != ((long) (sizeof (off_t)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (short)))) + if (i != ((long) (sizeof (off_t)))) exit (1); fprintf (f, "%lu\n", i); } @@ -4808,16 +4106,16 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_short=`cat conftest.val` + ac_cv_sizeof_off_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (short), 77 +echo "$as_me: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -4826,19 +4124,20 @@ fi rm -f conftest.val else - ac_cv_sizeof_short=0 + ac_cv_sizeof_off_t=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 -echo "${ECHO_T}$ac_cv_sizeof_short" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_SHORT $ac_cv_sizeof_short +#define SIZEOF_OFF_T $ac_cv_sizeof_off_t _ACEOF -echo "$as_me:$LINENO: checking for int" >&5 -echo $ECHO_N "checking for int... $ECHO_C" >&6 -if test "${ac_cv_type_int+set}" = set; then + +echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 +echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6 +if test "${ac_cv_header_stdbool_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -4847,14 +4146,43 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default + +#include +#ifndef bool +# error bool is not defined +#endif +#ifndef false +# error false is not defined +#endif +#if false +# error false is not 0 +#endif +#ifndef true +# error true is not defined +#endif +#if true != 1 +# error true is not 1 +#endif +#ifndef __bool_true_false_are_defined +# error __bool_true_false_are_defined is not defined +#endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) -0.5 == true ? 1 : -1]; + bool e = &s; + char f[(_Bool) -0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + int main () { -if ((int *) 0) - return 0; -if (sizeof (int)) - return 0; + return !a + !b + !c + !d + !e + !f + !g + !h + !i; ; return 0; } @@ -4868,8 +4196,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4881,31 +4208,23 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_int=yes + ac_cv_header_stdbool_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_int=no +ac_cv_header_stdbool_h=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 -echo "${ECHO_T}$ac_cv_type_int" >&6 - -echo "$as_me:$LINENO: checking size of int" >&5 -echo $ECHO_N "checking size of int... $ECHO_C" >&6 -if test "${ac_cv_sizeof_int+set}" = set; then +echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 +echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6 +echo "$as_me:$LINENO: checking for _Bool" >&5 +echo $ECHO_N "checking for _Bool... $ECHO_C" >&6 +if test "${ac_cv_type__Bool+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_int" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4915,9 +4234,10 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; -test_array [0] = 0 - +if ((_Bool *) 0) + return 0; +if (sizeof (_Bool)) + return 0; ; return 0; } @@ -4931,8 +4251,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4944,24 +4263,59 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF + ac_cv_type__Bool=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type__Bool=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 +echo "${ECHO_T}$ac_cv_type__Bool" >&6 +if test $ac_cv_type__Bool = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + +if test $ac_cv_header_stdbool_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STDBOOL_H 1 +_ACEOF + +fi + + + +for ac_header in unistd.h sys/time.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} +#include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -4972,8 +4326,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4985,24 +4338,129 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=$ac_mid; break + ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` +ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + +for ac_header in termios.h sys/ioctl.h sys/select.h utime.h sys/utime.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5010,15 +4468,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; -test_array [0] = 0 - - ; - return 0; -} +#include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -5029,8 +4479,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5042,24 +4491,135 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; -test_array [0] = 0 +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - ; - return 0; -} + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +for ac_header in stdint.h inttypes.h pwd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -5070,8 +4630,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5083,32 +4642,115 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_lo=$ac_mid; break + ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` +ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo= ac_hi= + ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking for short" >&5 +echo $ECHO_N "checking for short... $ECHO_C" >&6 +if test "${ac_cv_type_short+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5119,9 +4761,10 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; -test_array [0] = 0 - +if ((short *) 0) + return 0; +if (sizeof (short)) + return 0; ; return 0; } @@ -5135,8 +4778,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5148,171 +4790,24 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=$ac_mid + ac_cv_type_short=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo=`expr '(' $ac_mid ')' + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_int=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; -esac -else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -long longval () { return (long) (sizeof (int)); } -unsigned long ulongval () { return (long) (sizeof (int)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - exit (1); - if (((long) (sizeof (int))) < 0) - { - long i = longval (); - if (i != ((long) (sizeof (int)))) - exit (1); - fprintf (f, "%ld\n", i); - } - else - { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (int)))) - exit (1); - fprintf (f, "%lu\n", i); - } - exit (ferror (f) || fclose (f) != 0); - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_int=`cat conftest.val` -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -rm -f conftest.val -else - ac_cv_sizeof_int=0 -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 -echo "${ECHO_T}$ac_cv_sizeof_int" >&6 -cat >>confdefs.h <<_ACEOF -#define SIZEOF_INT $ac_cv_sizeof_int -_ACEOF - - -echo "$as_me:$LINENO: checking for long" >&5 -echo $ECHO_N "checking for long... $ECHO_C" >&6 -if test "${ac_cv_type_long+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((long *) 0) - return 0; -if (sizeof (long)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_long=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_long=no +ac_cv_type_short=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 -echo "${ECHO_T}$ac_cv_type_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 +echo "${ECHO_T}$ac_cv_type_short" >&6 -echo "$as_me:$LINENO: checking size of long" >&5 -echo $ECHO_N "checking size of long... $ECHO_C" >&6 -if test "${ac_cv_sizeof_long+set}" = set; then +echo "$as_me:$LINENO: checking size of short" >&5 +echo $ECHO_N "checking size of short... $ECHO_C" >&6 +if test "${ac_cv_sizeof_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long" = yes; then + if test "$ac_cv_type_short" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -5329,7 +4824,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (short))) >= 0)]; test_array [0] = 0 ; @@ -5345,8 +4840,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5370,7 +4864,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; test_array [0] = 0 ; @@ -5386,8 +4880,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5427,7 +4920,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (short))) < 0)]; test_array [0] = 0 ; @@ -5443,8 +4936,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5468,7 +4960,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (short))) >= $ac_mid)]; test_array [0] = 0 ; @@ -5484,8 +4976,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5533,7 +5024,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; test_array [0] = 0 ; @@ -5549,8 +5040,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5572,19 +5062,17 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +?*) ac_cv_sizeof_short=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long), 77 +echo "$as_me: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF @@ -5594,8 +5082,8 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (long)); } -unsigned long ulongval () { return (long) (sizeof (long)); } +long longval () { return (long) (sizeof (short)); } +unsigned long ulongval () { return (long) (sizeof (short)); } #include #include int @@ -5605,17 +5093,17 @@ FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (long))) < 0) + if (((long) (sizeof (short))) < 0) { long i = longval (); - if (i != ((long) (sizeof (long)))) + if (i != ((long) (sizeof (short)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (long)))) + if (i != ((long) (sizeof (short)))) exit (1); fprintf (f, "%lu\n", i); } @@ -5636,16 +5124,16 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_long=`cat conftest.val` + ac_cv_sizeof_short=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long), 77 +echo "$as_me: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -5654,19 +5142,19 @@ fi rm -f conftest.val else - ac_cv_sizeof_long=0 + ac_cv_sizeof_short=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 +echo "${ECHO_T}$ac_cv_sizeof_short" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG $ac_cv_sizeof_long +#define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF -echo "$as_me:$LINENO: checking for long long" >&5 -echo $ECHO_N "checking for long long... $ECHO_C" >&6 -if test "${ac_cv_type_long_long+set}" = set; then +echo "$as_me:$LINENO: checking for int" >&5 +echo $ECHO_N "checking for int... $ECHO_C" >&6 +if test "${ac_cv_type_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -5679,9 +5167,9 @@ int main () { -if ((long long *) 0) +if ((int *) 0) return 0; -if (sizeof (long long)) +if (sizeof (int)) return 0; ; return 0; @@ -5696,8 +5184,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5709,24 +5196,24 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_long_long=yes + ac_cv_type_int=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_long_long=no +ac_cv_type_int=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 -echo "${ECHO_T}$ac_cv_type_long_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 +echo "${ECHO_T}$ac_cv_type_int" >&6 -echo "$as_me:$LINENO: checking size of long long" >&5 -echo $ECHO_N "checking size of long long... $ECHO_C" >&6 -if test "${ac_cv_sizeof_long_long+set}" = set; then +echo "$as_me:$LINENO: checking size of int" >&5 +echo $ECHO_N "checking size of int... $ECHO_C" >&6 +if test "${ac_cv_sizeof_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long_long" = yes; then + if test "$ac_cv_type_int" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -5743,7 +5230,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; test_array [0] = 0 ; @@ -5759,8 +5246,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5784,7 +5270,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; test_array [0] = 0 ; @@ -5800,8 +5286,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5841,7 +5326,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; test_array [0] = 0 ; @@ -5857,8 +5342,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5882,7 +5366,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; test_array [0] = 0 ; @@ -5898,8 +5382,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5947,7 +5430,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; test_array [0] = 0 ; @@ -5963,8 +5446,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5986,19 +5468,17 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_long_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +?*) ac_cv_sizeof_int=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77 +echo "$as_me: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF @@ -6008,8 +5488,8 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (long long)); } -unsigned long ulongval () { return (long) (sizeof (long long)); } +long longval () { return (long) (sizeof (int)); } +unsigned long ulongval () { return (long) (sizeof (int)); } #include #include int @@ -6019,17 +5499,17 @@ FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (long long))) < 0) + if (((long) (sizeof (int))) < 0) { long i = longval (); - if (i != ((long) (sizeof (long long)))) + if (i != ((long) (sizeof (int)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (long long)))) + if (i != ((long) (sizeof (int)))) exit (1); fprintf (f, "%lu\n", i); } @@ -6050,16 +5530,16 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_long_long=`cat conftest.val` + ac_cv_sizeof_int=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77 +echo "$as_me: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -6068,89 +5548,40 @@ fi rm -f conftest.val else - ac_cv_sizeof_long_long=0 + ac_cv_sizeof_int=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 +echo "${ECHO_T}$ac_cv_sizeof_int" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long +#define SIZEOF_INT $ac_cv_sizeof_int _ACEOF - -# Check whether --enable-largefile or --disable-largefile was given. -if test "${enable_largefile+set}" = set; then - enableval="$enable_largefile" - -fi; -if test "$enable_largefile" != no; then - - echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 -echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 -if test "${ac_cv_sys_largefile_CC+set}" = set; then +echo "$as_me:$LINENO: checking for long" >&5 +echo $ECHO_N "checking for long... $ECHO_C" >&6 +if test "${ac_cv_type_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - ac_save_CC=$CC - while :; do - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; +$ac_includes_default int main () { - +if ((long *) 0) + return 0; +if (sizeof (long)) + return 0; ; return 0; } _ACEOF - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext - CC="$CC -n32" - rm -f conftest.$ac_objext +rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? @@ -6159,8 +5590,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6172,50 +5602,42 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sys_largefile_CC=' -n32'; break + ac_cv_type_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_type_long=no fi -rm -f conftest.err conftest.$ac_objext - break - done - CC=$ac_save_CC - rm -f conftest.$ac_ext - fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 -echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 - if test "$ac_cv_sys_largefile_CC" != no; then - CC=$CC$ac_cv_sys_largefile_CC - fi +echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 +echo "${ECHO_T}$ac_cv_type_long" >&6 - echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 -if test "${ac_cv_sys_file_offset_bits+set}" = set; then +echo "$as_me:$LINENO: checking size of long" >&5 +echo $ECHO_N "checking size of long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - while :; do - ac_cv_sys_file_offset_bits=no - cat >conftest.$ac_ext <<_ACEOF + if test "$ac_cv_type_long" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; +$ac_includes_default int main () { +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; +test_array [0] = 0 ; return 0; @@ -6230,8 +5652,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6243,32 +5664,20 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#define _FILE_OFFSET_BITS 64 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; +$ac_includes_default int main () { +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 ; return 0; @@ -6283,8 +5692,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6296,51 +5704,36 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sys_file_offset_bits=64; break + ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - break -done -fi -echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 -echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 -if test "$ac_cv_sys_file_offset_bits" != no; then - -cat >>confdefs.h <<_ACEOF -#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits -_ACEOF - -fi -rm -f conftest* - echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 -echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 -if test "${ac_cv_sys_large_files+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + done else - while :; do - ac_cv_sys_large_files=no - cat >conftest.$ac_ext <<_ACEOF + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; +$ac_includes_default int main () { +static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; +test_array [0] = 0 ; return 0; @@ -6355,8 +5748,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6368,32 +5760,20 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#define _LARGE_FILES 1 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; +$ac_includes_default int main () { +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; +test_array [0] = 0 ; return 0; @@ -6408,8 +5788,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6421,33 +5800,32 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sys_large_files=1; break + ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - break -done -fi -echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 -echo "${ECHO_T}$ac_cv_sys_large_files" >&6 -if test "$ac_cv_sys_large_files" != no; then - -cat >>confdefs.h <<_ACEOF -#define _LARGE_FILES $ac_cv_sys_large_files -_ACEOF + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_lo= ac_hi= fi -rm -f conftest* +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi - -echo "$as_me:$LINENO: checking for off_t" >&5 -echo $ECHO_N "checking for off_t... $ECHO_C" >&6 -if test "${ac_cv_type_off_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -6458,10 +5836,9 @@ int main () { -if ((off_t *) 0) - return 0; -if (sizeof (off_t)) - return 0; +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 + ; return 0; } @@ -6475,8 +5852,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6488,24 +5864,168 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_off_t=yes + ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_off_t=no +ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (long)); } +unsigned long ulongval () { return (long) (sizeof (long)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi -echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 -echo "${ECHO_T}$ac_cv_type_off_t" >&6 +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_long=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG $ac_cv_sizeof_long +_ACEOF -echo "$as_me:$LINENO: checking size of off_t" >&5 -echo $ECHO_N "checking size of off_t... $ECHO_C" >&6 -if test "${ac_cv_sizeof_off_t+set}" = set; then + +echo "$as_me:$LINENO: checking for long long" >&5 +echo $ECHO_N "checking for long long... $ECHO_C" >&6 +if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_off_t" = yes; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long long *) 0) + return 0; +if (sizeof (long long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 +echo "${ECHO_T}$ac_cv_type_long_long" >&6 + +echo "$as_me:$LINENO: checking size of long long" >&5 +echo $ECHO_N "checking size of long long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_long_long" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -6522,7 +6042,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; test_array [0] = 0 ; @@ -6538,8 +6058,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6563,7 +6082,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; test_array [0] = 0 ; @@ -6579,8 +6098,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6620,7 +6138,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; test_array [0] = 0 ; @@ -6636,8 +6154,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6661,7 +6178,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; test_array [0] = 0 ; @@ -6677,8 +6194,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6726,7 +6242,7 @@ int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; test_array [0] = 0 ; @@ -6742,8 +6258,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6765,19 +6280,17 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_off_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 +?*) ac_cv_sizeof_long_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (off_t), 77 +echo "$as_me: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF @@ -6787,8 +6300,8 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (off_t)); } -unsigned long ulongval () { return (long) (sizeof (off_t)); } +long longval () { return (long) (sizeof (long long)); } +unsigned long ulongval () { return (long) (sizeof (long long)); } #include #include int @@ -6798,17 +6311,17 @@ FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (off_t))) < 0) + if (((long) (sizeof (long long))) < 0) { long i = longval (); - if (i != ((long) (sizeof (off_t)))) + if (i != ((long) (sizeof (long long)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (off_t)))) + if (i != ((long) (sizeof (long long)))) exit (1); fprintf (f, "%lu\n", i); } @@ -6829,16 +6342,16 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_off_t=`cat conftest.val` + ac_cv_sizeof_long_long=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (off_t), 77 +echo "$as_me: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -6847,20 +6360,19 @@ fi rm -f conftest.val else - ac_cv_sizeof_off_t=0 + ac_cv_sizeof_long_long=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5 -echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_OFF_T $ac_cv_sizeof_off_t +#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF - -echo "$as_me:$LINENO: checking for size_t" >&5 -echo $ECHO_N "checking for size_t... $ECHO_C" >&6 -if test "${ac_cv_type_size_t+set}" = set; then +echo "$as_me:$LINENO: checking for void *" >&5 +echo $ECHO_N "checking for void *... $ECHO_C" >&6 +if test "${ac_cv_type_void_p+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -6873,9 +6385,9 @@ int main () { -if ((size_t *) 0) +if ((void * *) 0) return 0; -if (sizeof (size_t)) +if (sizeof (void *)) return 0; ; return 0; @@ -6890,8 +6402,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6903,33 +6414,31 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_size_t=yes + ac_cv_type_void_p=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_size_t=no +ac_cv_type_void_p=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 -echo "${ECHO_T}$ac_cv_type_size_t" >&6 -if test $ac_cv_type_size_t = yes; then - : -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned -_ACEOF - -fi +echo "$as_me:$LINENO: result: $ac_cv_type_void_p" >&5 +echo "${ECHO_T}$ac_cv_type_void_p" >&6 -echo "$as_me:$LINENO: checking for pid_t" >&5 -echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 -if test "${ac_cv_type_pid_t+set}" = set; then +echo "$as_me:$LINENO: checking size of void *" >&5 +echo $ECHO_N "checking size of void *... $ECHO_C" >&6 +if test "${ac_cv_sizeof_void_p+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + if test "$ac_cv_type_void_p" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -6939,10 +6448,9 @@ int main () { -if ((pid_t *) 0) - return 0; -if (sizeof (pid_t)) - return 0; +static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= 0)]; +test_array [0] = 0 + ; return 0; } @@ -6956,8 +6464,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6969,34 +6476,10 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_pid_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_pid_t=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 -echo "${ECHO_T}$ac_cv_type_pid_t" >&6 -if test $ac_cv_type_pid_t = yes; then - : -else - -cat >>confdefs.h <<_ACEOF -#define pid_t int -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for uint32_t" >&5 -echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6 -if test "${ac_cv_type_uint32_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF @@ -7005,10 +6488,9 @@ int main () { -if ((uint32_t *) 0) - return 0; -if (sizeof (uint32_t)) - return 0; +static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)]; +test_array [0] = 0 + ; return 0; } @@ -7022,8 +6504,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7035,52 +6516,37 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_uint32_t=yes + ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_uint32_t=no +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_uint32_t" >&5 -echo "${ECHO_T}$ac_cv_type_uint32_t" >&6 -if test $ac_cv_type_uint32_t = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_UINT32_T 1 -_ACEOF - - -fi - -echo "$as_me:$LINENO: checking return type of signal handlers" >&5 -echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 -if test "${ac_cv_type_signal+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + done else - cat >conftest.$ac_ext <<_ACEOF + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include -#ifdef signal -# undef signal -#endif -#ifdef __cplusplus -extern "C" void (*signal (int, void (*)(int)))(int); -#else -void (*signal ()) (); -#endif - +$ac_includes_default int main () { -int i; +static int test_array [1 - 2 * !(((long) (sizeof (void *))) < 0)]; +test_array [0] = 0 + ; return 0; } @@ -7094,8 +6560,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7107,52 +6572,21 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_signal=void -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_signal=int -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 -echo "${ECHO_T}$ac_cv_type_signal" >&6 - -cat >>confdefs.h <<_ACEOF -#define RETSIGTYPE $ac_cv_type_signal -_ACEOF - - -echo "$as_me:$LINENO: checking for sig_atomic_t" >&5 -echo $ECHO_N "checking for sig_atomic_t... $ECHO_C" >&6 -if test "${ac_cv_type_sig_atomic_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -#include -#include -#if HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_SIGNAL_H -# include -#endif - - +$ac_includes_default int main () { -if ((sig_atomic_t *) 0) - return 0; -if (sizeof (sig_atomic_t)) - return 0; +static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= $ac_mid)]; +test_array [0] = 0 + ; return 0; } @@ -7166,8 +6600,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7179,95 +6612,92 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_sig_atomic_t=yes + ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_sig_atomic_t=no +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_sig_atomic_t" >&5 -echo "${ECHO_T}$ac_cv_type_sig_atomic_t" >&6 -if test $ac_cv_type_sig_atomic_t = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_SIG_ATOMIC_T 1 -_ACEOF - + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_lo= ac_hi= fi - - -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -echo "$as_me:$LINENO: checking for working alloca.h" >&5 -echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6 -if test "${ac_cv_working_alloca_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +$ac_includes_default int main () { -char *p = (char *) alloca (2 * sizeof (int)); +static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)]; +test_array [0] = 0 + ; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_working_alloca_h=yes + ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_working_alloca_h=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 -echo "${ECHO_T}$ac_cv_working_alloca_h" >&6 -if test $ac_cv_working_alloca_h = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA_H 1 -_ACEOF - +ac_lo=`expr '(' $ac_mid ')' + 1` fi - -echo "$as_me:$LINENO: checking for alloca" >&5 -echo $ECHO_N "checking for alloca... $ECHO_C" >&6 -if test "${ac_cv_func_alloca_works+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_void_p=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} + { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -7275,92 +6705,81 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# if HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - +$ac_includes_default +long longval () { return (long) (sizeof (void *)); } +unsigned long ulongval () { return (long) (sizeof (void *)); } +#include +#include int main () { -char *p = (char *) alloca (1); + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (void *))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (void *)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (void *)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + ; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext +rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_alloca_works=yes + ac_cv_sizeof_void_p=`cat conftest.val` else - echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_alloca_works=no +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 -echo "${ECHO_T}$ac_cv_func_alloca_works" >&6 +fi +rm -f conftest.val +else + ac_cv_sizeof_void_p=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_void_p" >&5 +echo "${ECHO_T}$ac_cv_sizeof_void_p" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_VOID_P $ac_cv_sizeof_void_p +_ACEOF -if test $ac_cv_func_alloca_works = yes; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA 1 -_ACEOF -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=alloca.$ac_objext - -cat >>confdefs.h <<\_ACEOF -#define C_ALLOCA 1 -_ACEOF - - -echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 -echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6 -if test "${ac_cv_os_cray+set}" = set; then +echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7369,30 +6788,63 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#if defined(CRAY) && ! defined(CRAY2) -webecray -#else -wenotbecray -#endif - +$ac_includes_default +int +main () +{ +if ((size_t *) 0) + return 0; +if (sizeof (size_t)) + return 0; + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then - ac_cv_os_cray=yes +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes else - ac_cv_os_cray=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_size_t=no fi -rm -f conftest* +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned +_ACEOF fi -echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 -echo "${ECHO_T}$ac_cv_os_cray" >&6 -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then + +echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 +if test "${ac_cv_type_pid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7401,189 +6853,145 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - +$ac_includes_default int main () { -return f != $ac_func; +if ((pid_t *) 0) + return 0; +if (sizeof (pid_t)) + return 0; ; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - eval "$as_ac_var=yes" + ac_cv_type_pid_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" +ac_cv_type_pid_t=no fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then +echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6 +if test $ac_cv_type_pid_t = yes; then + : +else cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func +#define pid_t int _ACEOF - break -fi - - done fi -echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 -echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6 -if test "${ac_cv_c_stack_direction+set}" = set; then +echo "$as_me:$LINENO: checking for uint32_t" >&5 +echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6 +if test "${ac_cv_type_uint32_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$cross_compiling" = yes; then - ac_cv_c_stack_direction=0 -else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - +$ac_includes_default int main () { - exit (find_stack_direction () < 0); +if ((uint32_t *) 0) + return 0; +if (sizeof (uint32_t)) + return 0; + ; + return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_c_stack_direction=1 + ac_cv_type_uint32_t=yes else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_c_stack_direction=-1 -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +ac_cv_type_uint32_t=no fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 -echo "${ECHO_T}$ac_cv_c_stack_direction" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_uint32_t" >&5 +echo "${ECHO_T}$ac_cv_type_uint32_t" >&6 +if test $ac_cv_type_uint32_t = yes; then cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction +#define HAVE_UINT32_T 1 _ACEOF fi - - - -for ac_header in stdlib.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then +echo "$as_me:$LINENO: checking for uintptr_t" >&5 +echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6 +if test "${ac_cv_type_uintptr_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -#include <$ac_header> +int +main () +{ +if ((uintptr_t *) 0) + return 0; +if (sizeof (uintptr_t)) + return 0; + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -7594,8 +7002,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7607,116 +7014,104 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_header_compiler=yes + ac_cv_type_uintptr_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no +ac_cv_type_uintptr_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 +echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6 +if test $ac_cv_type_uintptr_t = yes; then -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF +cat >>confdefs.h <<_ACEOF +#define HAVE_UINTPTR_T 1 +_ACEOF + + +fi + +echo "$as_me:$LINENO: checking for sig_atomic_t" >&5 +echo $ECHO_N "checking for sig_atomic_t... $ECHO_C" >&6 +if test "${ac_cv_type_sig_atomic_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include <$ac_header> + +#include +#include +#if HAVE_INTTYPES_H +# include +#endif +#include + + +int +main () +{ +if ((sig_atomic_t *) 0) + return 0; +if (sizeof (sig_atomic_t)) + return 0; + ; + return 0; +} _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_sig_atomic_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_preproc=no +ac_cv_type_sig_atomic_t=no fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_sig_atomic_t" >&5 +echo "${ECHO_T}$ac_cv_type_sig_atomic_t" >&6 +if test $ac_cv_type_sig_atomic_t = yes; then -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +cat >>confdefs.h <<_ACEOF +#define HAVE_SIG_ATOMIC_T 1 _ACEOF -fi -done +fi -for ac_func in getpagesize -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +echo "$as_me:$LINENO: checking for working alloca.h" >&5 +echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6 +if test "${ac_cv_working_alloca_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7725,47 +7120,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - +#include int main () { -return f != $ac_func; +char *p = (char *) alloca (2 * sizeof (int)); ; return 0; } @@ -7779,8 +7138,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7792,383 +7150,471 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - eval "$as_ac_var=yes" + ac_cv_working_alloca_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" +ac_cv_working_alloca_h=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 +echo "${ECHO_T}$ac_cv_working_alloca_h" >&6 +if test $ac_cv_working_alloca_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ALLOCA_H 1 _ACEOF fi -done -echo "$as_me:$LINENO: checking for working mmap" >&5 -echo $ECHO_N "checking for working mmap... $ECHO_C" >&6 -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then +echo "$as_me:$LINENO: checking for alloca" >&5 +echo $ECHO_N "checking for alloca... $ECHO_C" >&6 +if test "${ac_cv_func_alloca_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$cross_compiling" = yes; then - ac_cv_func_mmap_fixed_mapped=no -else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -/* malloc might have been renamed as rpl_malloc. */ -#undef malloc - -/* Thanks to Mike Haertel and Jim Avera for this test. - Here is a matrix of mmap possibilities: - mmap private not fixed - mmap private fixed at somewhere currently unmapped - mmap private fixed at somewhere already mapped - mmap shared not fixed - mmap shared fixed at somewhere currently unmapped - mmap shared fixed at somewhere already mapped - For private mappings, we should verify that changes cannot be read() - back from the file, nor mmap's back from the file at a different - address. (There have been systems where private was not correctly - implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the file system buffer cache - like early versions of FreeBSD and possibly contemporary NetBSD.) - For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ - -#include -#include - -#if !STDC_HEADERS && !HAVE_STDLIB_H -char *malloc (); +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef _MSC_VER +# include +# define alloca _alloca +# else +# if HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +# endif #endif -/* This mess was copied from the GNU getpagesize.h. */ -#if !HAVE_GETPAGESIZE -/* Assume that all systems that can run configure have sys/param.h. */ -# if !HAVE_SYS_PARAM_H -# define HAVE_SYS_PARAM_H 1 -# endif - -# ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ -# if HAVE_SYS_PARAM_H -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else /* no EXEC_PAGESIZE */ -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif /* no CLSIZE */ -# else /* no NBPG */ -# ifdef NBPC -# define getpagesize() NBPC -# else /* no NBPC */ -# ifdef PAGESIZE -# define getpagesize() PAGESIZE -# endif /* PAGESIZE */ -# endif /* no NBPC */ -# endif /* no NBPG */ -# endif /* no EXEC_PAGESIZE */ -# else /* no HAVE_SYS_PARAM_H */ -# define getpagesize() 8192 /* punt totally */ -# endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ - int main () { - char *data, *data2, *data3; - int i, pagesize; - int fd; - - pagesize = getpagesize (); - - /* First, make a file with some known garbage in it. */ - data = (char *) malloc (pagesize); - if (!data) - exit (1); - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = creat ("conftest.mmap", 0600); - if (fd < 0) - exit (1); - if (write (fd, data, pagesize) != pagesize) - exit (1); - close (fd); - - /* Next, try to mmap the file at a fixed address which already has - something else allocated at it. If we can, also make sure that - we see the same garbage. */ - fd = open ("conftest.mmap", O_RDWR); - if (fd < 0) - exit (1); - data2 = (char *) malloc (2 * pagesize); - if (!data2) - exit (1); - data2 += (pagesize - ((long) data2 & (pagesize - 1))) & (pagesize - 1); - if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - exit (1); - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - exit (1); - - /* Finally, make sure that changes to the mapped area do not - percolate back to the file as seen by read(). (This is a bug on - some variants of i386 svr4.0.) */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - exit (1); - if (read (fd, data3, pagesize) != pagesize) - exit (1); - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - exit (1); - close (fd); - exit (0); +char *p = (char *) alloca (1); + ; + return 0; } _ACEOF -rm -f conftest$ac_exeext +rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_mmap_fixed_mapped=yes + ac_cv_func_alloca_works=yes else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_func_mmap_fixed_mapped=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +ac_cv_func_alloca_works=no fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 -echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6 -if test $ac_cv_func_mmap_fixed_mapped = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 +echo "${ECHO_T}$ac_cv_func_alloca_works" >&6 + +if test $ac_cv_func_alloca_works = yes; then cat >>confdefs.h <<\_ACEOF -#define HAVE_MMAP 1 +#define HAVE_ALLOCA 1 _ACEOF -fi -rm -f conftest.mmap +else + # The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. -echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 -echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6 -if test "${ac_cv_sys_largefile_source+set}" = set; then +ALLOCA=alloca.$ac_objext + +cat >>confdefs.h <<\_ACEOF +#define C_ALLOCA 1 +_ACEOF + + +echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 +echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6 +if test "${ac_cv_os_cray+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - while :; do - ac_cv_sys_largefile_source=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -int -main () -{ -return !fseeko; - ; - return 0; -} +#if defined(CRAY) && ! defined(CRAY2) +webecray +#else +wenotbecray +#endif + _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "webecray" >/dev/null 2>&1; then + ac_cv_os_cray=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + ac_cv_os_cray=no +fi +rm -f conftest* fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 +echo "${ECHO_T}$ac_cv_os_cray" >&6 +if test $ac_cv_os_cray = yes; then + for ac_func in _getb67 GETB67 getb67; do + as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#define _LARGEFILE_SOURCE 1 -#include +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + int main () { -return !fseeko; +return f != $ac_func; ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sys_largefile_source=1; break + eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 +eval "$as_ac_var=no" fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - break -done -fi -echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5 -echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6 -if test "$ac_cv_sys_largefile_source" != no; then +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +#define CRAY_STACKSEG_END $ac_func _ACEOF + break fi -rm -f conftest* -# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug -# in glibc 2.1.3, but that breaks too many other things. -# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. -echo "$as_me:$LINENO: checking for fseeko" >&5 -echo $ECHO_N "checking for fseeko... $ECHO_C" >&6 -if test "${ac_cv_func_fseeko+set}" = set; then + done +fi + +echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 +echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6 +if test "${ac_cv_c_stack_direction+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else + if test "$cross_compiling" = yes; then + ac_cv_c_stack_direction=0 +else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +int +find_stack_direction () +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; +} + int main () { -return fseeko && fseeko (stdin, 0, 0); - ; - return 0; + exit (find_stack_direction () < 0); } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext +rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_stack_direction=1 +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_stack_direction=-1 +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 +echo "${ECHO_T}$ac_cv_c_stack_direction" >&6 + +cat >>confdefs.h <<_ACEOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +_ACEOF + + +fi + + + +for ac_header in stdlib.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_fseeko=yes + ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_fseeko=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +ac_header_compiler=no fi -echo "$as_me:$LINENO: result: $ac_cv_func_fseeko" >&5 -echo "${ECHO_T}$ac_cv_func_fseeko" >&6 -if test $ac_cv_func_fseeko = yes; then +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 -cat >>confdefs.h <<\_ACEOF -#define HAVE_FSEEKO 1 +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF - +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF +fi +done -for ac_func in strdup strstr strcasecmp strncasecmp strpbrk memmove +for ac_func in getpagesize do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -8236,8 +7682,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -8269,227 +7714,467 @@ fi done - - - - - - - -for ac_func in gettimeofday mktime strptime timegm strerror snprintf vsnprintf -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +echo "$as_me:$LINENO: checking for working mmap" >&5 +echo $ECHO_N "checking for working mmap... $ECHO_C" >&6 +if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else + if test "$cross_compiling" = yes; then + ac_cv_func_mmap_fixed_mapped=no +else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func +$ac_includes_default +/* malloc might have been renamed as rpl_malloc. */ +#undef malloc -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} +/* Thanks to Mike Haertel and Jim Avera for this test. + Here is a matrix of mmap possibilities: + mmap private not fixed + mmap private fixed at somewhere currently unmapped + mmap private fixed at somewhere already mapped + mmap shared not fixed + mmap shared fixed at somewhere currently unmapped + mmap shared fixed at somewhere already mapped + For private mappings, we should verify that changes cannot be read() + back from the file, nor mmap's back from the file at a different + address. (There have been systems where private was not correctly + implemented like the infamous i386 svr4.0, and systems where the + VM page cache was not coherent with the file system buffer cache + like early versions of FreeBSD and possibly contemporary NetBSD.) + For shared mappings, we should conversely verify that changes get + propagated back to all the places they're supposed to be. + + Grep wants private fixed already mapped. + The main things grep needs to know about mmap are: + * does it exist and is it safe to write into the mmap'd area + * how to use it (BSD variants) */ + +#include +#include + +#if !STDC_HEADERS && !HAVE_STDLIB_H +char *malloc (); #endif +/* This mess was copied from the GNU getpagesize.h. */ +#if !HAVE_GETPAGESIZE +/* Assume that all systems that can run configure have sys/param.h. */ +# if !HAVE_SYS_PARAM_H +# define HAVE_SYS_PARAM_H 1 +# endif + +# ifdef _SC_PAGESIZE +# define getpagesize() sysconf(_SC_PAGESIZE) +# else /* no _SC_PAGESIZE */ +# if HAVE_SYS_PARAM_H +# include +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else /* no EXEC_PAGESIZE */ +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* no CLSIZE */ +# else /* no NBPG */ +# ifdef NBPC +# define getpagesize() NBPC +# else /* no NBPC */ +# ifdef PAGESIZE +# define getpagesize() PAGESIZE +# endif /* PAGESIZE */ +# endif /* no NBPC */ +# endif /* no NBPG */ +# endif /* no EXEC_PAGESIZE */ +# else /* no HAVE_SYS_PARAM_H */ +# define getpagesize() 8192 /* punt totally */ +# endif /* no HAVE_SYS_PARAM_H */ +# endif /* no _SC_PAGESIZE */ + +#endif /* no HAVE_GETPAGESIZE */ + int main () { -return f != $ac_func; - ; - return 0; + char *data, *data2, *data3; + int i, pagesize; + int fd; + + pagesize = getpagesize (); + + /* First, make a file with some known garbage in it. */ + data = (char *) malloc (pagesize); + if (!data) + exit (1); + for (i = 0; i < pagesize; ++i) + *(data + i) = rand (); + umask (0); + fd = creat ("conftest.mmap", 0600); + if (fd < 0) + exit (1); + if (write (fd, data, pagesize) != pagesize) + exit (1); + close (fd); + + /* Next, try to mmap the file at a fixed address which already has + something else allocated at it. If we can, also make sure that + we see the same garbage. */ + fd = open ("conftest.mmap", O_RDWR); + if (fd < 0) + exit (1); + data2 = (char *) malloc (2 * pagesize); + if (!data2) + exit (1); + data2 += (pagesize - ((long) data2 & (pagesize - 1))) & (pagesize - 1); + if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + exit (1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + exit (1); + + /* Finally, make sure that changes to the mapped area do not + percolate back to the file as seen by read(). (This is a bug on + some variants of i386 svr4.0.) */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = (char *) malloc (pagesize); + if (!data3) + exit (1); + if (read (fd, data3, pagesize) != pagesize) + exit (1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + exit (1); + close (fd); + exit (0); } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext +rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - eval "$as_ac_var=yes" + ac_cv_func_mmap_fixed_mapped=yes else - echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" +( exit $ac_status ) +ac_cv_func_mmap_fixed_mapped=no fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - fi -done - - - - +echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 +echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6 +if test $ac_cv_func_mmap_fixed_mapped = yes; then +cat >>confdefs.h <<\_ACEOF +#define HAVE_MMAP 1 +_ACEOF +fi +rm -f conftest.mmap -for ac_func in usleep select ftello sigblock sigsetjmp signal -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 +echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else + while :; do + ac_cv_sys_largefile_source=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - +#include int main () { -return f != $ac_func; +return !fseeko; ; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - eval "$as_ac_var=yes" + break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF - -fi -done - - - - +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _LARGEFILE_SOURCE 1 +#include +int +main () +{ +return !fseeko; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_largefile_source=1; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6 +if test "$ac_cv_sys_largefile_source" != no; then + +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF + +fi +rm -f conftest* + +# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug +# in glibc 2.1.3, but that breaks too many other things. +# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. +echo "$as_me:$LINENO: checking for fseeko" >&5 +echo $ECHO_N "checking for fseeko... $ECHO_C" >&6 +if test "${ac_cv_func_fseeko+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +return fseeko && fseeko (stdin, 0, 0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_fseeko=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_fseeko=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_fseeko" >&5 +echo "${ECHO_T}$ac_cv_func_fseeko" >&6 +if test $ac_cv_func_fseeko = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FSEEKO 1 +_ACEOF + +fi + + + + + + + +for ac_func in strptime timegm snprintf vsnprintf vasprintf drand48 +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + -for ac_func in symlink access isatty strtoll strtoimax + + +for ac_func in strtoll strtoimax usleep ftello sigblock sigsetjmp memrchr do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -8557,8 +8242,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -8592,6 +8276,32 @@ +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRCASECMP 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRNCASECMP 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRDUP 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ISATTY 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYMLINK 1 +_ACEOF + + + echo "$as_me:$LINENO: checking for struct utimbuf" >&5 echo $ECHO_N "checking for struct utimbuf... $ECHO_C" >&6 if test "${ac_cv_type_struct_utimbuf+set}" = set; then @@ -8633,8 +8343,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -8686,8 +8395,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -8722,8 +8430,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -8779,8 +8486,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -8882,8 +8588,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -8952,8 +8657,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9027,8 +8731,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9142,8 +8845,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9213,8 +8915,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9324,8 +9025,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9430,8 +9130,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9508,8 +9207,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9583,8 +9281,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9620,58 +9317,702 @@ -echo "$as_me:$LINENO: checking for getopt_long" >&5 -echo $ECHO_N "checking for getopt_long... $ECHO_C" >&6 -if test "${ac_cv_func_getopt_long+set}" = set; then +echo "$as_me:$LINENO: checking for getopt_long" >&5 +echo $ECHO_N "checking for getopt_long... $ECHO_C" >&6 +if test "${ac_cv_func_getopt_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define getopt_long to an innocuous variant, in case declares getopt_long. + For example, HP-UX 11i declares gettimeofday. */ +#define getopt_long innocuous_getopt_long + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char getopt_long (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef getopt_long + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char getopt_long (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_getopt_long) || defined (__stub___getopt_long) +choke me +#else +char (*f) () = getopt_long; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != getopt_long; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_getopt_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_getopt_long=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_getopt_long" >&5 +echo "${ECHO_T}$ac_cv_func_getopt_long" >&6 +if test $ac_cv_func_getopt_long = yes; then + : +else + + GETOPT_OBJ='getopt.o' + +fi + + + + +if test x"$with_ssl" = xgnutls +then + + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by GCC" >&5 +echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${acl_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$acl_cv_path_LD" +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${acl_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$acl_cv_prog_gnu_ld" >&6 +with_gnu_ld=$acl_cv_prog_gnu_ld + + + + + echo "$as_me:$LINENO: checking for shared library run path origin" >&5 +echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6 +if test "${acl_cv_rpath+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + +fi +echo "$as_me:$LINENO: result: $acl_cv_rpath" >&5 +echo "${ECHO_T}$acl_cv_rpath" >&6 + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + # Check whether --enable-rpath or --disable-rpath was given. +if test "${enable_rpath+set}" = set; then + enableval="$enable_rpath" + : +else + enable_rpath=yes +fi; + + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libgnutls-prefix or --without-libgnutls-prefix was given. +if test "${with_libgnutls_prefix+set}" = set; then + withval="$with_libgnutls_prefix" + + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi + +fi; + LIBGNUTLS= + LTLIBGNUTLS= + INCGNUTLS= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='gnutls ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBGNUTLS="${LTLIBGNUTLS}${LTLIBGNUTLS:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBGNUTLS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBGNUTLS="${LTLIBGNUTLS}${LTLIBGNUTLS:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$hardcode_direct" = yes; then + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBGNUTLS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$found_so" + else + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$found_a" + else + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCGNUTLS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCGNUTLS="${INCGNUTLS}${INCGNUTLS:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBGNUTLS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBGNUTLS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBGNUTLS="${LTLIBGNUTLS}${LTLIBGNUTLS:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$dep" + LTLIBGNUTLS="${LTLIBGNUTLS}${LTLIBGNUTLS:+ }$dep" + ;; + esac + done + fi + else + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }-l$name" + LTLIBGNUTLS="${LTLIBGNUTLS}${LTLIBGNUTLS:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBGNUTLS="${LIBGNUTLS}${LIBGNUTLS:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBGNUTLS="${LTLIBGNUTLS}${LTLIBGNUTLS:+ }-R$found_dir" + done + fi + + + ac_save_CPPFLAGS="$CPPFLAGS" + + for element in $INCGNUTLS; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + + echo "$as_me:$LINENO: checking for libgnutls" >&5 +echo $ECHO_N "checking for libgnutls... $ECHO_C" >&6 +if test "${ac_cv_libgnutls+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + + ac_save_LIBS="$LIBS" + LIBS="$LIBS $LIBGNUTLS" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define getopt_long to an innocuous variant, in case declares getopt_long. - For example, HP-UX 11i declares gettimeofday. */ -#define getopt_long innocuous_getopt_long - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char getopt_long (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef getopt_long -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char getopt_long (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_getopt_long) || defined (__stub___getopt_long) -choke me -#else -char (*f) () = getopt_long; -#endif -#ifdef __cplusplus -} -#endif +#include int main () { -return f != getopt_long; +gnutls_global_init() ; return 0; } @@ -9685,8 +10026,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9698,31 +10038,54 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_getopt_long=yes + ac_cv_libgnutls=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_getopt_long=no +ac_cv_libgnutls=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + LIBS="$ac_save_LIBS" + fi -echo "$as_me:$LINENO: result: $ac_cv_func_getopt_long" >&5 -echo "${ECHO_T}$ac_cv_func_getopt_long" >&6 -if test $ac_cv_func_getopt_long = yes; then - : -else +echo "$as_me:$LINENO: result: $ac_cv_libgnutls" >&5 +echo "${ECHO_T}$ac_cv_libgnutls" >&6 + if test "$ac_cv_libgnutls" = yes; then + HAVE_LIBGNUTLS=yes - GETOPT_OBJ='getopt$o' +cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBGNUTLS 1 +_ACEOF + + echo "$as_me:$LINENO: checking how to link with libgnutls" >&5 +echo $ECHO_N "checking how to link with libgnutls... $ECHO_C" >&6 + echo "$as_me:$LINENO: result: $LIBGNUTLS" >&5 +echo "${ECHO_T}$LIBGNUTLS" >&6 + else + HAVE_LIBGNUTLS=no + CPPFLAGS="$ac_save_CPPFLAGS" + LIBGNUTLS= + LTLIBGNUTLS= + fi -fi -if test x"$with_ssl" != x"no" -then + + if test x"$LIBGNUTLS" != x + then + { echo "$as_me:$LINENO: compiling in support for SSL via GnuTLS" >&5 +echo "$as_me: compiling in support for SSL via GnuTLS" >&6;} + SSL_OBJ='gnutls.o' + else + { { echo "$as_me:$LINENO: error: --with-ssl=gnutls was given, but GNUTLS is not available." >&5 +echo "$as_me: error: --with-ssl=gnutls was given, but GNUTLS is not available." >&2;} + { (exit 1); exit 1; }; } + fi +elif test x"$with_ssl" != xno; then echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 @@ -9762,8 +10125,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9836,8 +10198,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -9858,185 +10219,22 @@ fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_shl_load" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_shl_load" >&6 -if test $ac_cv_lib_dl_shl_load = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBDL 1 -_ACEOF - - LIBS="-ldl $LIBS" - -fi - - -fi - - - - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" - - -# Check whether --with-gnu-ld or --without-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then - withval="$with_gnu_ld" - test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi; -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo "$as_me:$LINENO: checking for ld used by GCC" >&5 -echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | [A-Za-z]:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - echo "$as_me:$LINENO: checking for GNU ld" >&5 -echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 -else - echo "$as_me:$LINENO: checking for non-GNU ld" >&5 -echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 -fi -if test "${acl_cv_path_LD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in - *GNU* | *'with BFD'*) - test "$with_gnu_ld" != no && break ;; - *) - test "$with_gnu_ld" != yes && break ;; - esac - fi - done - IFS="$ac_save_ifs" -else - acl_cv_path_LD="$LD" # Let the user override the test with a path. -fi -fi - -LD="$acl_cv_path_LD" -if test -n "$LD"; then - echo "$as_me:$LINENO: result: $LD" >&5 -echo "${ECHO_T}$LD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi -test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 -echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} - { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 -echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 -if test "${acl_cv_prog_gnu_ld+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # I'd rather use --version here, but apparently some GNU ld's only accept -v. -case `$LD -v 2>&1 &5 -echo "${ECHO_T}$acl_cv_prog_gnu_ld" >&6 -with_gnu_ld=$acl_cv_prog_gnu_ld - - - - - echo "$as_me:$LINENO: checking for shared library run path origin" >&5 -echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6 -if test "${acl_cv_rpath+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - -fi -echo "$as_me:$LINENO: result: $acl_cv_rpath" >&5 -echo "${ECHO_T}$acl_cv_rpath" >&6 - wl="$acl_cv_wl" - libext="$acl_cv_libext" - shlibext="$acl_cv_shlibext" - hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - hardcode_direct="$acl_cv_hardcode_direct" - hardcode_minus_L="$acl_cv_hardcode_minus_L" - # Check whether --enable-rpath or --disable-rpath was given. -if test "${enable_rpath+set}" = set; then - enableval="$enable_rpath" - : -else - enable_rpath=yes -fi; +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_shl_load" >&6 +if test $ac_cv_lib_dl_shl_load = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBDL 1 +_ACEOF + + LIBS="-ldl $LIBS" + +fi + + +fi + @@ -10488,8 +10686,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -10540,23 +10737,19 @@ if test x"$LIBSSL" != x then - { echo "$as_me:$LINENO: compiling in support for SSL" >&5 -echo "$as_me: compiling in support for SSL" >&6;} - -cat >>confdefs.h <<\_ACEOF -#define HAVE_SSL 1 -_ACEOF - - SSL_OBJ='openssl$o' + { echo "$as_me:$LINENO: compiling in support for SSL via OpenSSL" >&5 +echo "$as_me: compiling in support for SSL via OpenSSL" >&6;} + SSL_OBJ='openssl.o' elif test x"$with_ssl" != x then - { { echo "$as_me:$LINENO: error: --with-ssl was given, but OpenSSL is not available." >&5 -echo "$as_me: error: --with-ssl was given, but OpenSSL is not available." >&2;} + { { echo "$as_me:$LINENO: error: --with-ssl was given, but SSL is not available." >&5 +echo "$as_me: error: --with-ssl was given, but SSL is not available." >&2;} { (exit 1); exit 1; }; } fi fi + NTLM_OBJ='' if test x"$LIBSSL" != x then @@ -10567,7 +10760,7 @@ #define ENABLE_NTLM 1 _ACEOF - NTLM_OBJ='http-ntlm$o' + NTLM_OBJ='http-ntlm.o' fi else if test x"$ENABLE_NTLM" = xyes @@ -10583,7 +10776,7 @@ if test x"$wget_need_md5" = xyes then - MD5_OBJ='gen-md5$o' + MD5_OBJ='gen-md5.o' found_md5=no if test x"$found_md5" = xno; then @@ -10625,8 +10818,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -10668,8 +10860,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -10726,10 +10917,237 @@ #define HAVE_BUILTIN_MD5 1 _ACEOF - MD5_OBJ="$MD5_OBJ gnu-md5\$o" + MD5_OBJ="$MD5_OBJ gnu-md5.o" found_md5=yes - { echo "$as_me:$LINENO: using the GNU MD5 implementation" >&5 -echo "$as_me: using the GNU MD5 implementation" >&6;} + { echo "$as_me:$LINENO: using the built-in (GNU) MD5 implementation" >&5 +echo "$as_me: using the built-in (GNU) MD5 implementation" >&6;} + echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_bigendian=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 +_ACEOF + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + fi fi @@ -10841,8 +11259,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -10995,8 +11412,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -11083,8 +11499,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -11158,8 +11573,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -11207,8 +11621,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -11431,8 +11844,7 @@ fi - -for ac_header in locale.h libintl.h +for ac_header in libintl.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then @@ -11465,8 +11877,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -11621,8 +12032,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -11727,8 +12137,7 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -11935,7 +12344,7 @@ fi - ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile util/Makefile po/Makefile.in windows/Makefile" + ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile util/Makefile po/Makefile.in tests/Makefile windows/Makefile" ac_config_headers="$ac_config_headers src/config.h" @@ -12478,6 +12887,7 @@ "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "util/Makefile" ) CONFIG_FILES="$CONFIG_FILES util/Makefile" ;; "po/Makefile.in" ) CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; + "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; "windows/Makefile" ) CONFIG_FILES="$CONFIG_FILES windows/Makefile" ;; "stamp-h" ) CONFIG_FILES="$CONFIG_FILES stamp-h" ;; "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; @@ -12592,10 +13002,11 @@ s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t s,@exeext@,$exeext,;t t -s,@U@,$U,;t t -s,@ANSI2KNR@,$ANSI2KNR,;t t s,@ALLOCA@,$ALLOCA,;t t s,@GETOPT_OBJ@,$GETOPT_OBJ,;t t +s,@HAVE_LIBGNUTLS@,$HAVE_LIBGNUTLS,;t t +s,@LIBGNUTLS@,$LIBGNUTLS,;t t +s,@LTLIBGNUTLS@,$LTLIBGNUTLS,;t t s,@HAVE_LIBSSL@,$HAVE_LIBSSL,;t t s,@LIBSSL@,$LIBSSL,;t t s,@LTLIBSSL@,$LTLIBSSL,;t t @@ -12786,11 +13197,6 @@ *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -12829,6 +13235,12 @@ fi;; esac done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub diff -urN wget-1.10.2/configure.in wget-1.10.2_new/configure.in --- wget-1.10.2/configure.in 2005-08-26 13:57:04.000000000 +0200 +++ wget-1.10.2_new/configure.in 2006-06-27 12:03:49.000000000 +0200 @@ -90,7 +90,7 @@ wget_need_md5=yes esac if test x"$ENABLE_OPIE" = xyes; then - OPIE_OBJ='ftp-opie$o' + OPIE_OBJ='ftp-opie.o' fi AC_SUBST(OPIE_OBJ) @@ -114,7 +114,6 @@ AC_PROG_CC AC_AIX -AM_PROG_CC_STDC dnl Turn on optimization by default. Specifically: dnl @@ -125,7 +124,7 @@ dnl use os-specific flags or -O if test -n "$auto_cflags"; then if test -n "$GCC"; then - CFLAGS="$CFLAGS -O2 -Wall -Wno-implicit" + CFLAGS="$CFLAGS -O2 -Wall" else case "$host_os" in *hpux*) CFLAGS="$CFLAGS +O3" ;; @@ -151,64 +150,53 @@ AC_C_CONST AC_C_INLINE AC_C_VOLATILE -AC_C_BIGENDIAN -AC_C_PROTOTYPES -if test x"$am_cv_prog_cc_stdc" != xno; then : - AC_SUBST(U, []) - AC_SUBST(ANSI2KNR, []) -else - AC_SUBST(U, [_]) - AC_SUBST(ANSI2KNR, [./ansi2knr]) -fi +dnl Check for basic headers, even though we expect them to exist and +dnl #include them unconditionally in the code. Their detection is +dnl still needed because test programs used by Autoconf macros check +dnl for STDC_HEADERS, HAVE_SYS_TYPES_H, etc. before using them. +dnl Without the checks they will fail to be included in test programs, +dnl which will subsequently fail. +AC_HEADER_STDC + +dnl Check for large file support. This check needs to come fairly +dnl early because it could (in principle) affect whether functions and +dnl headers are available, whether they work, etc. +AC_SYS_LARGEFILE +AC_CHECK_SIZEOF(off_t) dnl -dnl Checks for header files that might be missing. +dnl Checks for system header files that might be missing. dnl - -dnl Check for basic headers, even those we assume the presence of. -dnl This is because Autoconf default includes check for STDC_HEADERS, -dnl HAVE_SYS_TYPES_H, etc. before including them. -AC_HEADER_STDC -AC_CHECK_HEADERS(sys/types.h sys/stat.h) -dnl Now check for the others. -AC_CHECK_HEADERS(string.h strings.h stdarg.h limits.h unistd.h sys/time.h) +AC_HEADER_STDBOOL +AC_CHECK_HEADERS(unistd.h sys/time.h) AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/select.h utime.h sys/utime.h) -AC_CHECK_HEADERS(stdint.h inttypes.h signal.h setjmp.h pwd.h) -AC_HEADER_TIME +AC_CHECK_HEADERS(stdint.h inttypes.h pwd.h) dnl -dnl Check integral type sizes. +dnl Check sizes of integer types. These are used to find n-bit +dnl integral types on older systems that fail to provide intN_t and +dnl uintN_t typedefs. dnl AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) - -dnl -dnl Check for large file support. This check needs to come fairly -dnl early because it could (in principle) affect whether functions and -dnl headers are available, whether they work, etc. -dnl -AC_SYS_LARGEFILE -AC_CHECK_SIZEOF(off_t) +AC_CHECK_SIZEOF(void *) dnl dnl Checks for non-universal or system-specific types. dnl AC_TYPE_SIZE_T AC_TYPE_PID_T -AC_CHECK_TYPES(uint32_t) -AC_TYPE_SIGNAL +AC_CHECK_TYPES([uint32_t, uintptr_t]) AC_CHECK_TYPES(sig_atomic_t, [], [], [ #include #include #if HAVE_INTTYPES_H # include #endif -#ifdef HAVE_SIGNAL_H -# include -#endif +#include ]) dnl @@ -217,13 +205,21 @@ AC_FUNC_ALLOCA AC_FUNC_MMAP AC_FUNC_FSEEKO -AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp strpbrk memmove) -AC_CHECK_FUNCS(gettimeofday mktime strptime timegm strerror snprintf vsnprintf) -AC_CHECK_FUNCS(usleep select ftello sigblock sigsetjmp signal) -AC_CHECK_FUNCS(symlink access isatty strtoll strtoimax) +AC_CHECK_FUNCS(strptime timegm snprintf vsnprintf vasprintf drand48) +AC_CHECK_FUNCS(strtoll strtoimax usleep ftello sigblock sigsetjmp memrchr) + +dnl We expect to have these functions on Unix-like systems configure +dnl runs on. The defines are provided to get them in config.h.in so +dnl Wget can still be ported to non-Unix systems (such as Windows) +dnl that lack some of these functions. +AC_DEFINE([HAVE_STRCASECMP], 1, [Define to 1 if you have the `strcasecmp' function.]) +AC_DEFINE([HAVE_STRNCASECMP], 1, [Define to 1 if you have the `strncasecmp' function.]) +AC_DEFINE([HAVE_STRDUP], 1, [Define to 1 if you have the `strdup' function.]) +AC_DEFINE([HAVE_ISATTY], 1, [Define to 1 if you have the `isatty' function.]) +AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the `symlink' function.]) dnl -dnl Call Wget's local macros defined in aclocal. +dnl Call Wget-specific macros defined in aclocal. dnl WGET_STRUCT_UTIMBUF WGET_SOCKLEN_T @@ -236,7 +232,7 @@ dnl Check if we need to compile in getopt.c. dnl AC_CHECK_FUNC(getopt_long, [], [ - GETOPT_OBJ='getopt$o' + GETOPT_OBJ='getopt.o' ]) AC_SUBST(GETOPT_OBJ) @@ -244,9 +240,20 @@ dnl Checks for libraries. dnl -dnl Check for OpenSSL -if test x"$with_ssl" != x"no" +if test x"$with_ssl" = xgnutls then + dnl Now actually check for -lssl + AC_LIB_HAVE_LINKFLAGS([gnutls], [], [ +#include + ], [gnutls_global_init()]) + if test x"$LIBGNUTLS" != x + then + AC_MSG_NOTICE([compiling in support for SSL via GnuTLS]) + SSL_OBJ='gnutls.o' + else + AC_MSG_ERROR([--with-ssl=gnutls was given, but GNUTLS is not available.]) + fi +elif test x"$with_ssl" != xno; then dnl As of this writing (OpenSSL 0.9.6), the libcrypto shared library dnl doesn't record its dependency on libdl, so we need to make sure dnl -ldl ends up in LIBS on systems that have it. Most OSes use @@ -267,15 +274,14 @@ ], [SSL_library_init ()]) if test x"$LIBSSL" != x then - AC_MSG_NOTICE([compiling in support for SSL]) - AC_DEFINE([HAVE_SSL], 1, - [Define if SSL support is being compiled in.]) - SSL_OBJ='openssl$o' + AC_MSG_NOTICE([compiling in support for SSL via OpenSSL]) + SSL_OBJ='openssl.o' elif test x"$with_ssl" != x then - AC_MSG_ERROR([--with-ssl was given, but OpenSSL is not available.]) + AC_MSG_ERROR([--with-ssl was given, but SSL is not available.]) fi fi + AC_SUBST(SSL_OBJ) dnl Enable NTLM if requested and if SSL is available. @@ -286,7 +292,7 @@ then AC_DEFINE([ENABLE_NTLM], 1, [Define if you want the NTLM authorization support compiled in.]) - NTLM_OBJ='http-ntlm$o' + NTLM_OBJ='http-ntlm.o' fi else dnl If SSL is unavailable and the user explicitly requested NTLM, @@ -308,7 +314,7 @@ dnl This should be moved to an AC_DEFUN, but I'm not sure how to dnl manipulate MD5_OBJ from the defun. - MD5_OBJ='gen-md5$o' + MD5_OBJ='gen-md5.o' found_md5=no dnl Check for the system MD5 library on Solaris. We don't check for @@ -324,7 +330,7 @@ AC_COMPILE_IFELSE([#include ], [ AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_SOLARIS_MD5], 1, [Define to use Solaris MD5.]) + AC_DEFINE([HAVE_SOLARIS_MD5], 1, [Define when using Solaris MD5.]) LIBS="-lmd5 $LIBS" found_md5=yes AC_MSG_NOTICE([using the Solaris MD5 implementation]) @@ -336,7 +342,7 @@ dnl implementation. if test x"$found_md5" = xno; then if test x"$LIBSSL" != x; then - AC_DEFINE([HAVE_OPENSSL_MD5], 1, [Define to use OpenSSL MD5.]) + AC_DEFINE([HAVE_OPENSSL_MD5], 1, [Define when using OpenSSL MD5.]) found_md5=yes AC_MSG_NOTICE([using the OpenSSL MD5 implementation]) fi @@ -344,10 +350,11 @@ dnl If none of the above worked, use the one we ship with Wget. if test x"$found_md5" = xno; then - AC_DEFINE([HAVE_BUILTIN_MD5], 1, [Define to use built-in MD5.]) - MD5_OBJ="$MD5_OBJ gnu-md5\$o" + AC_DEFINE([HAVE_BUILTIN_MD5], 1, [Define when using built-in MD5.]) + MD5_OBJ="$MD5_OBJ gnu-md5.o" found_md5=yes - AC_MSG_NOTICE([using the GNU MD5 implementation]) + AC_MSG_NOTICE([using the built-in (GNU) MD5 implementation]) + AC_C_BIGENDIAN fi fi AC_DEFINE([HAVE_MD5], 1, [Define if we're compiling support for MD5.]) @@ -470,7 +477,7 @@ dnl Create output dnl AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile util/Makefile - po/Makefile.in windows/Makefile]) + po/Makefile.in tests/Makefile windows/Makefile]) AC_CONFIG_HEADERS([src/config.h]) AH_BOTTOM([ #include "config-post.h" diff -urN wget-1.10.2/doc/Makefile.in wget-1.10.2_new/doc/Makefile.in --- wget-1.10.2/doc/Makefile.in 2005-06-06 22:42:17.000000000 +0200 +++ wget-1.10.2_new/doc/Makefile.in 2006-06-27 12:04:36.000000000 +0200 @@ -48,7 +48,7 @@ INSTALL_DATA = @INSTALL_DATA@ RM = rm -f -TEXI2POD = texi2pod.pl +TEXI2POD = $(srcdir)/texi2pod.pl POD2MAN = @POD2MAN@ MAN = wget.$(manext) WGETRC = $(sysconfdir)/wgetrc @@ -68,12 +68,8 @@ wget.info: $(srcdir)/wget.texi $(SAMPLERCTEXI) $(srcdir)/version.texi $(MAKEINFO) -I$(srcdir) $(srcdir)/wget.texi -$(TEXI2POD): $(srcdir)/$(TEXI2POD).in - sed 's,^#! /usr/bin/perl,#! @PERL@,' $? > $@ - chmod u+x $@ - -wget.pod: $(srcdir)/wget.texi $(TEXI2POD) $(srcdir)/version.texi - ./$(TEXI2POD) $(srcdir)/wget.texi $@ +wget.pod: $(srcdir)/wget.texi $(srcdir)/version.texi + $(TEXI2POD) $(srcdir)/wget.texi $@ $(MAN): wget.pod $(POD2MAN) --center="GNU Wget" --release="GNU Wget @VERSION@" $? > $@ @@ -166,7 +162,7 @@ distclean: clean $(RM) Makefile - $(RM) $(MAN) $(TEXI2POD) + $(RM) $(MAN) realclean: distclean $(RM) wget.info* diff -urN wget-1.10.2/doc/texi2pod.pl wget-1.10.2_new/doc/texi2pod.pl --- wget-1.10.2/doc/texi2pod.pl 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/doc/texi2pod.pl 2006-06-27 12:05:11.000000000 +0200 @@ -0,0 +1,438 @@ +#! /usr/bin/env perl + +# Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. + +# This file is part of GCC. + +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# GCC 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 GCC; see the file COPYING. If not, write to +# the Free Software Foundation, 59 Temple Place - Suite 330, +# Boston MA 02111-1307, USA. + +# This does trivial (and I mean _trivial_) conversion of Texinfo +# markup to Perl POD format. It's intended to be used to extract +# something suitable for a manpage from a Texinfo document. + +use warnings; + +$output = 0; +$skipping = 0; +%sects = (); +$section = ""; +@icstack = (); +@endwstack = (); +@skstack = (); +@instack = (); +$shift = ""; +%defs = (); +$fnno = 1; +$inf = ""; +$ibase = ""; + +while ($_ = shift) { + if (/^-D(.*)$/) { + if ($1 ne "") { + $flag = $1; + } else { + $flag = shift; + } + $value = ""; + ($flag, $value) = ($flag =~ /^([^=]+)(?:=(.+))?/); + die "no flag specified for -D\n" + unless $flag ne ""; + die "flags may only contain letters, digits, hyphens, dashes and underscores\n" + unless $flag =~ /^[a-zA-Z0-9_-]+$/; + $defs{$flag} = $value; + } elsif (/^-/) { + usage(); + } else { + $in = $_, next unless defined $in; + $out = $_, next unless defined $out; + usage(); + } +} + +if (defined $in) { + $inf = gensym(); + open($inf, "<$in") or die "opening \"$in\": $!\n"; + $ibase = $1 if $in =~ m|^(.+)/[^/]+$|; +} else { + $inf = \*STDIN; +} + +if (defined $out) { + open(STDOUT, ">$out") or die "opening \"$out\": $!\n"; +} + +while(defined $inf) { +while(<$inf>) { + # Certain commands are discarded without further processing. + /^\@(?: + [a-z]+index # @*index: useful only in complete manual + |need # @need: useful only in printed manual + |(?:end\s+)?group # @group .. @end group: ditto + |page # @page: ditto + |node # @node: useful only in .info file + |(?:end\s+)?ifnottex # @ifnottex .. @end ifnottex: use contents + )\b/x and next; + + chomp; + + # Look for filename and title markers. + /^\@setfilename\s+([^.]+)/ and $fn = $1, next; + /^\@settitle\s+([^.]+)/ and $tl = postprocess($1), next; + + # Identify a man title but keep only the one we are interested in. + /^\@c\s+man\s+title\s+([A-Za-z0-9-]+)\s+(.+)/ and do { + if (exists $defs{$1}) { + $fn = $1; + $tl = postprocess($2); + } + next; + }; + + # Look for blocks surrounded by @c man begin SECTION ... @c man end. + # This really oughta be @ifman ... @end ifman and the like, but such + # would require rev'ing all other Texinfo translators. + /^\@c\s+man\s+begin\s+([A-Z]+)\s+([A-Za-z0-9-]+)/ and do { + $output = 1 if exists $defs{$2}; + $sect = $1; + next; + }; + /^\@c\s+man\s+begin\s+([A-Z]+)/ and $sect = $1, $output = 1, next; + /^\@c\s+man\s+end/ and do { + $sects{$sect} = "" unless exists $sects{$sect}; + $sects{$sect} .= postprocess($section); + $section = ""; + $output = 0; + next; + }; + + # handle variables + /^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do { + $defs{$1} = $2; + next; + }; + /^\@clear\s+([a-zA-Z0-9_-]+)/ and do { + delete $defs{$1}; + next; + }; + + next unless $output; + + # Discard comments. (Can't do it above, because then we'd never see + # @c man lines.) + /^\@c\b/ and next; + + # End-block handler goes up here because it needs to operate even + # if we are skipping. + /^\@end\s+([a-z]+)/ and do { + # Ignore @end foo, where foo is not an operation which may + # cause us to skip, if we are presently skipping. + my $ended = $1; + next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|copying)$/; + + die "\@end $ended without \@$ended at line $.\n" unless defined $endw; + die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw; + + $endw = pop @endwstack; + + if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) { + $skipping = pop @skstack; + next; + } elsif ($ended =~ /^(?:example|smallexample|display)$/) { + $shift = ""; + $_ = ""; # need a paragraph break + } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) { + $_ = "\n=back\n"; + $ic = pop @icstack; + } else { + die "unknown command \@end $ended at line $.\n"; + } + }; + + # We must handle commands which can cause skipping even while we + # are skipping, otherwise we will not process nested conditionals + # correctly. + /^\@ifset\s+([a-zA-Z0-9_-]+)/ and do { + push @endwstack, $endw; + push @skstack, $skipping; + $endw = "ifset"; + $skipping = 1 unless exists $defs{$1}; + next; + }; + + /^\@ifclear\s+([a-zA-Z0-9_-]+)/ and do { + push @endwstack, $endw; + push @skstack, $skipping; + $endw = "ifclear"; + $skipping = 1 if exists $defs{$1}; + next; + }; + + /^\@(ignore|menu|iftex|copying)\b/ and do { + push @endwstack, $endw; + push @skstack, $skipping; + $endw = $1; + $skipping = 1; + next; + }; + + next if $skipping; + + # Character entities. First the ones that can be replaced by raw text + # or discarded outright: + s/\@copyright\{\}/(c)/g; + s/\@dots\{\}/.../g; + s/\@enddots\{\}/..../g; + s/\@([.!? ])/$1/g; + s/\@[:-]//g; + s/\@bullet(?:\{\})?/*/g; + s/\@TeX\{\}/TeX/g; + s/\@pounds\{\}/\#/g; + s/\@minus(?:\{\})?/-/g; + s/\\,/,/g; + + # Now the ones that have to be replaced by special escapes + # (which will be turned back into text by unmunge()) + s/&/&/g; + s/\@\@/&at;/g; + s/\@\{/{/g; + s/\@\}/}/g; + + # Inside a verbatim block, handle @var specially. + if ($shift ne "") { + s/\@var\{([^\}]*)\}/<$1>/g; + } + + # POD doesn't interpret E<> inside a verbatim block. + if ($shift eq "") { + s//>/g; + } else { + s//>/g; + } + + # Single line command handlers. + + /^\@include\s+(.+)$/ and do { + push @instack, $inf; + $inf = gensym(); + + # Try cwd and $ibase. + open($inf, "<" . $1) + or open($inf, "<" . $ibase . "/" . $1) + or die "cannot open $1 or $ibase/$1: $!\n"; + next; + }; + + /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/ + and $_ = "\n=head2 $1\n"; + /^\@subsection\s+(.+)$/ + and $_ = "\n=head3 $1\n"; + + # Block command handlers: + /^\@itemize(?:\s+(\@[a-z]+|\*|-))?/ and do { + push @endwstack, $endw; + push @icstack, $ic; + if (defined $1) { + $ic = $1; + } else { + $ic = '@bullet'; + } + $_ = "\n=over 4\n"; + $endw = "itemize"; + }; + + /^\@enumerate(?:\s+([a-zA-Z0-9]+))?/ and do { + push @endwstack, $endw; + push @icstack, $ic; + if (defined $1) { + $ic = $1 . "."; + } else { + $ic = "1."; + } + $_ = "\n=over 4\n"; + $endw = "enumerate"; + }; + + /^\@([fv]?table)\s+(\@[a-z]+)/ and do { + push @endwstack, $endw; + push @icstack, $ic; + $endw = $1; + $ic = $2; + $ic =~ s/\@(?:samp|strong|key|gcctabopt|env)/B/; + $ic =~ s/\@(?:code|kbd)/C/; + $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/; + $ic =~ s/\@(?:file)/F/; + $ic =~ s/\@(?:asis)/S/; # punt + $_ = "\n=over 4\n"; + }; + + /^\@((?:small)?example|display)/ and do { + push @endwstack, $endw; + $endw = $1; + $shift = "\t"; + $_ = ""; # need a paragraph break + }; + + /^\@itemx?\s*(.+)?$/ and do { + if (defined $1) { + # Entity escapes prevent munging by the <> processing below. + $_ = "\n=item $ic\<$1\>\n"; + } else { + $_ = "\n=item $ic\n"; + $ic =~ y/A-Ya-y/B-Zb-z/; + $ic =~ s/(\d+)/$1 + 1/eg; + } + }; + + $section .= $shift.$_."\n"; +} +# End of current file. +close($inf); +$inf = pop @instack; +} + +die "No filename or title\n" unless defined $fn && defined $tl; + +$sects{NAME} = "$fn \- $tl\n"; +$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES}; + +for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS ENVIRONMENT EXAMPLES FILES + BUGS NOTES FOOTNOTES SEEALSO AUTHOR COPYRIGHT)) { + if(exists $sects{$sect}) { + $head = $sect; + $head =~ s/SEEALSO/SEE ALSO/; + print "=head1 $head\n\n"; + print scalar unmunge ($sects{$sect}); + print "\n"; + } +} + +sub usage +{ + die "usage: $0 [-D toggle...] [infile [outfile]]\n"; +} + +sub postprocess +{ + local $_ = $_[0]; + + # @value{foo} is replaced by whatever 'foo' is defined as. + while (m/(\@value\{([a-zA-Z0-9_-]+)\})/g) { + if (! exists $defs{$2}) { + print STDERR "Option $2 not defined\n"; + s/\Q$1\E//; + } else { + $value = $defs{$2}; + s/\Q$1\E/$value/; + } + } + + # Formatting commands. + # Temporary escape for @r. + s/\@r\{([^\}]*)\}/R<$1>/g; + s/\@(?:dfn|var|emph|cite|i)\{([^\}]*)\}/I<$1>/g; + s/\@(?:code|kbd)\{([^\}]*)\}/C<$1>/g; + s/\@(?:gccoptlist|samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g; + s/\@sc\{([^\}]*)\}/\U$1/g; + s/\@file\{([^\}]*)\}/F<$1>/g; + s/\@w\{([^\}]*)\}/S<$1>/g; + s/\@(?:dmn|math)\{([^\}]*)\}/$1/g; + + # Cross references are thrown away, as are @noindent and @refill. + # (@noindent is impossible in .pod, and @refill is unnecessary.) + # @* is also impossible in .pod; we discard it and any newline that + # follows it. Similarly, our macro @gol must be discarded. + + s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g; + s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g; + s/;\s+\@pxref\{(?:[^\}]*)\}//g; + s/\@noindent\s*//g; + s/\@refill//g; + s/\@gol//g; + s/\@\*\s*\n?//g; + + # @uref can take one, two, or three arguments, with different + # semantics each time. @url and @email are just like @uref with + # one argument, for our purposes. + s/\@(?:uref|url|email)\{([^\},]*)\}/<B<$1>>/g; + s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g; + s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g; + + # Un-escape <> at this point. + s/<//g; + + # Now un-nest all B<>, I<>, R<>. Theoretically we could have + # indefinitely deep nesting; in practice, one level suffices. + 1 while s/([BIR])<([^<>]*)([BIR])<([^<>]*)>/$1<$2>$3<$4>$1 with bare ...; eliminate empty markup, B<>; + # shift white space at the ends of [BI]<...> expressions outside + # the expression. + s/R<([^<>]*)>/$1/g; + s/[BI]<>//g; + s/([BI])<(\s+)([^>]+)>/$2$1<$3>/g; + s/([BI])<([^>]+?)(\s+)>/$1<$2>$3/g; + + # Extract footnotes. This has to be done after all other + # processing because otherwise the regexp will choke on formatting + # inside @footnote. + while (/\@footnote/g) { + s/\@footnote\{([^\}]+)\}/[$fnno]/; + add_footnote($1, $fnno); + $fnno++; + } + + return $_; +} + +sub unmunge +{ + # Replace escaped symbols with their equivalents. + local $_ = $_[0]; + + s/</E/g; + s/>/E/g; + s/{/\{/g; + s/}/\}/g; + s/&at;/\@/g; + s/&/&/g; + return $_; +} + +sub add_footnote +{ + unless (exists $sects{FOOTNOTES}) { + $sects{FOOTNOTES} = "\n=over 4\n\n"; + } + + $sects{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++; + $sects{FOOTNOTES} .= $_[0]; + $sects{FOOTNOTES} .= "\n\n"; +} + +# stolen from Symbol.pm +{ + my $genseq = 0; + sub gensym + { + my $name = "GEN" . $genseq++; + my $ref = \*{$name}; + delete $::{$name}; + return $ref; + } +} diff -urN wget-1.10.2/doc/texi2pod.pl.in wget-1.10.2_new/doc/texi2pod.pl.in --- wget-1.10.2/doc/texi2pod.pl.in 2005-05-08 00:10:29.000000000 +0200 +++ wget-1.10.2_new/doc/texi2pod.pl.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,436 +0,0 @@ -#! /usr/bin/perl -w - -# Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. - -# This file is part of GCC. - -# GCC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# GCC 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 GCC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston MA 02111-1307, USA. - -# This does trivial (and I mean _trivial_) conversion of Texinfo -# markup to Perl POD format. It's intended to be used to extract -# something suitable for a manpage from a Texinfo document. - -$output = 0; -$skipping = 0; -%sects = (); -$section = ""; -@icstack = (); -@endwstack = (); -@skstack = (); -@instack = (); -$shift = ""; -%defs = (); -$fnno = 1; -$inf = ""; -$ibase = ""; - -while ($_ = shift) { - if (/^-D(.*)$/) { - if ($1 ne "") { - $flag = $1; - } else { - $flag = shift; - } - $value = ""; - ($flag, $value) = ($flag =~ /^([^=]+)(?:=(.+))?/); - die "no flag specified for -D\n" - unless $flag ne ""; - die "flags may only contain letters, digits, hyphens, dashes and underscores\n" - unless $flag =~ /^[a-zA-Z0-9_-]+$/; - $defs{$flag} = $value; - } elsif (/^-/) { - usage(); - } else { - $in = $_, next unless defined $in; - $out = $_, next unless defined $out; - usage(); - } -} - -if (defined $in) { - $inf = gensym(); - open($inf, "<$in") or die "opening \"$in\": $!\n"; - $ibase = $1 if $in =~ m|^(.+)/[^/]+$|; -} else { - $inf = \*STDIN; -} - -if (defined $out) { - open(STDOUT, ">$out") or die "opening \"$out\": $!\n"; -} - -while(defined $inf) { -while(<$inf>) { - # Certain commands are discarded without further processing. - /^\@(?: - [a-z]+index # @*index: useful only in complete manual - |need # @need: useful only in printed manual - |(?:end\s+)?group # @group .. @end group: ditto - |page # @page: ditto - |node # @node: useful only in .info file - |(?:end\s+)?ifnottex # @ifnottex .. @end ifnottex: use contents - )\b/x and next; - - chomp; - - # Look for filename and title markers. - /^\@setfilename\s+([^.]+)/ and $fn = $1, next; - /^\@settitle\s+([^.]+)/ and $tl = postprocess($1), next; - - # Identify a man title but keep only the one we are interested in. - /^\@c\s+man\s+title\s+([A-Za-z0-9-]+)\s+(.+)/ and do { - if (exists $defs{$1}) { - $fn = $1; - $tl = postprocess($2); - } - next; - }; - - # Look for blocks surrounded by @c man begin SECTION ... @c man end. - # This really oughta be @ifman ... @end ifman and the like, but such - # would require rev'ing all other Texinfo translators. - /^\@c\s+man\s+begin\s+([A-Z]+)\s+([A-Za-z0-9-]+)/ and do { - $output = 1 if exists $defs{$2}; - $sect = $1; - next; - }; - /^\@c\s+man\s+begin\s+([A-Z]+)/ and $sect = $1, $output = 1, next; - /^\@c\s+man\s+end/ and do { - $sects{$sect} = "" unless exists $sects{$sect}; - $sects{$sect} .= postprocess($section); - $section = ""; - $output = 0; - next; - }; - - # handle variables - /^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do { - $defs{$1} = $2; - next; - }; - /^\@clear\s+([a-zA-Z0-9_-]+)/ and do { - delete $defs{$1}; - next; - }; - - next unless $output; - - # Discard comments. (Can't do it above, because then we'd never see - # @c man lines.) - /^\@c\b/ and next; - - # End-block handler goes up here because it needs to operate even - # if we are skipping. - /^\@end\s+([a-z]+)/ and do { - # Ignore @end foo, where foo is not an operation which may - # cause us to skip, if we are presently skipping. - my $ended = $1; - next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|copying)$/; - - die "\@end $ended without \@$ended at line $.\n" unless defined $endw; - die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw; - - $endw = pop @endwstack; - - if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) { - $skipping = pop @skstack; - next; - } elsif ($ended =~ /^(?:example|smallexample|display)$/) { - $shift = ""; - $_ = ""; # need a paragraph break - } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) { - $_ = "\n=back\n"; - $ic = pop @icstack; - } else { - die "unknown command \@end $ended at line $.\n"; - } - }; - - # We must handle commands which can cause skipping even while we - # are skipping, otherwise we will not process nested conditionals - # correctly. - /^\@ifset\s+([a-zA-Z0-9_-]+)/ and do { - push @endwstack, $endw; - push @skstack, $skipping; - $endw = "ifset"; - $skipping = 1 unless exists $defs{$1}; - next; - }; - - /^\@ifclear\s+([a-zA-Z0-9_-]+)/ and do { - push @endwstack, $endw; - push @skstack, $skipping; - $endw = "ifclear"; - $skipping = 1 if exists $defs{$1}; - next; - }; - - /^\@(ignore|menu|iftex|copying)\b/ and do { - push @endwstack, $endw; - push @skstack, $skipping; - $endw = $1; - $skipping = 1; - next; - }; - - next if $skipping; - - # Character entities. First the ones that can be replaced by raw text - # or discarded outright: - s/\@copyright\{\}/(c)/g; - s/\@dots\{\}/.../g; - s/\@enddots\{\}/..../g; - s/\@([.!? ])/$1/g; - s/\@[:-]//g; - s/\@bullet(?:\{\})?/*/g; - s/\@TeX\{\}/TeX/g; - s/\@pounds\{\}/\#/g; - s/\@minus(?:\{\})?/-/g; - s/\\,/,/g; - - # Now the ones that have to be replaced by special escapes - # (which will be turned back into text by unmunge()) - s/&/&/g; - s/\@\@/&at;/g; - s/\@\{/{/g; - s/\@\}/}/g; - - # Inside a verbatim block, handle @var specially. - if ($shift ne "") { - s/\@var\{([^\}]*)\}/<$1>/g; - } - - # POD doesn't interpret E<> inside a verbatim block. - if ($shift eq "") { - s//>/g; - } else { - s//>/g; - } - - # Single line command handlers. - - /^\@include\s+(.+)$/ and do { - push @instack, $inf; - $inf = gensym(); - - # Try cwd and $ibase. - open($inf, "<" . $1) - or open($inf, "<" . $ibase . "/" . $1) - or die "cannot open $1 or $ibase/$1: $!\n"; - next; - }; - - /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/ - and $_ = "\n=head2 $1\n"; - /^\@subsection\s+(.+)$/ - and $_ = "\n=head3 $1\n"; - - # Block command handlers: - /^\@itemize(?:\s+(\@[a-z]+|\*|-))?/ and do { - push @endwstack, $endw; - push @icstack, $ic; - if (defined $1) { - $ic = $1; - } else { - $ic = '@bullet'; - } - $_ = "\n=over 4\n"; - $endw = "itemize"; - }; - - /^\@enumerate(?:\s+([a-zA-Z0-9]+))?/ and do { - push @endwstack, $endw; - push @icstack, $ic; - if (defined $1) { - $ic = $1 . "."; - } else { - $ic = "1."; - } - $_ = "\n=over 4\n"; - $endw = "enumerate"; - }; - - /^\@([fv]?table)\s+(\@[a-z]+)/ and do { - push @endwstack, $endw; - push @icstack, $ic; - $endw = $1; - $ic = $2; - $ic =~ s/\@(?:samp|strong|key|gcctabopt|env)/B/; - $ic =~ s/\@(?:code|kbd)/C/; - $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/; - $ic =~ s/\@(?:file)/F/; - $ic =~ s/\@(?:asis)/S/; # punt - $_ = "\n=over 4\n"; - }; - - /^\@((?:small)?example|display)/ and do { - push @endwstack, $endw; - $endw = $1; - $shift = "\t"; - $_ = ""; # need a paragraph break - }; - - /^\@itemx?\s*(.+)?$/ and do { - if (defined $1) { - # Entity escapes prevent munging by the <> processing below. - $_ = "\n=item $ic\<$1\>\n"; - } else { - $_ = "\n=item $ic\n"; - $ic =~ y/A-Ya-y/B-Zb-z/; - $ic =~ s/(\d+)/$1 + 1/eg; - } - }; - - $section .= $shift.$_."\n"; -} -# End of current file. -close($inf); -$inf = pop @instack; -} - -die "No filename or title\n" unless defined $fn && defined $tl; - -$sects{NAME} = "$fn \- $tl\n"; -$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES}; - -for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS ENVIRONMENT EXAMPLES FILES - BUGS NOTES FOOTNOTES SEEALSO AUTHOR COPYRIGHT)) { - if(exists $sects{$sect}) { - $head = $sect; - $head =~ s/SEEALSO/SEE ALSO/; - print "=head1 $head\n\n"; - print scalar unmunge ($sects{$sect}); - print "\n"; - } -} - -sub usage -{ - die "usage: $0 [-D toggle...] [infile [outfile]]\n"; -} - -sub postprocess -{ - local $_ = $_[0]; - - # @value{foo} is replaced by whatever 'foo' is defined as. - while (m/(\@value\{([a-zA-Z0-9_-]+)\})/g) { - if (! exists $defs{$2}) { - print STDERR "Option $2 not defined\n"; - s/\Q$1\E//; - } else { - $value = $defs{$2}; - s/\Q$1\E/$value/; - } - } - - # Formatting commands. - # Temporary escape for @r. - s/\@r\{([^\}]*)\}/R<$1>/g; - s/\@(?:dfn|var|emph|cite|i)\{([^\}]*)\}/I<$1>/g; - s/\@(?:code|kbd)\{([^\}]*)\}/C<$1>/g; - s/\@(?:gccoptlist|samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g; - s/\@sc\{([^\}]*)\}/\U$1/g; - s/\@file\{([^\}]*)\}/F<$1>/g; - s/\@w\{([^\}]*)\}/S<$1>/g; - s/\@(?:dmn|math)\{([^\}]*)\}/$1/g; - - # Cross references are thrown away, as are @noindent and @refill. - # (@noindent is impossible in .pod, and @refill is unnecessary.) - # @* is also impossible in .pod; we discard it and any newline that - # follows it. Similarly, our macro @gol must be discarded. - - s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g; - s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g; - s/;\s+\@pxref\{(?:[^\}]*)\}//g; - s/\@noindent\s*//g; - s/\@refill//g; - s/\@gol//g; - s/\@\*\s*\n?//g; - - # @uref can take one, two, or three arguments, with different - # semantics each time. @url and @email are just like @uref with - # one argument, for our purposes. - s/\@(?:uref|url|email)\{([^\},]*)\}/<B<$1>>/g; - s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g; - s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g; - - # Un-escape <> at this point. - s/<//g; - - # Now un-nest all B<>, I<>, R<>. Theoretically we could have - # indefinitely deep nesting; in practice, one level suffices. - 1 while s/([BIR])<([^<>]*)([BIR])<([^<>]*)>/$1<$2>$3<$4>$1 with bare ...; eliminate empty markup, B<>; - # shift white space at the ends of [BI]<...> expressions outside - # the expression. - s/R<([^<>]*)>/$1/g; - s/[BI]<>//g; - s/([BI])<(\s+)([^>]+)>/$2$1<$3>/g; - s/([BI])<([^>]+?)(\s+)>/$1<$2>$3/g; - - # Extract footnotes. This has to be done after all other - # processing because otherwise the regexp will choke on formatting - # inside @footnote. - while (/\@footnote/g) { - s/\@footnote\{([^\}]+)\}/[$fnno]/; - add_footnote($1, $fnno); - $fnno++; - } - - return $_; -} - -sub unmunge -{ - # Replace escaped symbols with their equivalents. - local $_ = $_[0]; - - s/</E/g; - s/>/E/g; - s/{/\{/g; - s/}/\}/g; - s/&at;/\@/g; - s/&/&/g; - return $_; -} - -sub add_footnote -{ - unless (exists $sects{FOOTNOTES}) { - $sects{FOOTNOTES} = "\n=over 4\n\n"; - } - - $sects{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++; - $sects{FOOTNOTES} .= $_[0]; - $sects{FOOTNOTES} .= "\n\n"; -} - -# stolen from Symbol.pm -{ - my $genseq = 0; - sub gensym - { - my $name = "GEN" . $genseq++; - my $ref = \*{$name}; - delete $::{$name}; - return $ref; - } -} diff -urN wget-1.10.2/doc/wget.texi wget-1.10.2_new/doc/wget.texi --- wget-1.10.2/doc/wget.texi 2006-06-27 11:47:13.000000000 +0200 +++ wget-1.10.2_new/doc/wget.texi 2006-06-27 12:08:30.000000000 +0200 @@ -462,6 +462,8 @@ which case @samp{-d} will not work. Please note that compiling with debug support is always safe---Wget compiled with the debug support will @emph{not} print any debug info unless requested with @samp{-d}. +@xref{Reporting Bugs}, for more information on how to use @samp{-d} for +sending bug reports. @cindex quiet @item -q @@ -787,7 +789,9 @@ Specifying a large value for this option is useful if the network or the destination host is down, so that Wget can wait long enough to -reasonably expect the network error to be fixed before the retry. +reasonably expect the network error to be fixed before the retry. The +waiting interval specified by this function is influenced by +@code{--random-wait}, which see. @cindex retries, waiting between @cindex waiting between retries @@ -809,11 +813,11 @@ Some web sites may perform log analysis to identify retrieval programs such as Wget by looking for statistically significant similarities in the time between requests. This option causes the time between requests -to vary between 0 and 2 * @var{wait} seconds, where @var{wait} was +to vary between 0.5 and 1.5 * @var{wait} seconds, where @var{wait} was specified using the @samp{--wait} option, in order to mask Wget's presence from such analysis. -A recent article in a publication devoted to development on a popular +A 2001 article in a publication devoted to development on a popular consumer platform provided code to perform this analysis on the fly. Its author suggested blocking at the class C address level to ensure automated retrieval programs were blocked despite changing DHCP-supplied @@ -828,7 +832,7 @@ Don't use proxies, even if the appropriate @code{*_proxy} environment variable is defined. -@xref{Proxies}, for more information about the use of proxies with Wget. +For more information about the use of proxies with Wget, @xref{Proxies}. @cindex quota @item -Q @var{quota} @@ -892,7 +896,7 @@ @samp{>}, and the control characters in the ranges 0--31 and 128--159. In addition to this, Wget in Windows mode uses @samp{+} instead of @samp{:} to separate host and port in local file names, and uses -@samp{ @@ } instead of @samp{ ? } to separate the query portion of the file +@samp{@@} instead of @samp{?} to separate the query portion of the file name from the rest. Therefore, a URL that would be saved as @samp{www.xemacs.org:4300/search.pl?input=blah} in Unix mode would be saved as @samp{www.xemacs.org+4300/search.pl@@input=blah} in Windows @@ -1132,7 +1136,7 @@ would send in the same situation. Different browsers keep textual cookie files in different locations: -@table @samp +@table @asis @item Netscape 4.x. The cookies are in @file{~/.netscape/cookies.txt}. @@ -1787,8 +1791,7 @@ @item -A @var{acclist} --accept @var{acclist} @itemx -R @var{rejlist} --reject @var{rejlist} Specify comma-separated lists of file name suffixes or patterns to -accept or reject. -(@pxref{Types of Files}). +accept or reject (@pxref{Types of Files} for more details). @item -D @var{domain-list} @itemx --domains=@var{domain-list} @@ -1845,13 +1848,13 @@ @item -I @var{list} @itemx --include-directories=@var{list} Specify a comma-separated list of directories you wish to follow when -downloading. (@pxref{Directory-Based Limits}) Elements +downloading (@pxref{Directory-Based Limits} for more details.) Elements of @var{list} may contain wildcards. @item -X @var{list} @itemx --exclude-directories=@var{list} Specify a comma-separated list of directories you wish to exclude from -download. (@pxref{Directory-Based Limits}) Elements of +download (@pxref{Directory-Based Limits} for more details.) Elements of @var{list} may contain wildcards. @item -np @@ -2402,7 +2405,9 @@ @cindex location of wgetrc When initializing, Wget will look for a @dfn{global} startup file, -@file{/etc/wgetrc} and read commands from there, if it exists. +@file{/usr/local/etc/wgetrc} by default (or some prefix other than +@file{/usr/local}, if Wget was not installed there) and read commands +from there, if it exists. Then it will look for the user's file. If the environmental variable @code{WGETRC} is set, Wget will try to load that file. Failing that, no @@ -2412,7 +2417,7 @@ The fact that user's settings are loaded after the system-wide ones means that in case of collision user's wgetrc @emph{overrides} the -system-wide wgetrc (in @file{/etc/wgetrc} by default). +system-wide wgetrc (in @file{/usr/local/etc/wgetrc} by default). Fascist admins, away! @node Wgetrc Syntax @@ -2448,12 +2453,7 @@ The complete set of commands is listed below. Legal values are listed after the @samp{=}. Simple Boolean values can be set or unset using -@samp{on} and @samp{off} or @samp{1} and @samp{0}. A fancier kind of -Boolean allowed in some cases is the @dfn{lockable Boolean}, which may -be set to @samp{on}, @samp{off}, @samp{always}, or @samp{never}. If an -option is set to @samp{always} or @samp{never}, that value will be -locked in for the duration of the Wget invocation---command-line options -will not override. +@samp{on} and @samp{off} or @samp{1} and @samp{0}. Some commands take pseudo-arbitrary values. @var{address} values can be hostnames or dotted-quad IP addresses. @var{n} can be any positive @@ -2464,7 +2464,7 @@ wgetrc command can be specified on the command line using the @samp{--execute} switch (@pxref{Basic Startup Options}.) -@table @samp +@table @asis @item accept/reject = @var{string} Same as @samp{-A}/@samp{-R} (@pxref{Types of Files}). @@ -2640,6 +2640,10 @@ Set @sc{http} user to @var{string}, equivalent to @samp{--http-user=@var{string}}. +@item https_proxy = @var{string} +Use @var{string} as @sc{https} proxy, instead of the one specified in +environment. + @item ignore_length = on/off When set to on, ignore @code{Content-Length} header; the same as @samp{--ignore-length}. @@ -2700,12 +2704,9 @@ Download all ancillary documents necessary for a single @sc{html} page to display properly---the same as @samp{-p}. -@item passive_ftp = on/off/always/never +@item passive_ftp = on/off Change setting of passive @sc{ftp}, equivalent to the -@samp{--passive-ftp} option. Some scripts and @samp{.pm} (Perl -module) files download files using @samp{wget --passive-ftp}. If your -firewall does not allow this, you can set @samp{passive_ftp = never} -to override the command-line. +@samp{--passive-ftp} option. @itemx password = @var{string} Specify password @var{string} for both @sc{ftp} and @sc{http} file retrieval. @@ -2768,6 +2769,10 @@ Use @var{file} as a source of randomness on systems lacking @file{/dev/random}. +@item random_wait = on/off +Turn random between-request wait times on or off. The same as +@samp{--random-wait}. + @item read_timeout = @var{n} Set the read (and write) timeout---the same as @samp{--read-timeout=@var{n}}. @@ -2860,10 +2865,6 @@ Wait up to @var{n} seconds between retries of failed retrievals only---the same as @samp{--waitretry=@var{n}}. Note that this is turned on by default in the global @file{wgetrc}. - -@item randomwait = on/off -Turn random between-request wait times on or off. The same as -@samp{--random-wait}. @end table @node Sample Wgetrc @@ -3171,13 +3172,15 @@ @table @code @item http_proxy -This variable should contain the @sc{url} of the proxy for @sc{http} -connections. +@itemx https_proxy +If set, the @code{http_proxy} and @code{https_proxy} variables should +contain the @sc{url}s of the proxies for @sc{http} and @sc{https} +connections respectively. @item ftp_proxy This variable should contain the @sc{url} of the proxy for @sc{ftp} -connections. It is quite common that @sc{http_proxy} and @sc{ftp_proxy} -are set to the same @sc{url}. +connections. It is quite common that @code{http_proxy} and +@code{ftp_proxy} are set to the same @sc{url}. @item no_proxy This variable should contain a comma-separated list of domain extensions @@ -3196,6 +3199,7 @@ use of proxy, even if the appropriate environment variables are set. @item http_proxy = @var{URL} +@itemx https_proxy = @var{URL} @itemx ftp_proxy = @var{URL} @itemx no_proxy = @var{string} These startup file variables allow you to override the proxy settings @@ -3511,10 +3515,28 @@ Special thanks goes to the following people (no particular order): @itemize @bullet +@item Mauro Tortonesi---contributed high-quality IPv6 code and many +other fixes. + +@item Dan Harkless---contributed a lot of code and documentation of +extremely high quality, as well as the @code{--page-requisites} and +related options. He was the principal maintainer for some time and +released Wget 1.6. + +@item Ian Abbott---contributed bug fixes, Windows-related fixes, and +provided a prototype implementation of the breadth-first recursive +download. Co-maintained Wget during the 1.8 release cycle. + +@item +The dotsrc.org crew, in particular Karsten Thygesen---donated system +resources such as the mailing list, web space, @sc{ftp} space, and +version control repositories, along with a lot of time to make these +actually work. Christian Reiniger was of invaluable help with setting +up Subversion. + @item -Karsten Thygesen---donated system resources such as the mailing list, -web space, and @sc{ftp} space, along with a lot of time to make these -actually work. +Heiko Herold---provided high-quality Windows builds and contributed +bug and build reports for many years. @item Shawn McHorse---bug reports and patches. @@ -3540,7 +3562,8 @@ Darko Budor---initial port to Windows. @item -Antonio Rosella---help and suggestions, plus the Italian translation. +Antonio Rosella---help and suggestions, plus the initial Italian +translation. @item @iftex @@ -3560,23 +3583,21 @@ @end ifnottex @item -Karl Eichwalder---lots of help with internationalization and other -things. +Karl Eichwalder---lots of help with internationalization, Makefile +layout and many other things. @item Junio Hamano---donated support for Opie and @sc{http} @code{Digest} authentication. @item -The people who provided donations for development, including Brian -Gough. +People who provided donations for development---including Brian Gough. @end itemize The following people have provided patches, bug/build reports, useful suggestions, beta testing services, fan mail and all the other things that make maintenance so much fun: -Ian Abbott Tim Adam, Adrian Aichner, Martin Baehr, @@ -3632,9 +3653,7 @@ Lemble Gregory, Hans Grobler, Mathieu Guillaume, -Dan Harkless, Aaron Hawley, -Herold Heiko, Jochen Hein, Karl Heuer, HIROSE Masaaki, @@ -3742,6 +3761,7 @@ Robert Schmidt, Nicolas Schodet, Andreas Schwab, +Steven M. Schweda, Chris Seawood, Dennis Smit, Toomas Soome, diff -urN wget-1.10.2/INSTALL wget-1.10.2_new/INSTALL --- wget-1.10.2/INSTALL 2005-07-03 14:56:47.000000000 +0200 +++ wget-1.10.2_new/INSTALL 2006-06-27 12:09:09.000000000 +0200 @@ -151,9 +151,9 @@ -------------- To compile GNU Wget after it has been configured, simply type make. -If your compiler is too old to handle function prototypes, Wget will -try to K&R-ize its sources on the fly. This should make GNU Wget -compilable on almost any Unix-like system you are likely to encounter. +Wget requires a compiler and standard library compliant with the 1990 +ISO C standard, which includes the vast majority of compilation +environments present on systems in use today. After the compilation a ready-to-use `wget' executable should reside in the src directory. At this point there is no formal test suite for diff -urN wget-1.10.2/m4/wget.m4 wget-1.10.2_new/m4/wget.m4 --- wget-1.10.2/m4/wget.m4 2005-06-27 00:06:49.000000000 +0200 +++ wget-1.10.2_new/m4/wget.m4 2006-06-27 12:09:27.000000000 +0200 @@ -138,63 +138,6 @@ ]) -# serial 1 - -# @defmac AC_PROG_CC_STDC -# @maindex PROG_CC_STDC -# @ovindex CC -# If the C compiler in not in ANSI C mode by default, try to add an option -# to output variable @code{CC} to make it so. This macro tries various -# options that select ANSI C on some system or another. It considers the -# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and -# handles function prototypes correctly. -# -# If you use this macro, you should check after calling it whether the C -# compiler has been set to accept ANSI C; if not, the shell variable -# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source -# code in ANSI C, you can make an un-ANSIfied copy of it by using the -# program @code{ansi2knr}, which comes with Ghostscript. -# @end defmac - -AC_DEFUN(AM_PROG_CC_STDC, -[AC_REQUIRE([AC_PROG_CC]) -AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C]) -AC_CACHE_VAL(am_cv_prog_cc_stdc, -[am_cv_prog_cc_stdc=no -ac_save_CC="$CC" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Aa -D_HPUX_SOURCE -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -do - CC="$ac_save_CC $ac_arg" - AC_TRY_COMPILE( -[#if !defined(__STDC__) -choke me -#endif -/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */ -#ifdef _SEQUENT_ -# include -# include -#endif -], [ -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);};], -[am_cv_prog_cc_stdc="$ac_arg"; break]) -done -CC="$ac_save_CC" -]) -AC_MSG_RESULT($am_cv_prog_cc_stdc) -case "x$am_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $am_cv_prog_cc_stdc" ;; -esac -]) - - dnl ************************************************************ dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS dnl ************************************************************ @@ -336,7 +279,7 @@ fi fi - AC_CHECK_HEADERS(locale.h libintl.h) + AC_CHECK_HEADERS(libintl.h) dnl Prefer gettext found in -lintl to the one in libc. dnl Otherwise it can happen that we include libintl.h from @@ -461,3 +404,4 @@ fi AC_SUBST($1)dnl ]) + diff -urN wget-1.10.2/Makefile.in wget-1.10.2_new/Makefile.in --- wget-1.10.2/Makefile.in 2005-06-27 00:06:49.000000000 +0200 +++ wget-1.10.2_new/Makefile.in 2006-06-27 12:09:44.000000000 +0200 @@ -57,7 +57,7 @@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\" -LIBS = @LIBS@ @LIBSSL@ +LIBS = @LIBS@ @LIBSSL@ @LIBGNUTLS@ LDFLAGS = @LDFLAGS@ # @@ -81,11 +81,14 @@ infodir='$(infodir)' mandir='$(mandir)' manext='$(manext)' # subdirectories in the distribution -SUBDIRS = src doc po util windows +SUBDIRS = src doc po tests util windows # default target all: src/config.h Makefile $(SUBDIRS) +unittest: src/config.h Makefile + cd tests && $(MAKE) $(MAKEDEFS) $@ + check: all $(SUBDIRS): FORCE @@ -107,17 +110,11 @@ install.mo: cd po && $(MAKE) $(MAKEDEFS) $@ -# Create configure.bat from configure.bat.in by DOS-ifying the lines. -# This is invoked by `make dist' and deleted by `make realclean' (not -# `make distclean' because we want to preserve it for distribution). -configure.bat: $(srcdir)/configure.bat.in - awk '{ print $$0 ($$0 ~ /\r$$/ ? "" : "\r") }' $< > $@ - # create tag files for Emacs TAGS: cd src && $(MAKE) $@ -dist: $(srcdir)/configure $(srcdir)/configure.bat DISTFILES +dist: $(srcdir)/configure DISTFILES mkdir $(DISTNAME) for d in `$(FIND) . -type d ! -name CVS -a ! -name RCS -print`; do \ if [ "$$d" != "." -a "$$d" != "./$(DISTNAME)" ]; then \ @@ -155,7 +152,7 @@ $(RM) -r autom4te.cache realclean-top: distclean-top - $(RM) configure configure.bat + $(RM) configure clean-recursive distclean-recursive realclean-recursive: for subdir in $(SUBDIRS); do \ diff -urN wget-1.10.2/NEWS wget-1.10.2_new/NEWS --- wget-1.10.2/NEWS 2005-06-19 15:45:33.000000000 +0200 +++ wget-1.10.2_new/NEWS 2006-06-27 12:10:19.000000000 +0200 @@ -1,11 +1,39 @@ GNU Wget NEWS -- history of user-visible changes. -Copyright (C) 2005 Free Software Foundation, Inc. +Copyright (C) 1997-2006 Free Software Foundation, Inc. See the end for copying conditions. Please send GNU Wget bug reports to . -* Wget 1.10.1 is a bugfix release with no user-visible changes. +* Changes in Wget 1.11. + +** Wget now saves HTTP downloads using file names specified by the +`Content-Disposition' header. This is a standard way of specifying +the file name used by many web dynamically generated pages. + +** The GnuTLS library is now also supported for https downloads. +This is still work-in-progress. OpenSSL is still used by default; use +--with-ssl=gnutls to build with GnuTLS. OpenSSL is still required for +NTLM authorization to work, but this should eventually change. + +** The new option `--ignore-case' makes Wget ignore case when +matching files, directories, and wildcards. This affects the -X, -I, +-A, and -R options, as well as globbing in FTP URLs. + +** ETA projection is now displayed in "dot" progress output as well as +in the default progress bar. (The dot progress is used by default when +logging Wget's output to file using the `-o' option.) + +** The "lockable boolean" argument type is no longer supported. It +was only used by the passive_ftp .wgetrc setting. If you're running +broken scripts or Perl modules that unconditionally specify +`--passive-ftp' and your firewall disallows it, you can override them +by replacing wget with a script that execs wget "$@" --no-passive-ftp. + +** The source code has migrated from CVS to Subversion. The +repository is available at http://svn.dotsrc.org/repo/wget/; to +checkout the trunk to a directory named `wget', use something like +`svn checkout http://svn.dotsrc.org/repo/wget/trunk/ wget'. * Changes in Wget 1.10. @@ -551,7 +579,7 @@ ---------------------------------------------------------------------- Copyright information: -Copyright (C) 2005 Free Software Foundation, Inc. +Copyright (C) 1997-2005 Free Software Foundation, Inc. Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that diff -urN wget-1.10.2/po/hr.po wget-1.10.2_new/po/hr.po --- wget-1.10.2/po/hr.po 2005-08-16 23:59:28.000000000 +0200 +++ wget-1.10.2_new/po/hr.po 2006-06-27 12:11:51.000000000 +0200 @@ -6,204 +6,215 @@ msgstr "" "Project-Id-Version: wget 1.10-b1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-05-12 11:00-0400\n" -"PO-Revision-Date: 2005-07-06 17:42+0200\n" +"POT-Creation-Date: 2005-06-27 03:15+0200\n" +"PO-Revision-Date: 2005-06-27 03:24+0200\n" "Last-Translator: Hrvoje Nik¹iæ \n" "Language-Team: Croatian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-2\n" "Content-Transfer-Encoding: 8bit\n" -#: src/connect.c:199 +#: src/connect.c:196 #, c-format msgid "%s: unable to resolve bind address `%s'; disabling bind.\n" msgstr "%s: ne mogu pronaæi adresu `%s' u svrhu binda; bindanje onemoguæeno.\n" -#: src/connect.c:271 +#: src/connect.c:268 #, c-format msgid "Connecting to %s|%s|:%d... " msgstr "Spajam se na %s|%s|:%d... " -#: src/connect.c:274 +#: src/connect.c:271 #, c-format msgid "Connecting to %s:%d... " msgstr "Spajam se na %s:%d... " -#: src/connect.c:335 +#: src/connect.c:331 msgid "connected.\n" msgstr "spojen.\n" -#: src/convert.c:176 +#: src/connect.c:343 src/host.c:777 src/host.c:806 +#, c-format +msgid "failed: %s.\n" +msgstr "nije uspjelo: %s.\n" + +#: src/convert.c:171 #, c-format msgid "Converted %d files in %.*f seconds.\n" msgstr "Konvertirao %d spisa za %.*f sekundi.\n" -#: src/convert.c:202 +#: src/convert.c:196 #, c-format msgid "Converting %s... " msgstr "Konvertiram %s... " -#: src/convert.c:215 +#: src/convert.c:209 msgid "nothing to do.\n" msgstr "nema posla.\n" -#: src/convert.c:223 src/convert.c:247 +#: src/convert.c:217 src/convert.c:241 #, c-format msgid "Cannot convert links in %s: %s\n" msgstr "Ne mogu konvertirati linkove u %s: %s\n" -#: src/convert.c:238 +#: src/convert.c:232 #, c-format msgid "Unable to delete `%s': %s\n" msgstr "Ne mogu izbrisati `%s': %s\n" -#: src/convert.c:447 +#: src/convert.c:441 #, c-format msgid "Cannot back up %s as %s: %s\n" msgstr "Ne mogu snimiti backup iz %s u %s: %s\n" -#: src/cookies.c:619 +#: src/cookies.c:614 #, c-format msgid "Error in Set-Cookie, field `%s'" msgstr "Gre¹ka u Set-Cookie, polje `%s'" -#: src/cookies.c:643 +#: src/cookies.c:638 #, c-format msgid "Syntax error in Set-Cookie: %s at position %d.\n" msgstr "Gre¹ka u Set-Cookie: %s na poziciji %d.\n" -#: src/cookies.c:1469 +#: src/cookies.c:876 +#, c-format +msgid "Cookie coming from %s attempted to set domain to %s\n" +msgstr "Cookie s adrese %s poku¹ao je postaviti domenu na %s\n" + +#: src/cookies.c:1323 src/cookies.c:1472 #, c-format msgid "Cannot open cookies file `%s': %s\n" msgstr "Ne mogu otvoriti spis s cookiejima `%s': %s\n" -#: src/cookies.c:1481 +#: src/cookies.c:1484 #, c-format msgid "Error writing to `%s': %s\n" msgstr "Gre¹ka pri pisanju u `%s': %s\n" -#: src/cookies.c:1484 +#: src/cookies.c:1487 #, c-format msgid "Error closing `%s': %s\n" msgstr "Gre¹ka pri zatvaranju `%s': %s\n" -#: src/ftp-ls.c:841 +#: src/ftp-ls.c:837 msgid "Unsupported listing type, trying Unix listing parser.\n" -msgstr "Nepodr¾ana vrsta ispisa, poku¹avat æu s razluèiteljem Unixovog ispisa.\n" +msgstr "" +"Nepodr¾ana vrsta ispisa, poku¹avat æu s razluèiteljem Unixovog ispisa.\n" -#: src/ftp-ls.c:887 src/ftp-ls.c:889 +#: src/ftp-ls.c:883 src/ftp-ls.c:885 #, c-format msgid "Index of /%s on %s:%d" msgstr "Indeks direktorija /%s na %s:%d" -#: src/ftp-ls.c:912 +#: src/ftp-ls.c:908 #, c-format msgid "time unknown " msgstr "nepoznato vrijeme " -#: src/ftp-ls.c:916 +#: src/ftp-ls.c:912 #, c-format msgid "File " msgstr "Spis " -#: src/ftp-ls.c:919 +#: src/ftp-ls.c:915 #, c-format msgid "Directory " msgstr "Direktorij " -#: src/ftp-ls.c:922 +#: src/ftp-ls.c:918 #, c-format msgid "Link " msgstr "Link " -#: src/ftp-ls.c:925 +#: src/ftp-ls.c:921 #, c-format msgid "Not sure " msgstr "Ne znam " -#: src/ftp-ls.c:943 +#: src/ftp-ls.c:939 #, c-format msgid " (%s bytes)" msgstr " (%s bajtova)" -#: src/ftp.c:226 +#: src/ftp.c:215 #, c-format msgid "Length: %s" msgstr "Duljina: %s" -#: src/ftp.c:232 src/http.c:1859 +#: src/ftp.c:221 src/http.c:1847 #, c-format msgid ", %s (%s) remaining" msgstr ", %s (%s) preostaje" -#: src/ftp.c:236 src/http.c:1863 +#: src/ftp.c:225 src/http.c:1851 #, c-format msgid ", %s remaining" msgstr ", %s preostaje" -#: src/ftp.c:240 +#: src/ftp.c:228 msgid " (unauthoritative)\n" msgstr " (nepouzdano)\n" #. Second: Login with proper USER/PASS sequence. -#: src/ftp.c:315 +#: src/ftp.c:304 #, c-format msgid "Logging in as %s ... " msgstr "Prijavljujem se kao %s ... " -#: src/ftp.c:328 src/ftp.c:374 src/ftp.c:403 src/ftp.c:455 src/ftp.c:567 -#: src/ftp.c:613 src/ftp.c:641 src/ftp.c:699 src/ftp.c:760 src/ftp.c:820 -#: src/ftp.c:867 +#: src/ftp.c:317 src/ftp.c:363 src/ftp.c:392 src/ftp.c:444 src/ftp.c:556 +#: src/ftp.c:602 src/ftp.c:631 src/ftp.c:689 src/ftp.c:750 src/ftp.c:810 +#: src/ftp.c:857 msgid "Error in server response, closing control connection.\n" msgstr "Gre¹ka u odgovoru, zatvaram kontrolnu vezu.\n" -#: src/ftp.c:335 +#: src/ftp.c:324 msgid "Error in server greeting.\n" msgstr "Gre¹ka u poslu¾iteljevom pozdravu.\n" -#: src/ftp.c:342 src/ftp.c:463 src/ftp.c:575 src/ftp.c:649 src/ftp.c:709 -#: src/ftp.c:770 src/ftp.c:830 src/ftp.c:877 +#: src/ftp.c:331 src/ftp.c:452 src/ftp.c:564 src/ftp.c:639 src/ftp.c:699 +#: src/ftp.c:760 src/ftp.c:820 src/ftp.c:867 msgid "Write failed, closing control connection.\n" msgstr "Pisanje je zakazalo, zatvaram kontrolnu vezu.\n" -#: src/ftp.c:348 +#: src/ftp.c:337 msgid "The server refuses login.\n" msgstr "Poslu¾itelj odbija prijavu.\n" -#: src/ftp.c:354 +#: src/ftp.c:343 msgid "Login incorrect.\n" msgstr "Pogre¹na prijava.\n" -#: src/ftp.c:360 +#: src/ftp.c:349 msgid "Logged in!\n" msgstr "Ulogiran!\n" -#: src/ftp.c:382 +#: src/ftp.c:371 msgid "Server error, can't determine system type.\n" msgstr "Gre¹ka na serveru, ne mogu utvrditi vrstu sustava.\n" -#: src/ftp.c:391 src/ftp.c:686 src/ftp.c:743 src/ftp.c:786 +#: src/ftp.c:380 src/ftp.c:676 src/ftp.c:733 src/ftp.c:776 msgid "done. " msgstr "gotovo. " -#: src/ftp.c:443 src/ftp.c:592 src/ftp.c:625 src/ftp.c:850 src/ftp.c:896 +#: src/ftp.c:432 src/ftp.c:581 src/ftp.c:614 src/ftp.c:840 src/ftp.c:886 msgid "done.\n" msgstr "gotovo.\n" -#: src/ftp.c:470 +#: src/ftp.c:459 #, c-format msgid "Unknown type `%c', closing control connection.\n" msgstr "Nepoznat tip `%c', zatvaram kontrolnu vezu.\n" -#: src/ftp.c:482 +#: src/ftp.c:471 msgid "done. " msgstr "gotovo." -#: src/ftp.c:488 +#: src/ftp.c:477 msgid "==> CWD not needed.\n" msgstr "==> CWD nepotreban.\n" -#: src/ftp.c:581 +#: src/ftp.c:570 #, c-format msgid "" "No such directory `%s'.\n" @@ -211,33 +222,33 @@ msgstr "Ne postoji direktorij `%s'.\n" #. do not CWD -#: src/ftp.c:596 +#: src/ftp.c:585 msgid "==> CWD not required.\n" msgstr "==> CWD se ne tra¾i.\n" -#: src/ftp.c:655 +#: src/ftp.c:645 msgid "Cannot initiate PASV transfer.\n" msgstr "Ne mogu otpoèeti PASV prijenos.\n" -#: src/ftp.c:659 +#: src/ftp.c:649 msgid "Cannot parse PASV response.\n" msgstr "Ne mogu ra¹èlaniti PASV odgovor.\n" -#: src/ftp.c:677 +#: src/ftp.c:667 #, c-format msgid "couldn't connect to %s port %d: %s\n" msgstr "nemoguæe spajanje na %s, port %d: %s\n" -#: src/ftp.c:725 +#: src/ftp.c:715 #, c-format msgid "Bind error (%s).\n" msgstr "Gre¹ka pri bindu (%s).\n" -#: src/ftp.c:731 +#: src/ftp.c:721 msgid "Invalid PORT.\n" msgstr "Neispravan PORT.\n" -#: src/ftp.c:777 +#: src/ftp.c:767 msgid "" "\n" "REST failed, starting from scratch.\n" @@ -245,7 +256,7 @@ "\n" "REST nije uspio, poèinjem ispoèetka.\n" -#: src/ftp.c:838 +#: src/ftp.c:828 #, c-format msgid "" "No such file `%s'.\n" @@ -254,7 +265,7 @@ "Nema spisa `%s'.\n" "\n" -#: src/ftp.c:885 +#: src/ftp.c:875 #, c-format msgid "" "No such file or directory `%s'.\n" @@ -267,40 +278,40 @@ #. what functions like unique_create typically do) #. because we told the user we'd use this name. #. Instead, return and retry the download. -#: src/ftp.c:947 src/http.c:1915 +#: src/ftp.c:937 src/http.c:1902 #, c-format msgid "%s has sprung into existence.\n" msgstr "%s se nenadano pojavio.\n" -#: src/ftp.c:1009 +#: src/ftp.c:1001 #, c-format msgid "%s: %s, closing control connection.\n" msgstr "%s: %s, zatvaram kontrolnu vezu.\n" -#: src/ftp.c:1017 +#: src/ftp.c:1009 #, c-format msgid "%s (%s) - Data connection: %s; " msgstr "%s (%s) - Podatkovna veza: %s; " -#: src/ftp.c:1032 +#: src/ftp.c:1024 msgid "Control connection closed.\n" msgstr "Kontrolna veza prekinuta.\n" -#: src/ftp.c:1050 +#: src/ftp.c:1042 msgid "Data transfer aborted.\n" msgstr "Prijenos podataka prekinut.\n" -#: src/ftp.c:1115 -#, fuzzy, c-format -msgid "File `%s' already there, not retrieving.\n" +#: src/ftp.c:1107 +#, c-format +msgid "File `%s' already there; not retrieving.\n" msgstr "Spis `%s' veæ postoji; ne dohvaæam.\n" -#: src/ftp.c:1179 src/http.c:2132 +#: src/ftp.c:1175 src/http.c:2123 #, c-format msgid "(try:%2d)" msgstr "(pok:%2d)" -#: src/ftp.c:1249 src/http.c:2406 +#: src/ftp.c:1245 src/http.c:2403 #, c-format msgid "" "%s (%s) - `%s' saved [%s]\n" @@ -309,35 +320,36 @@ "%s (%s) - `%s' snimljen [%s]\n" "\n" -#: src/ftp.c:1291 src/main.c:948 src/recur.c:376 src/retr.c:842 +#: src/ftp.c:1287 src/main.c:972 src/recur.c:368 src/retr.c:839 #, c-format msgid "Removing %s.\n" msgstr "Bri¹em %s.\n" -#: src/ftp.c:1333 +#: src/ftp.c:1329 #, c-format msgid "Using `%s' as listing tmp file.\n" msgstr "Koristim `%s' kao privremeni spis za listing.\n" -#: src/ftp.c:1348 +#: src/ftp.c:1344 #, c-format msgid "Removed `%s'.\n" msgstr "Izbrisao `%s'.\n" -#: src/ftp.c:1383 +#: src/ftp.c:1377 #, c-format msgid "Recursion depth %d exceeded max. depth %d.\n" msgstr "Dubina rekurzije %d prelazi najveæu dopu¹tenu %d.\n" #. Remote file is older, file sizes can be compared and #. are both equal. -#: src/ftp.c:1453 +#: src/ftp.c:1447 #, c-format msgid "Remote file no newer than local file `%s' -- not retrieving.\n" -msgstr "Spis na poslu¾itelju nije noviji od lokalnog spisa `%s' -- ne dohvaæam.\n" +msgstr "" +"Spis na poslu¾itelju nije noviji od lokalnog spisa `%s' -- ne dohvaæam.\n" #. Remote file is newer or sizes cannot be matched -#: src/ftp.c:1460 +#: src/ftp.c:1454 #, c-format msgid "" "Remote file is newer than local file `%s' -- retrieving.\n" @@ -345,18 +357,18 @@ msgstr "Spis na poslu¾itelju noviji od lokalnog spisa `%s' -- dohvaæam.\n" #. Sizes do not match -#: src/ftp.c:1467 +#: src/ftp.c:1461 #, c-format msgid "" "The sizes do not match (local %s) -- retrieving.\n" "\n" msgstr "Velièine se ne sla¾u (lokalno %s) -- dohvaæam.\n" -#: src/ftp.c:1485 +#: src/ftp.c:1479 msgid "Invalid name of the symlink, skipping.\n" msgstr "Neispravno ime simbolièkog linka, preskaèem.\n" -#: src/ftp.c:1502 +#: src/ftp.c:1496 #, c-format msgid "" "Already have correct symlink %s -> %s\n" @@ -365,42 +377,42 @@ "Veæ postoji ispravan link %s -> %s\n" "\n" -#: src/ftp.c:1510 +#: src/ftp.c:1504 #, c-format msgid "Creating symlink %s -> %s\n" msgstr "Stvaram simbolièki link %s -> %s\n" -#: src/ftp.c:1520 +#: src/ftp.c:1514 #, c-format msgid "Symlinks not supported, skipping symlink `%s'.\n" msgstr "Linkovi nisu podr¾ani, preskaèem link `%s'.\n" -#: src/ftp.c:1532 +#: src/ftp.c:1526 #, c-format msgid "Skipping directory `%s'.\n" msgstr "Preskaèem direktorij `%s'.\n" -#: src/ftp.c:1541 +#: src/ftp.c:1535 #, c-format msgid "%s: unknown/unsupported file type.\n" msgstr "%s: nepoznata/nepodr¾ana vrsta spisa.\n" -#: src/ftp.c:1568 +#: src/ftp.c:1562 #, c-format msgid "%s: corrupt time-stamp.\n" msgstr "%s: pogre¹no vrijeme.\n" -#: src/ftp.c:1596 +#: src/ftp.c:1590 #, c-format msgid "Will not retrieve dirs since depth is %d (max %d).\n" msgstr "Ne dohvaæam direktorije jer je dubina %d (najvi¹e %d).\n" -#: src/ftp.c:1646 +#: src/ftp.c:1640 #, c-format msgid "Not descending to `%s' as it is excluded/not-included.\n" msgstr "Ne ponirem u `%s' jer je iskljuèen ili nije ukljuèen.\n" -#: src/ftp.c:1712 src/ftp.c:1726 +#: src/ftp.c:1706 src/ftp.c:1720 #, c-format msgid "Rejecting `%s'.\n" msgstr "Odbijam `%s'.\n" @@ -408,199 +420,204 @@ #. No luck. #. #### This message SUCKS. We should see what was the #. reason that nothing was retrieved. -#: src/ftp.c:1772 +#: src/ftp.c:1766 #, c-format msgid "No matches on pattern `%s'.\n" msgstr "Ni¹ta ne ide uz `%s'.\n" -#: src/ftp.c:1838 +#: src/ftp.c:1832 #, c-format msgid "Wrote HTML-ized index to `%s' [%s].\n" msgstr "Snimio HTML-iziran indeks u `%s' [%s].\n" -#: src/ftp.c:1843 +#: src/ftp.c:1837 #, c-format msgid "Wrote HTML-ized index to `%s'.\n" msgstr "Snimio HTML-iziran indeks u `%s'.\n" -#: src/getopt.c:675 +#: src/getopt.c:671 #, c-format msgid "%s: option `%s' is ambiguous\n" msgstr "%s: opcija `%s' je dvosmislena\n" -#: src/getopt.c:700 +#: src/getopt.c:696 #, c-format msgid "%s: option `--%s' doesn't allow an argument\n" msgstr "%s: uz opciju `--%s' ne ide argument\n" -#: src/getopt.c:705 +#: src/getopt.c:701 #, c-format msgid "%s: option `%c%s' doesn't allow an argument\n" msgstr "%s: opcija `%c%s' ne dopu¹ta argument\n" -#: src/getopt.c:723 src/getopt.c:896 +#: src/getopt.c:719 src/getopt.c:892 #, c-format msgid "%s: option `%s' requires an argument\n" msgstr "%s: opcija `%s' tra¾i argument\n" #. --option -#: src/getopt.c:752 +#: src/getopt.c:748 #, c-format msgid "%s: unrecognized option `--%s'\n" msgstr "%s: nepoznata opcija `--%s'\n" #. +option or -option -#: src/getopt.c:756 +#: src/getopt.c:752 #, c-format msgid "%s: unrecognized option `%c%s'\n" msgstr "%s: nepoznata opcija `%c%s'\n" #. 1003.2 specifies the format of this message. -#: src/getopt.c:782 +#: src/getopt.c:778 #, c-format msgid "%s: illegal option -- %c\n" msgstr "%s: nedopu¹tena opcija -- %c\n" -#: src/getopt.c:785 +#: src/getopt.c:781 #, c-format msgid "%s: invalid option -- %c\n" msgstr "%s: neispravna opcija -- %c\n" #. 1003.2 specifies the format of this message. -#: src/getopt.c:815 src/getopt.c:945 +#: src/getopt.c:811 src/getopt.c:941 #, c-format msgid "%s: option requires an argument -- %c\n" msgstr "%s: opcija tra¾i argument -- %c\n" -#: src/getopt.c:862 +#: src/getopt.c:858 #, c-format msgid "%s: option `-W %s' is ambiguous\n" msgstr "%s: opcija `-W %s' je dvosmislena\n" -#: src/getopt.c:880 +#: src/getopt.c:876 #, c-format msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: uz opciju `-W %s' ne ide argument\n" -#: src/host.c:370 +#: src/host.c:356 msgid "Unknown host" msgstr "Nepoznat host" #. Message modeled after what gai_strerror returns in similar #. circumstances. -#: src/host.c:374 +#: src/host.c:360 msgid "Temporary failure in name resolution" msgstr "Privremena pogre¹ka pri pronala¾enju adrese" -#: src/host.c:376 +#: src/host.c:362 msgid "Unknown error" msgstr "Nepoznata gre¹ka" -#: src/host.c:755 +#: src/host.c:739 #, c-format msgid "Resolving %s... " msgstr "Tra¾im %s... " -#: src/host.c:799 src/host.c:828 -#, c-format -msgid "failed: %s.\n" -msgstr "nije uspjelo: %s.\n" - -#: src/host.c:808 +#: src/host.c:786 msgid "failed: No IPv4/IPv6 addresses for host.\n" msgstr "neuspjeh: raèunalo nema IPv4/IPv6 adresa.\n" -#: src/host.c:831 +#: src/host.c:809 msgid "failed: timed out.\n" msgstr "neuspjeh: isteklo vrijeme.\n" -#: src/html-url.c:298 +#: src/html-url.c:289 #, c-format msgid "%s: Cannot resolve incomplete link %s.\n" msgstr "%s: Ne mogu sastaviti nepotpun link %s.\n" -#: src/http.c:373 src/http.c:1545 +#: src/html-url.c:696 +#, c-format +msgid "%s: Invalid URL %s: %s\n" +msgstr "%s: Neispravan URL %s: %s\n" + +#: src/http.c:355 src/http.c:1537 #, c-format msgid "Failed writing HTTP request: %s.\n" msgstr "Nisam uspio poslati HTTP zahtjev: %s.\n" -#: src/http.c:687 +#: src/http.c:669 msgid "No headers, assuming HTTP/0.9" msgstr "Nema zaglavlja, pretpostavljam HTTP/0.9" -#: src/http.c:1194 +#: src/http.c:1186 msgid "Disabling SSL due to encountered errors.\n" msgstr "Iskljuèujem SSL zbog navedenih gre¹aka.\n" -#: src/http.c:1413 +#: src/http.c:1356 +#, c-format +msgid "POST data file `%s' missing: %s\n" +msgstr "Nema spisa `%s' za POST: %s\n" + +#: src/http.c:1405 #, c-format msgid "Reusing existing connection to %s:%d.\n" msgstr "Koristim postojeæu vezu prema %s:%d.\n" -#: src/http.c:1475 -#, fuzzy, c-format +#: src/http.c:1467 +#, c-format msgid "Failed writing to proxy: %s.\n" -msgstr "Nisam uspio poslati HTTP zahtjev: %s.\n" +msgstr "Nisam uspio pisati proxyju: %s.\n" -#: src/http.c:1484 +#: src/http.c:1476 #, c-format msgid "Failed reading proxy response: %s\n" msgstr "Nisam uspio procitati proxyjev odgovor: %s.\n" -#: src/http.c:1504 +#: src/http.c:1496 #, c-format msgid "Proxy tunneling failed: %s" msgstr "Neuspjeh tuneliranja kroz proxy: %s" -#: src/http.c:1551 +#: src/http.c:1543 #, c-format msgid "%s request sent, awaiting response... " msgstr "%s zahtjev poslan, i¹èekujem odgovor... " -#: src/http.c:1562 +#: src/http.c:1554 msgid "No data received.\n" msgstr "Podaci nisu primljeni.\n" -#: src/http.c:1569 +#: src/http.c:1561 #, c-format msgid "Read error (%s) in headers.\n" msgstr "Gre¹ka pri èitanju zaglavlja (%s).\n" #. If the authentication header is missing or #. unrecognized, there's no sense in retrying. -#: src/http.c:1657 +#: src/http.c:1646 msgid "Unknown authentication scheme.\n" msgstr "Nepoznata metoda ovjere.\n" -#: src/http.c:1681 +#: src/http.c:1670 msgid "Authorization failed.\n" msgstr "Ovjera nije uspjela.\n" -#: src/http.c:1695 +#: src/http.c:1684 msgid "Malformed status line" msgstr "Deformirana statusna linija" -#: src/http.c:1697 +#: src/http.c:1686 msgid "(no description)" msgstr "(bez opisa)" -#: src/http.c:1768 +#: src/http.c:1749 #, c-format msgid "Location: %s%s\n" msgstr "Polo¾aj: %s%s\n" -#: src/http.c:1769 src/http.c:1869 +#: src/http.c:1750 src/http.c:1857 msgid "unspecified" msgstr "nenaznaèen" -#: src/http.c:1770 +#: src/http.c:1751 msgid " [following]" msgstr " [pratim]" #. If `-c' is in use and the file has been fully downloaded (or #. the remote file has shrunk), Wget effectively requests bytes #. after the end of file and the server response with 416. -#: src/http.c:1819 +#: src/http.c:1807 msgid "" "\n" " The file is already fully retrieved; nothing to do.\n" @@ -613,70 +630,73 @@ #. No need to print this output if the body won't be #. downloaded at all, or if the original server response is #. printed. -#: src/http.c:1849 +#: src/http.c:1837 msgid "Length: " msgstr "Duljina: " -#: src/http.c:1869 +#: src/http.c:1857 msgid "ignored" msgstr "zanemarena" -#: src/http.c:2009 +#: src/http.c:2000 msgid "Warning: wildcards not supported in HTTP.\n" msgstr "Upozorenje: wildcardi nisu podr¾ani za HTTP.\n" #. If opt.noclobber is turned on and file already exists, do not #. retrieve the file -#: src/http.c:2044 -#, fuzzy, c-format -msgid "File `%s' already there, will not retrieve.\n" -msgstr "Spis `%s' veæ postoji; ne dohvaæam.\n" +#: src/http.c:2035 +#, c-format +msgid "" +"File `%s' already there; not retrieving.\n" +"\n" +msgstr "Spis `%s' veæ postoji; ne dohvaæam.\n\n" -#: src/http.c:2229 +#: src/http.c:2225 #, c-format msgid "Cannot write to `%s' (%s).\n" msgstr "Ne mogu pisati u `%s' (%s).\n" #. Another fatal error. -#: src/http.c:2236 +#: src/http.c:2232 msgid "Unable to establish SSL connection.\n" msgstr "Ne mogu uspostaviti SSL vezu.\n" -#: src/http.c:2245 +#: src/http.c:2241 #, c-format msgid "ERROR: Redirection (%d) without location.\n" msgstr "GRE©KA: Redirekcija (%d) bez novog polo¾aja (location).\n" -#: src/http.c:2275 +#: src/http.c:2271 #, c-format msgid "%s ERROR %d: %s.\n" msgstr "%s GRE©KA %d: %s.\n" -#: src/http.c:2288 +#: src/http.c:2284 msgid "Last-modified header missing -- time-stamps turned off.\n" msgstr "Nedostaje zaglavlje Last-Modified -- ignoriram vremensku granicu.\n" -#: src/http.c:2296 +#: src/http.c:2292 msgid "Last-modified header invalid -- time-stamp ignored.\n" msgstr "Neispravno zaglavlje Last-Modified -- ignoriram vremensku oznaku.\n" -#: src/http.c:2319 +#: src/http.c:2315 #, c-format msgid "" "Server file no newer than local file `%s' -- not retrieving.\n" "\n" -msgstr "Spis na poslu¾itelju nije noviji od lokalnog spisa `%s' -- ne dohvaæam.\n" +msgstr "" +"Spis na poslu¾itelju nije noviji od lokalnog spisa `%s' -- ne dohvaæam.\n" -#: src/http.c:2327 +#: src/http.c:2323 #, c-format msgid "The sizes do not match (local %s) -- retrieving.\n" msgstr "Velièine se ne sla¾u (lokalno %s) -- dohvaæam.\n" -#: src/http.c:2332 +#: src/http.c:2328 msgid "Remote file is newer, retrieving.\n" msgstr "Spis na poslu¾itelju je noviji, dohvaæam.\n" -#: src/http.c:2374 +#: src/http.c:2371 src/http.c:2437 #, c-format msgid "" "%s (%s) - `%s' saved [%s/%s]\n" @@ -685,116 +705,103 @@ "%s (%s) - `%s' snimljen [%s/%s]\n" "\n" -#: src/http.c:2431 +#: src/http.c:2428 #, c-format msgid "%s (%s) - Connection closed at byte %s. " msgstr "%s (%s) - Veza zatvorena na bajtu %s. " -#: src/http.c:2440 -#, fuzzy, c-format -msgid "" -"%s (%s) - `%s' saved [%s/%s])\n" -"\n" -msgstr "" -"%s (%s) - `%s' snimljen [%s/%s]\n" -"\n" - -#: src/http.c:2466 +#: src/http.c:2463 #, c-format msgid "%s (%s) - Connection closed at byte %s/%s. " msgstr "%s (%s) - Veza zatvorena na bajtu %s/%s. " -#: src/http.c:2480 +#: src/http.c:2477 #, c-format msgid "%s (%s) - Read error at byte %s (%s)." msgstr "%s (%s) - Gre¹ka pri èitanju na bajtu %s (%s)." -#: src/http.c:2490 +#: src/http.c:2487 #, c-format msgid "%s (%s) - Read error at byte %s/%s (%s). " msgstr "%s (%s) - Gre¹ka pri èitanju na bajtu %s/%s (%s). " -#: src/init.c:369 +#: src/init.c:359 #, c-format msgid "%s: WGETRC points to %s, which doesn't exist.\n" msgstr "%s: WGETRC pokazuje na %s, koji ne postoji.\n" -#: src/init.c:433 src/netrc.c:277 +#: src/init.c:422 src/netrc.c:268 #, c-format msgid "%s: Cannot read %s (%s).\n" msgstr "%s: Ne mogu proèitati %s (%s).\n" -#: src/init.c:451 +#: src/init.c:440 #, c-format msgid "%s: Error in %s at line %d.\n" msgstr "%s: Gre¹ka u %s na liniji %d.\n" -#: src/init.c:457 +#: src/init.c:446 #, c-format msgid "%s: Syntax error in %s at line %d.\n" msgstr "%s: Sintaksna gre¹ka u %s na liniji %d.\n" -#: src/init.c:462 +#: src/init.c:451 #, c-format msgid "%s: Unknown command `%s' in %s at line %d.\n" msgstr "%s: Nepoznata naredba `%s' u %s na liniji %d.\n" -#: src/init.c:507 +#: src/init.c:496 #, c-format msgid "%s: Warning: Both system and user wgetrc point to `%s'.\n" msgstr "%s: Upozorenje: sistemski i korisnikov wgetrc su `%s'.\n" -#: src/init.c:661 +#: src/init.c:649 #, c-format msgid "%s: Invalid --execute command `%s'\n" msgstr "%s: Neispravna --execute naredba `%s'\n" -#: src/init.c:707 -#, fuzzy, c-format -msgid "%s: %s: Invalid boolean `%s', use `on' or `off'.\n" -msgstr "%s: %s: Neispravan boolean `%s'; navedite `on' ili `off'.\n" - -#: src/init.c:750 -#, fuzzy, c-format -msgid "%s: %s: Invalid boolean `%s', use always, on, off, or never.\n" +#: src/init.c:694 +#, c-format +msgid "%s: %s: Invalid boolean `%s'; use `on' or `off'.\n" msgstr "%s: %s: Neispravan boolean `%s'; navedite `on' ili `off'.\n" -#: src/init.c:767 +#: src/init.c:711 #, c-format msgid "%s: %s: Invalid number `%s'.\n" msgstr "%s: %s: Neispravan broj `%s'.\n" -#: src/init.c:998 src/init.c:1017 +#: src/init.c:942 src/init.c:961 #, c-format msgid "%s: %s: Invalid byte value `%s'\n" msgstr "%s: %s: Neispravna bajtovna vrijednost `%s'\n" -#: src/init.c:1042 +#: src/init.c:986 #, c-format msgid "%s: %s: Invalid time period `%s'\n" msgstr "%s: %s: Neispravan vremenski period `%s'\n" -#: src/init.c:1096 src/init.c:1177 src/init.c:1272 src/init.c:1297 +#: src/init.c:1040 src/init.c:1130 src/init.c:1225 src/init.c:1250 #, c-format msgid "%s: %s: Invalid value `%s'.\n" msgstr "%s: %s: Neispravna vrijednost `%s'.\n" -#: src/init.c:1125 +#: src/init.c:1077 #, c-format msgid "%s: %s: Invalid header `%s'.\n" msgstr "%s: %s: Neispravno zaglavlje `%s'.\n" -#: src/init.c:1189 +#: src/init.c:1142 #, c-format msgid "%s: %s: Invalid progress type `%s'.\n" msgstr "%s: %s: Neispravan indikator napretka `%s'.\n" -#: src/init.c:1240 +#: src/init.c:1193 #, c-format msgid "%s: %s: Invalid restriction `%s', use `unix' or `windows'.\n" -msgstr "%s: %s: Neispravna restrikcija `%s', upotrijebite `unix' ili `windows'.\n" +msgstr "" +"%s: %s: Neispravna restrikcija `%s', upotrijebite `unix' ili `windows'.\n" -#: src/log.c:796 +#: src/log.c:784 #, c-format msgid "" "\n" @@ -805,7 +812,7 @@ #. Eek! Opening the alternate log file has failed. Nothing we #. can do but disable printing completely. -#: src/log.c:806 +#: src/log.c:794 #, c-format msgid "" "\n" @@ -814,17 +821,17 @@ "\n" "dobio %s.\n" -#: src/log.c:807 +#: src/log.c:795 #, c-format msgid "%s: %s; disabling logging.\n" msgstr "%s: %s; iskljuèujem logiranje.\n" -#: src/main.c:375 +#: src/main.c:361 #, c-format msgid "Usage: %s [OPTION]... [URL]...\n" msgstr "Uporaba: %s [OPCIJA]... [URL]...\n" -#: src/main.c:387 +#: src/main.c:373 msgid "" "Mandatory arguments to long options are mandatory for short options too.\n" "\n" @@ -832,501 +839,635 @@ "Ako dugaèka opcija zahtijeva argument, to vrijedi i za kratku.\n" "\n" -#: src/main.c:389 +#: src/main.c:375 msgid "Startup:\n" msgstr "Pokretanje:\n" -#: src/main.c:391 +#: src/main.c:377 msgid " -V, --version display the version of Wget and exit.\n" msgstr " -V, --version prika¾i verziju Wgeta i izaði.\n" -#: src/main.c:393 +#: src/main.c:379 msgid " -h, --help print this help.\n" msgstr " -h, --help ispi¹i pomoæ.\n" -#: src/main.c:395 +#: src/main.c:381 msgid " -b, --background go to background after startup.\n" msgstr " -b, --background radi u pozadini nakon pokretanja.\n" -#: src/main.c:397 +#: src/main.c:383 msgid " -e, --execute=COMMAND execute a `.wgetrc'-style command.\n" msgstr " -e, --execute=NAREDBA izv¹i NAREDBU poput onih u `.wgetrc'-u.\n" -#: src/main.c:401 +#: src/main.c:387 msgid "Logging and input file:\n" msgstr "Logiranje i ulazni spis:\n" -#: src/main.c:403 +#: src/main.c:389 msgid " -o, --output-file=FILE log messages to FILE.\n" msgstr " -o, --output-file=SPIS spremaj poruke u SPIS.\n" -#: src/main.c:405 +#: src/main.c:391 msgid " -a, --append-output=FILE append messages to FILE.\n" msgstr " -a, --append-output=SPIS spremaj poruke na kraj SPISA.\n" -#: src/main.c:408 +#: src/main.c:394 msgid " -d, --debug print lots of debugging information.\n" msgstr "" " -d, --debug ispisuj veliku kolièinu poruka korisnih pri\n" " ispravljanju gre¹aka.\n" -#: src/main.c:411 +#: src/main.c:397 msgid " -q, --quiet quiet (no output).\n" msgstr " -q, --quiet ti¹ina (bez ipisa).\n" -#: src/main.c:413 +#: src/main.c:399 msgid " -v, --verbose be verbose (this is the default).\n" msgstr " -v, --verbose rjeèit ispis (podrazumijevano).\n" -#: src/main.c:415 -msgid " -nv, --no-verbose turn off verboseness, without being quiet.\n" -msgstr " -nv, --no-verbose iskljuèi rjeèitost, ali ipak pone¹to ispisuj.\n" +#: src/main.c:401 +msgid "" +" -nv, --no-verbose turn off verboseness, without being quiet.\n" +msgstr "" +" -nv, --no-verbose iskljuèi rjeèitost, ali ipak pone¹to ispisuj.\n" -#: src/main.c:417 +#: src/main.c:403 msgid " -i, --input-file=FILE download URLs found in FILE.\n" msgstr " -i, --input-file=SPIS dohvati URL-ove navedene u SPISU.\n" -#: src/main.c:419 +#: src/main.c:405 msgid " -F, --force-html treat input file as HTML.\n" -msgstr " -F, --force-html tretiraj sadr¾aj ulaznog spisa kao HTML.\n" +msgstr "" +" -F, --force-html tretiraj sadr¾aj ulaznog spisa kao HTML.\n" -#: src/main.c:421 -msgid " -B, --base=URL prepends URL to relative links in -F -i file.\n" -msgstr " -B, --base=URL polazni URL za relativne linkove pri obradi -F -i.\n" +#: src/main.c:407 +msgid "" +" -B, --base=URL prepends URL to relative links in -F -i file.\n" +msgstr "" +" -B, --base=URL polazni URL za relativne linkove pri obradi -F -" +"i.\n" -#: src/main.c:425 +#: src/main.c:411 msgid "Download:\n" msgstr "Dohvat:\n" -#: src/main.c:427 -msgid " -t, --tries=NUMBER set number of retries to NUMBER (0 unlimits).\n" -msgstr " -t, --tries=BROJ postavi broj poku¹aja na BROJ (0 za bezbroj).\n" +#: src/main.c:413 +msgid "" +" -t, --tries=NUMBER set number of retries to NUMBER (0 " +"unlimits).\n" +msgstr "" +" -t, --tries=BROJ postavi broj poku¹aja na BROJ (0 za " +"bezbroj).\n" -#: src/main.c:429 +#: src/main.c:415 msgid " --retry-connrefused retry even if connection is refused.\n" -msgstr " --retry-connrefused poku¹avaj iznova i kad je spajanje odbijeno.\n" +msgstr "" +" --retry-connrefused poku¹avaj iznova i kad je spajanje " +"odbijeno.\n" -#: src/main.c:431 +#: src/main.c:417 msgid " -O, --output-document=FILE write documents to FILE.\n" msgstr " -O, --output-document=SPIS spremaj dohvaæene dokumente u SPIS.\n" -#: src/main.c:433 +#: src/main.c:419 msgid "" " -nc, --no-clobber skip downloads that would download to\n" " existing files.\n" -msgstr " -nc, --no-clobber ne dohvaæaj spise koji postoje lokalno.\n" +msgstr "" +" -nc, --no-clobber ne dohvaæaj spise koji postoje lokalno.\n" -#: src/main.c:436 -msgid " -c, --continue resume getting a partially-downloaded file.\n" -msgstr " -c, --continue nastavi s dohvatom napola skinutog spisa.\n" +#: src/main.c:422 +msgid "" +" -c, --continue resume getting a partially-downloaded " +"file.\n" +msgstr "" +" -c, --continue nastavi s dohvatom napola skinutog spisa.\n" -#: src/main.c:438 +#: src/main.c:424 msgid " --progress=TYPE select progress gauge type.\n" -msgstr " --progress=VRSTA promijeni izgled pokazatelj dohvata.\n" +msgstr "" +" --progress=VRSTA promijeni izgled pokazatelj dohvata.\n" -#: src/main.c:440 +#: src/main.c:426 msgid "" " -N, --timestamping don't re-retrieve files unless newer than\n" " local.\n" -msgstr " -N, --timestamping skidaj samo spise novije od lokalnih.\n" +msgstr "" +" -N, --timestamping skidaj samo spise novije od lokalnih.\n" -#: src/main.c:443 +#: src/main.c:429 msgid " -S, --server-response print server response.\n" msgstr " -S, --server-response ispisuj poslu¾iteljeve odgovore.\n" -#: src/main.c:445 +#: src/main.c:431 msgid " --spider don't download anything.\n" msgstr " --spider ne dohvaæaj sadr¾aje URL-ova.\n" -#: src/main.c:447 +#: src/main.c:433 msgid " -T, --timeout=SECONDS set all timeout values to SECONDS.\n" -msgstr " -T, --timeout=VRIJEME postavi sve vrijednosti isteka vremena.\n" +msgstr "" +" -T, --timeout=VRIJEME postavi sve vrijednosti isteka vremena.\n" -#: src/main.c:449 +#: src/main.c:435 msgid " --dns-timeout=SECS set the DNS lookup timeout to SECS.\n" -msgstr " --dns-timeout=VRIJEME postavi maksimalno vrijeme DNS pretrage.\n" +msgstr "" +" --dns-timeout=VRIJEME postavi maksimalno vrijeme DNS pretrage.\n" -#: src/main.c:451 +#: src/main.c:437 msgid " --connect-timeout=SECS set the connect timeout to SECS.\n" -msgstr " --connect-timeout=VRIJEME postavi maksimalno vrijeme spajanja.\n" +msgstr "" +" --connect-timeout=VRIJEME postavi maksimalno vrijeme spajanja.\n" -#: src/main.c:453 +#: src/main.c:439 msgid " --read-timeout=SECS set the read timeout to SECS.\n" msgstr " --read-timeout=VRIJEME postavi maksimalno vrijeme èitanja.\n" -#: src/main.c:455 +#: src/main.c:441 msgid " -w, --wait=SECONDS wait SECONDS between retrievals.\n" -msgstr " -w, --wait=VRIJEME napravi pauzu od VREMENA izmeðu dohvata.\n" +msgstr "" +" -w, --wait=VRIJEME napravi pauzu od VREMENA izmeðu dohvata.\n" -#: src/main.c:457 -msgid " --waitretry=SECONDS wait 1..SECONDS between retries of a retrieval.\n" +#: src/main.c:443 +msgid "" +" --waitretry=SECONDS wait 1..SECONDS between retries of a " +"retrieval.\n" msgstr "" " --waitretry=VRIJEME èekaj 1..VRIJEME sekundi izmeðu ponovnih\n" " poku¹aja dohvata.\n" -#: src/main.c:459 -msgid " --random-wait wait from 0...2*WAIT secs between retrievals.\n" +#: src/main.c:445 +msgid "" +" --random-wait wait from 0...2*WAIT secs between " +"retrievals.\n" msgstr "" -" --random-wait èekaj od 0..2*s sekundi izmeðu dohvata, gdje\n" +" --random-wait èekaj od 0..2*s sekundi izmeðu dohvata, " +"gdje\n" " je s vrijeme zadano s --wait.\n" -#: src/main.c:461 +#: src/main.c:447 msgid " -Y, --proxy explicitly turn on proxy.\n" msgstr " -Y, --proxy ukljuèi upotrebu proxyja.\n" -#: src/main.c:463 +#: src/main.c:449 msgid " --no-proxy explicitly turn off proxy.\n" msgstr " --no-proxy iskljuèi upotrebu proxyja.\n" -#: src/main.c:465 +#: src/main.c:451 msgid " -Q, --quota=NUMBER set retrieval quota to NUMBER.\n" -msgstr " -Q, --quote=KOLIÈINA ogranièi kolièinu dohvaæenih podataka.\n" +msgstr "" +" -Q, --quote=KOLIÈINA ogranièi kolièinu dohvaæenih podataka.\n" -#: src/main.c:467 -msgid " --bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local host.\n" -msgstr " --bind-address=ADRESA koristi lokalnu ADRESU (ime ili IP) za bind.\n" +#: src/main.c:453 +msgid "" +" --bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local " +"host.\n" +msgstr "" +" --bind-address=ADRESA koristi lokalnu ADRESU (ime ili IP) za " +"bind.\n" -#: src/main.c:469 +#: src/main.c:455 msgid " --limit-rate=RATE limit download rate to RATE.\n" -msgstr " --limit-rate=BRZINA ogranièi brzinu dohvata u bajtovima u sekundi.\n" +msgstr "" +" --limit-rate=BRZINA ogranièi brzinu dohvata u bajtovima u " +"sekundi.\n" -#: src/main.c:471 +#: src/main.c:457 msgid " --no-dns-cache disable caching DNS lookups.\n" msgstr " --no-dns-cache ne pamti rezultate pretraga DNS-a.\n" -#: src/main.c:473 -msgid " --restrict-file-names=OS restrict chars in file names to ones OS allows.\n" +#: src/main.c:459 +msgid "" +" --restrict-file-names=OS restrict chars in file names to ones OS " +"allows.\n" msgstr "" " --restrict-file-names=OS ogranièi znakove u nazivima spisâ na one\n" " koje dopu¹ta OS.\n" -#: src/main.c:476 +#: src/main.c:462 msgid " -4, --inet4-only connect only to IPv4 addresses.\n" msgstr " -4, --inet4-only spajaj se samo na IPv4 adrese.\n" -#: src/main.c:478 +#: src/main.c:464 msgid " -6, --inet6-only connect only to IPv6 addresses.\n" msgstr " -6, --inet6-only spajaj se samo na IPv6 adrese.\n" -#: src/main.c:480 +#: src/main.c:466 msgid "" -" --prefer-family=FAMILY connect first to addresses of specified family,\n" +" --prefer-family=FAMILY connect first to addresses of specified " +"family,\n" " one of IPv6, IPv4, or none.\n" msgstr "" -" --prefer-family=VRSTA daj prednost navedenoj vrsti IP adresa, jednoj\n" +" --prefer-family=VRSTA daj prednost navedenoj vrsti IP adresa, " +"jednoj\n" " od IPv6, IPv4 ili none.\n" -#: src/main.c:484 +#: src/main.c:470 msgid " --user=USER set both ftp and http user to USER.\n" -msgstr " --user=KORISNIK postavi KORISNIKA za http i ftp korisnika.\n" +msgstr "" +" --user=KORISNIK postavi KORISNIKA za http i ftp korisnika.\n" -#: src/main.c:486 -msgid " --password=PASS set both ftp and http password to PASS.\n" +#: src/main.c:472 +msgid "" +" --password=PASS set both ftp and http password to PASS.\n" msgstr " --password=ZAPORKA ¹alji ZAPORKU za http i ftp.\n" -#: src/main.c:490 +#: src/main.c:476 msgid "Directories:\n" msgstr "Direktoriji:\n" -#: src/main.c:492 +#: src/main.c:478 msgid " -nd, --no-directories don't create directories.\n" msgstr " -nd, --no-directories ne stvaraj direktorije.\n" -#: src/main.c:494 +#: src/main.c:480 msgid " -x, --force-directories force creation of directories.\n" msgstr " -x, --force-directories uvijek stvaraj direktorije.\n" -#: src/main.c:496 +#: src/main.c:482 msgid " -nH, --no-host-directories don't create host directories.\n" -msgstr " -nH, --no-host-directories ne stvaraj direktorije po imenu poslu¾itelja.\n" +msgstr "" +" -nH, --no-host-directories ne stvaraj direktorije po imenu " +"poslu¾itelja.\n" -#: src/main.c:498 +#: src/main.c:484 msgid " --protocol-directories use protocol name in directories.\n" msgstr " --protocol-directories stavi ime protokola u direktorij.\n" -#: src/main.c:500 +#: src/main.c:486 msgid " -P, --directory-prefix=PREFIX save files to PREFIX/...\n" msgstr " -P, --directory-prefix=PREFIX spremaj spise u PREFIX/...\n" -#: src/main.c:502 -msgid " --cut-dirs=NUMBER ignore NUMBER remote directory components.\n" -msgstr " --cut-dirs=N ignoriraj N stranih komponenti direktorija.\n" +#: src/main.c:488 +msgid "" +" --cut-dirs=NUMBER ignore NUMBER remote directory " +"components.\n" +msgstr "" +" --cut-dirs=N ignoriraj N stranih komponenti " +"direktorija.\n" -#: src/main.c:506 +#: src/main.c:492 msgid "HTTP options:\n" msgstr "Opcije HTTP-a:\n" -#: src/main.c:508 +#: src/main.c:494 msgid " --http-user=USER set http user to USER.\n" msgstr " --http-user=KORISNIK postavi KORISNIKA za http korisnika.\n" -#: src/main.c:510 +#: src/main.c:496 msgid " --http-password=PASS set http password to PASS.\n" msgstr " --http-password=ZAPORKA ¹alji ZAPORKU za http.\n" -#: src/main.c:512 +#: src/main.c:498 msgid " --no-cache disallow server-cached data.\n" -msgstr " --no-cache tra¾i od servera da ne ¹alje ke¹irane podatke.\n" +msgstr "" +" --no-cache tra¾i od servera da ne ¹alje ke¹irane " +"podatke.\n" -#: src/main.c:514 -msgid " -E, --html-extension save HTML documents with `.html' extension.\n" -msgstr " -E, --html-extension spremaj HTML dokumente s ekstenzijom `.html'.\n" +#: src/main.c:500 +msgid "" +" -E, --html-extension save HTML documents with `.html' extension.\n" +msgstr "" +" -E, --html-extension spremaj HTML dokumente s ekstenzijom `." +"html'.\n" -#: src/main.c:516 +#: src/main.c:502 msgid " --ignore-length ignore `Content-Length' header field.\n" -msgstr " --ignore-length ne uva¾avaj zaglavlje `Content-Length'.\n" +msgstr "" +" --ignore-length ne uva¾avaj zaglavlje `Content-Length'.\n" -#: src/main.c:518 +#: src/main.c:504 msgid " --header=STRING insert STRING among the headers.\n" -msgstr " --header=ZAGLAVLJE umetni ZAGLAVLJE meðu ostala zaglavlja.\n" +msgstr "" +" --header=ZAGLAVLJE umetni ZAGLAVLJE meðu ostala zaglavlja.\n" -#: src/main.c:520 +#: src/main.c:506 msgid " --proxy-user=USER set USER as proxy username.\n" -msgstr " --proxy-user=KORISNIK postavi KORISNIKA za korisnika proxyja.\n" +msgstr "" +" --proxy-user=KORISNIK postavi KORISNIKA za korisnika proxyja.\n" -#: src/main.c:522 +#: src/main.c:508 msgid " --proxy-password=PASS set PASS as proxy password.\n" msgstr " --proxy-password=ZAPORKA ¹alji ZAPORKU za proxy.\n" -#: src/main.c:524 -msgid " --referer=URL include `Referer: URL' header in HTTP request.\n" +#: src/main.c:510 +msgid "" +" --referer=URL include `Referer: URL' header in HTTP " +"request.\n" msgstr " --referer=URL ¹alji zaglavlje `Referer: URL'.\n" -#: src/main.c:526 +#: src/main.c:512 msgid " --save-headers save the HTTP headers to file.\n" msgstr " --save-headers snimaj HTTP zaglavlja na disk.\n" -#: src/main.c:528 -msgid " -U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION.\n" +#: src/main.c:514 +msgid "" +" -U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION.\n" msgstr "" " -U, --user-agent=KLIJENT identificiraj se kao KLIJENT umjesto kao\n" " Wget/VERZIJA.\n" -#: src/main.c:530 -msgid " --no-http-keep-alive disable HTTP keep-alive (persistent connections).\n" -msgstr " --no-http-keep-alive ne koristi neprekinutu HTTP vezu (keep-alive).\n" +#: src/main.c:516 +msgid "" +" --no-http-keep-alive disable HTTP keep-alive (persistent " +"connections).\n" +msgstr "" +" --no-http-keep-alive ne koristi neprekinutu HTTP vezu (keep-" +"alive).\n" -#: src/main.c:532 +#: src/main.c:518 msgid " --no-cookies don't use cookies.\n" msgstr " --no-cookies ne koristi cookieje.\n" -#: src/main.c:534 +#: src/main.c:520 msgid " --load-cookies=FILE load cookies from FILE before session.\n" -msgstr " --load-cookies=SPIS uèitaj cookieje iz SPISA na poèetku rada.\n" +msgstr "" +" --load-cookies=SPIS uèitaj cookieje iz SPISA na poèetku rada.\n" -#: src/main.c:536 +#: src/main.c:522 msgid " --save-cookies=FILE save cookies to FILE after session.\n" msgstr " --save-cookies=SPIS spremi cookieje u SPIS na kraju rada.\n" -#: src/main.c:538 -msgid " --keep-session-cookies load and save session (non-permanent) cookies.\n" -msgstr " --keep-session-cookies uèitaj i snimi cookieje ogranièene na \"session\".\n" +#: src/main.c:524 +msgid "" +" --keep-session-cookies load and save session (non-permanent) " +"cookies.\n" +msgstr "" +" --keep-session-cookies uèitaj i snimi cookieje ogranièene na " +"\"session\".\n" -#: src/main.c:540 -msgid " --post-data=STRING use the POST method; send STRING as the data.\n" -msgstr " --post-data=PODACI koristi metodu POST, ¹aljuæi PODATKE u zahtjevu.\n" +#: src/main.c:526 +msgid "" +" --post-data=STRING use the POST method; send STRING as the " +"data.\n" +msgstr "" +" --post-data=PODACI koristi metodu POST, ¹aljuæi PODATKE u " +"zahtjevu.\n" -#: src/main.c:542 -msgid " --post-file=FILE use the POST method; send contents of FILE.\n" -msgstr " --post-file=SPIS koristi metodu POST, ¹aljuæi sadr¾aj SPISA.\n" +#: src/main.c:528 +msgid "" +" --post-file=FILE use the POST method; send contents of FILE.\n" +msgstr "" +" --post-file=SPIS koristi metodu POST, ¹aljuæi sadr¾aj SPISA.\n" -#: src/main.c:547 +#: src/main.c:533 msgid "HTTPS (SSL/TLS) options:\n" msgstr "Opcije HTTPS-a (SSL-a/TLS-a):\n" -#: src/main.c:549 +#: src/main.c:535 msgid "" " --secure-protocol=PR choose secure protocol, one of auto, SSLv2,\n" " SSLv3, and TLSv1.\n" msgstr "" -" --secure-protocol=PR izaberi sigurni protokol, jedan od auto, SSLv2,\n" +" --secure-protocol=PR izaberi sigurni protokol, jedan od auto, " +"SSLv2,\n" " SSLv3 ili TLSv1.\n" -#: src/main.c:552 -msgid " --no-check-certificate don't validate the server's certificate.\n" -msgstr " --no-check-certificate ne provjeravaj poslu¾iteljevu ovjeru.\n" +#: src/main.c:538 +msgid "" +" --no-check-certificate don't validate the server's certificate.\n" +msgstr "" +" --no-check-certificate ne provjeravaj poslu¾iteljevu ovjeru.\n" -#: src/main.c:554 +#: src/main.c:540 msgid " --certificate=FILE client certificate file.\n" msgstr " --certificate=SPIS datoteka s klijentovom ovjerom.\n" -#: src/main.c:556 +#: src/main.c:542 msgid " --certificate-type=TYPE client certificate type, PEM or DER.\n" -msgstr " --certificate-type=VRSTA vrsta klijentove ovjere, PEM ili DER.\n" +msgstr "" +" --certificate-type=VRSTA vrsta klijentove ovjere, PEM ili DER.\n" -#: src/main.c:558 +#: src/main.c:544 msgid " --private-key=FILE private key file.\n" msgstr " --private-key=FILE spis s privatnim kljuèem.\n" -#: src/main.c:560 +#: src/main.c:546 msgid " --private-key-type=TYPE private key type, PEM or DER.\n" msgstr " --private-key-type=TYPE vrsta privatnog kljuèa, PEM ili DER.\n" -#: src/main.c:562 +#: src/main.c:548 msgid " --ca-certificate=FILE file with the bundle of CA's.\n" msgstr " --ca-certificate=SPIS spis s CA-ovima na okupu.\n" -#: src/main.c:564 -msgid " --ca-directory=DIR directory where hash list of CA's is stored.\n" +#: src/main.c:550 +msgid "" +" --ca-directory=DIR directory where hash list of CA's is " +"stored.\n" msgstr " --ca-directory=DIR direktorij s pojedinaènim CA-ovima.\n" -#: src/main.c:566 -msgid " --random-file=FILE file with random data for seeding the SSL PRNG.\n" +#: src/main.c:552 +msgid "" +" --random-file=FILE file with random data for seeding the SSL " +"PRNG.\n" msgstr "" -" --random-file=SPIS spis s nasumiènim podacima za zametak SSL-ovog\n" +" --random-file=SPIS spis s nasumiènim podacima za zametak SSL-" +"ovog\n" " generatora sluèajnih brojeva.\n" -#: src/main.c:568 -msgid " --egd-file=FILE file naming the EGD socket with random data.\n" +#: src/main.c:554 +msgid "" +" --egd-file=FILE file naming the EGD socket with random " +"data.\n" msgstr "" -" --egd-file=SPIS naziv spisa u kojem je EGD socket s nasumiènim\n" +" --egd-file=SPIS naziv spisa u kojem je EGD socket s " +"nasumiènim\n" " podacima.\n" -#: src/main.c:573 +#: src/main.c:559 msgid "FTP options:\n" msgstr "Opcije FTP-a:\n" -#: src/main.c:575 +#: src/main.c:561 msgid " --ftp-user=USER set ftp user to USER.\n" msgstr " --ftp-user=KORISNIK postavi KORISNIKA za ftp korisnika.\n" -#: src/main.c:577 +#: src/main.c:563 msgid " --ftp-password=PASS set ftp password to PASS.\n" msgstr " --ftp-password=ZAPORKA ¹alji ZAPORKU za ftp.\n" -#: src/main.c:579 +#: src/main.c:565 msgid " --no-remove-listing don't remove `.listing' files.\n" -msgstr " --no-remove-listing ne bri¹i ispise direktorija `.listing'.\n" +msgstr "" +" --no-remove-listing ne bri¹i ispise direktorija `.listing'.\n" -#: src/main.c:581 +#: src/main.c:567 msgid " --no-glob turn off FTP file name globbing.\n" -msgstr " --no-glob nemoj interpretirati * i ? u nazivu spisa.\n" +msgstr "" +" --no-glob nemoj interpretirati * i ? u nazivu spisa.\n" -#: src/main.c:583 +#: src/main.c:569 msgid " --no-passive-ftp disable the \"passive\" transfer mode.\n" msgstr " --no-passive-ftp onemoguæi \"pasivni\" mod prijenosa.\n" -#: src/main.c:585 -msgid " --retr-symlinks when recursing, get linked-to files (not dir).\n" +#: src/main.c:571 +msgid "" +" --retr-symlinks when recursing, get linked-to files (not " +"dir).\n" msgstr "" " --retr-symlinks pri rekurziji, dohvaæaj datoteke na koje\n" " pokazuju linkovi (ne radi za direktorije).\n" -#: src/main.c:587 +#: src/main.c:573 msgid " --preserve-permissions preserve remote file permissions.\n" -msgstr " --preserve-permissions saèuvaj dozvole na datotekama skinutim FTP-om.\n" +msgstr "" +" --preserve-permissions saèuvaj dozvole na datotekama skinutim FTP-" +"om.\n" -#: src/main.c:591 +#: src/main.c:577 msgid "Recursive download:\n" msgstr "Rekurzivni dohvat:\n" -#: src/main.c:593 +#: src/main.c:579 msgid " -r, --recursive specify recursive download.\n" msgstr " -r, --recursive rekurzivni dohvat.\n" -#: src/main.c:595 -msgid " -l, --level=NUMBER maximum recursion depth (inf or 0 for infinite).\n" -msgstr " -l, --level=BROJ najveæa dubina rekurzije (0 za neogranièenu).\n" +#: src/main.c:581 +msgid "" +" -l, --level=NUMBER maximum recursion depth (inf or 0 for " +"infinite).\n" +msgstr "" +" -l, --level=BROJ najveæa dubina rekurzije (0 za neogranièenu).\n" -#: src/main.c:597 -msgid " --delete-after delete files locally after downloading them.\n" +#: src/main.c:583 +msgid "" +" --delete-after delete files locally after downloading them.\n" msgstr " --delete-after pobri¹i lokalne spise nakon dohvata.\n" -#: src/main.c:599 -msgid " -k, --convert-links make links in downloaded HTML point to local files.\n" +#: src/main.c:585 +msgid "" +" -k, --convert-links make links in downloaded HTML point to local " +"files.\n" msgstr "" " -k, --convert-links promijeni linkove u lokalnom HTML-u tako da\n" " pokazuju na dohvaæene spise.\n" -#: src/main.c:601 -msgid " -K, --backup-converted before converting file X, back up as X.orig.\n" -msgstr " -K, --backup-converted prije konverzije spisa X, spremi sadr¾aj u X.orig.\n" +#: src/main.c:587 +msgid "" +" -K, --backup-converted before converting file X, back up as X.orig.\n" +msgstr "" +" -K, --backup-converted prije konverzije spisa X, spremi sadr¾aj u X." +"orig.\n" -#: src/main.c:603 -#, fuzzy -msgid " -m, --mirror shortcut option equivalent to -r -N -l inf -nr.\n" -msgstr " -m, --mirror kraæi oblik za -N -r -l inf --no-remove-listing.\n" +#: src/main.c:589 +msgid "" +" -m, --mirror shortcut option equivalent to -r -N -l inf -nr.\n" +msgstr " -m, --mirror opcija ekvivalentna -r -N -l inf -nr.\n" -#: src/main.c:605 -msgid " -p, --page-requisites get all images, etc. needed to display HTML page.\n" -msgstr " -p, --page-requisites dohvati sve slike itd. potrebne za prikaz HTML-a.\n" +#: src/main.c:591 +msgid "" +" -p, --page-requisites get all images, etc. needed to display HTML " +"page.\n" +msgstr "" +" -p, --page-requisites dohvati sve slike itd. potrebne za prikaz HTML-" +"a.\n" -#: src/main.c:607 -msgid " --strict-comments turn on strict (SGML) handling of HTML comments.\n" -msgstr " --strict-comments ukljuèi strog (SGML) tretman HTML komentara.\n" +#: src/main.c:593 +msgid "" +" --strict-comments turn on strict (SGML) handling of HTML " +"comments.\n" +msgstr "" +" --strict-comments ukljuèi strog (SGML) tretman HTML komentara.\n" -#: src/main.c:611 +#: src/main.c:597 msgid "Recursive accept/reject:\n" msgstr "Rekurzivno prihvaæanje/odbijanje:\n" -#: src/main.c:613 -msgid " -A, --accept=LIST comma-separated list of accepted extensions.\n" -msgstr " -A, --accept=POPIS zarezom odvojen popis prihvaæenih nastavaka.\n" +#: src/main.c:599 +msgid "" +" -A, --accept=LIST comma-separated list of accepted " +"extensions.\n" +msgstr "" +" -A, --accept=POPIS zarezom odvojen popis prihvaæenih " +"nastavaka.\n" -#: src/main.c:615 -msgid " -R, --reject=LIST comma-separated list of rejected extensions.\n" -msgstr " -R, --reject=POPIS zarezom odvojen popis odbijenih nastavaka.\n" +#: src/main.c:601 +msgid "" +" -R, --reject=LIST comma-separated list of rejected " +"extensions.\n" +msgstr "" +" -R, --reject=POPIS zarezom odvojen popis odbijenih " +"nastavaka.\n" -#: src/main.c:617 -msgid " -D, --domains=LIST comma-separated list of accepted domains.\n" -msgstr " -D, --domains=POPIS zarezom odvojen popis prihvaæenih domena.\n" +#: src/main.c:603 +msgid "" +" -D, --domains=LIST comma-separated list of accepted " +"domains.\n" +msgstr "" +" -D, --domains=POPIS zarezom odvojen popis prihvaæenih " +"domena.\n" -#: src/main.c:619 -msgid " --exclude-domains=LIST comma-separated list of rejected domains.\n" -msgstr " --exclude-domains=POPIS zarezom odvojen popis odbijenih domena.\n" +#: src/main.c:605 +msgid "" +" --exclude-domains=LIST comma-separated list of rejected " +"domains.\n" +msgstr "" +" --exclude-domains=POPIS zarezom odvojen popis odbijenih domena.\n" -#: src/main.c:621 -msgid " --follow-ftp follow FTP links from HTML documents.\n" -msgstr " --follow-ftp prati linkove na FTP iz HTML dokumenata.\n" +#: src/main.c:607 +msgid "" +" --follow-ftp follow FTP links from HTML documents.\n" +msgstr "" +" --follow-ftp prati linkove na FTP iz HTML dokumenata.\n" -#: src/main.c:623 -msgid " --follow-tags=LIST comma-separated list of followed HTML tags.\n" -msgstr " --follow-tags=POPIS popis HTML tagova koje treba pratiti.\n" +#: src/main.c:609 +msgid "" +" --follow-tags=LIST comma-separated list of followed HTML " +"tags.\n" +msgstr "" +" --follow-tags=POPIS popis HTML tagova koje treba pratiti.\n" -#: src/main.c:625 -msgid " --ignore-tags=LIST comma-separated list of ignored HTML tags.\n" -msgstr " --ignore-tags=POPIS popis HTML tagova koje ne treba pratiti.\n" +#: src/main.c:611 +msgid "" +" --ignore-tags=LIST comma-separated list of ignored HTML " +"tags.\n" +msgstr "" +" --ignore-tags=POPIS popis HTML tagova koje ne treba pratiti.\n" -#: src/main.c:627 -msgid " -H, --span-hosts go to foreign hosts when recursive.\n" +#: src/main.c:613 +msgid "" +" -H, --span-hosts go to foreign hosts when recursive.\n" msgstr "" -" -H, --span-hosts skaèi sa servera na server pri rekurzivnom\n" +" -H, --span-hosts skaèi sa servera na server pri " +"rekurzivnom\n" " dohvatu.\n" -#: src/main.c:629 +#: src/main.c:615 msgid " -L, --relative follow relative links only.\n" msgstr " -L, --relative prati samo relativne linkove.\n" -#: src/main.c:631 +#: src/main.c:617 msgid " -I, --include-directories=LIST list of allowed directories.\n" msgstr "" " -I, --include-directories=POPIS\n" " popis dopu¹tenih direktorija.\n" -#: src/main.c:633 +#: src/main.c:619 msgid " -X, --exclude-directories=LIST list of excluded directories.\n" msgstr "" " -X, --exclude-directories=POPIS\n" " popis nedopu¹tenih direktorija.\n" -#: src/main.c:635 -msgid " -np, --no-parent don't ascend to the parent directory.\n" -msgstr " -np, --no-parent ne uspinji se u direktorij iznad trenutnog.\n" +#: src/main.c:621 +msgid "" +" -np, --no-parent don't ascend to the parent directory.\n" +msgstr "" +" -np, --no-parent ne uspinji se u direktorij iznad " +"trenutnog.\n" -#: src/main.c:639 +#: src/main.c:625 msgid "Mail bug reports and suggestions to .\n" msgstr "Uoèene gre¹ke i prijedloge ¹aljite na .\n" -#: src/main.c:644 +#: src/main.c:630 #, c-format msgid "GNU Wget %s, a non-interactive network retriever.\n" msgstr "GNU Wget %s, program za neinteraktivni dohvat s mre¾e.\n" -#: src/main.c:658 +#: src/main.c:678 msgid "Copyright (C) 2005 Free Software Foundation, Inc.\n" msgstr "Copyright (C) 2005 Free Software Foundation, Inc.\n" -#: src/main.c:660 +#: src/main.c:680 msgid "" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" @@ -1343,7 +1484,7 @@ "PROIZVODNOSTI ili UPOTREBLJIVOSTI ZA ODREÐENU SVRHU. Pogledajte GNU\n" "General Public License za vi¹e detalja.\n" -#: src/main.c:665 +#: src/main.c:685 msgid "" "\n" "Originally written by Hrvoje Niksic .\n" @@ -1353,94 +1494,93 @@ #. #### Something nicer should be printed here -- similar to the #. pre-1.5 `--help' page. -#: src/main.c:711 src/main.c:780 src/main.c:859 +#: src/main.c:731 src/main.c:800 src/main.c:879 #, c-format msgid "Try `%s --help' for more options.\n" msgstr "Poku¹ajte `%s --help' za vi¹e opcija.\n" -#: src/main.c:777 +#: src/main.c:797 #, c-format msgid "%s: illegal option -- `-n%c'\n" msgstr "%s: nedopu¹tena opcija -- `-n%c'\n" -#: src/main.c:830 +#: src/main.c:850 #, c-format msgid "Can't be verbose and quiet at the same time.\n" msgstr "Ne mogu istovremeno biti rjeèit i tih.\n" -#: src/main.c:836 +#: src/main.c:856 #, c-format msgid "Can't timestamp and not clobber old files at the same time.\n" msgstr "Ne mogu istovremeno paziti na vrijeme i ne gaziti stare spise.\n" -#: src/main.c:844 +#: src/main.c:864 #, c-format msgid "Cannot specify both --inet4-only and --inet6-only.\n" msgstr "Nije dopu¹teno navesti i --inet4-only i --inet6-only.\n" #. No URL specified. -#: src/main.c:854 +#: src/main.c:874 #, c-format msgid "%s: missing URL\n" msgstr "%s: nedostaje URL\n" -#: src/main.c:963 +#: src/main.c:987 #, c-format msgid "No URLs found in %s.\n" msgstr "Nijedan URL nije pronaðen u %s.\n" -#: src/main.c:972 +#: src/main.c:996 #, c-format msgid "" -"\n" "FINISHED --%s--\n" -"Downloaded: %s bytes in %d files\n" +"Downloaded: %d files, %s in %s (%s)\n" msgstr "" -"\n" "ZAVR©IO --%s--\n" -"Dohvatio: %s bajtova u %d spisa\n" +"Dohvatio: %d spisa, %s u %s (%s)\n" -#: src/main.c:978 +#: src/main.c:1005 #, c-format -msgid "Download quota (%s bytes) EXCEEDED!\n" -msgstr "Ogranièenje dohvata (%s bajtova) je PREKORAÈENO!\n" +msgid "Download quota of %s EXCEEDED!\n" +msgstr "Ogranièenje dohvata od %s je PREKORAÈENO!\n" -#: src/mswindows.c:235 +#: src/mswindows.c:231 #, c-format msgid "Continuing in background.\n" msgstr "Nastavljam u pozadini.\n" -#: src/mswindows.c:427 +#: src/mswindows.c:423 #, c-format msgid "Continuing in background, pid %lu.\n" msgstr "Nastavljam u pozadini, s pid-om %lu.\n" -#: src/mswindows.c:429 src/utils.c:348 +#: src/mswindows.c:425 src/utils.c:326 #, c-format msgid "Output will be written to `%s'.\n" msgstr "Izlaz se sprema u `%s'.\n" -#: src/mswindows.c:597 src/mswindows.c:604 +#: src/mswindows.c:593 src/mswindows.c:600 #, c-format msgid "%s: Couldn't find usable socket driver.\n" msgstr "%s: Ne mogu naæi upotrebljiv pogonitelj za sockete.\n" -#: src/netrc.c:385 +#: src/netrc.c:376 #, c-format msgid "%s: %s:%d: warning: \"%s\" token appears before any machine name\n" -msgstr "%s: %s:%d: upozorenje: \"%s\" token se pojavljuje prije naziva stroja\n" +msgstr "" +"%s: %s:%d: upozorenje: \"%s\" token se pojavljuje prije naziva stroja\n" -#: src/netrc.c:416 +#: src/netrc.c:407 #, c-format msgid "%s: %s:%d: unknown token \"%s\"\n" msgstr "%s: %s:%d: nepoznat token \"%s\"\n" -#: src/netrc.c:480 +#: src/netrc.c:471 #, c-format msgid "Usage: %s NETRC [HOSTNAME]\n" msgstr "Uporaba: %s NETRC [RAÈUNALO]\n" -#: src/netrc.c:490 +#: src/netrc.c:481 #, c-format msgid "%s: cannot stat %s: %s\n" msgstr "%s: ne mogu stat-irati %s: %s\n" @@ -1449,43 +1589,50 @@ #. nor EGD were available. Try to seed OpenSSL's PRNG with libc #. PRNG. This is cryptographically weak and defeats the purpose #. of using OpenSSL, which is why it is highly discouraged. -#: src/openssl.c:121 +#: src/openssl.c:113 msgid "WARNING: using a weak random seed.\n" msgstr "UPOZORENJE: rabi se slab zametak sluèajnih brojeva.\n" -#: src/openssl.c:181 +#: src/openssl.c:173 msgid "Could not seed PRNG; consider using --random-file.\n" msgstr "Nije postavljen zametak PRNG-a; razmisli o --random-file.\n" #. If the user has specified --no-check-cert, we still want to warn #. him about problems with the server's certificate. -#: src/openssl.c:404 +#: src/openssl.c:411 msgid "ERROR" msgstr "GRE©KA" -#: src/openssl.c:404 +#: src/openssl.c:411 msgid "WARNING" msgstr "UPOZORENJE" -#: src/openssl.c:412 +#: src/openssl.c:419 #, c-format msgid "%s: No certificate presented by %s.\n" msgstr "%s: %s nije predoèio ovjeru.\n" -#: src/openssl.c:434 +#: src/openssl.c:448 #, c-format msgid "%s: Certificate verification error for %s: %s\n" msgstr "%s: gre¹ka pri verifikaciji ovjere od %s: %s\n" -#: src/openssl.c:457 +#: src/openssl.c:475 #, c-format -msgid "%s: certificate common name `%s' doesn't match requested host name `%s'.\n" -msgstr "%s: \"common name\" `%s' navedeno u ovjeri ne odgovara tra¾enom imenu `%s'.\n" +msgid "" +"%s: certificate common name `%s' doesn't match requested host name `%s'.\n" +msgstr "" +"%s: \"common name\" `%s' navedeno u ovjeri ne odgovara tra¾enom imenu `%s'.\n" + +#: src/openssl.c:488 +#, c-format +msgid "To connect to %s insecurely, use `--no-check-certificate'.\n" +msgstr "Za nesigurno spajanje na %s upotrijebite `--no-check-certificate'.\n" #. Align the [ skipping ... ] line with the dots. To do #. that, insert the number of spaces equal to the number of #. digits in the skipped amount in K. -#: src/progress.c:243 +#: src/progress.c:237 #, c-format msgid "" "\n" @@ -1494,36 +1641,55 @@ "\n" "%*s[ preskaèem %dK ]" -#: src/progress.c:410 +#: src/progress.c:404 #, c-format msgid "Invalid dot style specification `%s'; leaving unchanged.\n" -msgstr "Neispravna naznaka stila toèkica `%s': ostavljam prija¹nju vrijednost.\n" +msgstr "" +"Neispravna naznaka stila toèkica `%s': ostavljam prija¹nju vrijednost.\n" -#: src/recur.c:377 +#. Translation note: "ETA" is English-centric, but this must +#. be short, ideally 3 chars. Abbreviate if necessary. +#: src/progress.c:883 +#, c-format +msgid " eta %s" +msgstr " eta %s" + +#. Note to translators: this should not take up more room than +#. available here. Abbreviate if necessary. +#: src/progress.c:897 +msgid " in " +msgstr " za " + +#: src/recur.c:369 #, c-format msgid "Removing %s since it should be rejected.\n" msgstr "Uklanjam %s buduæi da bi ga trebalo odbiti.\n" -#: src/res.c:544 +#: src/res.c:389 +#, c-format +msgid "Cannot open %s: %s" +msgstr "Ne mogu otvoriti %s: %s" + +#: src/res.c:539 msgid "Loading robots.txt; please ignore errors.\n" msgstr "Uèitavam robots.txt; molim ne obazirati se na gre¹ke.\n" -#: src/retr.c:645 +#: src/retr.c:640 #, c-format msgid "Error parsing proxy URL %s: %s.\n" msgstr "Gre¹ka pri ra¹èlani proxy URL-a %s: %s.\n" -#: src/retr.c:653 +#: src/retr.c:648 #, c-format msgid "Error in proxy URL %s: Must be HTTP.\n" msgstr "Gre¹ka u proxy URL-u %s: Mora biti HTTP.\n" -#: src/retr.c:738 +#: src/retr.c:735 #, c-format msgid "%d redirections exceeded.\n" msgstr "Vi¹e od %d preusmjeravanja.\n" -#: src/retr.c:863 +#: src/retr.c:860 msgid "" "Giving up.\n" "\n" @@ -1531,7 +1697,7 @@ "Odustajem.\n" "\n" -#: src/retr.c:863 +#: src/retr.c:860 msgid "" "Retrying.\n" "\n" @@ -1539,83 +1705,50 @@ "Poku¹avam ponovo.\n" "\n" -#: src/url.c:620 +#: src/url.c:617 msgid "No error" msgstr "Nema gre¹ke" -#: src/url.c:622 +#: src/url.c:619 msgid "Unsupported scheme" msgstr "Nepodr¾ana shema" -#: src/url.c:624 +#: src/url.c:621 msgid "Empty host" -msgstr "" +msgstr "Prazno ime poslu¾itelja" -#: src/url.c:626 +#: src/url.c:623 msgid "Bad port number" msgstr "Neispravan broj porta" -#: src/url.c:628 +#: src/url.c:625 msgid "Invalid user name" msgstr "Neispravno korisnièko ime" -#: src/url.c:630 +#: src/url.c:627 msgid "Unterminated IPv6 numeric address" msgstr "Nedovrssena IPv6 numerièka adresa" -#: src/url.c:632 +#: src/url.c:629 msgid "IPv6 addresses not supported" msgstr "IPv6 adrese nisu podr¾ane" -#: src/url.c:634 +#: src/url.c:631 msgid "Invalid IPv6 numeric address" msgstr "Neispravna IPv6 numerièka adresa" #. parent, no error -#: src/utils.c:346 +#: src/utils.c:324 #, c-format msgid "Continuing in background, pid %d.\n" msgstr "Nastavljam u pozadini, s pid-om %d.\n" -#: src/utils.c:394 +#: src/utils.c:372 #, c-format msgid "Failed to unlink symlink `%s': %s\n" msgstr "Ne mogu izbrisati link `%s': %s\n" -#: src/xmalloc.c:72 +#: src/xmalloc.c:63 #, c-format msgid "%s: %s: Failed to allocate %ld bytes; memory exhausted.\n" msgstr "%s: %s: Nije uspjela alokacija %ld bajtova; memorija je potro¹ena.\n" - -#~ msgid "Cookie coming from %s attempted to set domain to %s\n" -#~ msgstr "Cookie s adrese %s poku¹ao je postaviti domenu na %s\n" - -#~ msgid "%s: Invalid URL %s: %s\n" -#~ msgstr "%s: Neispravan URL %s: %s\n" - -#~ msgid "POST data file `%s' missing: %s\n" -#~ msgstr "Nema spisa `%s' za POST: %s\n" - -#~ msgid "" -#~ "File `%s' already there; not retrieving.\n" -#~ "\n" -#~ msgstr "Spis `%s' veæ postoji; ne dohvaæam.\n" - -#~ msgid "" -#~ "%s: %s: Invalid extended boolean `%s';\n" -#~ "use one of `on', `off', `always', or `never'.\n" -#~ msgstr "" -#~ "%s: %s: Neispravan boolean `%s';\n" -#~ "navedite `always', `on', `off' ili `never'.\n" - -#~ msgid "To connect to %s insecurely, use `--no-check-certificate'.\n" -#~ msgstr "Za nesigurno spajanje na %s upotrijebite `--no-check-certificate'.\n" - -#~ msgid "Cannot get REALTIME clock frequency: %s\n" -#~ msgstr "Nedostupna frekvencija REALTIME clocka: %s\n" - -#~ msgid "Cannot open %s: %s" -#~ msgstr "Ne mogu otvoriti %s: %s" - -#~ msgid "Invalid host name" -#~ msgstr "Neispravno ime poslu¾itelja" diff -urN wget-1.10.2/po/sl.po wget-1.10.2_new/po/sl.po --- wget-1.10.2/po/sl.po 2005-08-16 23:59:28.000000000 +0200 +++ wget-1.10.2_new/po/sl.po 2006-06-27 12:11:51.000000000 +0200 @@ -1,7 +1,7 @@ # -*- mode:po; coding:iso-latin-2; -*- Slovenian messages for GNU Wget # Copyright (C) 2003 Free Software Foundation, Inc. # Roman Maurer , 2001. -# $Id: sl.po 2053 2005-08-16 21:59:28Z mtortonesi $ +# $Id: sl.po 2054 2005-08-16 22:00:05Z mtortonesi $ # # Spremembe: # diff -urN wget-1.10.2/po/zh_TW.po wget-1.10.2_new/po/zh_TW.po --- wget-1.10.2/po/zh_TW.po 2005-08-17 07:57:32.000000000 +0200 +++ wget-1.10.2_new/po/zh_TW.po 2006-06-27 12:11:51.000000000 +0200 @@ -7,10 +7,10 @@ # msgid "" msgstr "" -"Project-Id-Version: wget 1.10.1-b1\n" +"Project-Id-Version: wget 1.10-rc1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-07-08 08:08-0400\n" -"PO-Revision-Date: 2005-08-17 13:30+0800\n" +"POT-Creation-Date: 2005-06-06 09:11-0400\n" +"PO-Revision-Date: 2005-06-28 01:17+0800\n" "Last-Translator: Abel Cheung \n" "Language-Team: Chinese (traditional) \n" "MIME-Version: 1.0\n" @@ -20,7 +20,7 @@ #: src/connect.c:199 #, c-format msgid "%s: unable to resolve bind address `%s'; disabling bind.\n" -msgstr "%s: 無法解æžä½å€ ‘%s’;ä¸ä½¿ç”¨ bind。\n" +msgstr "" #: src/connect.c:271 #, c-format @@ -36,15 +36,10 @@ msgid "connected.\n" msgstr "連上了。\n" -#: src/connect.c:347 src/host.c:789 src/host.c:818 -#, c-format -msgid "failed: %s.\n" -msgstr "失敗: %s。\n" - #: src/convert.c:176 -#, c-format +#, fuzzy, c-format msgid "Converted %d files in %.*f seconds.\n" -msgstr "已在 %3$.*2$f 秒之內轉æ›äº† %1$d 個檔案。\n" +msgstr "已在 %.*f 秒之內轉æ›äº† %d 個檔案。\n" #: src/convert.c:202 #, c-format @@ -80,22 +75,17 @@ msgid "Syntax error in Set-Cookie: %s at position %d.\n" msgstr "Set-Cookie 出ç¾èªžæ³•éŒ¯èª¤: 在 %2$d ä½ç½®çš„ %1$s。\n" -#: src/cookies.c:881 -#, c-format -msgid "Cookie coming from %s attempted to set domain to %s\n" -msgstr "來自 %s çš„ cookie 嘗試將網域設定為 %s\n" - -#: src/cookies.c:1328 src/cookies.c:1477 +#: src/cookies.c:1469 #, c-format msgid "Cannot open cookies file `%s': %s\n" msgstr "無法開啟 cookie 檔‘%s’: %s\n" -#: src/cookies.c:1489 +#: src/cookies.c:1481 #, c-format msgid "Error writing to `%s': %s\n" msgstr "寫入‘%s’時發生錯誤: %s\n" -#: src/cookies.c:1492 +#: src/cookies.c:1484 #, c-format msgid "Error closing `%s': %s\n" msgstr "關閉‘%s’時發生錯誤: %s\n" @@ -144,12 +134,12 @@ msgid "Length: %s" msgstr "長度: %s" -#: src/ftp.c:232 src/http.c:1861 +#: src/ftp.c:232 src/http.c:1857 #, c-format msgid ", %s (%s) remaining" msgstr ",剩餘 %s (%s)" -#: src/ftp.c:236 src/http.c:1865 +#: src/ftp.c:236 src/http.c:1861 #, c-format msgid ", %s remaining" msgstr ",剩餘 %s" @@ -282,10 +272,10 @@ #. what functions like unique_create typically do) #. because we told the user we'd use this name. #. Instead, return and retry the download. -#: src/ftp.c:946 src/http.c:1922 +#: src/ftp.c:946 src/http.c:1913 #, c-format msgid "%s has sprung into existence.\n" -msgstr "%s çªç„¶å‡ºç¾ã€‚\n" +msgstr "" #: src/ftp.c:1008 #, c-format @@ -305,17 +295,17 @@ msgid "Data transfer aborted.\n" msgstr "已中止傳é€è³‡æ–™ã€‚\n" -#: src/ftp.c:1117 +#: src/ftp.c:1114 #, c-format -msgid "File `%s' already there; not retrieving.\n" -msgstr "檔案 ‘%s’ 已存在,ä¸æœƒä¸‹è¼‰ã€‚\n" +msgid "File `%s' already there, not retrieving.\n" +msgstr "檔案‘%s’已存在,ä¸æœƒä¸‹è¼‰ã€‚\n" -#: src/ftp.c:1185 src/http.c:2142 +#: src/ftp.c:1182 src/http.c:2130 #, c-format msgid "(try:%2d)" msgstr "(嘗試第 %2d 次)" -#: src/ftp.c:1255 src/http.c:2421 +#: src/ftp.c:1252 src/http.c:2409 #, c-format msgid "" "%s (%s) - `%s' saved [%s]\n" @@ -324,35 +314,35 @@ "%s (%s) - 已儲存‘%s’ [%s]\n" "\n" -#: src/ftp.c:1297 src/main.c:948 src/recur.c:376 src/retr.c:844 +#: src/ftp.c:1294 src/main.c:948 src/recur.c:376 src/retr.c:842 #, c-format msgid "Removing %s.\n" msgstr "刪除 %s。\n" -#: src/ftp.c:1339 +#: src/ftp.c:1336 #, c-format msgid "Using `%s' as listing tmp file.\n" msgstr "使用‘%s’作為檔案清單暫存檔。\n" -#: src/ftp.c:1354 +#: src/ftp.c:1351 #, c-format msgid "Removed `%s'.\n" msgstr "已刪除‘%s’。\n" -#: src/ftp.c:1389 +#: src/ftp.c:1386 #, c-format msgid "Recursion depth %d exceeded max. depth %d.\n" msgstr "éˆçµæ·±åº¦ %d 超éŽæœ€å¤§å€¼ %d。\n" #. Remote file is older, file sizes can be compared and #. are both equal. -#: src/ftp.c:1459 +#: src/ftp.c:1456 #, c-format msgid "Remote file no newer than local file `%s' -- not retrieving.\n" msgstr "é ç«¯æª”案ä¸æ¯”本機檔案‘%s’新 ─ ä¸æœƒä¸‹è¼‰ã€‚\n" #. Remote file is newer or sizes cannot be matched -#: src/ftp.c:1466 +#: src/ftp.c:1463 #, c-format msgid "" "Remote file is newer than local file `%s' -- retrieving.\n" @@ -360,7 +350,7 @@ msgstr "é ç«¯æª”案較本機檔案‘%s’新 ─ 會下載檔案。\n" #. Sizes do not match -#: src/ftp.c:1473 +#: src/ftp.c:1470 #, c-format msgid "" "The sizes do not match (local %s) -- retrieving.\n" @@ -369,11 +359,11 @@ "檔案大å°ä¸ç¬¦ (本機檔案為 %s) -- 下載檔案。\n" "\n" -#: src/ftp.c:1491 +#: src/ftp.c:1488 msgid "Invalid name of the symlink, skipping.\n" msgstr "ç•¥éŽå稱有誤的符號éˆçµã€‚\n" -#: src/ftp.c:1508 +#: src/ftp.c:1505 #, c-format msgid "" "Already have correct symlink %s -> %s\n" @@ -382,42 +372,42 @@ "正確的符號éˆçµ %s → %s 已經存在\n" "\n" -#: src/ftp.c:1516 +#: src/ftp.c:1513 #, c-format msgid "Creating symlink %s -> %s\n" msgstr "建立符號éˆçµ %s → %s\n" -#: src/ftp.c:1526 +#: src/ftp.c:1523 #, c-format msgid "Symlinks not supported, skipping symlink `%s'.\n" msgstr "本系統ä¸æ”¯æ´ç¬¦è™Ÿéˆçµï¼Œç•¥éŽç¬¦è™Ÿéˆçµâ€˜%s’。\n" -#: src/ftp.c:1538 +#: src/ftp.c:1535 #, c-format msgid "Skipping directory `%s'.\n" msgstr "ç•¥éŽç›®éŒ„‘%s’。\n" -#: src/ftp.c:1547 +#: src/ftp.c:1544 #, c-format msgid "%s: unknown/unsupported file type.\n" msgstr "%s: 檔案類別ä¸è©³æˆ–ä¸æ”¯æ´ã€‚\n" -#: src/ftp.c:1574 +#: src/ftp.c:1571 #, c-format msgid "%s: corrupt time-stamp.\n" msgstr "%s: 時間標記錯誤。\n" -#: src/ftp.c:1602 +#: src/ftp.c:1599 #, c-format msgid "Will not retrieve dirs since depth is %d (max %d).\n" msgstr "因為深度為 %d (最大值為 %d),所以ä¸ä¸‹è¼‰ã€‚\n" -#: src/ftp.c:1652 +#: src/ftp.c:1649 #, c-format msgid "Not descending to `%s' as it is excluded/not-included.\n" msgstr "ä¸é€²å…¥â€˜%s’目錄因為已被排除或ä¸è¢«åˆ—入清單中。\n" -#: src/ftp.c:1718 src/ftp.c:1732 +#: src/ftp.c:1715 src/ftp.c:1729 #, c-format msgid "Rejecting `%s'.\n" msgstr "拒絕‘%s’。\n" @@ -425,17 +415,17 @@ #. No luck. #. #### This message SUCKS. We should see what was the #. reason that nothing was retrieved. -#: src/ftp.c:1778 +#: src/ftp.c:1775 #, c-format msgid "No matches on pattern `%s'.\n" msgstr "沒有任何項目符åˆæ¨£å¼â€˜%s’。\n" -#: src/ftp.c:1844 +#: src/ftp.c:1841 #, c-format msgid "Wrote HTML-ized index to `%s' [%s].\n" msgstr "å°‡ HTML 化的索引寫入至 ‘%s’ [%s]。\n" -#: src/ftp.c:1849 +#: src/ftp.c:1846 #, c-format msgid "Wrote HTML-ized index to `%s'.\n" msgstr "å°‡ HTML 化的索引寫入至 ‘%s’。\n" @@ -499,30 +489,35 @@ msgid "%s: option `-W %s' doesn't allow an argument\n" msgstr "%s: é¸é …‘-W %s’ä¸å¯é…åˆå¼•æ•¸ä½¿ç”¨\n" -#: src/host.c:366 +#: src/host.c:371 msgid "Unknown host" msgstr "ä¸æ˜Žä¸»æ©Ÿ" #. Message modeled after what gai_strerror returns in similar #. circumstances. -#: src/host.c:370 +#: src/host.c:375 msgid "Temporary failure in name resolution" msgstr "暫時無法檢索主機å稱" -#: src/host.c:372 +#: src/host.c:377 msgid "Unknown error" msgstr "錯誤原因ä¸æ˜Ž" -#: src/host.c:751 +#: src/host.c:756 #, c-format msgid "Resolving %s... " msgstr "正在查找主機 %s... " -#: src/host.c:798 +#: src/host.c:800 src/host.c:829 +#, c-format +msgid "failed: %s.\n" +msgstr "失敗: %s。\n" + +#: src/host.c:809 msgid "failed: No IPv4/IPv6 addresses for host.\n" msgstr "失敗: 該主機沒有 IPv4/IPv6 地å€ã€‚\n" -#: src/host.c:821 +#: src/host.c:832 msgid "failed: timed out.\n" msgstr "失敗: 連線逾時。\n" @@ -531,12 +526,7 @@ msgid "%s: Cannot resolve incomplete link %s.\n" msgstr "%s: 無法解æžä¸å®Œæ•´çš„符號éˆçµ %s。\n" -#: src/html-url.c:705 -#, c-format -msgid "%s: Invalid URL %s: %s\n" -msgstr "%s: URL ‘%s’ 無效: %s\n" - -#: src/http.c:373 +#: src/http.c:373 src/http.c:1549 #, c-format msgid "Failed writing HTTP request: %s.\n" msgstr "無法寫入 HTTP è¦æ±‚: %s。\n" @@ -545,79 +535,79 @@ msgid "No headers, assuming HTTP/0.9" msgstr "沒有任何標頭資料,å‡è¨­ç‚º HTTP/0.9" -#: src/http.c:1204 +#: src/http.c:1198 msgid "Disabling SSL due to encountered errors.\n" msgstr "å› é‡åˆ°éŒ¯èª¤è€Œåœæ­¢ä½¿ç”¨ SSL。\n" -#: src/http.c:1374 -#, c-format -msgid "POST data file `%s' missing: %s\n" -msgstr "載有 POST 資料的檔案 ‘%s’ ä¸è¦‹äº†ï¼š%s\n" - -#: src/http.c:1423 +#: src/http.c:1417 #, c-format msgid "Reusing existing connection to %s:%d.\n" msgstr "繼續使用和 %s:%d 的連線。\n" -#: src/http.c:1492 +#: src/http.c:1479 +#, c-format +msgid "Failed writing to proxy: %s.\n" +msgstr "無法寫入代ç†ä¼ºæœå™¨: %s。\n" + +#: src/http.c:1488 #, c-format msgid "Failed reading proxy response: %s\n" msgstr "無法讀å–代ç†ä¼ºæœå™¨å›žæ‡‰: %s。\n" -#: src/http.c:1512 +#: src/http.c:1508 #, c-format msgid "Proxy tunneling failed: %s" -msgstr "無法é€éŽä»£ç†ä¼ºæœå™¨é€²è¡Œ tunneling: %s" +msgstr "" -#: src/http.c:1557 +#: src/http.c:1555 #, c-format msgid "%s request sent, awaiting response... " msgstr "å·²é€å‡º %s è¦æ±‚,正在等候回應... " -#: src/http.c:1568 +#: src/http.c:1566 msgid "No data received.\n" msgstr "收ä¸åˆ°è³‡æ–™ã€‚\n" -#: src/http.c:1575 +#: src/http.c:1573 #, c-format msgid "Read error (%s) in headers.\n" msgstr "讀å–標頭時發生錯誤 (%s)。\n" #. If the authentication header is missing or #. unrecognized, there's no sense in retrying. -#: src/http.c:1660 +#: src/http.c:1658 msgid "Unknown authentication scheme.\n" msgstr "èªè­‰æ–¹å¼ä¸è©³ã€‚\n" -#: src/http.c:1684 +#: src/http.c:1682 msgid "Authorization failed.\n" msgstr "èªè­‰å¤±æ•—ï¼\n" -#: src/http.c:1698 +#: src/http.c:1696 msgid "Malformed status line" msgstr "ä¸æ­£å¸¸çš„狀態行" -#: src/http.c:1700 +#: src/http.c:1698 msgid "(no description)" msgstr "(沒有任何說明)" -#: src/http.c:1763 +#: src/http.c:1769 #, c-format msgid "Location: %s%s\n" msgstr "ä½ç½®: %s%s\n" -#: src/http.c:1764 src/http.c:1871 +#: src/http.c:1770 src/http.c:1867 msgid "unspecified" msgstr "未指定" -#: src/http.c:1765 +#: src/http.c:1771 msgid " [following]" msgstr " [跟隨至新的 URL]" #. If `-c' is in use and the file has been fully downloaded (or #. the remote file has shrunk), Wget effectively requests bytes #. after the end of file and the server response with 416. -#: src/http.c:1821 +#: src/http.c:1817 msgid "" "\n" " The file is already fully retrieved; nothing to do.\n" @@ -630,58 +620,54 @@ #. No need to print this output if the body won't be #. downloaded at all, or if the original server response is #. printed. -#: src/http.c:1851 +#: src/http.c:1847 msgid "Length: " msgstr "長度: " -#: src/http.c:1871 +#: src/http.c:1867 msgid "ignored" msgstr "忽略" -#: src/http.c:2019 +#: src/http.c:2007 msgid "Warning: wildcards not supported in HTTP.\n" msgstr "警告: HTTP ä¸æ”¯æ´è¬ç”¨å­—元。\n" #. If opt.noclobber is turned on and file already exists, do not #. retrieve the file -#: src/http.c:2054 +#: src/http.c:2042 #, c-format -msgid "" -"File `%s' already there; not retrieving.\n" -"\n" -msgstr "" -"檔案 ‘%s’ 已存在,ä¸æœƒä¸‹è¼‰ã€‚\n" -"\n" +msgid "File `%s' already there, will not retrieve.\n" +msgstr "檔案‘%s’已存在,ä¸æœƒä¸‹è¼‰ã€‚\n" -#: src/http.c:2244 +#: src/http.c:2232 #, c-format msgid "Cannot write to `%s' (%s).\n" msgstr "無法寫入‘%s’(%s)。\n" #. Another fatal error. -#: src/http.c:2251 +#: src/http.c:2239 msgid "Unable to establish SSL connection.\n" msgstr "無法建立 SSL 連線。\n" -#: src/http.c:2260 +#: src/http.c:2248 #, c-format msgid "ERROR: Redirection (%d) without location.\n" msgstr "錯誤: é‡æ–°å°Žå‘ (%d) 但沒有指定ä½ç½®ã€‚\n" -#: src/http.c:2290 +#: src/http.c:2278 #, c-format msgid "%s ERROR %d: %s.\n" msgstr "%s 錯誤 %d: %s。\n" -#: src/http.c:2303 +#: src/http.c:2291 msgid "Last-modified header missing -- time-stamps turned off.\n" msgstr "缺少了最後修改時間標頭 ─ 關閉時間標記。\n" -#: src/http.c:2311 +#: src/http.c:2299 msgid "Last-modified header invalid -- time-stamp ignored.\n" msgstr "無效的最後修改時間標頭 ─ 忽略時間標記。\n" -#: src/http.c:2334 +#: src/http.c:2322 #, c-format msgid "" "Server file no newer than local file `%s' -- not retrieving.\n" @@ -690,16 +676,16 @@ "é ç«¯æª”案ä¸æ¯”本機檔案‘%s’新 ─ ä¸æœƒä¸‹è¼‰ã€‚\n" "\n" -#: src/http.c:2342 +#: src/http.c:2330 #, c-format msgid "The sizes do not match (local %s) -- retrieving.\n" msgstr "檔案大å°ä¸ç¬¦ (本機檔案為 %s) -- 會下載檔案。\n" -#: src/http.c:2347 +#: src/http.c:2335 msgid "Remote file is newer, retrieving.\n" msgstr "é ç«¯æª”案較新,會下載檔案。\n" -#: src/http.c:2389 src/http.c:2455 +#: src/http.c:2377 #, c-format msgid "" "%s (%s) - `%s' saved [%s/%s]\n" @@ -708,22 +694,31 @@ "%s (%s) -- 已儲存 ‘%s’ [%s/%s])\n" "\n" -#: src/http.c:2446 +#: src/http.c:2434 #, c-format msgid "%s (%s) - Connection closed at byte %s. " msgstr "%s (%s) - 在 %s ä½å…ƒçµ„後連線çªç„¶ä¸­æ–·ã€‚ " -#: src/http.c:2481 +#: src/http.c:2443 +#, c-format +msgid "" +"%s (%s) - `%s' saved [%s/%s])\n" +"\n" +msgstr "" +"%s (%s) - 已儲存 ‘%s’ [%s/%s])\n" +"\n" + +#: src/http.c:2469 #, c-format msgid "%s (%s) - Connection closed at byte %s/%s. " msgstr "%s (%s) - 在 %s/%s ä½å…ƒçµ„後連線çªç„¶ä¸­æ–·ã€‚ " -#: src/http.c:2495 +#: src/http.c:2483 #, c-format msgid "%s (%s) - Read error at byte %s (%s)." msgstr "%s (%s) - 讀å–至 %s ä½å…ƒçµ„時發生錯誤 (%s)。" -#: src/http.c:2505 +#: src/http.c:2493 #, c-format msgid "%s (%s) - Read error at byte %s/%s (%s). " msgstr "%s (%s) - 讀å–至 %s/%s ä½å…ƒçµ„時發生錯誤 (%s)。" @@ -765,49 +760,45 @@ #: src/init.c:707 #, c-format -msgid "%s: %s: Invalid boolean `%s'; use `on' or `off'.\n" -msgstr "%s: %s: é‚輯值 ‘%s’ 無效,請使用 ‘on’ 或 ‘off’。\n" +msgid "%s: %s: Invalid boolean `%s', use `on' or `off'.\n" +msgstr "%s: %s: é‚輯值 ‘%s’ 無效,請使用 on 或 off。\n" -#: src/init.c:759 +#: src/init.c:750 #, c-format -msgid "" -"%s: %s: Invalid extended boolean `%s';\n" -"use one of `on', `off', `always', or `never'.\n" -msgstr "" -"%s: %s: é‚輯值 ‘%s’ 無效,\n" -"請使用 ‘always’, ‘on’, ‘off’ 或 ‘never’。\n" +msgid "%s: %s: Invalid boolean `%s', use always, on, off, or never.\n" +msgstr "%s: %s: é‚輯值 ‘%s’ 無效,請使用 always, on, off 或 never。\n" -#: src/init.c:777 +#: src/init.c:767 #, c-format msgid "%s: %s: Invalid number `%s'.\n" msgstr "%s: %s: 數值 ‘%s’ 無效。\n" -#: src/init.c:1008 src/init.c:1027 +#: src/init.c:998 src/init.c:1017 #, c-format msgid "%s: %s: Invalid byte value `%s'\n" msgstr "%s: %s: ä½å…ƒå€¼ ‘%s’ 無效。\n" -#: src/init.c:1052 +#: src/init.c:1042 #, c-format msgid "%s: %s: Invalid time period `%s'\n" msgstr "%s: %s: 時間 ‘%s’ 無效。\n" -#: src/init.c:1106 src/init.c:1196 src/init.c:1291 src/init.c:1316 +#: src/init.c:1096 src/init.c:1186 src/init.c:1281 src/init.c:1306 #, c-format msgid "%s: %s: Invalid value `%s'.\n" msgstr "%s: %s: 數值 ‘%s’ 無效。\n" -#: src/init.c:1143 +#: src/init.c:1133 #, c-format msgid "%s: %s: Invalid header `%s'.\n" msgstr "%s: %s: 標頭內容 ‘%s’ 無效。\n" -#: src/init.c:1208 +#: src/init.c:1198 #, c-format msgid "%s: %s: Invalid progress type `%s'.\n" msgstr "%s: %s: 無效的進度指示方å¼â€˜%s’。\n" -#: src/init.c:1259 +#: src/init.c:1249 #, c-format msgid "%s: %s: Invalid restriction `%s', use `unix' or `windows'.\n" msgstr "%s: %s: 作業系統類型 ‘%s’ 無效,請使用 unix 或 windows。\n" @@ -1174,12 +1165,11 @@ #: src/main.c:562 msgid " --ca-certificate=FILE file with the bundle of CA's.\n" -msgstr " --ca-certificate=檔案 載有憑證管ç†ä¸­å¿ƒ (CA) 簽章的檔案\n" +msgstr "" -# (Abel) 這裡 hashed filename å’Œé¸é …的用æ„無關,所以ä¸ç¿»è­¯ #: src/main.c:564 msgid " --ca-directory=DIR directory where hash list of CA's is stored.\n" -msgstr " --ca-directory=目錄 載有憑證管ç†ä¸­å¿ƒ (CA) 簽章的目錄\n" +msgstr "" #: src/main.c:566 msgid " --random-file=FILE file with random data for seeding the SSL PRNG.\n" @@ -1248,8 +1238,8 @@ msgstr " -K, --backup-converted 將檔案 X 轉æ›å‰å…ˆå‚™ä»½ç‚º X.orig\n" #: src/main.c:603 -msgid " -m, --mirror shortcut for -N -r -l inf --no-remove-listing.\n" -msgstr " -m, --mirror 相等於 -N -r -l inf --no-remove-listing é¸é …\n" +msgid " -m, --mirror shortcut option equivalent to -r -N -l inf -nr.\n" +msgstr " -m, --mirror 相等於 -r -N -l inf -nr é¸é …\n" #: src/main.c:605 msgid " -p, --page-requisites get all images, etc. needed to display HTML page.\n" @@ -1393,7 +1383,7 @@ "å®Œæˆ --%s--\n" "下載了: %s ä½å…ƒçµ„,共 %d 個檔案\n" -#: src/main.c:979 +#: src/main.c:978 #, c-format msgid "Download quota (%s bytes) EXCEEDED!\n" msgstr "超éŽä¸‹è¼‰é™é¡ (%s ä½å…ƒçµ„)ï¼\n" @@ -1408,7 +1398,7 @@ msgid "Continuing in background, pid %lu.\n" msgstr "繼續在背景中執行,pid 為 %lu。\n" -#: src/mswindows.c:429 src/utils.c:351 +#: src/mswindows.c:429 src/utils.c:348 #, c-format msgid "Output will be written to `%s'.\n" msgstr "將輸出資料寫入 ‘%s’。\n" @@ -1497,23 +1487,11 @@ msgid "Invalid dot style specification `%s'; leaving unchanged.\n" msgstr "é€²åº¦æŒ‡ç¤ºæ–¹å¼ â€˜%s’ 無效;ä¸æœƒæ”¹è®ŠåŽŸä¾†æ–¹å¼ã€‚\n" -#. If no clock was found, it means that clock_getres failed for -#. the realtime clock. -#: src/ptimer.c:176 -#, c-format -msgid "Cannot get REALTIME clock frequency: %s\n" -msgstr "無法讀å–實時時é˜çš„頻率:%s\n" - #: src/recur.c:377 #, c-format msgid "Removing %s since it should be rejected.\n" msgstr "刪除 %s,因為它應該被指定了拒絕下載。\n" -#: src/res.c:394 -#, c-format -msgid "Cannot open %s: %s" -msgstr "無法開啟 %s: %s" - #: src/res.c:544 msgid "Loading robots.txt; please ignore errors.\n" msgstr "正在載入 robots.txt;請忽略錯誤訊æ¯ã€‚\n" @@ -1528,12 +1506,12 @@ msgid "Error in proxy URL %s: Must be HTTP.\n" msgstr "代ç†ä¼ºæœå™¨ URL %s 錯誤: 必須是 HTTP。\n" -#: src/retr.c:740 +#: src/retr.c:738 #, c-format msgid "%d redirections exceeded.\n" msgstr "å·²è¶…éŽ %d 次é‡æ–°å°Žå‘。\n" -#: src/retr.c:865 +#: src/retr.c:863 msgid "" "Giving up.\n" "\n" @@ -1541,7 +1519,7 @@ "放棄。\n" "\n" -#: src/retr.c:865 +#: src/retr.c:863 msgid "" "Retrying.\n" "\n" @@ -1558,8 +1536,8 @@ msgstr "ä¸æ”¯æ´é€™ç¨® URL æ ¼å¼" #: src/url.c:630 -msgid "Invalid host name" -msgstr "主機å稱無效" +msgid "Empty host" +msgstr "沒有主機å稱" #: src/url.c:632 msgid "Bad port number" @@ -1582,12 +1560,12 @@ msgstr "IPv6 ä½å€ç„¡æ•ˆ" #. parent, no error -#: src/utils.c:349 +#: src/utils.c:346 #, c-format msgid "Continuing in background, pid %d.\n" msgstr "繼續在背景中執行,pid 為 %d。\n" -#: src/utils.c:397 +#: src/utils.c:394 #, c-format msgid "Failed to unlink symlink `%s': %s\n" msgstr "無法刪除符號éˆçµ '%s': %s\n" @@ -1596,19 +1574,3 @@ #, c-format msgid "%s: %s: Failed to allocate %ld bytes; memory exhausted.\n" msgstr "%s:%sï¼šç„¡æ³•åˆ†é… %ld ä½å…ƒçµ„,記憶體已耗盡。\n" - -#~ msgid "Failed writing to proxy: %s.\n" -#~ msgstr "無法寫入代ç†ä¼ºæœå™¨: %s。\n" - -#~ msgid "File `%s' already there, will not retrieve.\n" -#~ msgstr "檔案‘%s’已存在,ä¸æœƒä¸‹è¼‰ã€‚\n" - -#~ msgid "" -#~ "%s (%s) - `%s' saved [%s/%s])\n" -#~ "\n" -#~ msgstr "" -#~ "%s (%s) - 已儲存 ‘%s’ [%s/%s])\n" -#~ "\n" - -#~ msgid "Empty host" -#~ msgstr "沒有主機å稱" diff -urN wget-1.10.2/README wget-1.10.2_new/README --- wget-1.10.2/README 2006-06-27 11:47:13.000000000 +0200 +++ wget-1.10.2_new/README 2006-06-27 12:12:22.000000000 +0200 @@ -62,7 +62,7 @@ detailed listing of all contributions. -Copyright (C) 2005 Free Software Foundation, Inc. +Copyright (C) 1995-2005 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 @@ -76,7 +76,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the diff -urN wget-1.10.2/src/ChangeLog wget-1.10.2_new/src/ChangeLog --- wget-1.10.2/src/ChangeLog 2005-10-13 10:52:21.000000000 +0200 +++ wget-1.10.2_new/src/ChangeLog 2006-06-27 12:13:03.000000000 +0200 @@ -1,11 +1,281 @@ +2006-06-13 Mauro Tortonesi + + * options.h (struct options): Introduced member restrict_files_case to + keep track of preferences on character case restrictions for + filenames. + + * init.c: Modified defaults and cmd_spec_restrict_file_names to + support character case restrictions for filenames. Added + test_cmd_spec_restrict_file_names unit test. + + * url.c: Modified append_uri_pathel to support character case + restrictions for filenames. Added test_append_uri_pathel unit test. + + * test.c: Added test_cmd_spec_restrict_file_names and + test_append_uri_pathel to the list of unit tests to run. + +2006-06-12 Mauro Tortonesi + + * retr.c (retrieve_from_file): Use retrieve_tree and automatically + turn on opt.follow_ftp in case of recursive FTP retrieval through HTTP + proxy. + + * main.c: Automatically turn on opt.follow_ftp in case of recursive + FTP retrieval through HTTP proxy. + +2006-06-12 Tony Lewis + + * main.c: Improved CHEN Peng's patch by proposing a simpler logic. + +2006-06-12 CHEN Peng + + * main.c: Use retrieve_tree in case of recursive FTP retrieval through + HTTP proxy. + +2006-05-25 Mauro Tortonesi + + * convert.c: Added mechanisms to keep track broken links. + + * convert.h: Ditto. + + * wget.h: Reordered and enumerated uerr_t constants. + + * recur.c: Fixes to support recursive spider mode. + + * http.c: Ditto. + + * main.c: Print broken links in case of recursive spider mode. + + * retr.c: Changed interface of retrieve_url. + + * retr.h: Ditto. + + * ftp.c: Changed interface of ftp_loop. + + * ftp.h: Ditto. + + * res.c: Minor change to reflect changes in interface of retrieve_url. + +2006-05-18 Lawrence Jones + + * ftp-ls.c (ftp_parse_unix_ls): Correct size parsing, add size + and filename debugging output. + +2006-04-28 Mauro Tortonesi + + * http.c: If Content-Disposition header is present, allow unique + filename generation unless -nc is given. Permit to disable parsing of + Content-Disposition header. + + * options.h: Added option --no-content-disposition to disable parsing + of HTTP Content-Disposition header. + + * init.c: Ditto. + + * main.c: Ditto. + +2006-04-11 Hrvoje Niksic + + * hash.c (TOLOWER): Wrap macro arg in parentheses. + +2006-04-08 Hrvoje Niksic + + * http.c (parse_content_disposition): Doc fix. + +2006-03-15 Mauro Tortonesi + + * utils.c: Restricted operational semantics of frontcmp and proclist + from generic strings to directory names and them to subdir_p and + dir_matches_p respectively. Applied George Ogata's one line patch to + restrict algorithm of subdir_p to full directory name matching. Added + testcases for subdir_p and dir_matches_p. + + * utils.h: Changed all frontcmp occurrences to subdir_p. + + * recur.c: Ditto. + + * test.c: Changed type returned by test functions from char * to const + char *. Added test_subdir_p and test_dir_matches_p to the list of + tests to run. + + * http.c (test_parse_content_disposition): Changed return type from + char * to const char *. + +2006-03-14 Mauro Tortonesi + + * recur.c (struct queue_element): Changed type of html_allowed member + to bool. + +2006-03-09 Mauro Tortonesi + + * ftp.c (ftp_list): Try `LIST -a' command first and revert to `LIST' + in case of failure. + +2006-03-06 Hrvoje Niksic + + * hash.c (TOLOWER): Fix definition when STANDALONE. + Reported by Beni Serfaty. + +2006-03-02 Mauro Tortonesi + + * http.c (http_loop): Fixed recursive HTTP retrieval. + +2006-02-28 Hrvoje Niksic + + * http.c (extract_param): Declare extern so it can be used from + other files. + (extract_param): Return error for empty name. + +2006-02-28 Hrvoje Niksic + + * url.c (find_last_char): Define in terms of memrchr. + + * cmpt.c (memrchr): Define it on systems that don't have it. + + * http.c (extract_param): New function for parsing header values + with parameters. + (parse_content_disposition): Use it. Don't allow slashes and + backslashes in the file name. + +2006-02-27 Hrvoje Niksic + + * url.c (path_simplify): Don't preserve ".." at beginning of path. + Suggested by Frank McCown. + +2006-02-25 Hrvoje Niksic + + * http.c (gethttp): Only use FILE.N.html if FILE.html exists. + +2006-02-09 Hrvoje Niksic + + * mswindows.c (run_with_timeout): Made thread_hnd non-static. + +2006-02-05 Hrvoje Niksic + + * retr.c (sleep_between_retrievals): Sleep at a minimum of 1/2 of + the specified wait period. + +2006-02-03 Hrvoje Niksic + + * utils.c (number_to_string): Don't use sprintf for printing + WGINT_MIN; simply divide n by 10 and defer printing the last + digit. + (number_to_string): Removed the SPRINTF_WGINT macro. + +2006-02-03 Mauro Tortonesi + + * http.c: Fixed support for Content-Disposition header. + + * test.c: Added test_parse_content_disposition to the list of unit + tests to run. + +2006-02-02 Hrvoje Niksic + + * hash.c: Don't define countof if it's already defined. + + * hash.c: Obtain the definition of uintptr_t when standalone. + +2006-01-30 Mauro Tortonesi + + * http.c: Changed output format. Removed excessively verbose debugging + output. + +2005-12-07 Mauro Tortonesi + + * http.c: Fixed pre-download verbose output which was broken by + HTTP code refactoring. + +2005-11-23 Mauro Tortonesi + + * http.c: Refactored HTTP code. If -O is not used, the new code + delays the choice of the file name where the downloaded resource + will be saved until the HTTP headers have been retrieved. + Added support for Content-Disposition header. + +2005-11-19 Hrvoje Niksic + + * hash.c (INVALID_PTR): Use uintptr_t instead of unsigned long. + (hash_pointer): Don't assume a pointer fits in `unsigned long'. + +2005-11-02 Mauro Tortonesi + + * Makefile.in: Removed support for unit testing (now it is in + tests/Makefile.in). + +2005-10-27 Mauro Tortonesi + + * Makefile.in: Added basic support for unit testing. + + * test.c: Ditto. + + * test.h: Ditto. + 2005-10-13 Daniel Stenberg * http-ntlm.c (ntlm_output): Fixed buffer overflow vulnerability. +2005-10-09 Russ Allbery + + * snprintf.c: Remove round to round_int and pow10 to pow10_int, to + avoid warnings from GCC 4.0. + +2005-10-05 Mauro Tortonesi + + * retr.c: Changed semantics of no_proxy_match. + +2005-09-17 Hrvoje Niksic + + * main.c (main): Don't print the summary if nothing has been downloaded. + +2005-09-17 Hrvoje Niksic + + * retr.c (retr_rate): Rename parameter from MSECS to SECS since it + no longer holds milliseconds. + +2005-09-01 Hrvoje Niksic + + * progress.c: Introduce symbolic constants for "magic" values of + 0.2 and 0.9, REFRESH_INTERVAL and ETA_REFRESH_INTERVAL. + +2005-08-27 Hrvoje Niksic + + * cmpt.c (strtoll): Correctly handle strtoll("0x", ptr, 0) and + strtoll("0x", ptr, 0) -- in both cases *ptr must be + set to the position of 'x', not after it. + +2005-08-27 Hrvoje Niksic + + * hash.c (hash_table_map): Rename to hash_table_for_each and + update callers. + Document the meaning of the callback's return value. + (hash_table_iterate): New function. + (hash_table_iter_next): Likewise. + Update most places that used hash_table_for_each to use the + iteration, which doesn't require a temporary function with + explicit state management. + +2005-08-26 Albert Chin + + * Makefile.in: Use @datadir@. Define localedir as $(datadir)/locale. + 2005-08-26 Jeremy Shapiro * openssl.c (ssl_init): Set SSL_MODE_AUTO_RETRY. +2005-08-23 Hrvoje Niksic + + * host.c (address_list_from_ipv4_addresses): Use IP_INADDR_DATA. + +2005-08-12 Hrvoje Niksic + + * wget.h: Renamed strtoll_return to strtoll_type. + +2005-08-11 Hrvoje Niksic + + * progress.c (eta_to_human_short): Switch to days when printing + more than 48h rather than 100h. (It's not immediately apparent + how many days there are in 83h.) + 2005-08-11 Hrvoje Niksic * cmpt.c (strtoll): Define it if missing on the system and if Wget @@ -13,6 +283,18 @@ * mswindows.c (str_to_int64): Move to cmpt.c and rename to strtoll. +2005-08-10 Hrvoje Niksic + + * host.c (print_address): Always use inet_ntop when IPv6 is + enabled. + + * host.h (ip_address): Simplify the data union. + +2005-08-09 Hrvoje Niksic + + * mswindows.c (inet_ntop): Also handle IPv4 addresses for + completeness. + 2005-08-09 Hrvoje Niksic * http.c (gethttp): Don't read more than the amount of data @@ -28,6 +310,63 @@ * ftp-ls.c (ftp_parse_unix_ls): Remember the position of the previous token instead of backtracking back to it. +2005-07-08 Gisle Vanem + + * mswindows.h: Include process.h to get getpid() declaration. + +2005-07-08 Hrvoje Niksic + + * utils.c (aprintf): Use vasprintf where available. + +2005-07-08 Hrvoje Niksic + + * url.c (rewrite_shorthand_url): Simplify code using aprintf and + strspn. + +2005-07-07 Hrvoje Niksic + + * gnutls.c (ssl_check_certificate): Check for the validity of the + presented X509 certificate. + +2005-07-07 Hrvoje Niksic + + * openssl.c (ssl_check_certificate): Print custom error messages + for frequent X509 certificate problems. + +2005-07-07 Hrvoje Niksic + + * mswindows.h: Define an alias for stat and fstat, as requested by + config-compiler.h. + (gai_strerror): Define to windows_strerror if NEED_GAI_STRERROR is + defined. + +2005-07-06 Hrvoje Niksic + + * mswindows.h: Use strtoll where available. + +2005-07-06 Hrvoje Niksic + + * sysdep.h: Add a full declaration of fnmatch.h. + +2005-07-06 Hrvoje Niksic + + * utils.c: Unconditionally include . + +2005-07-06 Hrvoje Niksic + + * utils.c (fnmatch_nocase): New function. + (proclist): Use it instead of fnmatch when opt.ignore_case is + requested. + (in_acclist): Respect opt.ignore_case. + (frontcmp): Respect opt.ignore_case. + + * options.h (struct options): New flag opt.ignore_case. + +2005-07-06 Hrvoje Niksic + + * ptimer.c: Measure time in seconds rather than milliseconds. + Adjusted all callers. + 2005-07-06 Hrvoje Niksic * http.c (gethttp): When freeing MESSAGE, take into account that @@ -39,56 +378,243 @@ 2005-07-05 Hrvoje Niksic - * cmpt.c (timegm): New function, used where timegm is unavailable. + * cmpt.c (timegm): Remove unused variable. + +2005-07-05 Hrvoje Niksic + + * cmpt.c (timegm): Don't call mktime; simply count the seconds + between 1970-01-01 and the specified date. + +2005-07-05 Hrvoje Niksic + + * wget.h (or): Define HAVE_SSL when either HAVE_OPENSSL or + HAVE_GNUTLS are defined. + + * gnutls.c: New file. 2005-07-05 Hrvoje Niksic * http.c (gethttp): Don't print the request write error message twice. - (http_atotm): Use timegm instead of mktime_from_utc. + +2005-07-04 Hrvoje Niksic + + * openssl.c (openssl_errstr): Instead of always using a large + static buffer, only allocate the error string when there is an + actual error. 2005-07-04 Hrvoje Niksic * xmalloc.c (debugging_free): Prefix hex pointer value with "0x" when printing. +2005-07-04 Hrvoje Niksic + + * utils.c (NEXT_BASE64_CHAR): Rename to NEXT_CHAR and simplify to + get the next non-whitespace character. + +2005-07-04 Hrvoje Niksic + + * utils.c (base64_decode): Don't silently tolerate non-base64 + non-white-space characters in the base64 stream. + +2005-07-04 Hrvoje Niksic + + * connect.c (LAZY_RETRIEVE_INFO): Make last_tick unsigned to match + transport_map_modified_tick. + +2005-07-04 Hrvoje Niksic + + * config-post.h (alloca): Updated declaration to not enumerate all + Windows compilers. + +2005-07-04 Hrvoje Niksic + + * openssl.c (openssl_errstr): Separate error messages with "; ". + +2005-07-03 Hrvoje Niksic + + * ftp.c (getftp): Ditto. + + * http.c (gethttp): Use fd_errstr. + + * connect.c (fd_register_transport): Restructure parameters to + include only a single structure that describes transport + implementation. + + * openssl.c (openssl_errstr): New function: dump SSL error strings + into a static buffer and return a pointer to the buffer. + + * connect.c (fd_errstr): New function; returns transport-specific + error message, or strerror(errno) if transport doesn't supply one. + 2005-07-03 Hrvoje Niksic * mswindows.h: Also wrap accept() and listen(). +2005-07-03 Hrvoje Niksic + + * url.c (path_end): Skip separators appropriate for the scheme. + (strpbrk_or_eos): Remove gcc-specific version, as the optimization + it tried to perform no longer applies. + 2005-07-02 Hrvoje Niksic * host.c: Don't include "connect.h" now that we no longer have socket_has_inet6. - * host.c: Remove extraneous include of netdb.h. +2005-07-02 Hrvoje Niksic + + * host.c: Remove extraneous definition of netdb.h. 2005-07-02 Hrvoje Niksic * http.c (gethttp): Skip error message body in the keep-alive case. +2005-07-02 Hrvoje Niksic + + * url.c (url_parse): Would crash when parsing fragments. Support + fragments for FTP URLs too. + +2005-07-02 Hrvoje Niksic + + * version.c: Don't use "cvs" in version name, since we're not + using CVS anymore. + +2005-07-02 Hrvoje Niksic + + * progress.c (create_image): Ditto. + + * retr.c (retr_rate): Display smaller rate numbers with greater + precision. + +2005-07-02 Hrvoje Niksic + + * http.c (response_head_terminator): Minor optimization. + + * retr.c (fd_read_hunk): Call terminator with pointer to the start + of the data and the pointer to the current data. Changed all + callers. + 2005-07-01 Hrvoje Niksic - * url.c (url_parse): Don't crash on []-delimited IPv6 addresses - followed by garbage. + * url.c (url_parse): Make sure u->params is not initialized for + http/https URLs. + (url_parse): Don't crash on garbage following []-delimited IPv6 + addresses. 2005-07-01 Hrvoje Niksic * main.c (print_help): Don't refer to the non-existent -nr in description of --mirror. +2005-06-30 Hrvoje Niksic + + * host.c (pretty_print_address): Renamed to just print_address. + Clarify documentation. + +2005-06-30 Hrvoje Niksic + + * http.c (gethttp): Explicitly document the different cases when + generating the Host header. + +2005-06-30 Hrvoje Niksic + + * host.c (pretty_print_address): Handle error result from + inet_ntop. + +2005-06-30 Gisle Vanem + + * mswindows.c (inet_ntop): New function. Print IPv6 addresses + using WSAAddressToString. + +2005-06-27 Hrvoje Niksic + + * progress.c (dot_update): Remove unused variable row_qty. + +2005-06-29 Hrvoje Niksic + + * main.c: Check for both SIGHUP and SIGUSR1 before using them. + +2005-06-29 Hrvoje Niksic + + * utils.c: Unconditionally include locale.h. + +2005-06-29 Hrvoje Niksic + + * ptimer.c: Include sys/time.h to get struct timeval. + +2005-06-29 Hrvoje Niksic + + * wget.h: Remove obsolete definition of with_thousand_seps_sum. + +2005-06-29 Hrvoje Niksic + + * gnu-md5.h: Unconditionally include limits.h. + +2005-06-29 Hrvoje Niksic + + * utils.c (random_number): Use lrand48 if available. + (random_float): Use drand48 if available. + +2005-06-29 Hrvoje Niksic + + * main.c (secs_to_human_time): Use print_decimal when printing + total download time in seconds. + + * progress.c (print_row_stats): Use it to print total download + time at the end of the download. + (create_image): Ditto. + + * utils.c (print_decimal): New function; print small decimal + numbers with more precision than large ones. + + * progress.c (print_row_stats): New function. Print ETA after the + download rate at the end of each row. + 2005-06-28 Hrvoje Niksic * init.c (parse_line): Check for alphanumerics. 2005-06-28 Hrvoje Niksic + * (dot_create): Remove unnecessary casts. + +2005-06-28 Hrvoje Niksic + * ftp.c (getftp): Delete trailing newlines from LIST output so lines don't come out with trailing \015\012 with -S. 2005-06-27 Hrvoje Niksic + * mswindows.h: Remove superfluous includes. + +2005-06-27 Hrvoje Niksic + + * config-post.h (alloca): Amend alloca declaration to take care of + all Win32 compilers, not just MSVC and MinGW. + +2005-06-27 Hrvoje Niksic + + * utils.c (get_grouping_data): Force separator to "." rather than + " " when "," is taken. + +2005-06-27 Hrvoje Niksic + + * wget.h (PTR_FORMAT): Cast the result of sizeof to int before + passing it to printf's %*. + + * retr.h: Declare output_stream and output_stream_regular. + + * ftp.h: Declare ftp_last_respline. + + * convert.h: Declare dl_url_file_map. + + * http.h: New file. + +2005-06-27 Hrvoje Niksic + * cookies.c: Make cookies_now static. 2005-06-27 Hrvoje Niksic @@ -98,12 +624,33 @@ 2005-06-27 Hrvoje Niksic - (get_grouping_data): Restore LC_NUMERIC after querying thousand - grouping info. + * sysdep.h: Use the system-provided fnmatch by default. + +2005-06-27 Hrvoje Niksic + + * http.c (mktime_from_utc): Renamed to timegm and moved to cmpt.c. + Don't compile it if GNU timegm is available. + (http_atotm): Use timegm. + +2005-06-27 Hrvoje Niksic + + * http.c (http_atotm): Correctly query the old locale value. + +2005-06-27 Hrvoje Niksic + + * config-post.h (alloca): Don't #define alloca under MinGW32, + which defines it in malloc.h, included from mswindows.h. 2005-06-27 Hrvoje Niksic - * utils.c (get_grouping_data): Would omit separators in C locale. + * utils.c (get_grouping_data): Force the use of separators in C + locale. + +2005-06-27 Hrvoje Niksic + + * main.c (i18n_initialize): Set all locale categories. + + * http.c (http_atotm): Temporarily set locale to "C". 2005-06-27 Hrvoje Niksic @@ -112,32 +659,81 @@ 2005-06-27 Hrvoje Niksic - * utils.c (add_thousand_seps): Add thousand separators using the - character and grouping rules appropriate for the locale, with the - exception that "," and 3-digit groups are used in the locales that - don't specify thousand separators. (For compatibility with the - output of Wget 1.10.) - Based on with_thousand_seps from the trunk. + * progress.c (set_progress_implementation): Type COLON as const + char *. 2005-06-27 Hrvoje Niksic - * Makefile.in: Don't remove .libs; adapt to the use of - AC_LIB_HAVE_LINKFLAGS. + * utils.c (with_thousand_seps): Handle negative numbers. + +2005-06-26 Hrvoje Niksic + + * progress.c (create_image): Mark the "eta" string for translation. + +2005-06-26 Hrvoje Niksic + + * html-url.c (get_urls_file): Don't explicitly set entry->next to + NULL since entry is already zeroed out. 2005-06-26 Gisle Vanem * mswindows.h: Define gai_strerror under MinGW. -2005-06-25 Hrvoje Niksic +2005-06-26 Hrvoje Niksic - * cookies.c (parse_set_cookies): Cast pointer subtraction to int - before using it with %d; AIX compiler warns on this. - Reported by Jens Schleusener. + * utils.c (with_thousand_seps): Correctly implement thousand seps + consisting of more than one character. + +2005-06-26 Hrvoje Niksic + + * main.c (secs_to_human_time): Ditto. + + * progress.c (create_image): Print more exact duration of very + short downloads. + + * main.c (secs_to_human_time): Don't translate time suffixes "h", + "m", and "s", which are not strictly SI, but are "accepted for use + with SI". + (secs_to_human_time): Print really small intervals as 0s, not + 0.00s. + +2005-06-26 Hrvoje Niksic + + * config-post.h: Replace the alloca declaration with the one from + the latest Autoconf manual. This should remove a warning with GCC + on AIX. + +2005-06-26 Hrvoje Niksic + + * ftp.c (getftp): Always invoke SIZE, not only when continuing a + download. + + * main.c (main): Ditto here. + + * progress.c (create_image): When the download is finished, print + how long it took. 2005-06-26 Hrvoje Niksic - * progress.c (create_image): Don't unnecessarily call - with_thousand_seps twice. + * main.c (main): Print the downloaded and quota amounts with the + "human_readable" function. + + * ftp.c (print_length): Ditto. + + * http.c (gethttp): Don't display thousand separators. + + * utils.c (with_thousand_seps): Rewritten to respect locale + settings and to be type size agnostic. + +2005-06-25 Hrvoje Niksic + + * utils.c (human_readable): Divide with 1024 instead of shifting + so the operation can work with non-integer N. + +2005-06-25 Hrvoje Niksic + + * progress.c (eta_to_human): New logic for more human-readable + ETA. 2005-06-25 Hrvoje Niksic @@ -170,6 +766,16 @@ * sysdeps.h (LARGE_INT): Renamed to SUM_SIZE_INT to better reflect its intent, and moved to wget.h. +2005-06-25 Hrvoje Niksic + + * Makefile.in: No need to clean .libs. + +2005-06-25 Hrvoje Niksic + + * cookies.c (parse_set_cookies): Cast pointer subtraction to int + before using it with %d; AIX compiler warns on this. + Reported by Jens Schleusener. + 2005-06-24 Hrvoje Niksic * http.c (gethttp): Don't prepend / here. @@ -177,6 +783,16 @@ * cookies.c (cookie_handle_set_cookie): Prepend / to PATH. (cookie_header): Ditto. +2005-06-24 Hrvoje Niksic + + * init.c: opt.verbose must be declared as int. + +2005-06-23 Hrvoje Niksic + + * cmpt.c (strpbrk): Removed. + (mktime): Removed. + Include . + 2005-06-23 Hrvoje Niksic * utils.c (read_file): Ditto. @@ -186,6 +802,43 @@ * mswindows.h (struct_fstat): Define a struct_fstat to deal with the fact that Borland 5.5 has 64-bit stat, but not 64-bit fstat! +2005-06-23 Hrvoje Niksic + + * sysdep.h: Remove code that deals with Watcom. + +2005-06-22 Hrvoje Niksic + + * all: Use bool instead of int and false/true instead of 0/non-0 + for boolean variables and values. + +2005-06-22 Hrvoje Niksic + + * sysdep.h: Include the stdbool.h/_Bool/bool blurb from Autoconf. + +2005-06-22 Hrvoje Niksic + + * init.c (cmd_lockable_boolean): Removed. + +2005-06-22 Hrvoje Niksic + + * cookies.c (struct cookie): Use 1-bit bitfields for booleans + which makes the structure takes less space at no cost in + complexity. + +2005-06-22 Hrvoje Niksic + + * Makefile.in ($(OBJ)): Add the config.h dependency. + +2005-06-22 Hrvoje Niksic + + * openssl.c, connect.c, host.c: Replace instances of #ifdef + ENABLE_DEBUG if (opt.debug) {...} #endif with IF_DEBUG {...}. + + * main.c: Rename the IF_DEBUG defined here to WHEN_DEBUG. + + * wget.h (IF_DEBUG): New macro. + (DEBUGP): Define in terms of IF_DEBUG. + 2005-06-22 Hrvoje Niksic * http.c (gethttp): Only handle --set-cookies (and assert that @@ -195,9 +848,62 @@ 2005-06-22 Hrvoje Niksic + * connect.c (select_fd): Expect select() to exist. + + * utils.c (xsleep): Always use select() as sleep fallback on + non-Windows platforms. + + * ptimer.c: Delete the implementation of PTIMER_TIME. + + * main.c: Assume existence of signal(), test for different signal + names instead. + + * cmpt.c: Better document reasons why certain functions are + included. + +2005-06-22 Hrvoje Niksic + * Makefile.in: Remove the manually maintained dependency list; make all object files depend on every header. +2005-06-20 Hrvoje Niksic + + * hash.c: Rename "mapping" to "cell" to avoid confusion with the + term "mapping" (or "map") sometimes being used for the entire hash + table. Also rename "non-empty" to "occupied" for easier reading + of if (!NON_EMPTY (...)) ... . + +2005-06-20 Hrvoje Niksic + + * main.c, ptimer.c, sysdep.h, utils.c: Use #elif to simplify reading of + chained if-else-else-else-... statements. + +2005-06-20 Hrvoje Niksic + + * all: Return type of signal handlers is `void'. Include signal.h + unconditionally. + + * all: Don't explicitly cast values returned by malloc. We no + longer support ancient compilers that don't declare malloc, and we + never supported C++ builds. + +2005-06-19 Hrvoje Niksic + + * all: Don't declare errno. Include both time.h and sys/time.h, + as long as sys/time.h exists. Don't dereference function pointers + when invoking the functions they point to. + + * cmpt.c (memmove): Remove function mandated by C89. + (strerror): Ditto. + (strstr): Ditto. + + * all: Undo the K&R-ization changes from 2005-05-03. + + * all: Remove support for K&R compilers: use C89 function + declarations, remove definition of PARAMS, remove support for + varargs, and remove ansi2knr. Assume the presence of time.h, + string.h, and other headers mandated by C89. + 2005-06-19 Hrvoje Niksic * init.c (cmd_lockable_boolean): Don't recognize literal "2" and diff -urN wget-1.10.2/src/cmpt.c wget-1.10.2_new/src/cmpt.c --- wget-1.10.2/src/cmpt.c 2005-08-11 23:35:27.000000000 +0200 +++ wget-1.10.2_new/src/cmpt.c 2006-06-27 12:15:32.000000000 +0200 @@ -1,5 +1,5 @@ /* Replacements for routines missing on some systems. - Copyright (C) 1995-2005 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,38 +31,30 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ +#include +#include -#include #ifdef HAVE_UNISTD_H # include #endif -#include #include -#ifndef errno -extern int errno; -#endif #include "wget.h" -#ifndef HAVE_STRERROR -/* A strerror() clone, for systems that don't have it. */ -char * -strerror (int err) -{ - /* This loses on a system without `sys_errlist'. */ - extern char *sys_errlist[]; - return sys_errlist[err]; -} -#endif /* not HAVE_STRERROR */ - -/* Some systems don't have some str* functions in libc. Here we - define them. The same goes for strptime. */ +/* Some systems lack certain functions normally taken for granted. + For example, Windows doesn't have strptime, and some systems don't + have a usable fnmatch. This file should contain fallback + implementations of such missing functions. It should *not* define + new Wget-specific interfaces -- those should be placed in utils.c + or elsewhere. */ + +/* strcasecmp and strncasecmp apparently originated with BSD 4.4. + SUSv3 seems to be the only standard out there (that I can find) + that requires their existence, so in theory there might be systems + still in use that lack them. Note that these don't get defined + under Windows because mswindows.h defines them to the equivalent + Windows functions stricmp and strnicmp. */ #ifndef HAVE_STRCASECMP /* From GNU libc. */ @@ -120,395 +112,27 @@ } #endif /* not HAVE_STRNCASECMP */ -#ifndef HAVE_STRSTR -/* From GNU libc 2.3.5. */ - -/* - * My personal strstr() implementation that beats most other algorithms. - * Until someone tells me otherwise, I assume that this is the - * fastest implementation of strstr() in C. - * I deliberately chose not to comment it. You should have at least - * as much fun trying to understand it, as I had to write it :-). - * - * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */ - -typedef unsigned chartype; - -#undef strstr - -char * -strstr (const char *phaystack, const char *pneedle) -{ - const unsigned char *haystack, *needle; - chartype b; - const unsigned char *rneedle; - - haystack = (const unsigned char *) phaystack; - - if ((b = *(needle = (const unsigned char *) pneedle))) - { - chartype c; - haystack--; /* possible ANSI violation */ - - { - chartype a; - do - if (!(a = *++haystack)) - goto ret0; - while (a != b); - } - - if (!(c = *++needle)) - goto foundneedle; - ++needle; - goto jin; - - for (;;) - { - { - chartype a; - if (0) - jin:{ - if ((a = *++haystack) == c) - goto crest; - } - else - a = *++haystack; - do - { - for (; a != b; a = *++haystack) - { - if (!a) - goto ret0; - if ((a = *++haystack) == b) - break; - if (!a) - goto ret0; - } - } - while ((a = *++haystack) != c); - } - crest: - { - chartype a; - { - const unsigned char *rhaystack; - if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle))) - do - { - if (!a) - goto foundneedle; - if (*++rhaystack != (a = *++needle)) - break; - if (!a) - goto foundneedle; - } - while (*++rhaystack == (a = *++needle)); - needle = rneedle; /* took the register-poor aproach */ - } - if (!a) - break; - } - } - } -foundneedle: - return (char *) haystack; -ret0: - return 0; -} -#endif /* not HAVE_STRSTR */ - -#ifndef HAVE_STRPBRK -/* Find the first ocurrence in S of any character in ACCEPT. */ -char * -strpbrk (const char *s, const char *accept) -{ - while (*s != '\0') - { - const char *a = accept; - while (*a != '\0') - if (*a++ == *s) - return (char *) s; - ++s; - } - - return 0; -} -#endif /* HAVE_STRPBRK */ - -#ifndef HAVE_MKTIME -/* From GNU libc 2.0. */ - -/* Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Paul Eggert (eggert@twinsun.com). */ - -#ifdef _LIBC -# define HAVE_LIMITS_H 1 -# define HAVE_LOCALTIME_R 1 -# define STDC_HEADERS 1 -#endif - -/* Assume that leap seconds are possible, unless told otherwise. - If the host has a `zic' command with a `-L leapsecondfilename' option, - then it supports leap seconds; otherwise it probably doesn't. */ -#ifndef LEAP_SECONDS_POSSIBLE -# define LEAP_SECONDS_POSSIBLE 1 -#endif - -#ifndef __P -# define __P(args) PARAMS (args) -#endif /* Not __P. */ - -#ifndef CHAR_BIT -# define CHAR_BIT 8 -#endif - -#ifndef INT_MIN -# define INT_MIN (~0 << (sizeof (int) * CHAR_BIT - 1)) -#endif -#ifndef INT_MAX -# define INT_MAX (~0 - INT_MIN) -#endif - -#ifndef TIME_T_MIN -/* The outer cast to time_t works around a bug in Cray C 5.0.3.0. */ -# define TIME_T_MIN ((time_t) \ - (0 < (time_t) -1 ? (time_t) 0 \ - : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))) -#endif -#ifndef TIME_T_MAX -# define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN) -#endif - -#define TM_YEAR_BASE 1900 -#define EPOCH_YEAR 1970 +#ifndef HAVE_MEMRCHR +/* memrchr is a GNU extension. It is like the memchr function, except + that it searches backwards from the end of the n bytes pointed to + by s instead of forwards from the front. */ -#ifndef __isleap -/* Nonzero if YEAR is a leap year (every 4 years, - except every 100th isn't, and every 400th is). */ -# define __isleap(year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) -#endif - -/* How many days come before each month (0-12). */ -/* __mon_yday[][] is common to mktime and strptime implementations. - --abbotti */ -const unsigned short int __mon_yday[2][13]; -#ifndef NEED_MON_YDAY -# define NEED_MON_YDAY -#endif - -static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *)); -time_t __mktime_internal __P ((struct tm *, - struct tm *(*) (const time_t *, struct tm *), - time_t *)); - - -#ifdef _LIBC -# define localtime_r __localtime_r -#else -# if ! HAVE_LOCALTIME_R && ! defined localtime_r -/* Approximate localtime_r as best we can in its absence. */ -# define localtime_r my_mktime_localtime_r -static struct tm *localtime_r __P ((const time_t *, struct tm *)); -static struct tm * -localtime_r (t, tp) - const time_t *t; - struct tm *tp; -{ - struct tm *l = localtime (t); - if (! l) - return 0; - *tp = *l; - return tp; -} -# endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */ -#endif /* ! _LIBC */ - - -/* Yield the difference between (YEAR-YDAY HOUR:MIN:SEC) and (*TP), - measured in seconds, ignoring leap seconds. - YEAR uses the same numbering as TM->tm_year. - All values are in range, except possibly YEAR. - If overflow occurs, yield the low order bits of the correct answer. */ -static time_t -ydhms_tm_diff (year, yday, hour, min, sec, tp) - int year, yday, hour, min, sec; - const struct tm *tp; +void * +memrchr (const void *s, int c, size_t n) { - /* Compute intervening leap days correctly even if year is negative. - Take care to avoid int overflow. time_t overflow is OK, since - only the low order bits of the correct time_t answer are needed. - Don't convert to time_t until after all divisions are done, since - time_t might be unsigned. */ - int a4 = (year >> 2) + (TM_YEAR_BASE >> 2) - ! (year & 3); - int b4 = (tp->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (tp->tm_year & 3); - int a100 = a4 / 25 - (a4 % 25 < 0); - int b100 = b4 / 25 - (b4 % 25 < 0); - int a400 = a100 >> 2; - int b400 = b100 >> 2; - int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); - time_t years = year - (time_t) tp->tm_year; - time_t days = (365 * years + intervening_leap_days - + (yday - tp->tm_yday)); - return (60 * (60 * (24 * days + (hour - tp->tm_hour)) - + (min - tp->tm_min)) - + (sec - tp->tm_sec)); + const char *b = s; + const char *e = b + n; + while (e > b) + if (*--e == c) + return (void *) e; + return NULL; } - - -static time_t localtime_offset; - -/* Convert *TP to a time_t value. */ -time_t -mktime (tp) - struct tm *tp; -{ -#ifdef _LIBC - /* POSIX.1 8.1.1 requires that whenever mktime() is called, the - time zone names contained in the external variable `tzname' shall - be set as if the tzset() function had been called. */ - __tzset (); #endif - - return __mktime_internal (tp, localtime_r, &localtime_offset); -} - -/* Convert *TP to a time_t value, inverting - the monotonic and mostly-unit-linear conversion function CONVERT. - Use *OFFSET to keep track of a guess at the offset of the result, - compared to what the result would be for UTC without leap seconds. - If *OFFSET's guess is correct, only one CONVERT call is needed. */ -time_t -__mktime_internal (tp, convert, offset) - struct tm *tp; - struct tm *(*convert) __P ((const time_t *, struct tm *)); - time_t *offset; -{ - time_t t, dt, t0; - struct tm tm; - - /* The maximum number of probes (calls to CONVERT) should be enough - to handle any combinations of time zone rule changes, solar time, - and leap seconds. Posix.1 prohibits leap seconds, but some hosts - have them anyway. */ - int remaining_probes = 4; - - /* Time requested. Copy it in case CONVERT modifies *TP; this can - occur if TP is localtime's returned value and CONVERT is localtime. */ - int sec = tp->tm_sec; - int min = tp->tm_min; - int hour = tp->tm_hour; - int mday = tp->tm_mday; - int mon = tp->tm_mon; - int year_requested = tp->tm_year; - int isdst = tp->tm_isdst; - - /* Ensure that mon is in range, and set year accordingly. */ - int mon_remainder = mon % 12; - int negative_mon_remainder = mon_remainder < 0; - int mon_years = mon / 12 - negative_mon_remainder; - int year = year_requested + mon_years; - - /* The other values need not be in range: - the remaining code handles minor overflows correctly, - assuming int and time_t arithmetic wraps around. - Major overflows are caught at the end. */ - - /* Calculate day of year from year, month, and day of month. - The result need not be in range. */ - int yday = ((__mon_yday[__isleap (year + TM_YEAR_BASE)] - [mon_remainder + 12 * negative_mon_remainder]) - + mday - 1); - - int sec_requested = sec; -#if LEAP_SECONDS_POSSIBLE - /* Handle out-of-range seconds specially, - since ydhms_tm_diff assumes every minute has 60 seconds. */ - if (sec < 0) - sec = 0; - if (59 < sec) - sec = 59; -#endif - - /* Invert CONVERT by probing. First assume the same offset as last time. - Then repeatedly use the error to improve the guess. */ - - tm.tm_year = EPOCH_YEAR - TM_YEAR_BASE; - tm.tm_yday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - t0 = ydhms_tm_diff (year, yday, hour, min, sec, &tm); - - for (t = t0 + *offset; - (dt = ydhms_tm_diff (year, yday, hour, min, sec, (*convert) (&t, &tm))); - t += dt) - if (--remaining_probes == 0) - return -1; - - /* Check whether tm.tm_isdst has the requested value, if any. */ - if (0 <= isdst && 0 <= tm.tm_isdst) - { - int dst_diff = (isdst != 0) - (tm.tm_isdst != 0); - if (dst_diff) - { - /* Move two hours in the direction indicated by the disagreement, - probe some more, and switch to a new time if found. - The largest known fallback due to daylight savings is two hours: - once, in Newfoundland, 1988-10-30 02:00 -> 00:00. */ - time_t ot = t - 2 * 60 * 60 * dst_diff; - while (--remaining_probes != 0) - { - struct tm otm; - if (! (dt = ydhms_tm_diff (year, yday, hour, min, sec, - (*convert) (&ot, &otm)))) - { - t = ot; - tm = otm; - break; - } - if ((ot += dt) == t) - break; /* Avoid a redundant probe. */ - } - } - } - - *offset = t - t0; - -#if LEAP_SECONDS_POSSIBLE - if (sec_requested != tm.tm_sec) - { - /* Adjust time to reflect the tm_sec requested, not the normalized value. - Also, repair any damage from a false match due to a leap second. */ - t += sec_requested - sec + (sec == 0 && tm.tm_sec == 60); - (*convert) (&t, &tm); - } -#endif - - if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) - { - /* time_t isn't large enough to rule out overflows in ydhms_tm_diff, - so check for major overflows. A gross check suffices, - since if t has overflowed, it is off by a multiple of - TIME_T_MAX - TIME_T_MIN + 1. So ignore any component of - the difference that is bounded by a small value. */ - - double dyear = (double) year_requested + mon_years - tm.tm_year; - double dday = 366 * dyear + mday; - double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested; - - if (TIME_T_MAX / 3 - TIME_T_MIN / 3 < (dsec < 0 ? - dsec : dsec)) - return -1; - } - - *tp = tm; - return t; -} - -#ifdef weak_alias -weak_alias (mktime, timelocal) -#endif -#endif /* not HAVE_MKTIME */ - + +/* strptime is required by POSIX, but it is missing from Windows, + which means we must keep a fallback implementation. It is + reportedly missing or broken on many older Unix systems as well, so + it's good to have around. */ #ifndef HAVE_STRPTIME /* From GNU libc 2.1.3. */ @@ -525,7 +149,7 @@ this is enough information for determining the date. */ #ifndef __P -# define __P(args) PARAMS (args) +# define __P(args) args #endif /* not __P */ #if ! HAVE_LOCALTIME_R && ! defined localtime_r @@ -728,8 +352,6 @@ # define HERE_T_FMT_AMPM "%I:%M:%S %p" # define HERE_T_FMT "%H:%M:%S" -/* __mon_yday[][] is common to mktime and strptime implementations. - --abbotti */ const unsigned short int __mon_yday[2][13]; # ifndef NEED_MON_YDAY # define NEED_MON_YDAY @@ -1057,10 +679,12 @@ } #endif if (!match_string (HERE_AM_STR, rp)) - if (match_string (HERE_PM_STR, rp)) - is_pm = 1; - else - return NULL; + { + if (match_string (HERE_PM_STR, rp)) + is_pm = 1; + else + return NULL; + } break; case 'r': #ifdef _NL_CURRENT @@ -1422,8 +1046,6 @@ #endif /* not HAVE_STRPTIME */ #ifdef NEED_MON_YDAY -/* __mon_yday[][] is common to mktime and strptime implementations. - --abbotti */ const unsigned short int __mon_yday[2][13] = { /* Normal years. */ @@ -1432,31 +1054,20 @@ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; #endif - -#ifndef HAVE_MEMMOVE -void * -memmove (char *dest, const char *source, unsigned length) -{ - char *d0 = dest; - if (source < dest) - /* Moving from low mem to hi mem; start at end. */ - for (source += length, dest += length; length; --length) - *--dest = *--source; - else if (source != dest) - { - /* Moving from hi mem to low mem; start at beginning. */ - for (; length; --length) - *dest++ = *source++; - } - return (void *) d0; -} -#endif /* not HAVE_MEMMOVE */ - -/* fnmatch is a POSIX function, but we include an implementation for - the sake of systems that don't have it. Furthermore, according to - anecdotal evidence, historical implementations of fnmatch are buggy - and unreliable. So we use our version, except when compiling under - systems where fnmatch is known to work (currently glibc.) */ + +/* fnmatch is required by POSIX, but we include an implementation for + the sake of systems that don't have it, most notably Windows. Some + systems do have fnmatch, but Apache's installation process installs + its own fnmatch.h (incompatible with the system one!) in a system + include directory, effectively rendering fnmatch unusable. This + has been fixed with Apache 2, where fnmatch has been moved to apr + and given a prefix, but many systems out there are still (as of + this writing in 2005) broken and we must cater to them. + + Additionally, according to some conventional wisdom, many + historical implementations of fnmatch are buggy and unreliable. If + yours is such, undefine SYSTEM_FNMATCH in sysdep.h and tell us + about it. */ #ifndef SYSTEM_FNMATCH @@ -1465,8 +1076,8 @@ /* Match STRING against the filename pattern PATTERN, returning zero if it matches, FNM_NOMATCH if not. This implementation comes from an earlier version of GNU Bash. (It doesn't make sense to update - it with a newer version because it adds a lot of features Wget - doesn't use or care about.) */ + it with a newer version because those versions add a lot of + features Wget doesn't use or care about.) */ int fnmatch (const char *pattern, const char *string, int flags) @@ -1541,7 +1152,8 @@ { register const char *np; - for (np = p; np && *np && *np != ']'; np++); + for (np = p; np && *np && *np != ']'; np++) + ; if (np && !*np) { @@ -1703,9 +1315,9 @@ return value; } -#define LL strtoll_return /* long long or __int64 */ +#define LL strtoll_type /* long long or __int64 */ -/* These constants assume 64-bit strtoll_return. */ +/* These constants assume 64-bit strtoll_type. */ /* A roundabout way of writing 2**63-1 = 9223372036854775807 */ #define STRTOLL_OVERFLOW (((LL) 1 << 62) - 1 + ((LL) 1 << 62)) @@ -1713,14 +1325,14 @@ #define STRTOLL_UNDERFLOW (-STRTOLL_OVERFLOW - 1) /* A strtoll replacement for systems that have LFS but don't supply - strtoll. The headers typedef strtoll_return to long long or to + strtoll. The headers typedef strtoll_type to long long or to __int64. */ -strtoll_return +strtoll_type strtoll (const char *nptr, char **endptr, int base) { - strtoll_return result = 0; - int negative; + strtoll_type result = 0; + bool negative; if (base != 0 && (base < 2 || base > 36)) { @@ -1732,16 +1344,16 @@ ++nptr; if (*nptr == '-') { - negative = 1; + negative = true; ++nptr; } else if (*nptr == '+') { - negative = 0; + negative = false; ++nptr; } else - negative = 0; + negative = false; /* If base is 0, determine the real base based on the beginning on the number; octal numbers begin with "0", hexadecimal with "0x", @@ -1754,6 +1366,13 @@ { base = 16; nptr += 2; + /* "0x" must be followed by at least one hex char. If not, + return 0 and place ENDPTR on 'x'. */ + if (!ISXDIGIT (*nptr)) + { + --nptr; + goto out; + } } else if (base == 0) base = 8; @@ -1767,7 +1386,7 @@ int val; for (; (val = char_value (*nptr, base)) != -1; ++nptr) { - strtoll_return newresult = base * result + val; + strtoll_type newresult = base * result + val; if (newresult < result) { result = STRTOLL_OVERFLOW; @@ -1783,7 +1402,7 @@ int val; for (; (val = char_value (*nptr, base)) != -1; ++nptr) { - strtoll_return newresult = base * result - val; + strtoll_type newresult = base * result - val; if (newresult > result) { result = STRTOLL_UNDERFLOW; @@ -1793,6 +1412,7 @@ result = newresult; } } + out: if (endptr) *endptr = (char *) nptr; return result; diff -urN wget-1.10.2/src/config.h.in wget-1.10.2_new/src/config.h.in --- wget-1.10.2/src/config.h.in 2005-10-13 11:22:28.000000000 +0200 +++ wget-1.10.2_new/src/config.h.in 2006-06-27 12:16:40.000000000 +0200 @@ -23,9 +23,6 @@ /* Define if you want the Opie support for FTP compiled in. */ #undef ENABLE_OPIE -/* Define to 1 if you have the `access' function. */ -#undef HAVE_ACCESS - /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA @@ -33,12 +30,15 @@ */ #undef HAVE_ALLOCA_H -/* Define to use built-in MD5. */ +/* Define when using built-in MD5. */ #undef HAVE_BUILTIN_MD5 /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME +/* Define to 1 if you have the `drand48' function. */ +#undef HAVE_DRAND48 + /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO @@ -57,9 +57,6 @@ /* Define to 1 if you have the `gettext' function. */ #undef HAVE_GETTEXT -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA @@ -72,6 +69,9 @@ /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL +/* Define if you have the gnutls library. */ +#undef HAVE_LIBGNUTLS + /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H @@ -87,23 +87,14 @@ /* Define if you have the ssl library. */ #undef HAVE_LIBSSL -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LOCALE_H - /* Define if we're compiling support for MD5. */ #undef HAVE_MD5 -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* Define to 1 if you have the `mktime' function. */ -#undef HAVE_MKTIME +/* Define to 1 if you have the `memrchr' function. */ +#undef HAVE_MEMRCHR /* Define to 1 if you have a working `mmap' system call. */ #undef HAVE_MMAP @@ -114,27 +105,15 @@ /* Define this if you want the NLS support. */ #undef HAVE_NLS -/* Define to use OpenSSL MD5. */ +/* Define when using OpenSSL MD5. */ #undef HAVE_OPENSSL_MD5 /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H -/* Define to 1 if you have the `select' function. */ -#undef HAVE_SELECT - -/* Define to 1 if you have the header file. */ -#undef HAVE_SETJMP_H - /* Define to 1 if you have the `sigblock' function. */ #undef HAVE_SIGBLOCK -/* Define to 1 if you have the `signal' function. */ -#undef HAVE_SIGNAL - -/* Define to 1 if you have the header file. */ -#undef HAVE_SIGNAL_H - /* Define to 1 if you have the `sigsetjmp' function. */ #undef HAVE_SIGSETJMP @@ -147,14 +126,11 @@ /* Define if struct sockaddr_in6 has the sin6_scope_id member */ #undef HAVE_SOCKADDR_IN6_SCOPE_ID -/* Define to use Solaris MD5. */ +/* Define when using Solaris MD5. */ #undef HAVE_SOLARIS_MD5 -/* Define if SSL support is being compiled in. */ -#undef HAVE_SSL - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDARG_H +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H @@ -168,9 +144,6 @@ /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP -/* Define to 1 if you have the `strerror' function. */ -#undef HAVE_STRERROR - /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H @@ -180,15 +153,9 @@ /* Define to 1 if you have the `strncasecmp' function. */ #undef HAVE_STRNCASECMP -/* Define to 1 if you have the `strpbrk' function. */ -#undef HAVE_STRPBRK - /* Define to 1 if you have the `strptime' function. */ #undef HAVE_STRPTIME -/* Define to 1 if you have the `strstr' function. */ -#undef HAVE_STRSTR - /* Define to 1 if you have the `strtoimax' function. */ #undef HAVE_STRTOIMAX @@ -234,6 +201,9 @@ /* Define to 1 if the system has the type `uint32_t'. */ #undef HAVE_UINT32_T +/* Define to 1 if the system has the type `uintptr_t'. */ +#undef HAVE_UINTPTR_T + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -243,12 +213,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UTIME_H +/* Define to 1 if you have the `vasprintf' function. */ +#undef HAVE_VASPRINTF + /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define if fnmatch.h can be included. */ #undef HAVE_WORKING_FNMATCH_H +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + /* Define to be the name of the operating system. */ #undef OS_TYPE @@ -267,12 +243,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Define to 1 if the C compiler supports function prototypes. */ -#undef PROTOTYPES - -/* Define as the return type of signal handlers (`int' or `void'). */ -#undef RETSIGTYPE - /* The size of a `int', as computed by sizeof. */ #undef SIZEOF_INT @@ -288,6 +258,9 @@ /* The size of a `short', as computed by sizeof. */ #undef SIZEOF_SHORT +/* The size of a `void *', as computed by sizeof. */ +#undef SIZEOF_VOID_P + /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at run-time. @@ -299,9 +272,6 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN @@ -322,9 +292,6 @@ /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES -/* Define like PROTOTYPES; this can be used by system headers. */ -#undef __PROTOTYPES - /* Define to empty if `const' does not conform to ANSI C. */ #undef const diff -urN wget-1.10.2/src/config-post.h wget-1.10.2_new/src/config-post.h --- wget-1.10.2/src/config-post.h 2005-04-11 15:04:08.000000000 +0200 +++ wget-1.10.2_new/src/config-post.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,24 +1,12 @@ /* Some autoconf-unrelated preprocessor magic that needs to be done - before including the system includes and therefore cannot belong in - sysdep.h. This file is included at the bottom of config.h. */ + *before* including the system includes and therefore cannot belong + in sysdep.h. -/* Alloca-related defines, straight out of the Autoconf manual. */ + Everything else related to system tweaking belongs to sysdep.h. -/* AIX requires this to be the first thing in the file. */ -#ifndef __GNUC__ -# if HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -void *alloca (); -# endif -# endif -# endif -#endif + This file is included at the bottom of config.h. */ +/* Testing for __sun is not enough because it's also defined on SunOS. */ #ifdef __sun # ifdef __SVR4 # define solaris @@ -59,17 +47,33 @@ #define _SVID_SOURCE #define _BSD_SOURCE +/* Under glibc-based systems we want all GNU extensions as well. This + declares some unnecessary cruft, but also useful functions such as + timegm, FNM_CASEFOLD extension to fnmatch, memrchr, etc. */ +#define _GNU_SOURCE + #endif /* NAMESPACE_TWEAKS */ -/* Determine whether to use stdarg. Use it only if the compiler - supports ANSI C and stdarg.h is present. We check for both because - there are configurations where stdarg.h exists, but doesn't work. - This check cannot be in sysdep.h because we use it to choose which - system headers to include. */ -#ifndef WGET_USE_STDARG -# ifdef __STDC__ -# ifdef HAVE_STDARG_H -# define WGET_USE_STDARG -# endif + +/* Alloca declaration, based on recommendation in the Autoconf manual. + These have to be after the above namespace tweaks, but before any + non-preprocessor code. */ + +#if HAVE_ALLOCA_H +# include +#elif defined WINDOWS +# include +# ifndef alloca +# define alloca _alloca +# endif +#elif defined __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#else +# include +# ifdef __cplusplus +extern "C" # endif -#endif /* not WGET_USE_STDARG */ +void *alloca (size_t); +#endif diff -urN wget-1.10.2/src/connect.c wget-1.10.2_new/src/connect.c --- wget-1.10.2/src/connect.c 2005-06-19 15:47:10.000000000 +0200 +++ wget-1.10.2_new/src/connect.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Establishing and handling network connections. - Copyright (C) 1995, 1996, 1997, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,7 +31,6 @@ #include #include -#include #ifdef HAVE_UNISTD_H # include #endif @@ -47,11 +46,7 @@ #endif /* not WINDOWS */ #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ +#include #ifdef HAVE_SYS_SELECT_H # include #endif /* HAVE_SYS_SELECT_H */ @@ -62,10 +57,6 @@ #include "connect.h" #include "hash.h" -#ifndef errno -extern int errno; -#endif - /* Define sockaddr_storage where unavailable (presumably on IPv4-only hosts). */ @@ -82,27 +73,27 @@ static void sockaddr_set_data (struct sockaddr *sa, const ip_address *ip, int port) { - switch (ip->type) + switch (ip->family) { - case IPV4_ADDRESS: + case AF_INET: { struct sockaddr_in *sin = (struct sockaddr_in *)sa; xzero (*sin); sin->sin_family = AF_INET; sin->sin_port = htons (port); - sin->sin_addr = ADDRESS_IPV4_IN_ADDR (ip); + sin->sin_addr = ip->data.d4; break; } #ifdef ENABLE_IPV6 - case IPV6_ADDRESS: + case AF_INET6: { struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; xzero (*sin6); sin6->sin6_family = AF_INET6; sin6->sin6_port = htons (port); - sin6->sin6_addr = ADDRESS_IPV6_IN6_ADDR (ip); + sin6->sin6_addr = ip->data.d6; #ifdef HAVE_SOCKADDR_IN6_SCOPE_ID - sin6->sin6_scope_id = ADDRESS_IPV6_SCOPE (ip); + sin6->sin6_scope_id = ip->ipv6_scope; #endif break; } @@ -126,8 +117,8 @@ struct sockaddr_in *sin = (struct sockaddr_in *)sa; if (ip) { - ip->type = IPV4_ADDRESS; - ADDRESS_IPV4_IN_ADDR (ip) = sin->sin_addr; + ip->family = AF_INET; + ip->data.d4 = sin->sin_addr; } if (port) *port = ntohs (sin->sin_port); @@ -139,10 +130,10 @@ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; if (ip) { - ip->type = IPV6_ADDRESS; - ADDRESS_IPV6_IN6_ADDR (ip) = sin6->sin6_addr; + ip->family = AF_INET6; + ip->data.d6 = sin6->sin6_addr; #ifdef HAVE_SOCKADDR_IN6_SCOPE_ID - ADDRESS_IPV6_SCOPE (ip) = sin6->sin6_scope_id; + ip->ipv6_scope = sin6->sin6_scope_id; #endif } if (port) @@ -174,14 +165,20 @@ } } -static int +/* Resolve the bind address specified via --bind-address and store it + to SA. The resolved value is stored in a static variable and + reused after the first invocation of this function. + + Returns true on success, false on failure. */ + +static bool resolve_bind_address (struct sockaddr *sa) { struct address_list *al; /* Make sure this is called only once. opt.bind_address doesn't change during a Wget run. */ - static int called, should_bind; + static bool called, should_bind; static ip_address ip; if (called) { @@ -189,7 +186,7 @@ sockaddr_set_data (sa, &ip, 0); return should_bind; } - called = 1; + called = true; al = lookup_host (opt.bind_address, LH_BIND | LH_SILENT); if (!al) @@ -198,8 +195,8 @@ logprintf (LOG_NOTQUIET, _("%s: unable to resolve bind address `%s'; disabling bind.\n"), exec_name, opt.bind_address); - should_bind = 0; - return 0; + should_bind = false; + return false; } /* Pick the first address in the list and use it as bind address. @@ -209,8 +206,8 @@ address_list_release (al); sockaddr_set_data (sa, &ip, 0); - should_bind = 1; - return 1; + should_bind = true; + return true; } struct cwt_context { @@ -266,7 +263,7 @@ PRINT being the host name we're connecting to. */ if (print) { - const char *txt_addr = pretty_print_address (ip); + const char *txt_addr = print_address (ip); if (print && 0 != strcmp (print, txt_addr)) logprintf (LOG_VERBOSE, _("Connecting to %s|%s|:%d... "), escnonprint (print), txt_addr, port); @@ -287,10 +284,9 @@ int on = 1; /* In case of error, we will go on anyway... */ int err = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on)); -#ifdef ENABLE_DEBUG - if (err < 0) - DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno))); -#endif + IF_DEBUG + if (err < 0) + DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno))); } #endif @@ -419,7 +415,6 @@ bind_local (const ip_address *bind_address, int *port) { int sock; - int family = AF_INET; struct sockaddr_storage ss; struct sockaddr *sa = (struct sockaddr *)&ss; @@ -428,12 +423,7 @@ void *setopt_ptr = (void *)&setopt_val; socklen_t setopt_size = sizeof (setopt_val); -#ifdef ENABLE_IPV6 - if (bind_address->type == IPV6_ADDRESS) - family = AF_INET6; -#endif - - sock = socket (family, SOCK_STREAM, 0); + sock = socket (bind_address->family, SOCK_STREAM, 0); if (sock < 0) return -1; @@ -464,8 +454,8 @@ return -1; } sockaddr_get_data (sa, NULL, port); - DEBUGP (("binding to address %s using port %i.\n", - pretty_print_address (bind_address), *port)); + DEBUGP (("binding to address %s using port %i.\n", + print_address (bind_address), *port)); } if (listen (sock, 1) < 0) { @@ -510,13 +500,13 @@ } /* Get the IP address associated with the connection on FD and store - it to IP. Return 1 on success, 0 otherwise. + it to IP. Return true on success, false otherwise. If ENDPOINT is ENDPOINT_LOCAL, it returns the address of the local (client) side of the socket. Else if ENDPOINT is ENDPOINT_PEER, it returns the address of the remote (peer's) side of the socket. */ -int +bool socket_ip_address (int sock, ip_address *ip, int endpoint) { struct sockaddr_storage storage; @@ -531,48 +521,47 @@ else abort (); if (ret < 0) - return 0; + return false; + ip->family = sockaddr->sa_family; switch (sockaddr->sa_family) { #ifdef ENABLE_IPV6 case AF_INET6: { struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&storage; - ip->type = IPV6_ADDRESS; - ADDRESS_IPV6_IN6_ADDR (ip) = sa6->sin6_addr; + ip->data.d6 = sa6->sin6_addr; #ifdef HAVE_SOCKADDR_IN6_SCOPE_ID - ADDRESS_IPV6_SCOPE (ip) = sa6->sin6_scope_id; + ip->ipv6_scope = sa6->sin6_scope_id; #endif - DEBUGP (("conaddr is: %s\n", pretty_print_address (ip))); - return 1; + DEBUGP (("conaddr is: %s\n", print_address (ip))); + return true; } #endif case AF_INET: { struct sockaddr_in *sa = (struct sockaddr_in *)&storage; - ip->type = IPV4_ADDRESS; - ADDRESS_IPV4_IN_ADDR (ip) = sa->sin_addr; - DEBUGP (("conaddr is: %s\n", pretty_print_address (ip))); - return 1; + ip->data.d4 = sa->sin_addr; + DEBUGP (("conaddr is: %s\n", print_address (ip))); + return true; } default: abort (); } } -/* Return non-zero if the error from the connect code can be - considered retryable. Wget normally retries after errors, but the - exception are the "unsupported protocol" type errors (possible on - IPv4/IPv6 dual family systems) and "connection refused". */ +/* Return true if the error from the connect code can be considered + retryable. Wget normally retries after errors, but the exception + are the "unsupported protocol" type errors (possible on IPv4/IPv6 + dual family systems) and "connection refused". */ -int +bool retryable_socket_connect_error (int err) { /* Have to guard against some of these values not being defined. Cannot use a switch statement because some of the values might be equal. */ - if (0 + if (false #ifdef EAFNOSUPPORT || err == EAFNOSUPPORT #endif @@ -592,7 +581,7 @@ instead of EAFNOSUPPORT and such. */ || err == EINVAL ) - return 0; + return false; if (!opt.retry_connrefused) if (err == ECONNREFUSED @@ -603,9 +592,9 @@ || err == EHOSTUNREACH /* host is unreachable */ #endif ) - return 0; + return false; - return 1; + return true; } /* Wait for a single descriptor to become available, timing out after @@ -620,7 +609,6 @@ int select_fd (int fd, double maxtime, int wait_for) { -#ifdef HAVE_SELECT fd_set fdset; fd_set *rd = NULL, *wr = NULL; struct timeval tmout; @@ -641,23 +629,22 @@ while (result < 0 && errno == EINTR); return result; +} -#else /* not HAVE_SELECT */ - - /* If select() unavailable, just return 1. In most usages in Wget, - this is the appropriate response -- "if we can't poll, go ahead - with the blocking operation". If a specific part of code needs - different behavior, it can use #ifdef HAVE_SELECT to test whether - polling really occurs. */ - return 1; +/* Return true iff the connection to the remote site established + through SOCK is still open. -#endif /* not HAVE_SELECT */ -} + Specifically, this function returns true if SOCK is not ready for + reading. This is because, when the connection closes, the socket + is ready for reading because EOF is about to be delivered. A side + effect of this method is that sockets that have pending data are + considered non-open. This is actually a good thing for callers of + this function, where such pending data can only be unwanted + leftover from a previous request. */ -int +bool test_socket_open (int sock) { -#ifdef HAVE_SELECT fd_set check_set; struct timeval to; @@ -671,18 +658,13 @@ to.tv_sec = 0; to.tv_usec = 1; - /* If we get a timeout, then that means still connected */ if (select (sock + 1, &check_set, NULL, NULL, &to) == 0) - { - /* Connection is valid (not EOF), so continue */ - return 1; - } + /* We got a timeout, it means we're still connected. */ + return true; else - return 0; -#else - /* Without select, it's hard to know for sure. */ - return 1; -#endif + /* Read now would not wait, it means we have either pending data + or EOF/error. */ + return false; } /* Basic socket operations, mostly EINTR wrappers. */ @@ -753,14 +735,10 @@ or SSL_read or whatever is necessary. */ static struct hash_table *transport_map; -static int transport_map_modified_tick; +static unsigned int transport_map_modified_tick; struct transport_info { - fd_reader_t reader; - fd_writer_t writer; - fd_poller_t poller; - fd_peeker_t peeker; - fd_closer_t closer; + struct transport_implementation *imp; void *ctx; }; @@ -772,9 +750,7 @@ call getpeername, etc. */ void -fd_register_transport (int fd, fd_reader_t reader, fd_writer_t writer, - fd_poller_t poller, fd_peeker_t peeker, - fd_closer_t closer, void *ctx) +fd_register_transport (int fd, struct transport_implementation *imp, void *ctx) { struct transport_info *info; @@ -784,11 +760,7 @@ assert (fd >= 0); info = xnew (struct transport_info); - info->reader = reader; - info->writer = writer; - info->poller = poller; - info->peeker = peeker; - info->closer = closer; + info->imp = imp; info->ctx = ctx; if (!transport_map) transport_map = hash_table_new (0, NULL, NULL); @@ -818,7 +790,8 @@ #define LAZY_RETRIEVE_INFO(info) do { \ static struct transport_info *last_info; \ - static int last_fd = -1, last_tick; \ + static int last_fd = -1; \ + static unsigned int last_tick; \ if (!transport_map) \ info = NULL; \ else if (last_fd == fd && last_tick == transport_map_modified_tick) \ @@ -832,7 +805,7 @@ } \ } while (0) -static int +static bool poll_internal (int fd, struct transport_info *info, int wf, double timeout) { if (timeout == -1) @@ -840,16 +813,16 @@ if (timeout) { int test; - if (info && info->poller) - test = info->poller (fd, timeout, wf, info->ctx); + if (info && info->imp->poller) + test = info->imp->poller (fd, timeout, wf, info->ctx); else test = sock_poll (fd, timeout, wf); if (test == 0) errno = ETIMEDOUT; if (test <= 0) - return 0; + return false; } - return 1; + return true; } /* Read no more than BUFSIZE bytes of data from FD, storing them to @@ -864,8 +837,8 @@ LAZY_RETRIEVE_INFO (info); if (!poll_internal (fd, info, WAIT_FOR_READ, timeout)) return -1; - if (info && info->reader) - return info->reader (fd, buf, bufsize, info->ctx); + if (info && info->imp->reader) + return info->imp->reader (fd, buf, bufsize, info->ctx); else return sock_read (fd, buf, bufsize); } @@ -889,8 +862,8 @@ LAZY_RETRIEVE_INFO (info); if (!poll_internal (fd, info, WAIT_FOR_READ, timeout)) return -1; - if (info && info->peeker) - return info->peeker (fd, buf, bufsize, info->ctx); + if (info && info->imp->peeker) + return info->imp->peeker (fd, buf, bufsize, info->ctx); else return sock_peek (fd, buf, bufsize); } @@ -914,8 +887,8 @@ { if (!poll_internal (fd, info, WAIT_FOR_WRITE, timeout)) return -1; - if (info && info->writer) - res = info->writer (fd, buf, bufsize, info->ctx); + if (info && info->imp->writer) + res = info->imp->writer (fd, buf, bufsize, info->ctx); else res = sock_write (fd, buf, bufsize); if (res <= 0) @@ -926,6 +899,35 @@ return res; } +/* Report the most recent error(s) on FD. This should only be called + after fd_* functions, such as fd_read and fd_write, and only if + they return a negative result. For errors coming from other calls + such as setsockopt or fopen, strerror should continue to be + used. + + If the transport doesn't support error messages or doesn't supply + one, strerror(errno) is returned. The returned error message + should not be used after fd_close has been called. */ + +const char * +fd_errstr (int fd) +{ + /* Don't bother with LAZY_RETRIEVE_INFO, as this will only be called + in case of error, never in a tight loop. */ + struct transport_info *info = NULL; + if (transport_map) + info = hash_table_get (transport_map, (void *) fd); + + if (info && info->imp->errstr) + { + const char *err = info->imp->errstr (fd, info->ctx); + if (err) + return err; + /* else, fall through and print the system error. */ + } + return strerror (errno); +} + /* Close the file descriptor FD. */ void @@ -941,8 +943,8 @@ if (transport_map) info = hash_table_get (transport_map, (void *) fd); - if (info && info->closer) - info->closer (fd, info->ctx); + if (info && info->imp->closer) + info->imp->closer (fd, info->ctx); else sock_close (fd); diff -urN wget-1.10.2/src/connect.h wget-1.10.2_new/src/connect.h --- wget-1.10.2/src/connect.h 2005-06-19 15:47:10.000000000 +0200 +++ wget-1.10.2_new/src/connect.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for connect. - Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -38,40 +38,43 @@ enum { E_HOST = -100 }; -int connect_to_host PARAMS ((const char *, int)); -int connect_to_ip PARAMS ((const ip_address *, int, const char *)); +int connect_to_host (const char *, int); +int connect_to_ip (const ip_address *, int, const char *); -int bind_local PARAMS ((const ip_address *, int *)); -int accept_connection PARAMS ((int)); +int bind_local (const ip_address *, int *); +int accept_connection (int); enum { ENDPOINT_LOCAL, ENDPOINT_PEER }; -int socket_ip_address PARAMS ((int, ip_address *, int)); +bool socket_ip_address (int, ip_address *, int); -int retryable_socket_connect_error PARAMS ((int)); +bool retryable_socket_connect_error (int); /* Flags for select_fd's WAIT_FOR argument. */ enum { WAIT_FOR_READ = 1, WAIT_FOR_WRITE = 2 }; -int select_fd PARAMS ((int, double, int)); -int test_socket_open PARAMS ((int)); +int select_fd (int, double, int); +bool test_socket_open (int); + +struct transport_implementation { + int (*reader) (int, char *, int, void *); + int (*writer) (int, char *, int, void *); + int (*poller) (int, double, int, void *); + int (*peeker) (int, char *, int, void *); + const char *(*errstr) (int, void *); + void (*closer) (int, void *); +}; + +void fd_register_transport (int, struct transport_implementation *, void *); +void *fd_transport_context (int); +int fd_read (int, char *, int, double); +int fd_write (int, char *, int, double); +int fd_peek (int, char *, int, double); +const char *fd_errstr (int); +void fd_close (int); -typedef int (*fd_reader_t) PARAMS ((int, char *, int, void *)); -typedef int (*fd_writer_t) PARAMS ((int, char *, int, void *)); -typedef int (*fd_poller_t) PARAMS ((int, double, int, void *)); -typedef int (*fd_peeker_t) PARAMS ((int, char *, int, void *)); -typedef void (*fd_closer_t) PARAMS ((int, void *)); -void fd_register_transport PARAMS ((int, fd_reader_t, fd_writer_t, - fd_poller_t, fd_peeker_t, fd_closer_t, - void *)); -void *fd_transport_context PARAMS ((int)); - -int fd_read PARAMS ((int, char *, int, double)); -int fd_write PARAMS ((int, char *, int, double)); -int fd_peek PARAMS ((int, char *, int, double)); -void fd_close PARAMS ((int)); #endif /* CONNECT_H */ diff -urN wget-1.10.2/src/convert.c wget-1.10.2_new/src/convert.c --- wget-1.10.2/src/convert.c 2005-04-11 01:39:41.000000000 +0200 +++ wget-1.10.2_new/src/convert.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Conversion of links to local files. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,17 +31,12 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ +#include #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #include #include -#include #include "wget.h" #include "convert.h" @@ -58,7 +53,9 @@ conversion after Wget is done. */ struct hash_table *downloaded_html_set; -static void convert_links PARAMS ((const char *, struct urlpos *)); +static struct hash_table *nonexisting_urls_hash; + +static void convert_links (const char *, struct urlpos *); /* This function is called when the retrieval is done to convert the links that have been downloaded. It has to be called at the end of @@ -171,19 +168,18 @@ free_urlpos (urls); } - secs = ptimer_measure (timer) / 1000; + secs = ptimer_measure (timer); ptimer_destroy (timer); - logprintf (LOG_VERBOSE, _("Converted %d files in %.*f seconds.\n"), - file_count, secs < 10 ? 3 : 1, secs); + logprintf (LOG_VERBOSE, _("Converted %d files in %s seconds.\n"), + file_count, print_decimal (secs)); } -static void write_backup_file PARAMS ((const char *, downloaded_file_t)); -static const char *replace_attr PARAMS ((const char *, int, FILE *, - const char *)); -static const char *replace_attr_refresh_hack PARAMS ((const char *, int, FILE *, - const char *, int)); -static char *local_quote_string PARAMS ((const char *)); -static char *construct_relative PARAMS ((const char *, const char *)); +static void write_backup_file (const char *, downloaded_file_t); +static const char *replace_attr (const char *, int, FILE *, const char *); +static const char *replace_attr_refresh_hack (const char *, int, FILE *, + const char *, int); +static char *local_quote_string (const char *); +static char *construct_relative (const char *, const char *); /* Change the links in one HTML file. LINKS is a list of links in the document, along with their positions and the desired direction of @@ -388,7 +384,7 @@ } /* Construct LINK as explained above. */ - link = (char *)xmalloc (3 * basedirs + strlen (linkfile) + 1); + link = xmalloc (3 * basedirs + strlen (linkfile) + 1); for (i = 0; i < basedirs; i++) memcpy (link + 3 * i, "../", 3); strcpy (link + 3 * i, linkfile); @@ -468,15 +464,14 @@ } } -static int find_fragment PARAMS ((const char *, int, const char **, - const char **)); +static bool find_fragment (const char *, int, const char **, const char **); /* Replace an attribute's original text with NEW_TEXT. */ static const char * replace_attr (const char *p, int size, FILE *fp, const char *new_text) { - int quote_flag = 0; + bool quote_flag = false; char quote_char = '\"'; /* use "..." for quoting, unless the original value is quoted, in which case reuse its quoting char. */ @@ -492,7 +487,7 @@ if (*p == '\"' || *p == '\'') { quote_char = *p; - quote_flag = 1; + quote_flag = true; ++p; size -= 2; /* disregard opening and closing quote */ } @@ -530,36 +525,36 @@ /* Find the first occurrence of '#' in [BEG, BEG+SIZE) that is not preceded by '&'. If the character is not found, return zero. If - the character is found, return 1 and set BP and EP to point to the - beginning and end of the region. + the character is found, return true and set BP and EP to point to + the beginning and end of the region. This is used for finding the fragment indentifiers in URLs. */ -static int +static bool find_fragment (const char *beg, int size, const char **bp, const char **ep) { const char *end = beg + size; - int saw_amp = 0; + bool saw_amp = false; for (; beg < end; beg++) { switch (*beg) { case '&': - saw_amp = 1; + saw_amp = true; break; case '#': if (!saw_amp) { *bp = beg; *ep = end; - return 1; + return true; } /* fallthrough */ default: - saw_amp = 0; + saw_amp = false; } } - return 0; + return false; } /* Quote FILE for use as local reference to an HTML file. @@ -630,9 +625,9 @@ dl_url_file_map = make_string_hash_table (0); \ } while (0) -/* Return 1 if S1 and S2 are the same, except for "/index.html". The - three cases in which it returns one are (substitute any substring - for "foo"): +/* Return true if S1 and S2 are the same, except for "/index.html". + The three cases in which it returns one are (substitute any + substring for "foo"): m("foo/index.html", "foo/") ==> 1 m("foo/", "foo/index.html") ==> 1 @@ -640,7 +635,7 @@ m("foo", "foo/" ==> 1 m("foo", "foo") ==> 1 */ -static int +static bool match_except_index (const char *s1, const char *s2) { int i; @@ -653,14 +648,14 @@ /* Strings differ at the very beginning -- bail out. We need to check this explicitly to avoid `lng - 1' reading outside the array. */ - return 0; + return false; if (!*s1 && !*s2) /* Both strings hit EOF -- strings are equal. */ - return 1; + return true; else if (*s1 && *s2) /* Strings are randomly different, e.g. "/foo/bar" and "/foo/qux". */ - return 0; + return false; else if (*s1) /* S1 is the longer one. */ lng = s1; @@ -679,7 +674,7 @@ if (*lng == '/' && *(lng + 1) == '\0') /* foo */ /* foo/ */ - return 1; + return true; return 0 == strcmp (lng, "/index.html"); } @@ -707,8 +702,9 @@ static void dissociate_urls_from_file (const char *file) { - hash_table_map (dl_url_file_map, dissociate_urls_from_file_mapper, - (char *)file); + /* Can't use hash_table_iter_* because the table mutates while mapping. */ + hash_table_for_each (dl_url_file_map, dissociate_urls_from_file_mapper, + (char *) file); } /* Register that URL has been successfully downloaded to FILE. This @@ -837,7 +833,8 @@ string_set_add (downloaded_html_set, file); } -static void downloaded_files_free PARAMS ((void)); +static void downloaded_files_free (void); +static void nonexisting_urls_free (void); /* Cleanup the data structures associated with this file. */ @@ -859,6 +856,7 @@ if (downloaded_html_set) string_set_free (downloaded_html_set); downloaded_files_free (); + nonexisting_urls_free (); if (converted_files) string_set_free (converted_files); } @@ -944,24 +942,133 @@ return FILE_NOT_ALREADY_DOWNLOADED; } -static int -df_free_mapper (void *key, void *value, void *ignored) -{ - xfree (key); - return 0; -} - static void downloaded_files_free (void) { if (downloaded_files_hash) { - hash_table_map (downloaded_files_hash, df_free_mapper, NULL); + hash_table_iterator iter; + for (hash_table_iterate (downloaded_files_hash, &iter); + hash_table_iter_next (&iter); + ) + xfree (iter.key); hash_table_destroy (downloaded_files_hash); downloaded_files_hash = NULL; } } +/* Remembers broken links. */ + +struct broken_urls_list +{ + char *url; + struct broken_urls_list *next; +}; + +static bool +in_list (const struct broken_urls_list *list, const char *url) +{ + const struct broken_urls_list *ptr; + + for (ptr = list; ptr; ptr = ptr->next) + { + /* TODO: strcasecmp may not be appropriate to compare URLs */ + if (strcasecmp (url, ptr->url) == 0) return true; + } + + return false; +} + +void +nonexisting_url (const char *url, const char *referrer) +{ + struct broken_urls_list *list; + + if (!nonexisting_urls_hash) + nonexisting_urls_hash = make_string_hash_table (0); + + list = hash_table_get (nonexisting_urls_hash, url); + if (!list) + { + list = (struct broken_urls_list *) xnew0 (struct broken_urls_list); + list->url = referrer ? xstrdup (referrer) : NULL; + hash_table_put (nonexisting_urls_hash, xstrdup (url), list); + } + else if (list && !in_list (list, referrer)) + { + /* Append referrer at the end of the list */ + struct broken_urls_list *newnode; + + while (list->next) list = list->next; + + newnode = xnew0 (struct broken_urls_list); + newnode->url = xstrdup (referrer); + list->next = newnode; + } +} + +static void +nonexisting_urls_free (void) +{ + if (nonexisting_urls_hash) + { + hash_table_iterator iter; + for (hash_table_iterate (nonexisting_urls_hash, &iter); + hash_table_iter_next (&iter); + ) + { + xfree (iter.key); + xfree (iter.value); + } + hash_table_destroy (nonexisting_urls_hash); + nonexisting_urls_hash = NULL; + } +} + +void +print_broken_links (void) +{ + hash_table_iterator iter; + int num_elems; + + if (!nonexisting_urls_hash) + { + logprintf (LOG_NOTQUIET, _("Found no broken links.\n\n")); + return; + } + + num_elems = hash_table_count (nonexisting_urls_hash); + assert (num_elems > 0); + + if (num_elems > 1) + { + logprintf (LOG_NOTQUIET, _("Found %d broken links.\n\n"), + num_elems); + } + else + { + logprintf (LOG_NOTQUIET, _("Found 1 broken link.\n\n")); + } + + for (hash_table_iterate (nonexisting_urls_hash, &iter); + hash_table_iter_next (&iter); + ) + { + struct broken_urls_list *list; + + logprintf (LOG_NOTQUIET, _("%s referred by:\n"), (const char *)iter.key); + + for (list = (struct broken_urls_list *) iter.value; + list; + list = list->next) + { + logprintf (LOG_NOTQUIET, _(" %s\n"), list->url); + } + } + logputs (LOG_NOTQUIET, "\n"); +} + + /* The function returns the pointer to the malloc-ed quoted version of string s. It will recognize and quote numeric and special graphic entities, as per RFC1866: @@ -992,7 +1099,7 @@ else if (*s == ' ') i += 4; /* #32; */ } - res = (char *)xmalloc (i + 1); + res = xmalloc (i + 1); s = b; for (p = res; *s; s++) { diff -urN wget-1.10.2/src/convert.h wget-1.10.2_new/src/convert.h --- wget-1.10.2/src/convert.h 2005-04-07 23:37:22.000000000 +0200 +++ wget-1.10.2_new/src/convert.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for convert.c - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,6 +31,7 @@ #define CONVERT_H struct hash_table; /* forward decl */ +extern struct hash_table *dl_url_file_map; extern struct hash_table *downloaded_html_set; enum convert_options { @@ -92,15 +93,18 @@ CHECK_FOR_FILE } downloaded_file_t; -downloaded_file_t downloaded_file PARAMS ((downloaded_file_t, const char *)); +downloaded_file_t downloaded_file (downloaded_file_t, const char *); -void register_download PARAMS ((const char *, const char *)); -void register_redirection PARAMS ((const char *, const char *)); -void register_html PARAMS ((const char *, const char *)); -void register_delete_file PARAMS ((const char *)); -void convert_all_links PARAMS ((void)); -void convert_cleanup PARAMS ((void)); +void register_download (const char *, const char *); +void register_redirection (const char *, const char *); +void register_html (const char *, const char *); +void register_delete_file (const char *); +void convert_all_links (void); +void convert_cleanup (void); -char *html_quote_string PARAMS ((const char *)); +char *html_quote_string (const char *); + +void nonexisting_url (const char *, const char *); +void print_broken_links (void); #endif /* CONVERT_H */ diff -urN wget-1.10.2/src/cookies.c wget-1.10.2_new/src/cookies.c --- wget-1.10.2/src/cookies.c 2005-06-27 17:35:45.000000000 +0200 +++ wget-1.10.2_new/src/cookies.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Support for cookies. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -45,22 +45,17 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #include #include +#include #include "wget.h" #include "utils.h" #include "hash.h" #include "cookies.h" - -/* This should *really* be in a .h file! */ -time_t http_atotm PARAMS ((const char *)); +#include "http.h" /* for http_atotm */ /* Declarations of `struct cookie' and the most basic functions. */ @@ -101,21 +96,21 @@ int port; /* port number */ char *path; /* path prefix of the cookie */ - int secure; /* whether cookie should be + unsigned discard_requested :1; /* whether cookie was created to + request discarding another + cookie. */ + + unsigned secure :1; /* whether cookie should be transmitted over non-https connections. */ - int domain_exact; /* whether DOMAIN must match as a + unsigned domain_exact :1; /* whether DOMAIN must match as a whole. */ - int permanent; /* whether the cookie should outlive + unsigned permanent :1; /* whether the cookie should outlive the session. */ time_t expiry_time; /* time when the cookie expires, 0 means undetermined. */ - int discard_requested; /* whether cookie was created to - request discarding another - cookie. */ - char *attr; /* cookie attribute name */ char *value; /* cookie attribute value */ @@ -143,7 +138,7 @@ /* Non-zero if the cookie has expired. Assumes cookies_now has been set by one of the entry point functions. */ -static int +static bool cookie_expired_p (const struct cookie *c) { return c->expiry_time != 0 && c->expiry_time < cookies_now; @@ -261,8 +256,7 @@ hash_table_put (jar->chains, chain_key, cookie); ++jar->cookie_count; -#ifdef ENABLE_DEBUG - if (opt.debug) + IF_DEBUG { time_t exptime = cookie->expiry_time; DEBUGP (("\nStored cookie %s %d%s %s <%s> <%s> [expiry %s] %s %s\n", @@ -274,7 +268,6 @@ cookie->expiry_time ? datetime_str (&exptime) : "none", cookie->attr, cookie->value)); } -#endif } /* Discard a cookie matching COOKIE's domain, port, path, and @@ -326,139 +319,10 @@ /* Functions for parsing the `Set-Cookie' header, and creating new cookies from the wire. */ -#define NAME_IS(string_literal) \ - BOUNDED_EQUAL_NO_CASE (name_b, name_e, string_literal) - -#define VALUE_EXISTS (value_b && value_e) +#define TOKEN_IS(token, string_literal) \ + BOUNDED_EQUAL_NO_CASE (token.b, token.e, string_literal) -#define VALUE_NON_EMPTY (VALUE_EXISTS && (value_b != value_e)) - -/* Update the appropriate cookie field. [name_b, name_e) are expected - to delimit the attribute name, while [value_b, value_e) (optional) - should delimit the attribute value. - - When called the first time, it will set the cookie's attribute name - and value. After that, it will check the attribute name for - special fields such as `domain', `path', etc. Where appropriate, - it will parse the values of the fields it recognizes and fill the - corresponding fields in COOKIE. - - Returns 1 on success. Returns zero in case a syntax error is - found; such a cookie should be discarded. */ - -static int -update_cookie_field (struct cookie *cookie, - const char *name_b, const char *name_e, - const char *value_b, const char *value_e) -{ - assert (name_b != NULL && name_e != NULL); - - if (!cookie->attr) - { - if (!VALUE_EXISTS) - return 0; - cookie->attr = strdupdelim (name_b, name_e); - cookie->value = strdupdelim (value_b, value_e); - return 1; - } - - if (NAME_IS ("domain")) - { - if (!VALUE_NON_EMPTY) - return 0; - xfree_null (cookie->domain); - /* Strictly speaking, we should set cookie->domain_exact if the - domain doesn't begin with a dot. But many sites set the - domain to "foo.com" and expect "subhost.foo.com" to get the - cookie, and it apparently works. */ - if (*value_b == '.') - ++value_b; - cookie->domain = strdupdelim (value_b, value_e); - return 1; - } - else if (NAME_IS ("path")) - { - if (!VALUE_NON_EMPTY) - return 0; - xfree_null (cookie->path); - cookie->path = strdupdelim (value_b, value_e); - return 1; - } - else if (NAME_IS ("expires")) - { - char *value_copy; - time_t expires; - - if (!VALUE_NON_EMPTY) - return 0; - BOUNDED_TO_ALLOCA (value_b, value_e, value_copy); - - expires = http_atotm (value_copy); - if (expires != (time_t) -1) - { - cookie->permanent = 1; - cookie->expiry_time = expires; - } - else - /* Error in expiration spec. Assume default (cookie doesn't - expire, but valid only for this session.) */ - ; - - /* According to netscape's specification, expiry time in the - past means that discarding of a matching cookie is - requested. */ - if (cookie->expiry_time < cookies_now) - cookie->discard_requested = 1; - - return 1; - } - else if (NAME_IS ("max-age")) - { - double maxage = -1; - char *value_copy; - - if (!VALUE_NON_EMPTY) - return 0; - BOUNDED_TO_ALLOCA (value_b, value_e, value_copy); - - sscanf (value_copy, "%lf", &maxage); - if (maxage == -1) - /* something went wrong. */ - return 0; - cookie->permanent = 1; - cookie->expiry_time = cookies_now + maxage; - - /* According to rfc2109, a cookie with max-age of 0 means that - discarding of a matching cookie is requested. */ - if (maxage == 0) - cookie->discard_requested = 1; - - return 1; - } - else if (NAME_IS ("secure")) - { - /* ignore value completely */ - cookie->secure = 1; - return 1; - } - else - /* Unrecognized attribute; ignore it. */ - return 1; -} - -#undef NAME_IS - -/* Returns non-zero for characters that are legal in the name of an - attribute. This used to allow only alphanumerics, '-', and '_', - but we need to be more lenient because a number of sites wants to - use weirder attribute names. rfc2965 "informally specifies" - attribute name (token) as "a sequence of non-special, non-white - space characters". So we allow everything except the stuff we know - could harm us. */ - -#define ATTR_NAME_CHAR(c) ((c) > 32 && (c) < 127 \ - && (c) != '"' && (c) != '=' \ - && (c) != ';' && (c) != ',') +#define TOKEN_NON_EMPTY(token) (token.b != NULL && token.b != token.e) /* Parse the contents of the `Set-Cookie' header. The header looks like this: @@ -468,182 +332,124 @@ Trailing semicolon is optional; spaces are allowed between all tokens. Additionally, values may be quoted. - A new cookie is returned upon success, NULL otherwise. The - specified CALLBACK function (normally `update_cookie_field' is used - to update the fields of the newly created cookie structure. */ + A new cookie is returned upon success, NULL otherwise. + + The first name-value pair will be used to set the cookie's + attribute name and value. Subsequent parameters will be checked + against field names such as `domain', `path', etc. Recognized + fields will be parsed and the corresponding members of COOKIE + filled. */ static struct cookie * -parse_set_cookies (const char *sc, - int (*callback) (struct cookie *, - const char *, const char *, - const char *, const char *), - int silent) +parse_set_cookie (const char *set_cookie, bool silent) { + const char *ptr = set_cookie; struct cookie *cookie = cookie_new (); + param_token name, value; - /* #### Hand-written DFAs are no fun to debug. We'de be better off - to rewrite this as an inline parser. */ + if (!extract_param (&ptr, &name, &value, ';')) + goto error; + if (!value.b) + goto error; + cookie->attr = strdupdelim (name.b, name.e); + cookie->value = strdupdelim (value.b, value.e); - enum { S_START, S_NAME, S_NAME_POST, - S_VALUE_PRE, S_VALUE, S_QUOTED_VALUE, S_VALUE_TRAILSPACE, - S_ATTR_ACTION, S_DONE, S_ERROR - } state = S_START; - - const char *p = sc; - char c; - - const char *name_b = NULL, *name_e = NULL; - const char *value_b = NULL, *value_e = NULL; - - c = *p; - - while (state != S_DONE && state != S_ERROR) + while (extract_param (&ptr, &name, &value, ';')) { - switch (state) + if (TOKEN_IS (name, "domain")) { - case S_START: - if (!c) - state = S_DONE; - else if (ISSPACE (c)) - /* Strip all whitespace preceding the name. */ - c = *++p; - else if (ATTR_NAME_CHAR (c)) - { - name_b = p; - state = S_NAME; - } - else - /* empty attr name not allowed */ - state = S_ERROR; - break; - case S_NAME: - if (!c || c == ';' || c == '=' || ISSPACE (c)) - { - name_e = p; - state = S_NAME_POST; - } - else if (ATTR_NAME_CHAR (c)) - c = *++p; - else - state = S_ERROR; - break; - case S_NAME_POST: - if (!c || c == ';') - { - value_b = value_e = NULL; - if (c == ';') - c = *++p; - state = S_ATTR_ACTION; - } - else if (c == '=') - { - c = *++p; - state = S_VALUE_PRE; - } - else if (ISSPACE (c)) - /* Ignore space and keep the state. */ - c = *++p; - else - state = S_ERROR; - break; - case S_VALUE_PRE: - if (!c || c == ';') - { - value_b = value_e = p; - if (c == ';') - c = *++p; - state = S_ATTR_ACTION; - } - else if (c == '"') - { - c = *++p; - value_b = p; - state = S_QUOTED_VALUE; - } - else if (ISSPACE (c)) - c = *++p; - else - { - value_b = p; - value_e = NULL; - state = S_VALUE; - } - break; - case S_VALUE: - if (!c || c == ';' || ISSPACE (c)) - { - value_e = p; - state = S_VALUE_TRAILSPACE; - } - else - { - value_e = NULL; /* no trailing space */ - c = *++p; - } - break; - case S_QUOTED_VALUE: - if (c == '"') - { - value_e = p; - c = *++p; - state = S_VALUE_TRAILSPACE; - } - else if (!c) - state = S_ERROR; - else - c = *++p; - break; - case S_VALUE_TRAILSPACE: - if (c == ';') + if (!TOKEN_NON_EMPTY (value)) + goto error; + xfree_null (cookie->domain); + /* Strictly speaking, we should set cookie->domain_exact if the + domain doesn't begin with a dot. But many sites set the + domain to "foo.com" and expect "subhost.foo.com" to get the + cookie, and it apparently works in browsers. */ + if (*value.b == '.') + ++value.b; + cookie->domain = strdupdelim (value.b, value.e); + } + else if (TOKEN_IS (name, "path")) + { + if (!TOKEN_NON_EMPTY (value)) + goto error; + xfree_null (cookie->path); + cookie->path = strdupdelim (value.b, value.e); + } + else if (TOKEN_IS (name, "expires")) + { + char *value_copy; + time_t expires; + + if (!TOKEN_NON_EMPTY (value)) + goto error; + BOUNDED_TO_ALLOCA (value.b, value.e, value_copy); + + expires = http_atotm (value_copy); + if (expires != (time_t) -1) { - c = *++p; - state = S_ATTR_ACTION; + cookie->permanent = 1; + cookie->expiry_time = expires; } - else if (!c) - state = S_ATTR_ACTION; - else if (ISSPACE (c)) - c = *++p; else - state = S_VALUE; - break; - case S_ATTR_ACTION: - { - int legal = callback (cookie, name_b, name_e, value_b, value_e); - if (!legal) - { - if (!silent) - { - char *name; - BOUNDED_TO_ALLOCA (name_b, name_e, name); - logprintf (LOG_NOTQUIET, - _("Error in Set-Cookie, field `%s'"), - escnonprint (name)); - } - state = S_ERROR; - break; - } - state = S_START; - } - break; - case S_DONE: - case S_ERROR: - /* handled by loop condition */ - break; + /* Error in expiration spec. Assume default (cookie doesn't + expire, but valid only for this session.) */ + ; + + /* According to netscape's specification, expiry time in the + past means that discarding of a matching cookie is + requested. */ + if (cookie->expiry_time < cookies_now) + cookie->discard_requested = 1; + } + else if (TOKEN_IS (name, "max-age")) + { + double maxage = -1; + char *value_copy; + + if (!TOKEN_NON_EMPTY (value)) + goto error; + BOUNDED_TO_ALLOCA (value.b, value.e, value_copy); + + sscanf (value_copy, "%lf", &maxage); + if (maxage == -1) + /* something went wrong. */ + goto error; + cookie->permanent = 1; + cookie->expiry_time = cookies_now + maxage; + + /* According to rfc2109, a cookie with max-age of 0 means that + discarding of a matching cookie is requested. */ + if (maxage == 0) + cookie->discard_requested = 1; + } + else if (TOKEN_IS (name, "secure")) + { + /* ignore value completely */ + cookie->secure = 1; } + else + /* Ignore unrecognized attribute. */ + ; } - if (state == S_DONE) - return cookie; + if (*ptr) + /* extract_param has encountered a syntax error */ + goto error; - delete_cookie (cookie); - if (state != S_ERROR) - abort (); + /* The cookie has been successfully constructed; return it. */ + return cookie; + error: if (!silent) logprintf (LOG_NOTQUIET, _("Syntax error in Set-Cookie: %s at position %d.\n"), - escnonprint (sc), (int) (p - sc)); + escnonprint (set_cookie), (int) (ptr - set_cookie)); + delete_cookie (cookie); return NULL; } + +#undef TOKEN_IS +#undef TOKEN_NON_EMPTY /* Sanity checks. These are important, otherwise it is possible for mailcious attackers to destroy important cookie information and/or @@ -652,14 +458,14 @@ #define REQUIRE_DIGITS(p) do { \ if (!ISDIGIT (*p)) \ - return 0; \ + return false; \ for (++p; ISDIGIT (*p); p++) \ ; \ } while (0) #define REQUIRE_DOT(p) do { \ if (*p++ != '.') \ - return 0; \ + return false; \ } while (0) /* Check whether ADDR matches .... @@ -668,7 +474,7 @@ all we need is a check, preferrably one that is small, fast, and well-defined. */ -static int +static bool numeric_address_p (const char *addr) { const char *p = addr; @@ -682,8 +488,8 @@ REQUIRE_DIGITS (p); /* D */ if (*p != '\0') - return 0; - return 1; + return false; + return true; } /* Check whether COOKIE_DOMAIN is an appropriate domain for HOST. @@ -691,7 +497,7 @@ the sites deviated too often, so I had to fall back to "tail matching", as defined by the original Netscape's cookie spec. */ -static int +static bool check_domain_match (const char *cookie_domain, const char *host) { DEBUGP (("cdm: 1")); @@ -705,13 +511,13 @@ /* For the sake of efficiency, check for exact match first. */ if (0 == strcasecmp (cookie_domain, host)) - return 1; + return true; DEBUGP ((" 3")); /* HOST must match the tail of cookie_domain. */ - if (!match_tail (host, cookie_domain, 1)) - return 0; + if (!match_tail (host, cookie_domain, true)) + return false; /* We know that COOKIE_DOMAIN is a subset of HOST; however, we must make sure that somebody is not trying to set the cookie for a @@ -757,7 +563,7 @@ case '.': if (ldcl == 0) /* Empty domain component found -- the domain is invalid. */ - return 0; + return false; if (*(p + 1) == '\0') { /* Tolerate trailing '.' by not treating the domain as @@ -776,25 +582,25 @@ DEBUGP ((" 5")); if (dccount < 2) - return 0; + return false; DEBUGP ((" 6")); if (dccount == 2) { int i; - int known_toplevel = 0; + int known_toplevel = false; static const char *known_toplevel_domains[] = { ".com", ".edu", ".net", ".org", ".gov", ".mil", ".int" }; for (i = 0; i < countof (known_toplevel_domains); i++) - if (match_tail (cookie_domain, known_toplevel_domains[i], 1)) + if (match_tail (cookie_domain, known_toplevel_domains[i], true)) { - known_toplevel = 1; + known_toplevel = true; break; } if (!known_toplevel && nldcl <= 3) - return 0; + return false; } } @@ -810,22 +616,22 @@ /* desired domain: bar.com */ /* '.' must be here in host-> ^ */ if (hlen > dlen && host[hlen - dlen - 1] != '.') - return 0; + return false; } DEBUGP ((" 8")); - return 1; + return true; } -static int path_matches PARAMS ((const char *, const char *)); +static int path_matches (const char *, const char *); /* Check whether PATH begins with COOKIE_PATH. */ -static int +static bool check_path_match (const char *cookie_path, const char *path) { - return path_matches (path, cookie_path); + return path_matches (path, cookie_path) != 0; } /* Prepend '/' to string S. S is copied to fresh stack-allocated @@ -856,7 +662,7 @@ simply prepend slash to PATH. */ PREPEND_SLASH (path); - cookie = parse_set_cookies (set_cookie, update_cookie_field, 0); + cookie = parse_set_cookie (set_cookie, false); if (!cookie) goto out; @@ -1008,17 +814,17 @@ return len + 1; } -/* Return non-zero iff COOKIE matches the provided parameters of the - URL being downloaded: HOST, PORT, PATH, and SECFLAG. +/* Return true iff COOKIE matches the provided parameters of the URL + being downloaded: HOST, PORT, PATH, and SECFLAG. If PATH_GOODNESS is non-NULL, store the "path goodness" value there. That value is a measure of how closely COOKIE matches PATH, used for ordering cookies. */ -static int +static bool cookie_matches_url (const struct cookie *cookie, const char *host, int port, const char *path, - int secflag, int *path_goodness) + bool secflag, int *path_goodness) { int pg; @@ -1028,31 +834,31 @@ stale cookies will not be saved by `save_cookies'. On the other hand, this function should be as efficient as possible. */ - return 0; + return false; if (cookie->secure && !secflag) /* Don't transmit secure cookies over insecure connections. */ - return 0; + return false; if (cookie->port != PORT_ANY && cookie->port != port) - return 0; + return false; /* If exact domain match is required, verify that cookie's domain is equal to HOST. If not, assume success on the grounds of the cookie's chain having been found by find_chains_of_host. */ if (cookie->domain_exact && 0 != strcasecmp (host, cookie->domain)) - return 0; + return false; pg = path_matches (path, cookie->path); - if (!pg) - return 0; + if (pg == 0) + return false; if (path_goodness) /* If the caller requested path_goodness, we return it. This is an optimization, so that the caller doesn't need to call path_matches() again. */ *path_goodness = pg; - return 1; + return true; } /* A structure that points to a cookie, along with the additional @@ -1151,7 +957,7 @@ char * cookie_header (struct cookie_jar *jar, const char *host, - int port, const char *path, int secflag) + int port, const char *path, bool secflag) { struct cookie **chains; int chain_count; @@ -1428,44 +1234,13 @@ fclose (fp); } -/* Mapper for save_cookies callable by hash_table_map. VALUE points - to the head in a chain of cookies. The function prints the entire - chain. */ - -static int -save_cookies_mapper (void *key, void *value, void *arg) -{ - FILE *fp = (FILE *)arg; - char *domain = (char *)key; - struct cookie *cookie = (struct cookie *)value; - for (; cookie; cookie = cookie->next) - { - if (!cookie->permanent && !opt.keep_session_cookies) - continue; - if (cookie_expired_p (cookie)) - continue; - if (!cookie->domain_exact) - fputc ('.', fp); - fputs (domain, fp); - if (cookie->port != PORT_ANY) - fprintf (fp, ":%d", cookie->port); - fprintf (fp, "\t%s\t%s\t%s\t%.0f\t%s\t%s\n", - cookie->domain_exact ? "FALSE" : "TRUE", - cookie->path, cookie->secure ? "TRUE" : "FALSE", - (double)cookie->expiry_time, - cookie->attr, cookie->value); - if (ferror (fp)) - return 1; /* stop mapping */ - } - return 0; -} - /* Save cookies, in format described above, to FILE. */ void cookie_jar_save (struct cookie_jar *jar, const char *file) { FILE *fp; + hash_table_iterator iter; DEBUGP (("Saving cookies to %s.\n", file)); @@ -1483,8 +1258,33 @@ fprintf (fp, "# Generated by Wget on %s.\n", datetime_str (&cookies_now)); fputs ("# Edit at your own risk.\n\n", fp); - hash_table_map (jar->chains, save_cookies_mapper, fp); - + for (hash_table_iterate (jar->chains, &iter); + hash_table_iter_next (&iter); + ) + { + const char *domain = iter.key; + struct cookie *cookie = iter.value; + for (; cookie; cookie = cookie->next) + { + if (!cookie->permanent && !opt.keep_session_cookies) + continue; + if (cookie_expired_p (cookie)) + continue; + if (!cookie->domain_exact) + fputc ('.', fp); + fputs (domain, fp); + if (cookie->port != PORT_ANY) + fprintf (fp, ":%d", cookie->port); + fprintf (fp, "\t%s\t%s\t%s\t%.0f\t%s\t%s\n", + cookie->domain_exact ? "FALSE" : "TRUE", + cookie->path, cookie->secure ? "TRUE" : "FALSE", + (double)cookie->expiry_time, + cookie->attr, cookie->value); + if (ferror (fp)) + goto out; + } + } + out: if (ferror (fp)) logprintf (LOG_NOTQUIET, _("Error writing to `%s': %s\n"), file, strerror (errno)); @@ -1495,40 +1295,25 @@ DEBUGP (("Done saving cookies.\n")); } -/* Destroy all the elements in the chain and unhook it from the cookie - jar. This is written in the form of a callback to hash_table_map - and used by cookie_jar_delete to delete all the cookies in a - jar. */ - -static int -nuke_cookie_chain (void *value, void *key, void *arg) -{ - char *chain_key = (char *)value; - struct cookie *chain = (struct cookie *)key; - struct cookie_jar *jar = (struct cookie_jar *)arg; - - /* Remove the chain from the table and free the key. */ - hash_table_remove (jar->chains, chain_key); - xfree (chain_key); - - /* Then delete all the cookies in the chain. */ - while (chain) - { - struct cookie *next = chain->next; - delete_cookie (chain); - chain = next; - } - - /* Keep mapping. */ - return 0; -} - /* Clean up cookie-related data. */ void cookie_jar_delete (struct cookie_jar *jar) { - hash_table_map (jar->chains, nuke_cookie_chain, jar); + /* Iterate over chains (indexed by domain) and free them. */ + hash_table_iterator iter; + for (hash_table_iterate (jar->chains, &iter); hash_table_iter_next (&iter); ) + { + struct cookie *chain = iter.value; + xfree (iter.key); + /* Then all cookies in this chain. */ + while (chain) + { + struct cookie *next = chain->next; + delete_cookie (chain); + chain = next; + } + } hash_table_destroy (jar->chains); xfree (jar); } @@ -1538,27 +1323,14 @@ from main. */ #ifdef TEST_COOKIES -int test_count; -char *test_results[10]; - -static int test_parse_cookies_callback (struct cookie *ignored, - const char *nb, const char *ne, - const char *vb, const char *ve) -{ - test_results[test_count++] = strdupdelim (nb, ne); - test_results[test_count++] = strdupdelim (vb, ve); - return 1; -} - void test_cookies (void) { /* Tests expected to succeed: */ static struct { - char *data; - char *results[10]; + const char *data; + const char *results[10]; } tests_succ[] = { - { "", {NULL} }, { "arg=value", {"arg", "value", NULL} }, { "arg1=value1;arg2=value2", {"arg1", "value1", "arg2", "value2", NULL} }, { "arg1=value1; arg2=value2", {"arg1", "value1", "arg2", "value2", NULL} }, @@ -1582,39 +1354,51 @@ for (i = 0; i < countof (tests_succ); i++) { int ind; - char *data = tests_succ[i].data; - char **expected = tests_succ[i].results; + const char *data = tests_succ[i].data; + const char **expected = tests_succ[i].results; struct cookie *c; - test_count = 0; - c = parse_set_cookies (data, test_parse_cookies_callback, 1); + c = parse_set_cookie (data, true); if (!c) { printf ("NULL cookie returned for valid data: %s\n", data); continue; } - for (ind = 0; ind < test_count; ind += 2) - { - if (!expected[ind]) - break; - if (0 != strcmp (expected[ind], test_results[ind])) - printf ("Invalid name %d for '%s' (expected '%s', got '%s')\n", - ind / 2 + 1, data, expected[ind], test_results[ind]); - if (0 != strcmp (expected[ind + 1], test_results[ind + 1])) - printf ("Invalid value %d for '%s' (expected '%s', got '%s')\n", - ind / 2 + 1, data, expected[ind + 1], test_results[ind + 1]); - } - if (ind < test_count || expected[ind]) - printf ("Unmatched number of results: %s\n", data); + /* Test whether extract_param handles these cases correctly. */ + { + param_token name, value; + const char *ptr = data; + int j = 0; + while (extract_param (&ptr, &name, &value, ';')) + { + char *n = strdupdelim (name.b, name.e); + char *v = strdupdelim (value.b, value.e); + if (!expected[j]) + { + printf ("Too many parameters for '%s'\n", data); + break; + } + if (0 != strcmp (expected[j], n)) + printf ("Invalid name %d for '%s' (expected '%s', got '%s')\n", + j / 2 + 1, data, expected[j], n); + if (0 != strcmp (expected[j + 1], v)) + printf ("Invalid value %d for '%s' (expected '%s', got '%s')\n", + j / 2 + 1, data, expected[j + 1], v); + j += 2; + free (n); + free (v); + } + if (expected[j]) + printf ("Too few parameters for '%s'\n", data); + } } for (i = 0; i < countof (tests_fail); i++) { struct cookie *c; char *data = tests_fail[i]; - test_count = 0; - c = parse_set_cookies (data, test_parse_cookies_callback, 1); + c = parse_set_cookie (data, true); if (c) printf ("Failed to report error on invalid data: %s\n", data); } diff -urN wget-1.10.2/src/cookies.h wget-1.10.2_new/src/cookies.h --- wget-1.10.2/src/cookies.h 2003-11-05 01:11:33.000000000 +0100 +++ wget-1.10.2_new/src/cookies.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Support for cookies. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -32,15 +32,15 @@ struct cookie_jar; -struct cookie_jar *cookie_jar_new PARAMS ((void)); -void cookie_jar_delete PARAMS ((struct cookie_jar *)); +struct cookie_jar *cookie_jar_new (void); +void cookie_jar_delete (struct cookie_jar *); -void cookie_handle_set_cookie PARAMS ((struct cookie_jar *, const char *, - int, const char *, const char *)); -char *cookie_header PARAMS ((struct cookie_jar *, - const char *, int, const char *, int)); +void cookie_handle_set_cookie (struct cookie_jar *, const char *, int, + const char *, const char *); +char *cookie_header (struct cookie_jar *, const char *, int, + const char *, bool); -void cookie_jar_load PARAMS ((struct cookie_jar *, const char *)); -void cookie_jar_save PARAMS ((struct cookie_jar *, const char *)); +void cookie_jar_load (struct cookie_jar *, const char *); +void cookie_jar_save (struct cookie_jar *, const char *); #endif /* COOKIES_H */ diff -urN wget-1.10.2/src/ftp-basic.c wget-1.10.2_new/src/ftp-basic.c --- wget-1.10.2/src/ftp-basic.c 2005-06-19 15:47:10.000000000 +0200 +++ wget-1.10.2_new/src/ftp-basic.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Basic FTP routines. - Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -34,15 +34,10 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #ifdef HAVE_UNISTD_H # include #endif -#include #include "wget.h" #include "utils.h" @@ -164,7 +159,7 @@ xfree (respline); /* Send USER username. */ request = ftp_request ("USER", acc); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -228,7 +223,7 @@ xfree (respline); /* Send PASS password. */ request = ftp_request ("PASS", pass); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -255,13 +250,11 @@ { unsigned char *ptr; - assert (addr != NULL); - assert (addr->type == IPV4_ADDRESS); - assert (buf != NULL); + assert (addr->family == AF_INET); /* buf must contain the argument of PORT (of the form a,b,c,d,e,f). */ assert (buflen >= 6 * 4); - ptr = ADDRESS_IPV4_DATA (addr); + ptr = IP_INADDR_DATA (addr); snprintf (buf, buflen, "%d,%d,%d,%d,%d,%d", ptr[0], ptr[1], ptr[2], ptr[3], (port & 0xff00) >> 8, port & 0xff); buf[buflen - 1] = '\0'; @@ -285,7 +278,7 @@ if (!socket_ip_address (csock, &addr, ENDPOINT_LOCAL)) return FTPSYSERR; - assert (addr.type == IPV4_ADDRESS); + assert (addr.family == AF_INET); /* Setting port to 0 lets the system choose a free port. */ port = 0; @@ -300,7 +293,7 @@ /* Send PORT request. */ request = ftp_request ("PORT", bytes); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -331,32 +324,29 @@ ip_address_to_lprt_repr (const ip_address *addr, int port, char *buf, size_t buflen) { - unsigned char *ptr; + unsigned char *ptr = IP_INADDR_DATA (addr); - assert (addr != NULL); - assert (addr->type == IPV4_ADDRESS || addr->type == IPV6_ADDRESS); - assert (buf != NULL); /* buf must contain the argument of LPRT (of the form af,n,h1,h2,...,hn,p1,p2). */ assert (buflen >= 21 * 4); /* Construct the argument of LPRT (of the form af,n,h1,h2,...,hn,p1,p2). */ - switch (addr->type) + switch (addr->family) { - case IPV4_ADDRESS: - ptr = ADDRESS_IPV4_DATA (addr); - snprintf (buf, buflen, "%d,%d,%d,%d,%d,%d,%d,%d,%d", 4, 4, - ptr[0], ptr[1], ptr[2], ptr[3], 2, - (port & 0xff00) >> 8, port & 0xff); - buf[buflen - 1] = '\0'; - break; - case IPV6_ADDRESS: - ptr = ADDRESS_IPV6_DATA (addr); - snprintf (buf, buflen, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", - 6, 16, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], - ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15], 2, - (port & 0xff00) >> 8, port & 0xff); - buf[buflen - 1] = '\0'; - break; + case AF_INET: + snprintf (buf, buflen, "%d,%d,%d,%d,%d,%d,%d,%d,%d", 4, 4, + ptr[0], ptr[1], ptr[2], ptr[3], 2, + (port & 0xff00) >> 8, port & 0xff); + break; + case AF_INET6: + snprintf (buf, buflen, + "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", + 6, 16, + ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], + ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15], + 2, (port & 0xff00) >> 8, port & 0xff); + break; + default: + abort (); } } @@ -378,7 +368,7 @@ if (!socket_ip_address (csock, &addr, ENDPOINT_LOCAL)) return FTPSYSERR; - assert (addr.type == IPV4_ADDRESS || addr.type == IPV6_ADDRESS); + assert (addr.family == AF_INET || addr.family == AF_INET6); /* Setting port to 0 lets the system choose a free port. */ port = 0; @@ -393,7 +383,7 @@ /* Send PORT request. */ request = ftp_request ("LPRT", bytes); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -424,17 +414,14 @@ { int afnum; - assert (addr != NULL); - assert (addr->type == IPV4_ADDRESS || addr->type == IPV6_ADDRESS); - assert (buf != NULL); /* buf must contain the argument of EPRT (of the form |af|addr|port|). * 4 chars for the | separators, INET6_ADDRSTRLEN chars for addr * 1 char for af (1-2) and 5 chars for port (0-65535) */ assert (buflen >= 4 + INET6_ADDRSTRLEN + 1 + 5); /* Construct the argument of EPRT (of the form |af|addr|port|). */ - afnum = (addr->type == IPV4_ADDRESS ? 1 : 2); - snprintf (buf, buflen, "|%d|%s|%d|", afnum, pretty_print_address (addr), port); + afnum = (addr->family == AF_INET ? 1 : 2); + snprintf (buf, buflen, "|%d|%s|%d|", afnum, print_address (addr), port); buf[buflen - 1] = '\0'; } @@ -458,8 +445,6 @@ if (!socket_ip_address (csock, &addr, ENDPOINT_LOCAL)) return FTPSYSERR; - assert (addr.type == IPV4_ADDRESS || addr.type == IPV6_ADDRESS); - /* Setting port to 0 lets the system choose a free port. */ port = 0; @@ -473,7 +458,7 @@ /* Send PORT request. */ request = ftp_request ("EPRT", bytes); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -518,7 +503,7 @@ /* Form the request. */ request = ftp_request ("PASV", NULL); /* And send it. */ - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -536,7 +521,8 @@ } /* Parse the request. */ s = respline; - for (s += 4; *s && !ISDIGIT (*s); s++); + for (s += 4; *s && !ISDIGIT (*s); s++) + ; if (!*s) return FTPINVPASV; for (i = 0; i < 6; i++) @@ -555,8 +541,8 @@ } xfree (respline); - addr->type = IPV4_ADDRESS; - memcpy (ADDRESS_IPV4_DATA (addr), tmp, 4); + addr->family = AF_INET; + memcpy (IP_INADDR_DATA (addr), tmp, 4); *port = ((tmp[4] << 8) & 0xff00) + tmp[5]; return FTPOK; @@ -584,7 +570,7 @@ request = ftp_request ("LPSV", NULL); /* And send it. */ - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -604,7 +590,8 @@ /* Parse the response. */ s = respline; - for (s += 4; *s && !ISDIGIT (*s); s++); + for (s += 4; *s && !ISDIGIT (*s); s++) + ; if (!*s) return FTPINVPASV; @@ -700,10 +687,10 @@ if (af == 4) { - addr->type = IPV4_ADDRESS; - memcpy (ADDRESS_IPV4_DATA (addr), tmp, 4); + addr->family = AF_INET; + memcpy (IP_INADDR_DATA (addr), tmp, 4); *port = ((tmpprt[0] << 8) & 0xff00) + tmpprt[1]; - DEBUGP (("lpsv addr is: %s\n", pretty_print_address(addr))); + DEBUGP (("lpsv addr is: %s\n", print_address(addr))); DEBUGP (("tmpprt[0] is: %d\n", tmpprt[0])); DEBUGP (("tmpprt[1] is: %d\n", tmpprt[1])); DEBUGP (("*port is: %d\n", *port)); @@ -711,10 +698,10 @@ else { assert (af == 6); - addr->type = IPV6_ADDRESS; - memcpy (ADDRESS_IPV6_DATA (addr), tmp, 16); + addr->family = AF_INET6; + memcpy (IP_INADDR_DATA (addr), tmp, 16); *port = ((tmpprt[0] << 8) & 0xff00) + tmpprt[1]; - DEBUGP (("lpsv addr is: %s\n", pretty_print_address(addr))); + DEBUGP (("lpsv addr is: %s\n", print_address(addr))); DEBUGP (("tmpprt[0] is: %d\n", tmpprt[0])); DEBUGP (("tmpprt[1] is: %d\n", tmpprt[1])); DEBUGP (("*port is: %d\n", *port)); @@ -743,10 +730,10 @@ /* Form the request. */ /* EPSV 1 means that we ask for IPv4 and EPSV 2 means that we ask for IPv6. */ - request = ftp_request ("EPSV", (ip->type == IPV4_ADDRESS ? "1" : "2")); + request = ftp_request ("EPSV", (ip->family == AF_INET ? "1" : "2")); /* And send it. */ - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -843,7 +830,7 @@ stype[1] = 0; /* Send TYPE request. */ request = ftp_request ("TYPE", stype); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -875,7 +862,7 @@ /* Send CWD request. */ request = ftp_request ("CWD", dir); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -910,7 +897,7 @@ uerr_t err; request = ftp_request ("REST", number_to_static_string (offset)); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -941,7 +928,7 @@ /* Send RETR request. */ request = ftp_request ("RETR", file); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -975,33 +962,45 @@ char *request, *respline; int nwritten; uerr_t err; - - /* Send LIST request. */ - request = ftp_request ("LIST", file); - nwritten = fd_write (csock, request, strlen (request), -1.0); - if (nwritten < 0) - { - xfree (request); - return WRITEFAILED; - } - xfree (request); - /* Get appropriate respone. */ - err = ftp_response (csock, &respline); - if (err != FTPOK) - return err; - if (*respline == '5') - { - xfree (respline); - return FTPNSFOD; - } - if (*respline != '1') - { - xfree (respline); - return FTPRERR; - } - xfree (respline); - /* All OK. */ - return FTPOK; + bool ok = false; + int i = 0; + /* Try `LIST -a' first and revert to `LIST' in case of failure. */ + const char *list_commands[] = { "LIST -a", + "LIST" }; + + do { + /* Send request. */ + request = ftp_request (list_commands[i], file); + nwritten = fd_write (csock, request, strlen (request), -1); + if (nwritten < 0) + { + xfree (request); + return WRITEFAILED; + } + xfree (request); + /* Get appropriate response. */ + err = ftp_response (csock, &respline); + if (err == FTPOK) + { + if (*respline == '5') + { + err = FTPNSFOD; + } + else if (*respline == '1') + { + err = FTPOK; + ok = true; + } + else + { + err = FTPRERR; + } + xfree (respline); + } + ++i; + } while (i < countof (list_commands) && !ok); + + return err; } /* Sends the SYST command to the server. */ @@ -1014,7 +1013,7 @@ /* Send SYST request. */ request = ftp_request ("SYST", NULL); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -1068,7 +1067,7 @@ /* Send PWD request. */ request = ftp_request ("PWD", NULL); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); @@ -1116,7 +1115,7 @@ /* Send PWD request. */ request = ftp_request ("SIZE", file); - nwritten = fd_write (csock, request, strlen (request), -1.0); + nwritten = fd_write (csock, request, strlen (request), -1); if (nwritten < 0) { xfree (request); diff -urN wget-1.10.2/src/ftp.c wget-1.10.2_new/src/ftp.c --- wget-1.10.2/src/ftp.c 2005-08-09 00:23:09.000000000 +0200 +++ wget-1.10.2_new/src/ftp.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,6 +1,5 @@ /* File Transfer Protocol support. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 - Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -15,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -32,15 +31,10 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #ifdef HAVE_UNISTD_H # include #endif -#include #include #include @@ -55,20 +49,9 @@ #include "convert.h" /* for downloaded_file */ #include "recur.h" /* for INFINITE_RECURSION */ -#ifndef errno -extern int errno; -#endif - -extern SUM_SIZE_INT total_downloaded_bytes; - /* File where the "ls -al" listing will be saved. */ #define LIST_FILENAME ".listing" -extern char ftp_last_respline[]; - -extern FILE *output_stream; -extern int output_stream_regular; - typedef struct { int st; /* connection status */ @@ -133,14 +116,14 @@ /* If our control connection is over IPv6, then we first try EPSV and then * LPSV if the former is not supported. If the control connection is over * IPv4, we simply issue the good old PASV request. */ - switch (addr->type) + switch (addr->family) { - case IPV4_ADDRESS: + case AF_INET: if (!opt.server_response) logputs (LOG_VERBOSE, "==> PASV ... "); err = ftp_pasv (csock, addr, port); break; - case IPV6_ADDRESS: + case AF_INET6: if (!opt.server_response) logputs (LOG_VERBOSE, "==> EPSV ... "); err = ftp_epsv (csock, addr, port); @@ -176,14 +159,14 @@ /* If our control connection is over IPv6, then we first try EPRT and then * LPRT if the former is not supported. If the control connection is over * IPv4, we simply issue the good old PORT request. */ - switch (cip.type) + switch (cip.family) { - case IPV4_ADDRESS: + case AF_INET: if (!opt.server_response) logputs (LOG_VERBOSE, "==> PORT ... "); err = ftp_port (csock, local_sock); break; - case IPV6_ADDRESS: + case AF_INET6: if (!opt.server_response) logputs (LOG_VERBOSE, "==> EPRT ... "); err = ftp_eprt (csock, local_sock); @@ -221,20 +204,20 @@ #endif static void -print_length (wgint size, wgint start, int authoritative) +print_length (wgint size, wgint start, bool authoritative) { - logprintf (LOG_VERBOSE, _("Length: %s"), with_thousand_seps (size)); + logprintf (LOG_VERBOSE, _("Length: %s"), number_to_static_string (size)); if (size >= 1024) logprintf (LOG_VERBOSE, " (%s)", human_readable (size)); if (start > 0) { if (start >= 1024) logprintf (LOG_VERBOSE, _(", %s (%s) remaining"), - with_thousand_seps (size - start), + number_to_static_string (size - start), human_readable (size - start)); else logprintf (LOG_VERBOSE, _(", %s remaining"), - with_thousand_seps (size - start)); + number_to_static_string (size - start)); } logputs (LOG_VERBOSE, !authoritative ? _(" (unauthoritative)\n") : "\n"); } @@ -249,11 +232,12 @@ uerr_t err = RETROK; /* appease the compiler */ FILE *fp; char *user, *passwd, *respline; - char *tms, *tmrate; + char *tms; + const char *tmrate; int cmd = con->cmd; - int pasv_mode_open = 0; + bool pasv_mode_open = false; wgint expected_bytes = 0; - int rest_failed = 0; + bool rest_failed = false; int flags; wgint rd_size; @@ -594,7 +578,7 @@ else /* do not CWD */ logputs (LOG_VERBOSE, _("==> CWD not required.\n")); - if ((cmd & DO_RETR) && restval && *len == 0) + if ((cmd & DO_RETR) && *len == 0) { if (opt.verbose) { @@ -607,7 +591,7 @@ switch (err) { case FTPRERR: - case FTPSRVERR : + case FTPSRVERR: logputs (LOG_VERBOSE, "\n"); logputs (LOG_NOTQUIET, _("\ Error in server response, closing control connection.\n")); @@ -621,13 +605,14 @@ abort (); } if (!opt.server_response) - logputs (LOG_VERBOSE, _("done.\n")); + logprintf (LOG_VERBOSE, *len ? "%s\n" : _("done.\n"), + number_to_static_string (*len)); } /* If anything is to be retrieved, PORT (or PASV) must be sent. */ if (cmd & (DO_LIST | DO_RETR)) { - if (opt.ftp_pasv > 0) + if (opt.ftp_pasv) { ip_address passive_addr; int passive_port; @@ -665,8 +650,7 @@ if (err==FTPOK) { DEBUGP (("trying to connect to %s port %d\n", - pretty_print_address (&passive_addr), - passive_port)); + print_address (&passive_addr), passive_port)); dtsock = connect_to_ip (&passive_addr, passive_port, NULL); if (dtsock < 0) { @@ -674,13 +658,13 @@ fd_close (csock); con->csock = -1; logprintf (LOG_VERBOSE, _("couldn't connect to %s port %d: %s\n"), - pretty_print_address (&passive_addr), passive_port, + print_address (&passive_addr), passive_port, strerror (save_errno)); return (retryable_socket_connect_error (save_errno) ? CONERROR : CONIMPOSSIBLE); } - pasv_mode_open = 1; /* Flag to avoid accept port */ + pasv_mode_open = true; /* Flag to avoid accept port */ if (!opt.server_response) logputs (LOG_VERBOSE, _("done. ")); } /* err==FTP_OK */ @@ -774,7 +758,7 @@ return err; case FTPRESTFAIL: logputs (LOG_VERBOSE, _("\nREST failed, starting from scratch.\n")); - rest_failed = 1; + rest_failed = true; break; case FTPOK: break; @@ -936,7 +920,7 @@ fp = fopen (con->target, "wb"); else { - fp = fopen_excl (con->target, 1); + fp = fopen_excl (con->target, true); if (!fp && errno == EEXIST) { /* We cannot just invent a new name and use it (which is @@ -967,11 +951,11 @@ if (*len) { - print_length (*len, restval, 1); - expected_bytes = *len; /* for get_contents/show_progress */ + print_length (*len, restval, true); + expected_bytes = *len; /* for fd_read_body's progress bar */ } else if (expected_bytes) - print_length (expected_bytes, restval, 0); + print_length (expected_bytes, restval, false); /* Get the contents of the document. */ flags = 0; @@ -984,40 +968,32 @@ restval, &rd_size, len, &con->dltime, flags); tms = time_str (NULL); - tmrate = retr_rate (rd_size, con->dltime, 0); - /* Close data connection socket. */ - fd_close (dtsock); + tmrate = retr_rate (rd_size, con->dltime); + total_download_time += con->dltime; + fd_close (local_sock); /* Close the local file. */ - { - /* Close or flush the file. We have to be careful to check for - error here. Checking the result of fwrite() is not enough -- - errors could go unnoticed! */ - int flush_res; - if (!output_stream || con->cmd & DO_LIST) - flush_res = fclose (fp); - else - flush_res = fflush (fp); - if (flush_res == EOF) - res = -2; - } + if (!output_stream || con->cmd & DO_LIST) + fclose (fp); - /* If get_contents couldn't write to fp, bail out. */ + /* If fd_read_body couldn't write to fp, bail out. */ if (res == -2) { logprintf (LOG_NOTQUIET, _("%s: %s, closing control connection.\n"), con->target, strerror (errno)); fd_close (csock); con->csock = -1; + fd_close (dtsock); return FWRITEERR; } else if (res == -1) { logprintf (LOG_NOTQUIET, _("%s (%s) - Data connection: %s; "), - tms, tmrate, strerror (errno)); + tms, tmrate, fd_errstr (dtsock)); if (opt.server_response) logputs (LOG_ALWAYS, "\n"); } + fd_close (dtsock); /* Get the server to tell us if everything is retrieved. */ err = ftp_response (csock, &respline); @@ -1103,7 +1079,7 @@ int count, orig_lp; wgint restval, len = 0; char *tms, *locf; - char *tmrate = NULL; + const char *tmrate = NULL; uerr_t err; struct_stat st; @@ -1177,7 +1153,7 @@ /* Print fetch message, if opt.verbose. */ if (opt.verbose) { - char *hurl = url_string (u, 1); + char *hurl = url_string (u, true); char tmp[256]; strcpy (tmp, " "); if (count > 1) @@ -1239,7 +1215,7 @@ } tms = time_str (NULL); if (!opt.spider) - tmrate = retr_rate (len - restval, con->dltime, 0); + tmrate = retr_rate (len - restval, con->dltime); /* If we get out of the switch above without continue'ing, we've successfully downloaded a file. Remember this fact. */ @@ -1258,7 +1234,7 @@ /* Need to hide the password from the URL. The `if' is here so that we don't do the needless allocation every time. */ - char *hurl = url_string (u, 1); + char *hurl = url_string (u, true); logprintf (LOG_NONVERBOSE, "%s URL: %s [%s] -> \"%s\" [%d]\n", tms, hurl, number_to_static_string (len), locf, count); xfree (hurl); @@ -1317,7 +1293,7 @@ /* Return the directory listing in a reusable format. The directory is specifed in u->dir. */ -uerr_t +static uerr_t ftp_get_listing (struct url *u, ccon *con, struct fileinfo **f) { uerr_t err; @@ -1357,12 +1333,10 @@ return err; } -static uerr_t ftp_retrieve_dirs PARAMS ((struct url *, struct fileinfo *, - ccon *)); -static uerr_t ftp_retrieve_glob PARAMS ((struct url *, ccon *, int)); -static struct fileinfo *delelement PARAMS ((struct fileinfo *, - struct fileinfo **)); -static void freefileinfo PARAMS ((struct fileinfo *f)); +static uerr_t ftp_retrieve_dirs (struct url *, struct fileinfo *, ccon *); +static uerr_t ftp_retrieve_glob (struct url *, ccon *, int); +static struct fileinfo *delelement (struct fileinfo *, struct fileinfo **); +static void freefileinfo (struct fileinfo *f); /* Retrieve a list of files given in struct fileinfo linked list. If a file is a symbolic link, do not retrieve it, but rather try to @@ -1379,7 +1353,7 @@ struct fileinfo *orig; wgint local_size; time_t tml; - int dlthis; + bool dlthis; /* Increase the depth. */ ++depth; @@ -1425,7 +1399,7 @@ con->target = url_file_name (u); err = RETROK; - dlthis = 1; + dlthis = true; if (opt.timestamping && f->type == FT_PLAINFILE) { struct_stat st; @@ -1436,8 +1410,8 @@ .orig suffix. */ if (!stat (con->target, &st)) { - int eq_size; - int cor_val; + bool eq_size; + bool cor_val; /* Else, get it from the file. */ local_size = st.st_size; tml = st.st_mtime; @@ -1447,17 +1421,17 @@ tml++; #endif /* Compare file sizes only for servers that tell us correct - values. Assumme sizes being equal for servers that lie + values. Assume sizes being equal for servers that lie about file size. */ cor_val = (con->rs == ST_UNIX || con->rs == ST_WINNT); - eq_size = cor_val ? (local_size == f->size) : 1 ; + eq_size = cor_val ? (local_size == f->size) : true; if (f->tstamp <= tml && eq_size) { /* Remote file is older, file sizes can be compared and are both equal. */ logprintf (LOG_VERBOSE, _("\ Remote file no newer than local file `%s' -- not retrieving.\n"), con->target); - dlthis = 0; + dlthis = false; } else if (eq_size) { @@ -1507,7 +1481,7 @@ logprintf (LOG_VERBOSE, _("\ Already have correct symlink %s -> %s\n\n"), con->target, escnonprint (f->linkto)); - dlthis = 0; + dlthis = false; break; } } @@ -1646,7 +1620,7 @@ DEBUGP (("Composing new CWD relative to the initial directory.\n")); DEBUGP ((" odir = '%s'\n f->name = '%s'\n newdir = '%s'\n\n", odir, f->name, newdir)); - if (!accdir (newdir, ALLABS)) + if (!accdir (newdir)) { logprintf (LOG_VERBOSE, _("\ Not descending to `%s' as it is excluded/not-included.\n"), @@ -1672,17 +1646,17 @@ return RETROK; } -/* Return non-zero if S has a leading '/' or contains '../' */ -static int +/* Return true if S has a leading '/' or contains '../' */ +static bool has_insecure_name_p (const char *s) { if (*s == '/') - return 1; + return true; if (strstr (s, "../") != 0) - return 1; + return true; - return 0; + return false; } /* A near-top-level function to retrieve the files in a directory. @@ -1739,12 +1713,14 @@ If we are dealing with a globbing pattern, that is. */ if (*u->file && (action == GLOB_GLOBALL || action == GLOB_GETONE)) { + int (*matcher) (const char *, const char *, int) + = opt.ignore_case ? fnmatch_nocase : fnmatch; int matchres = 0; f = start; while (f) { - matchres = fnmatch (u->file, f->name, 0); + matchres = matcher (u->file, f->name, 0); if (matchres == -1) { logprintf (LOG_NOTQUIET, "%s: %s\n", con->target, @@ -1797,7 +1773,7 @@ of URL. Inherently, its capabilities are limited on what can be encoded into a URL. */ uerr_t -ftp_loop (struct url *u, int *dt, struct url *proxy) +ftp_loop (struct url *u, int *dt, struct url *proxy, bool recursive, bool glob) { ccon con; /* FTP connection */ uerr_t res; @@ -1815,7 +1791,7 @@ /* If the file name is empty, the user probably wants a directory index. We'll provide one, properly HTML-ized. Unless opt.htmlify is 0, of course. :-) */ - if (!*u->file && !opt.recursive) + if (!*u->file && !recursive) { struct fileinfo *f; res = ftp_get_listing (u, &con, &f); @@ -1855,8 +1831,8 @@ } else { - int ispattern = 0; - if (opt.ftp_glob) + bool ispattern = false; + if (glob) { /* Treat the URL as a pattern if the file name part of the URL path contains wildcards. (Don't check for u->file @@ -1867,7 +1843,7 @@ file_part = u->path; ispattern = has_wildcards_p (file_part); } - if (ispattern || opt.recursive || opt.timestamping) + if (ispattern || recursive || opt.timestamping) { /* ftp_retrieve_glob is a catch-all function that gets called if we need globbing, time-stamping or recursion. Its diff -urN wget-1.10.2/src/ftp.h wget-1.10.2_new/src/ftp.h --- wget-1.10.2/src/ftp.h 2005-04-06 22:42:22.000000000 +0200 +++ wget-1.10.2_new/src/ftp.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for FTP support. - Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -42,28 +42,30 @@ ST_OS400, ST_OTHER }; - -uerr_t ftp_response PARAMS ((int, char **)); -uerr_t ftp_login PARAMS ((int, const char *, const char *)); -uerr_t ftp_port PARAMS ((int, int *)); -uerr_t ftp_pasv PARAMS ((int, ip_address *, int *)); + +extern char ftp_last_respline[]; + +uerr_t ftp_response (int, char **); +uerr_t ftp_login (int, const char *, const char *); +uerr_t ftp_port (int, int *); +uerr_t ftp_pasv (int, ip_address *, int *); #ifdef ENABLE_IPV6 -uerr_t ftp_lprt PARAMS ((int, int *)); -uerr_t ftp_lpsv PARAMS ((int, ip_address *, int *)); -uerr_t ftp_eprt PARAMS ((int, int *)); -uerr_t ftp_epsv PARAMS ((int, ip_address *, int *)); +uerr_t ftp_lprt (int, int *); +uerr_t ftp_lpsv (int, ip_address *, int *); +uerr_t ftp_eprt (int, int *); +uerr_t ftp_epsv (int, ip_address *, int *); #endif -uerr_t ftp_type PARAMS ((int, int)); -uerr_t ftp_cwd PARAMS ((int, const char *)); -uerr_t ftp_retr PARAMS ((int, const char *)); -uerr_t ftp_rest PARAMS ((int, wgint)); -uerr_t ftp_list PARAMS ((int, const char *)); -uerr_t ftp_syst PARAMS ((int, enum stype *)); -uerr_t ftp_pwd PARAMS ((int, char **)); -uerr_t ftp_size PARAMS ((int, const char *, wgint *)); +uerr_t ftp_type (int, int); +uerr_t ftp_cwd (int, const char *); +uerr_t ftp_retr (int, const char *); +uerr_t ftp_rest (int, wgint); +uerr_t ftp_list (int, const char *); +uerr_t ftp_syst (int, enum stype *); +uerr_t ftp_pwd (int, char **); +uerr_t ftp_size (int, const char *, wgint *); #ifdef ENABLE_OPIE -const char *skey_response PARAMS ((int, const char *, const char *)); +const char *skey_response (int, const char *, const char *); #endif struct url; @@ -116,12 +118,12 @@ correct. */ }; -struct fileinfo *ftp_parse_ls PARAMS ((const char *, const enum stype)); -uerr_t ftp_loop PARAMS ((struct url *, int *, struct url *)); +struct fileinfo *ftp_parse_ls (const char *, const enum stype); +uerr_t ftp_loop (struct url *, int *, struct url *, bool, bool); -uerr_t ftp_index PARAMS ((const char *, struct url *, struct fileinfo *)); +uerr_t ftp_index (const char *, struct url *, struct fileinfo *); -char ftp_process_type PARAMS ((const char *)); +char ftp_process_type (const char *); #endif /* FTP_H */ diff -urN wget-1.10.2/src/ftp-ls.c wget-1.10.2_new/src/ftp-ls.c --- wget-1.10.2/src/ftp-ls.c 2005-08-04 23:52:33.000000000 +0200 +++ wget-1.10.2_new/src/ftp-ls.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,6 +1,5 @@ /* Parsing FTP `ls' output. - Copyright (C) 1995, 1996, 1997, 2000, 2001 - Free Software Foundation, Inc. + Copyright (C) 1996-2004 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -15,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -32,24 +31,19 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #ifdef HAVE_UNISTD_H # include #endif -#include #include +#include #include "wget.h" #include "utils.h" #include "ftp.h" #include "url.h" #include "convert.h" /* for html_quote_string prototype */ - -extern FILE *output_stream; +#include "retr.h" /* for output_stream */ /* Converts symbolic permissions to number-style ones, e.g. string rwxr-xr-x to 755. For now, it knows nothing of @@ -201,7 +195,7 @@ This tactic is quite dubious when it comes to internationalization issues (non-English month names), but it works for now. */ - ptok = line; + tok = line; while (ptok = tok, (tok = strtok (NULL, " ")) != NULL) { @@ -217,25 +211,22 @@ { wgint size; - /* Back up to the beginning of the previous token - and parse it with str_to_wgint. */ - char *t = ptok; - while (t > line && ISDIGIT (*t)) - --t; - if (t == line) + /* Parse the previous token with str_to_wgint. */ + if (ptok == line) { /* Something has gone wrong during parsing. */ error = 1; break; } errno = 0; - size = str_to_wgint (t, NULL, 10); + size = str_to_wgint (ptok, NULL, 10); if (size == WGINT_MAX && errno == ERANGE) /* Out of range -- ignore the size. #### Should we refuse to start the download. */ cur.size = 0; else cur.size = size; + DEBUGP (("size: %s; ", number_to_static_string(cur.size))); month = i; next = 5; @@ -336,7 +327,7 @@ default -F output. I believe these cases are very rare. */ fnlen = strlen (tok); /* re-calculate `fnlen' */ - cur.name = (char *)xmalloc (fnlen + 1); + cur.name = xmalloc (fnlen + 1); memcpy (cur.name, tok, fnlen + 1); if (fnlen) { @@ -369,7 +360,7 @@ if (!cur.name || (cur.type == FT_SYMLINK && !cur.linkto)) error = 1; - DEBUGP (("\n")); + DEBUGP (("%s\n", cur.name ? cur.name : "")); if (error || ignore) { @@ -650,7 +641,8 @@ tok = strtok(line, " "); if (tok == NULL) tok = line; DEBUGP(("file name: '%s'\n", tok)); - for (p = tok ; *p && *p != ';' ; p++); + for (p = tok ; *p && *p != ';' ; p++) + ; if (*p == ';') *p = '\0'; p = tok + strlen(tok) - 4; if (!strcmp(p, ".DIR")) *p = '\0'; @@ -732,10 +724,12 @@ min = sec = 0; p = tok; hour = atoi (p); - for (; *p && *p != ':'; ++p); + for (; *p && *p != ':'; ++p) + ; if (*p) min = atoi (++p); - for (; *p && *p != ':'; ++p); + for (; *p && *p != ':'; ++p) + ; if (*p) sec = atoi (++p); @@ -781,14 +775,14 @@ /* And put everything into the linked list */ if (!dir) { - l = dir = (struct fileinfo *)xmalloc (sizeof (struct fileinfo)); + l = dir = xnew (struct fileinfo); memcpy (l, &cur, sizeof (cur)); l->prev = l->next = NULL; } else { cur.prev = l; - l->next = (struct fileinfo *)xmalloc (sizeof (struct fileinfo)); + l->next = xnew (struct fileinfo); l = l->next; memcpy (l, &cur, sizeof (cur)); l->next = NULL; @@ -942,7 +936,7 @@ putc ('/', fp); fprintf (fp, " "); if (f->type == FT_PLAINFILE) - fprintf (fp, _(" (%s bytes)"), with_thousand_seps (f->size)); + fprintf (fp, _(" (%s bytes)"), number_to_static_string (f->size)); else if (f->type == FT_SYMLINK) fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)"); putc ('\n', fp); diff -urN wget-1.10.2/src/ftp-opie.c wget-1.10.2_new/src/ftp-opie.c --- wget-1.10.2/src/ftp-opie.c 2004-01-28 02:02:26.000000000 +0100 +++ wget-1.10.2_new/src/ftp-opie.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Opie (s/key) support for FTP. - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998-2004 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,11 +31,7 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include "wget.h" #include "gen-md5.h" diff -urN wget-1.10.2/src/gen-md5.c wget-1.10.2_new/src/gen-md5.c --- wget-1.10.2/src/gen-md5.c 2005-03-20 11:41:46.000000000 +0100 +++ wget-1.10.2_new/src/gen-md5.c 2006-06-27 12:16:40.000000000 +0200 @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the diff -urN wget-1.10.2/src/gen-md5.h wget-1.10.2_new/src/gen-md5.h --- wget-1.10.2/src/gen-md5.h 2003-10-31 15:31:56.000000000 +0100 +++ wget-1.10.2_new/src/gen-md5.h 2006-06-27 12:16:40.000000000 +0200 @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -42,9 +42,9 @@ gen_md5_context *var_name = \ (gen_md5_context *) alloca (gen_md5_context_size ()) -int gen_md5_context_size PARAMS ((void)); -void gen_md5_init PARAMS ((gen_md5_context *)); -void gen_md5_update PARAMS ((const unsigned char *, int, gen_md5_context *)); -void gen_md5_finish PARAMS ((gen_md5_context *, unsigned char *)); +int gen_md5_context_size (void); +void gen_md5_init (gen_md5_context *); +void gen_md5_update (const unsigned char *, int, gen_md5_context *); +void gen_md5_finish (gen_md5_context *, unsigned char *); #endif /* GEN_MD5_H */ diff -urN wget-1.10.2/src/getopt.c wget-1.10.2_new/src/getopt.c --- wget-1.10.2/src/getopt.c 2003-10-08 16:55:44.000000000 +0200 +++ wget-1.10.2_new/src/getopt.c 2006-06-27 12:16:40.000000000 +0200 @@ -196,11 +196,7 @@ # define my_index strchr #else -# if HAVE_STRING_H -# include -# else -# include -# endif +#include /* Avoid depending on library functions or files whose names are inconsistent. */ diff -urN wget-1.10.2/src/gnu-md5.c wget-1.10.2_new/src/gnu-md5.c --- wget-1.10.2/src/gnu-md5.c 2001-11-18 05:36:21.000000000 +0100 +++ wget-1.10.2_new/src/gnu-md5.c 2006-06-27 12:16:40.000000000 +0200 @@ -24,19 +24,9 @@ # include #endif -/* Wget */ -/*#if STDC_HEADERS || defined _LIBC*/ -# include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif -/*#else*/ -/*# ifndef HAVE_MEMCPY*/ -/*# define memcpy(d, s, n) bcopy ((s), (d), (n))*/ -/*# endif*/ -/*#endif*/ +/* modified for Wget: depend on C89 */ +#include +#include #include "wget.h" #include "gnu-md5.h" diff -urN wget-1.10.2/src/gnu-md5.h wget-1.10.2_new/src/gnu-md5.h --- wget-1.10.2/src/gnu-md5.h 2005-03-06 03:11:10.000000000 +0100 +++ wget-1.10.2_new/src/gnu-md5.h 2006-06-27 12:16:40.000000000 +0200 @@ -21,9 +21,7 @@ #ifndef _MD5_H #define _MD5_H 1 -#if defined HAVE_LIMITS_H || _LIBC -# include -#endif +#include /* The following contortions are an attempt to use the C preprocessor to determine an unsigned integral type that is 32 bits wide. An @@ -88,21 +86,21 @@ /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ -extern void md5_init_ctx PARAMS ((struct md5_ctx *ctx)); +extern void md5_init_ctx (struct md5_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ -extern void md5_process_block PARAMS ((const void *buffer, size_t len, - struct md5_ctx *ctx)); +extern void md5_process_block (const void *buffer, size_t len, + struct md5_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ -extern void md5_process_bytes PARAMS ((const void *buffer, size_t len, - struct md5_ctx *ctx)); +extern void md5_process_bytes (const void *buffer, size_t len, + struct md5_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little @@ -111,7 +109,7 @@ IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *md5_finish_ctx PARAMS ((struct md5_ctx *ctx, void *resbuf)); +extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf); /* Put result from CTX in first 16 bytes following RESBUF. The result is @@ -120,21 +118,20 @@ IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *md5_read_ctx PARAMS ((const struct md5_ctx *ctx, void *resbuf)); +extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf); #if 0 /* Unused in Wget */ /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ -extern int md5_stream PARAMS ((FILE *stream, void *resblock)); +extern int md5_stream (FILE *stream, void *resblock); #endif /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ -extern void *md5_buffer PARAMS ((const char *buffer, size_t len, - void *resblock)); +extern void *md5_buffer (const char *buffer, size_t len, void *resblock); #endif diff -urN wget-1.10.2/src/gnutls.c wget-1.10.2_new/src/gnutls.c --- wget-1.10.2/src/gnutls.c 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/src/gnutls.c 2006-06-27 12:16:40.000000000 +0200 @@ -0,0 +1,303 @@ +/* SSL support via GnuTLS library. + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Wget. + +GNU Wget is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GNU Wget is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +In addition, as a special exception, the Free Software Foundation +gives permission to link the code of its release of Wget with the +OpenSSL project's "OpenSSL" library (or with modified versions of it +that use the same license as the "OpenSSL" library), and distribute +the linked executables. You must obey the GNU General Public License +in all respects for all of the code used other than "OpenSSL". If you +modify this file, you may extend this exception to your version of the +file, but you are not obligated to do so. If you do not wish to do +so, delete this exception statement from your version. */ + +#include + +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include +#include + +#include +#include + +#include "wget.h" +#include "utils.h" +#include "connect.h" +#include "url.h" +#include "ssl.h" + +/* Note: some of the functions private to this file have names that + begin with "wgnutls_" (e.g. wgnutls_read) so that they wouldn't be + confused with actual gnutls functions -- such as the gnutls_read + preprocessor macro. */ + +static gnutls_certificate_credentials credentials; + +bool +ssl_init () +{ + gnutls_global_init (); + gnutls_certificate_allocate_credentials (&credentials); + if (opt.ca_cert) + gnutls_certificate_set_x509_trust_file (credentials, opt.ca_cert, + GNUTLS_X509_FMT_PEM); + return true; +} + +struct wgnutls_transport_context { + gnutls_session session; /* GnuTLS session handle */ + int last_error; /* last error returned by read/write/... */ + + /* Since GnuTLS doesn't support the equivalent to recv(..., + MSG_PEEK) or SSL_peek(), we have to do it ourselves. Peeked data + is stored to PEEKBUF, and wgnutls_read checks that buffer before + actually reading. */ + char peekbuf[512]; + int peekstart, peeklen; +}; + +#ifndef MIN +# define MIN(i, j) ((i) <= (j) ? (i) : (j)) +#endif + +static int +wgnutls_read (int fd, char *buf, int bufsize, void *arg) +{ + int ret; + struct wgnutls_transport_context *ctx = arg; + + if (ctx->peeklen) + { + /* If we have any peek data, simply return that. */ + int copysize = MIN (bufsize, ctx->peeklen); + memcpy (buf, ctx->peekbuf + ctx->peekstart, copysize); + ctx->peeklen -= copysize; + if (ctx->peeklen != 0) + ctx->peekstart += copysize; + else + ctx->peekstart = 0; + return copysize; + } + + do + ret = gnutls_record_recv (ctx->session, buf, bufsize); + while (ret == GNUTLS_E_INTERRUPTED); + + if (ret < 0) + ctx->last_error = ret; + return ret; +} + +static int +wgnutls_write (int fd, char *buf, int bufsize, void *arg) +{ + int ret; + struct wgnutls_transport_context *ctx = arg; + do + ret = gnutls_record_send (ctx->session, buf, bufsize); + while (ret == GNUTLS_E_INTERRUPTED); + if (ret < 0) + ctx->last_error = ret; + return ret; +} + +static int +wgnutls_poll (int fd, double timeout, int wait_for, void *arg) +{ + return 1; +} + +static int +wgnutls_peek (int fd, char *buf, int bufsize, void *arg) +{ + int ret; + struct wgnutls_transport_context *ctx = arg; + + /* We don't support peeks following peeks: the reader must drain all + peeked data before the next peek. */ + assert (ctx->peeklen == 0); + if (bufsize > sizeof ctx->peekbuf) + bufsize = sizeof ctx->peekbuf; + + do + ret = gnutls_record_recv (ctx->session, buf, bufsize); + while (ret == GNUTLS_E_INTERRUPTED); + + if (ret >= 0) + { + memcpy (ctx->peekbuf, buf, ret); + ctx->peeklen = ret; + } + return ret; +} + +static const char * +wgnutls_errstr (int fd, void *arg) +{ + struct wgnutls_transport_context *ctx = arg; + return gnutls_strerror (ctx->last_error); +} + +static void +wgnutls_close (int fd, void *arg) +{ + struct wgnutls_transport_context *ctx = arg; + /*gnutls_bye (ctx->session, GNUTLS_SHUT_RDWR);*/ + gnutls_deinit (ctx->session); + xfree (ctx); +#ifndef WINDOWS + close (fd); +#else + closesocket (fd); +#endif +} + +/* gnutls_transport is the singleton that describes the SSL transport + methods provided by this file. */ + +static struct transport_implementation wgnutls_transport = { + wgnutls_read, wgnutls_write, wgnutls_poll, + wgnutls_peek, wgnutls_errstr, wgnutls_close +}; + +bool +ssl_connect (int fd) +{ + static const int cert_type_priority[] = { + GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 + }; + struct wgnutls_transport_context *ctx; + gnutls_session session; + int err; + gnutls_init (&session, GNUTLS_CLIENT); + gnutls_set_default_priority (session); + gnutls_certificate_type_set_priority (session, cert_type_priority); + gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, credentials); + gnutls_transport_set_ptr (session, (gnutls_transport_ptr) fd); + err = gnutls_handshake (session); + if (err < 0) + { + logprintf (LOG_NOTQUIET, "GnuTLS: %s\n", gnutls_strerror (err)); + gnutls_deinit (session); + return false; + } + ctx = xnew0 (struct wgnutls_transport_context); + ctx->session = session; + fd_register_transport (fd, &wgnutls_transport, ctx); + return true; +} + +bool +ssl_check_certificate (int fd, const char *host) +{ + struct wgnutls_transport_context *ctx = fd_transport_context (fd); + + unsigned int status; + int err; + + /* If the user has specified --no-check-cert, we still want to warn + him about problems with the server's certificate. */ + const char *severity = opt.check_cert ? _("ERROR") : _("WARNING"); + bool success = true; + + err = gnutls_certificate_verify_peers2 (ctx->session, &status); + if (err < 0) + { + logprintf (LOG_NOTQUIET, _("%s: No certificate presented by %s.\n"), + severity, escnonprint (host)); + success = false; + goto out; + } + + if (status & GNUTLS_CERT_INVALID) + { + logprintf (LOG_NOTQUIET, _("%s: The certificate of `%s' is not trusted.\n"), + severity, escnonprint (host)); + success = false; + } + if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) + { + logprintf (LOG_NOTQUIET, _("%s: The certificate of `%s' hasn't got a known issuer.\n"), + severity, escnonprint (host)); + success = false; + } + if (status & GNUTLS_CERT_REVOKED) + { + logprintf (LOG_NOTQUIET, _("%s: The certificate of `%s' has been revoked.\n"), + severity, escnonprint (host)); + success = false; + } + + if (gnutls_certificate_type_get (ctx->session) == GNUTLS_CRT_X509) + { + time_t now = time (NULL); + gnutls_x509_crt cert; + const gnutls_datum *cert_list; + unsigned int cert_list_size; + + if ((err = gnutls_x509_crt_init (&cert)) < 0) + { + logprintf (LOG_NOTQUIET, _("Error initializing X509 certificate: %s\n"), + gnutls_strerror (err)); + success = false; + goto out; + } + + cert_list = gnutls_certificate_get_peers (ctx->session, &cert_list_size); + if (!cert_list) + { + logprintf (LOG_NOTQUIET, _("No certificate found\n")); + success = false; + goto out; + } + err = gnutls_x509_crt_import (cert, cert_list, GNUTLS_X509_FMT_DER); + if (err < 0) + { + logprintf (LOG_NOTQUIET, _("Error parsing certificate: %s\n"), + gnutls_strerror (err)); + success = false; + goto out; + } + if (now < gnutls_x509_crt_get_activation_time (cert)) + { + logprintf (LOG_NOTQUIET, _("The certificate has not yet been activated\n")); + success = false; + } + if (now >= gnutls_x509_crt_get_expiration_time (cert)) + { + logprintf (LOG_NOTQUIET, _("The certificate has expired\n")); + success = false; + } + if (!gnutls_x509_crt_check_hostname (cert, host)) + { + logprintf (LOG_NOTQUIET, + _("The certificate's owner does not match hostname '%s'\n"), + host); + success = false; + } + gnutls_x509_crt_deinit (cert); + } + + out: + return opt.check_cert ? success : true; +} diff -urN wget-1.10.2/src/hash.c wget-1.10.2_new/src/hash.c --- wget-1.10.2/src/hash.c 2005-04-28 15:52:02.000000000 +0200 +++ wget-1.10.2_new/src/hash.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Hash tables. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -32,24 +32,13 @@ #ifdef HAVE_CONFIG_H # include -# ifdef HAVE_STRING_H -# include -# else -# include -# endif -# ifdef HAVE_LIMITS_H -# include -# endif -#else -/* If running without Autoconf, go ahead and assume presence of - standard C89 headers. */ -# include -# include #endif #include #include #include +#include +#include #ifndef STANDALONE /* Get Wget's utility headers. */ @@ -59,12 +48,18 @@ /* Make do without them. */ # define xnew(x) xmalloc (sizeof (x)) # define xnew_array(type, x) xmalloc (sizeof (type) * (x)) -# define xmalloc malloc /* or something that exits - if not enough memory */ +# define xmalloc malloc # define xfree free -# define countof(x) (sizeof (x) / sizeof ((x)[0])) -# define TOLOWER(x) ('A' <= (x) && (x) <= 'Z' ? (x) - 32 : (x)) -# define PARAMS(x) x +# ifndef countof +# define countof(x) (sizeof (x) / sizeof ((x)[0])) +# endif +# include +# define TOLOWER(x) tolower ((unsigned char) (x)) +# if __STDC_VERSION__ >= 199901L +# include /* for uintptr_t */ +# else + typedef unsigned long uintptr_t; +# endif #endif #include "hash.h" @@ -84,8 +79,10 @@ hash_table_get -- retrieves value of key. hash_table_get_pair -- get key/value pair for key. hash_table_contains -- test whether the table contains key. - hash_table_remove -- remove the key->value mapping for key. - hash_table_map -- iterate through table mappings. + hash_table_remove -- remove key->value mapping for given key. + hash_table_for_each -- call function for each table entry. + hash_table_iterate -- iterate over entries in hash table. + hash_table_iter_next -- return next element during iteration. hash_table_clear -- clear hash table contents. hash_table_count -- return the number of entries in the table. @@ -94,33 +91,34 @@ with each resize, which ensures that the amortized time per operation remains constant. - By default, tables created by hash_table_new consider the keys to - be equal if their pointer values are the same. You can use - make_string_hash_table to create tables whose keys are considered - equal if their string contents are the same. In the general case, - the criterion of equality used to compare keys is specified at - table creation time with two callback functions, "hash" and "test". - The hash function transforms the key into an arbitrary number that - must be the same for two equal keys. The test function accepts two - keys and returns non-zero if they are to be considered equal. + If not instructed otherwise, tables created by hash_table_new + consider the keys to be equal if their pointer values are the same. + You can use make_string_hash_table to create tables whose keys are + considered equal if their string contents are the same. In the + general case, the criterion of equality used to compare keys is + specified at table creation time with two callback functions, + "hash" and "test". The hash function transforms the key into an + arbitrary number that must be the same for two equal keys. The + test function accepts two keys and returns non-zero if they are to + be considered equal. Note that neither keys nor values are copied when inserted into the hash table, so they must exist for the lifetime of the table. This means that e.g. the use of static strings is OK, but objects with a - shorter life-time need to be copied (with strdup() or the like in - the case of strings) before being inserted. */ + shorter life-time probably need to be copied (with strdup() or the + like in the case of strings) before being inserted. */ /* IMPLEMENTATION: The hash table is implemented as an open-addressed table with linear probing collision resolution. - The above means that all the hash entries (pairs of pointers, key - and value) are stored in a contiguous array. The position of each - mapping is determined by the hash value of its key and the size of - the table: location := hash(key) % size. If two different keys end - up on the same position (collide), the one that came second is - placed at the next empty position following the occupied place. + The above means that all the cells (each cell containing a key and + a value pointer) are stored in a contiguous array. Array position + of each cell is determined by the hash value of its key and the + size of the table: location := hash(key) % size. If two different + keys end up on the same position (collide), the one that came + second is stored in the first unoccupied cell that follows it. This collision resolution technique is called "linear probing". There are more advanced collision resolution methods (quadratic @@ -130,13 +128,13 @@ count/size ratio (fullness) is kept below 75%. We make sure to grow and rehash the table whenever this threshold is exceeded. - Collisions make deletion tricky because clearing a position - followed by a colliding entry would make the position seem empty - and the colliding entry not found. One solution is to leave a - "tombstone" instead of clearing the entry, and another is to - carefully rehash the entries immediately following the deleted one. - We use the latter method because it results in less bookkeeping and - faster retrieval at the (slight) expense of deletion. */ + Collisions complicate deletion because simply clearing a cell + followed by previously collided entries would cause those neighbors + to not be picked up by find_cell later. One solution is to leave a + "tombstone" marker instead of clearing the cell, and another is to + recalculate the positions of adjacent cells. We take the latter + approach because it results in less bookkeeping garbage and faster + retrieval at the (slight) expense of deletion. */ /* Maximum allowed fullness: when hash table's fullness exceeds this value, the table is resized. */ @@ -147,22 +145,22 @@ resizes. */ #define HASH_RESIZE_FACTOR 2 -struct mapping { +struct cell { void *key; void *value; }; -typedef unsigned long (*hashfun_t) PARAMS ((const void *)); -typedef int (*testfun_t) PARAMS ((const void *, const void *)); +typedef unsigned long (*hashfun_t) (const void *); +typedef int (*testfun_t) (const void *, const void *); struct hash_table { hashfun_t hash_function; testfun_t test_function; - struct mapping *mappings; /* pointer to the table entries. */ + struct cell *cells; /* contiguous array of cells. */ int size; /* size of the array. */ - int count; /* number of non-empty entries. */ + int count; /* number of occupied entries. */ int resize_threshold; /* after size exceeds this number of entries, resize the table. */ int prime_offset; /* the offset of the current prime in @@ -170,9 +168,9 @@ }; /* We use the all-bits-set constant (INVALID_PTR) marker to mean that - a mapping is empty. It is unaligned and therefore illegal as a - pointer. INVALID_PTR_BYTE (0xff) is the one-byte value used to - initialize the mappings array as empty. + a cell is empty. It is unaligned and therefore illegal as a + pointer. INVALID_PTR_CHAR (0xff) is the single-character constant + used to initialize the entire cells array as empty. The all-bits-set value is a better choice than NULL because it allows the use of NULL/0 keys. Since the keys are either integers @@ -180,23 +178,26 @@ -1. This is acceptable because it still allows the use of nonnegative integer keys. */ -#define INVALID_PTR ((void *) ~(unsigned long)0) +#define INVALID_PTR ((void *) ~(uintptr_t) 0) #ifndef UCHAR_MAX # define UCHAR_MAX 0xff #endif -#define INVALID_PTR_BYTE UCHAR_MAX +#define INVALID_PTR_CHAR UCHAR_MAX -#define NON_EMPTY(mp) ((mp)->key != INVALID_PTR) -#define MARK_AS_EMPTY(mp) ((mp)->key = INVALID_PTR) +/* Whether the cell C is occupied (non-empty). */ +#define CELL_OCCUPIED(c) ((c)->key != INVALID_PTR) -/* "Next" mapping is the mapping after MP, but wrapping back to - MAPPINGS when MP would reach MAPPINGS+SIZE. */ -#define NEXT_MAPPING(mp, mappings, size) (mp != mappings + (size - 1) \ - ? mp + 1 : mappings) - -/* Loop over non-empty mappings starting at MP. */ -#define LOOP_NON_EMPTY(mp, mappings, size) \ - for (; NON_EMPTY (mp); mp = NEXT_MAPPING (mp, mappings, size)) +/* Clear the cell C, i.e. mark it as empty (unoccupied). */ +#define CLEAR_CELL(c) ((c)->key = INVALID_PTR) + +/* "Next" cell is the cell following C, but wrapping back to CELLS + when C would reach CELLS+SIZE. */ +#define NEXT_CELL(c, cells, size) (c != cells + (size - 1) ? c + 1 : cells) + +/* Loop over occupied cells starting at C, terminating the loop when + an empty cell is encountered. */ +#define FOREACH_OCCUPIED_ADJACENT(c, cells, size) \ + for (; CELL_OCCUPIED (c); c = NEXT_CELL (c, cells, size)) /* Return the position of KEY in hash table SIZE large, hash function being HASHFUN. */ @@ -242,7 +243,7 @@ abort (); } -static int cmp_pointer PARAMS ((const void *, const void *)); +static int cmp_pointer (const void *, const void *); /* Create a hash table with hash function HASH_FUNCTION and test function TEST_FUNCTION. The table is empty (its count is 0), but @@ -291,11 +292,11 @@ ht->resize_threshold = size * HASH_MAX_FULLNESS; /*assert (ht->resize_threshold >= items);*/ - ht->mappings = xnew_array (struct mapping, ht->size); + ht->cells = xnew_array (struct cell, ht->size); - /* Mark mappings as empty. We use 0xff rather than 0 to mark empty + /* Mark cells as empty. We use 0xff rather than 0 to mark empty keys because it allows us to use NULL/0 as keys. */ - memset (ht->mappings, INVALID_PTR_BYTE, size * sizeof (struct mapping)); + memset (ht->cells, INVALID_PTR_CHAR, size * sizeof (struct cell)); ht->count = 0; @@ -307,26 +308,26 @@ void hash_table_destroy (struct hash_table *ht) { - xfree (ht->mappings); + xfree (ht->cells); xfree (ht); } -/* The heart of most functions in this file -- find the mapping whose - KEY is equal to key, using linear probing. Returns the mapping - that matches KEY, or the first empty mapping if none matches. */ +/* The heart of most functions in this file -- find the cell whose + KEY is equal to key, using linear probing. Returns the cell + that matches KEY, or the first empty cell if none matches. */ -static inline struct mapping * -find_mapping (const struct hash_table *ht, const void *key) +static inline struct cell * +find_cell (const struct hash_table *ht, const void *key) { - struct mapping *mappings = ht->mappings; + struct cell *cells = ht->cells; int size = ht->size; - struct mapping *mp = mappings + HASH_POSITION (key, ht->hash_function, size); + struct cell *c = cells + HASH_POSITION (key, ht->hash_function, size); testfun_t equals = ht->test_function; - LOOP_NON_EMPTY (mp, mappings, size) - if (equals (key, mp->key)) + FOREACH_OCCUPIED_ADJACENT (c, cells, size) + if (equals (key, c->key)) break; - return mp; + return c; } /* Get the value that corresponds to the key KEY in the hash table HT. @@ -339,9 +340,9 @@ void * hash_table_get (const struct hash_table *ht, const void *key) { - struct mapping *mp = find_mapping (ht, key); - if (NON_EMPTY (mp)) - return mp->value; + struct cell *c = find_cell (ht, key); + if (CELL_OCCUPIED (c)) + return c->value; else return NULL; } @@ -353,13 +354,13 @@ hash_table_get_pair (const struct hash_table *ht, const void *lookup_key, void *orig_key, void *value) { - struct mapping *mp = find_mapping (ht, lookup_key); - if (NON_EMPTY (mp)) + struct cell *c = find_cell (ht, lookup_key); + if (CELL_OCCUPIED (c)) { if (orig_key) - *(void **)orig_key = mp->key; + *(void **)orig_key = c->key; if (value) - *(void **)value = mp->value; + *(void **)value = c->value; return 1; } else @@ -371,8 +372,8 @@ int hash_table_contains (const struct hash_table *ht, const void *key) { - struct mapping *mp = find_mapping (ht, key); - return NON_EMPTY (mp); + struct cell *c = find_cell (ht, key); + return CELL_OCCUPIED (c); } /* Grow hash table HT as necessary, and rehash all the key-value @@ -382,9 +383,9 @@ grow_hash_table (struct hash_table *ht) { hashfun_t hasher = ht->hash_function; - struct mapping *old_mappings = ht->mappings; - struct mapping *old_end = ht->mappings + ht->size; - struct mapping *mp, *mappings; + struct cell *old_cells = ht->cells; + struct cell *old_end = ht->cells + ht->size; + struct cell *c, *cells; int newsize; newsize = prime_size (ht->size * HASH_RESIZE_FACTOR, &ht->prime_offset); @@ -398,24 +399,24 @@ ht->size = newsize; ht->resize_threshold = newsize * HASH_MAX_FULLNESS; - mappings = xnew_array (struct mapping, newsize); - memset (mappings, INVALID_PTR_BYTE, newsize * sizeof (struct mapping)); - ht->mappings = mappings; + cells = xnew_array (struct cell, newsize); + memset (cells, INVALID_PTR_CHAR, newsize * sizeof (struct cell)); + ht->cells = cells; - for (mp = old_mappings; mp < old_end; mp++) - if (NON_EMPTY (mp)) + for (c = old_cells; c < old_end; c++) + if (CELL_OCCUPIED (c)) { - struct mapping *new_mp; + struct cell *new_c; /* We don't need to test for uniqueness of keys because they come from the hash table and are therefore known to be unique. */ - new_mp = mappings + HASH_POSITION (mp->key, hasher, newsize); - LOOP_NON_EMPTY (new_mp, mappings, newsize) + new_c = cells + HASH_POSITION (c->key, hasher, newsize); + FOREACH_OCCUPIED_ADJACENT (new_c, cells, newsize) ; - *new_mp = *mp; + *new_c = *c; } - xfree (old_mappings); + xfree (old_cells); } /* Put VALUE in the hash table HT under the key KEY. This regrows the @@ -424,12 +425,12 @@ void hash_table_put (struct hash_table *ht, const void *key, void *value) { - struct mapping *mp = find_mapping (ht, key); - if (NON_EMPTY (mp)) + struct cell *c = find_cell (ht, key); + if (CELL_OCCUPIED (c)) { /* update existing item */ - mp->key = (void *)key; /* const? */ - mp->value = value; + c->key = (void *)key; /* const? */ + c->value = value; return; } @@ -438,54 +439,54 @@ if (ht->count >= ht->resize_threshold) { grow_hash_table (ht); - mp = find_mapping (ht, key); + c = find_cell (ht, key); } /* add new item */ ++ht->count; - mp->key = (void *)key; /* const? */ - mp->value = value; + c->key = (void *)key; /* const? */ + c->value = value; } -/* Remove a mapping that matches KEY from HT. Return 0 if there was - no such entry; return 1 if an entry was removed. */ +/* Remove KEY->value mapping from HT. Return 0 if there was no such + entry; return 1 if an entry was removed. */ int hash_table_remove (struct hash_table *ht, const void *key) { - struct mapping *mp = find_mapping (ht, key); - if (!NON_EMPTY (mp)) + struct cell *c = find_cell (ht, key); + if (!CELL_OCCUPIED (c)) return 0; else { int size = ht->size; - struct mapping *mappings = ht->mappings; + struct cell *cells = ht->cells; hashfun_t hasher = ht->hash_function; - MARK_AS_EMPTY (mp); + CLEAR_CELL (c); --ht->count; - /* Rehash all the entries following MP. The alternative + /* Rehash all the entries following C. The alternative approach is to mark the entry as deleted, i.e. create a "tombstone". That speeds up removal, but leaves a lot of garbage and slows down hash_table_get and hash_table_put. */ - mp = NEXT_MAPPING (mp, mappings, size); - LOOP_NON_EMPTY (mp, mappings, size) + c = NEXT_CELL (c, cells, size); + FOREACH_OCCUPIED_ADJACENT (c, cells, size) { - const void *key2 = mp->key; - struct mapping *mp_new; + const void *key2 = c->key; + struct cell *c_new; /* Find the new location for the key. */ - mp_new = mappings + HASH_POSITION (key2, hasher, size); - LOOP_NON_EMPTY (mp_new, mappings, size) - if (key2 == mp_new->key) - /* The mapping MP (key2) is already where we want it (in - MP_NEW's "chain" of keys.) */ + c_new = cells + HASH_POSITION (key2, hasher, size); + FOREACH_OCCUPIED_ADJACENT (c_new, cells, size) + if (key2 == c_new->key) + /* The cell C (key2) is already where we want it (in + C_NEW's "chain" of keys.) */ goto next_rehash; - *mp_new = *mp; - MARK_AS_EMPTY (mp); + *c_new = *c; + CLEAR_CELL (c); next_rehash: ; @@ -501,41 +502,84 @@ void hash_table_clear (struct hash_table *ht) { - memset (ht->mappings, INVALID_PTR_BYTE, ht->size * sizeof (struct mapping)); + memset (ht->cells, INVALID_PTR_CHAR, ht->size * sizeof (struct cell)); ht->count = 0; } -/* Map MAPFUN over all the mappings in hash table HT. MAPFUN is - called with three arguments: the key, the value, and MAPARG. +/* Call FN for each entry in HT. FN is called with three arguments: + the key, the value, and ARG. When FN returns a non-zero value, the + mapping stops. It is undefined what happens if you add or remove entries in the - hash table while hash_table_map is running. The exception is the - entry you're currently mapping over; you may remove or change that - entry. */ + hash table while hash_table_for_each is running. The exception is + the entry you're currently mapping over; you may call + hash_table_put or hash_table_remove on that entry's key. That is + also the reason why this function cannot be implemented in terms of + hash_table_iterate. */ void -hash_table_map (struct hash_table *ht, - int (*mapfun) (void *, void *, void *), - void *maparg) +hash_table_for_each (struct hash_table *ht, + int (*fn) (void *, void *, void *), void *arg) { - struct mapping *mp = ht->mappings; - struct mapping *end = ht->mappings + ht->size; + struct cell *c = ht->cells; + struct cell *end = ht->cells + ht->size; - for (; mp < end; mp++) - if (NON_EMPTY (mp)) + for (; c < end; c++) + if (CELL_OCCUPIED (c)) { void *key; repeat: - key = mp->key; - if (mapfun (key, mp->value, maparg)) + key = c->key; + if (fn (key, c->value, arg)) return; - /* hash_table_remove might have moved the adjacent - mappings. */ - if (mp->key != key && NON_EMPTY (mp)) + /* hash_table_remove might have moved the adjacent cells. */ + if (c->key != key && CELL_OCCUPIED (c)) goto repeat; } } +/* Initiate iteration over HT. Entries are obtained with + hash_table_iter_next, a typical iteration loop looking like this: + + hash_table_iterator iter; + for (hash_table_iterate (ht, &iter); hash_table_iter_next (&iter); ) + ... do something with iter.key and iter.value ... + + The iterator does not need to be deallocated after use. The hash + table must not be modified while being iterated over. */ + +void +hash_table_iterate (struct hash_table *ht, hash_table_iterator *iter) +{ + iter->pos = ht->cells; + iter->end = ht->cells + ht->size; +} + +/* Get the next hash table entry. ITER is an iterator object + initialized using hash_table_iterate. While there are more + entries, the key and value pointers are stored to ITER->key and + ITER->value respectively and 1 is returned. When there are no more + entries, 0 is returned. + + If the hash table is modified between calls to this function, the + result is undefined. */ + +int +hash_table_iter_next (hash_table_iterator *iter) +{ + struct cell *c = iter->pos; + struct cell *end = iter->end; + for (; c < end; c++) + if (CELL_OCCUPIED (c)) + { + iter->key = c->key; + iter->value = c->value; + iter->pos = c + 1; + return 1; + } + return 0; +} + /* Return the number of elements in the hash table. This is not the same as the physical size of the hash table, which is always greater than the number of elements. */ @@ -566,7 +610,7 @@ a hash function that returns 0 for any given object is a perfectly valid (albeit extremely bad) hash function. A hash function that hashes a string by adding up all its characters is - another example of a valid (but quite bad) hash function. + another example of a valid (but still quite bad) hash function. It is not hard to make hash and test functions agree about equality. For example, if the test function compares strings @@ -574,24 +618,25 @@ characters when calculating the hash value. That ensures that two strings differing only in case will hash the same. - - If you care about performance, choose a hash function with as - good "spreading" as possible. A good hash function will use all - the bits of the input when calculating the hash, and will react - to even small changes in input with a completely different - output. Finally, don't make the hash function itself overly - slow, because you'll be incurring a non-negligible overhead to - all hash table operations. */ + - To prevent performance degradation, choose a hash function with + as good "spreading" as possible. A good hash function will use + all the bits of the input when calculating the hash, and will + react to even small changes in input with a completely different + output. But don't make the hash function itself overly slow, + because you'll be incurring a non-negligible overhead to all hash + table operations. */ /* * Support for hash tables whose keys are strings. * */ -/* 31 bit hash function. Taken from Gnome's glib, modified to use +/* Base 31 hash function. Taken from Gnome's glib, modified to use standard C types. We used to use the popular hash function from the Dragon Book, but - this one seems to perform much better. */ + this one seems to perform much better, both by being faster and by + generating less collisions. */ static unsigned long hash_string (const void *key) @@ -664,14 +709,15 @@ /* Hashing of numeric values, such as pointers and integers. This implementation is the Robert Jenkins' 32 bit Mix Function, - with a simple adaptation for 64-bit values. It offers excellent - spreading of values and doesn't need to know the hash table size to - work (unlike the very popular Knuth's multiplication hash). */ + with a simple adaptation for 64-bit values. According to Jenkins + it should offer excellent spreading of values. Unlike the popular + Knuth's multiplication hash, this function doesn't need to know the + hash table size to work. */ unsigned long hash_pointer (const void *ptr) { - unsigned long key = (unsigned long)ptr; + uintptr_t key = (uintptr_t) ptr; key += (key << 12); key ^= (key >> 22); key += (key << 4); @@ -680,7 +726,7 @@ key ^= (key >> 2); key += (key << 7); key ^= (key >> 12); -#if SIZEOF_LONG > 4 +#if SIZEOF_VOID_P > 4 key += (key << 44); key ^= (key >> 54); key += (key << 36); @@ -690,7 +736,7 @@ key += (key << 39); key ^= (key >> 44); #endif - return key; + return (unsigned long) key; } static int @@ -704,20 +750,16 @@ #include #include -int -print_hash_table_mapper (void *key, void *value, void *count) -{ - ++*(int *)count; - printf ("%s: %s\n", (const char *)key, (char *)value); - return 0; -} - void print_hash (struct hash_table *sht) { - int debug_count = 0; - hash_table_map (sht, print_hash_table_mapper, &debug_count); - assert (debug_count == sht->count); + hash_table_iterator iter; + int count = 0; + + for (hash_table_iterate (sht, &iter); hash_table_iter_next (&iter); + ++count) + printf ("%s: %s\n", iter.key, iter.value); + assert (count == sht->count); } int diff -urN wget-1.10.2/src/hash.h wget-1.10.2_new/src/hash.h --- wget-1.10.2/src/hash.h 2005-03-20 16:07:40.000000000 +0100 +++ wget-1.10.2_new/src/hash.h 2006-06-27 12:16:40.000000000 +0200 @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -32,41 +32,34 @@ struct hash_table; -struct hash_table *hash_table_new PARAMS ((int, - unsigned long (*) (const void *), - int (*) (const void *, - const void *))); -void hash_table_destroy PARAMS ((struct hash_table *)); - -void *hash_table_get PARAMS ((const struct hash_table *, const void *)); -int hash_table_get_pair PARAMS ((const struct hash_table *, const void *, - void *, void *)); -int hash_table_contains PARAMS ((const struct hash_table *, const void *)); - -void hash_table_put PARAMS ((struct hash_table *, const void *, void *)); -int hash_table_remove PARAMS ((struct hash_table *, const void *)); -void hash_table_clear PARAMS ((struct hash_table *)); - -void hash_table_map PARAMS ((struct hash_table *, - int (*) (void *, void *, void *), - void *)); -int hash_table_count PARAMS ((const struct hash_table *)); - -struct hash_table *make_string_hash_table PARAMS ((int)); -struct hash_table *make_nocase_string_hash_table PARAMS ((int)); - -unsigned long hash_pointer PARAMS ((const void *)); - -/* From XEmacs, and hence from Dragon book. */ - -#define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */ -#define HASH2(a,b) (GOOD_HASH * (a) + (b)) -#define HASH3(a,b,c) (GOOD_HASH * HASH2 (a,b) + (c)) -#define HASH4(a,b,c,d) (GOOD_HASH * HASH3 (a,b,c) + (d)) -#define HASH5(a,b,c,d,e) (GOOD_HASH * HASH4 (a,b,c,d) + (e)) -#define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f)) -#define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g)) -#define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h)) -#define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i)) +struct hash_table *hash_table_new (int, unsigned long (*) (const void *), + int (*) (const void *, const void *)); +void hash_table_destroy (struct hash_table *); + +void *hash_table_get (const struct hash_table *, const void *); +int hash_table_get_pair (const struct hash_table *, const void *, + void *, void *); +int hash_table_contains (const struct hash_table *, const void *); + +void hash_table_put (struct hash_table *, const void *, void *); +int hash_table_remove (struct hash_table *, const void *); +void hash_table_clear (struct hash_table *); + +void hash_table_for_each (struct hash_table *, + int (*) (void *, void *, void *), void *); + +typedef struct { + void *key, *value; /* public members */ + void *pos, *end; /* private members */ +} hash_table_iterator; +void hash_table_iterate (struct hash_table *, hash_table_iterator *); +int hash_table_iter_next (hash_table_iterator *); + +int hash_table_count (const struct hash_table *); + +struct hash_table *make_string_hash_table (int); +struct hash_table *make_nocase_string_hash_table (int); + +unsigned long hash_pointer (const void *); #endif /* HASH_H */ diff -urN wget-1.10.2/src/host.c wget-1.10.2_new/src/host.c --- wget-1.10.2/src/host.c 2005-07-02 15:31:37.000000000 +0200 +++ wget-1.10.2_new/src/host.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Host name resolution and matching. - Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,13 +31,8 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include -#include #ifndef WINDOWS # include @@ -59,16 +54,6 @@ #include "url.h" #include "hash.h" -#ifndef errno -extern int errno; -#endif - -#ifndef h_errno -# ifndef __CYGWIN__ -extern int h_errno; -# endif -#endif - #ifndef NO_ADDRESS # define NO_ADDRESS NO_DATA #endif @@ -81,7 +66,7 @@ ip_address *addresses; /* pointer to the string of addresses */ int faulty; /* number of addresses known not to work. */ - int connected; /* whether we were able to connect to + bool connected; /* whether we were able to connect to one of the addresses in the list, at least once. */ @@ -107,39 +92,36 @@ return al->addresses + pos; } -/* Return non-zero if AL contains IP, zero otherwise. */ +/* Return true if AL contains IP, false otherwise. */ -int +bool address_list_contains (const struct address_list *al, const ip_address *ip) { int i; - switch (ip->type) + switch (ip->family) { - case IPV4_ADDRESS: + case AF_INET: for (i = 0; i < al->count; i++) { ip_address *cur = al->addresses + i; - if (cur->type == IPV4_ADDRESS - && (ADDRESS_IPV4_IN_ADDR (cur).s_addr - == - ADDRESS_IPV4_IN_ADDR (ip).s_addr)) - return 1; + if (cur->family == AF_INET + && (cur->data.d4.s_addr == ip->data.d4.s_addr)) + return true; } - return 0; + return false; #ifdef ENABLE_IPV6 - case IPV6_ADDRESS: + case AF_INET6: for (i = 0; i < al->count; i++) { ip_address *cur = al->addresses + i; - if (cur->type == IPV6_ADDRESS + if (cur->family == AF_INET6 #ifdef HAVE_SOCKADDR_IN6_SCOPE_ID - && ADDRESS_IPV6_SCOPE (cur) == ADDRESS_IPV6_SCOPE (ip) + && cur->ipv6_scope == ip->ipv6_scope #endif - && IN6_ARE_ADDR_EQUAL (&ADDRESS_IPV6_IN6_ADDR (cur), - &ADDRESS_IPV6_IN6_ADDR (ip))) - return 1; + && IN6_ARE_ADDR_EQUAL (&cur->data.d6, &ip->data.d6)) + return true; } - return 0; + return false; #endif /* ENABLE_IPV6 */ default: abort (); @@ -172,12 +154,12 @@ void address_list_set_connected (struct address_list *al) { - al->connected = 1; + al->connected = true; } /* Return the value of the "connected" flag. */ -int +bool address_list_connected_p (const struct address_list *al) { return al->connected; @@ -214,10 +196,10 @@ { const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)ptr->ai_addr; - ip->type = IPV6_ADDRESS; - ADDRESS_IPV6_IN6_ADDR (ip) = sin6->sin6_addr; + ip->family = AF_INET6; + ip->data.d6 = sin6->sin6_addr; #ifdef HAVE_SOCKADDR_IN6_SCOPE_ID - ADDRESS_IPV6_SCOPE (ip) = sin6->sin6_scope_id; + ip->ipv6_scope = sin6->sin6_scope_id; #endif ++ip; } @@ -225,17 +207,17 @@ { const struct sockaddr_in *sin = (const struct sockaddr_in *)ptr->ai_addr; - ip->type = IPV4_ADDRESS; - ADDRESS_IPV4_IN_ADDR (ip) = sin->sin_addr; + ip->family = AF_INET; + ip->data.d4 = sin->sin_addr; ++ip; } assert (ip - al->addresses == cnt); return al; } -#define IS_IPV4(addr) (((const ip_address *) addr)->type == IPV4_ADDRESS) +#define IS_IPV4(addr) (((const ip_address *) addr)->family == AF_INET) -/* Compare two IP addresses by type, giving preference to the IPv4 +/* Compare two IP addresses by family, giving preference to the IPv4 address (sorting it first). In other words, return -1 if ADDR1 is IPv4 and ADDR2 is IPv6, +1 if ADDR1 is IPv6 and ADDR2 is IPv4, and 0 otherwise. @@ -249,7 +231,7 @@ return !IS_IPV4 (addr1) - !IS_IPV4 (addr2); } -#define IS_IPV6(addr) (((const ip_address *) addr)->type == IPV6_ADDRESS) +#define IS_IPV6(addr) (((const ip_address *) addr)->family == AF_INET6) /* Like the above, but give preference to the IPv6 address. */ @@ -282,8 +264,8 @@ for (i = 0; i < count; i++) { ip_address *ip = &al->addresses[i]; - ip->type = IPV4_ADDRESS; - memcpy (ADDRESS_IPV4_DATA (ip), vec[i], 4); + ip->family = AF_INET; + memcpy (IP_INADDR_DATA (ip), vec[i], 4); } return al; @@ -414,46 +396,30 @@ #endif /* ENABLE_IPV6 */ -/* Pretty-print ADDR. When compiled without IPv6, this is the same as - inet_ntoa. With IPv6, it either prints an IPv6 address or an IPv4 - address. */ +/* Return a textual representation of ADDR, i.e. the dotted quad for + IPv4 addresses, and the colon-separated list of hex words (with all + zeros omitted, etc.) for IPv6 addresses. */ const char * -pretty_print_address (const ip_address *addr) +print_address (const ip_address *addr) { - switch (addr->type) - { - case IPV4_ADDRESS: - return inet_ntoa (ADDRESS_IPV4_IN_ADDR (addr)); #ifdef ENABLE_IPV6 - case IPV6_ADDRESS: - { - static char buf[128]; - inet_ntop (AF_INET6, &ADDRESS_IPV6_IN6_ADDR (addr), buf, sizeof (buf)); -#if 0 -#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID - { - /* append "%SCOPE_ID" for all ?non-global? addresses */ - char *p = buf + strlen (buf); - *p++ = '%'; - number_to_string (p, ADDRESS_IPV6_SCOPE (addr)); - } -#endif -#endif - buf[sizeof (buf) - 1] = '\0'; - return buf; - } + static char buf[64]; + if (!inet_ntop (addr->family, IP_INADDR_DATA (addr), buf, sizeof buf)) + snprintf (buf, sizeof buf, "", strerror (errno)); + return buf; +#else + return inet_ntoa (addr->data.d4); #endif - } - abort (); } -/* The following two functions were adapted from glibc. */ +/* The following two functions were adapted from glibc's + implementation of inet_pton, written by Paul Vixie. */ -static int +static bool is_valid_ipv4_address (const char *str, const char *end) { - int saw_digit = 0; + bool saw_digit = false; int octets = 0; int val = 0; @@ -466,31 +432,31 @@ val = val * 10 + (ch - '0'); if (val > 255) - return 0; - if (saw_digit == 0) + return false; + if (!saw_digit) { if (++octets > 4) - return 0; - saw_digit = 1; + return false; + saw_digit = true; } } - else if (ch == '.' && saw_digit == 1) + else if (ch == '.' && saw_digit) { if (octets == 4) - return 0; + return false; val = 0; - saw_digit = 0; + saw_digit = false; } else - return 0; + return false; } if (octets < 4) - return 0; + return false; - return 1; + return true; } -int +bool is_valid_ipv6_address (const char *str, const char *end) { /* Use lower-case for these to avoid clash with system headers. */ @@ -503,25 +469,25 @@ const char *curtok; int tp; const char *colonp; - int saw_xdigit; + bool saw_xdigit; unsigned int val; tp = 0; colonp = NULL; if (str == end) - return 0; + return false; /* Leading :: requires some special handling. */ if (*str == ':') { ++str; if (str == end || *str != ':') - return 0; + return false; } curtok = str; - saw_xdigit = 0; + saw_xdigit = false; val = 0; while (str < end) @@ -534,8 +500,8 @@ val <<= 4; val |= XDIGIT_TO_NUM (ch); if (val > 0xffff) - return 0; - saw_xdigit = 1; + return false; + saw_xdigit = true; continue; } @@ -543,19 +509,19 @@ if (ch == ':') { curtok = str; - if (saw_xdigit == 0) + if (!saw_xdigit) { if (colonp != NULL) - return 0; + return false; colonp = str + tp; continue; } else if (str == end) - return 0; + return false; if (tp > ns_in6addrsz - ns_int16sz) - return 0; + return false; tp += ns_int16sz; - saw_xdigit = 0; + saw_xdigit = false; val = 0; continue; } @@ -565,31 +531,31 @@ && is_valid_ipv4_address (curtok, end) == 1) { tp += ns_inaddrsz; - saw_xdigit = 0; + saw_xdigit = false; break; } - return 0; + return false; } - if (saw_xdigit == 1) + if (saw_xdigit) { if (tp > ns_in6addrsz - ns_int16sz) - return 0; + return false; tp += ns_int16sz; } if (colonp != NULL) { if (tp == ns_in6addrsz) - return 0; + return false; tp = ns_in6addrsz; } if (tp != ns_in6addrsz) - return 0; + return false; - return 1; + return true; } /* Simple host cache, used by lookup_host to speed up resolving. The @@ -632,16 +598,14 @@ ++al->refcount; hash_table_put (host_name_addresses_map, xstrdup_lower (host), al); -#ifdef ENABLE_DEBUG - if (opt.debug) + IF_DEBUG { int i; debug_logprintf ("Caching %s =>", host); for (i = 0; i < al->count; i++) - debug_logprintf (" %s", pretty_print_address (al->addresses + i)); + debug_logprintf (" %s", print_address (al->addresses + i)); debug_logprintf ("\n"); } -#endif } /* Remove HOST from the DNS cache. Does nothing is HOST is not in @@ -687,9 +651,9 @@ lookup_host (const char *host, int flags) { struct address_list *al; - int silent = flags & LH_SILENT; - int use_cache; - int numeric_address = 0; + bool silent = !!(flags & LH_SILENT); + bool use_cache; + bool numeric_address = false; double timeout = opt.dns_timeout; #ifndef ENABLE_IPV6 @@ -718,7 +682,7 @@ { const char *end = host + strlen (host); if (is_valid_ipv4_address (host, end) || is_valid_ipv6_address (host, end)) - numeric_address = 1; + numeric_address = true; } #endif @@ -727,7 +691,7 @@ use_cache = opt.dns_cache; #ifdef ENABLE_IPV6 if ((flags & LH_BIND) || numeric_address) - use_cache = 0; + use_cache = false; #endif /* Try to find the host in the cache so we don't need to talk to the @@ -835,8 +799,7 @@ int printmax = al->count <= 3 ? al->count : 3; for (i = 0; i < printmax; i++) { - logprintf (LOG_VERBOSE, "%s", - pretty_print_address (al->addresses + i)); + logputs (LOG_VERBOSE, print_address (al->addresses + i)); if (i < printmax - 1) logputs (LOG_VERBOSE, ", "); } @@ -854,21 +817,21 @@ /* Determine whether a URL is acceptable to be followed, according to a list of domains to accept. */ -int +bool accept_domain (struct url *u) { assert (u->host != NULL); if (opt.domains) { if (!sufmatch ((const char **)opt.domains, u->host)) - return 0; + return false; } if (opt.exclude_domains) { if (sufmatch ((const char **)opt.exclude_domains, u->host)) - return 0; + return false; } - return 1; + return true; } /* Check whether WHAT is matched in LIST, each element of LIST being a @@ -876,7 +839,7 @@ match_backwards() in utils.c). If an element of LIST matched, 1 is returned, 0 otherwise. */ -int +bool sufmatch (const char **list, const char *what) { int i, j, k, lw; @@ -889,23 +852,9 @@ break; /* The domain must be first to reach to beginning. */ if (j == -1) - return 1; + return true; } - return 0; -} - -static int -host_cleanup_mapper (void *key, void *value, void *arg_ignored) -{ - struct address_list *al; - - xfree (key); /* host */ - - al = (struct address_list *)value; - assert (al->refcount == 1); - address_list_delete (al); - - return 0; + return false; } void @@ -913,7 +862,17 @@ { if (host_name_addresses_map) { - hash_table_map (host_name_addresses_map, host_cleanup_mapper, NULL); + hash_table_iterator iter; + for (hash_table_iterate (host_name_addresses_map, &iter); + hash_table_iter_next (&iter); + ) + { + char *host = iter.key; + struct address_list *al = iter.value; + xfree (host); + assert (al->refcount == 1); + address_list_delete (al); + } hash_table_destroy (host_name_addresses_map); host_name_addresses_map = NULL; } diff -urN wget-1.10.2/src/host.h wget-1.10.2_new/src/host.h --- wget-1.10.2/src/host.h 2005-06-19 15:47:10.000000000 +0200 +++ wget-1.10.2_new/src/host.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for host.c - Copyright (C) 1995, 1996, 1997, 2001 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -47,74 +47,54 @@ /* This struct defines an IP address, tagged with family type. */ typedef struct { - /* Address type. */ - enum { - IPV4_ADDRESS -#ifdef ENABLE_IPV6 - , IPV6_ADDRESS -#endif /* ENABLE_IPV6 */ - } type; + /* Address family, one of AF_INET or AF_INET6. */ + int family; - /* Address data union: ipv6 contains IPv6-related data (address and - scope), and ipv4 contains the IPv4 address. */ + /* The actual data, in the form of struct in_addr or in6_addr: */ union { + struct in_addr d4; /* IPv4 address */ #ifdef ENABLE_IPV6 - struct { - struct in6_addr addr; -# ifdef HAVE_SOCKADDR_IN6_SCOPE_ID - unsigned int scope_id; -# endif - } ipv6; -#endif /* ENABLE_IPV6 */ - struct { - struct in_addr addr; - } ipv4; - } u; -} ip_address; + struct in6_addr d6; /* IPv6 address */ +#endif + } data; -/* Because C doesn't support anonymous unions, access to ip_address - elements is unwieldy. Hence the accessors. + /* Under IPv6 getaddrinfo also returns scope_id. Since it's + IPv6-specific it strictly belongs in the above union, but we put + it here for simplicity. */ +#if defined ENABLE_IPV6 && defined HAVE_SOCKADDR_IN6_SCOPE_ID + int ipv6_scope; +#endif +} ip_address; - The _ADDR accessors return the address as the struct in_addr or - in6_addr. The _DATA accessor returns a pointer to the address data - -- pretty much the same as the above, but cast to void*. The - _SCOPE accessor returns the address's scope_id, and makes sense - only when IPv6 and HAVE_SOCKADDR_IN6_SCOPE_ID are both defined. */ - -#define ADDRESS_IPV4_IN_ADDR(x) ((x)->u.ipv4.addr) -/* Don't use &x->u.ipv4.addr.s_addr because it can be #defined to a - bitfield, which you can't take an address of. */ -#define ADDRESS_IPV4_DATA(x) ((void *)&(x)->u.ipv4.addr) - -#define ADDRESS_IPV6_IN6_ADDR(x) ((x)->u.ipv6.addr) -#define ADDRESS_IPV6_DATA(x) ((void *)&(x)->u.ipv6.addr) -#define ADDRESS_IPV6_SCOPE(x) ((x)->u.ipv6.scope_id) +/* IP_INADDR_DATA macro returns a void pointer that can be interpreted + as a pointer to struct in_addr in IPv4 context or a pointer to + struct in6_addr in IPv4 context. This pointer can be passed to + functions that work on either, such as inet_ntop. */ +#define IP_INADDR_DATA(x) ((void *) &(x)->data) enum { LH_SILENT = 1, LH_BIND = 2, LH_REFRESH = 4 }; -struct address_list *lookup_host PARAMS ((const char *, int)); +struct address_list *lookup_host (const char *, int); -void address_list_get_bounds PARAMS ((const struct address_list *, - int *, int *)); -const ip_address *address_list_address_at PARAMS ((const struct address_list *, - int)); -int address_list_contains PARAMS ((const struct address_list *, const ip_address *)); -void address_list_set_faulty PARAMS ((struct address_list *, int)); -void address_list_set_connected PARAMS ((struct address_list *)); -int address_list_connected_p PARAMS ((const struct address_list *)); -void address_list_release PARAMS ((struct address_list *)); +void address_list_get_bounds (const struct address_list *, int *, int *); +const ip_address *address_list_address_at (const struct address_list *, int); +bool address_list_contains (const struct address_list *, const ip_address *); +void address_list_set_faulty (struct address_list *, int); +void address_list_set_connected (struct address_list *); +bool address_list_connected_p (const struct address_list *); +void address_list_release (struct address_list *); -const char *pretty_print_address PARAMS ((const ip_address *)); +const char *print_address (const ip_address *); #ifdef ENABLE_IPV6 -int is_valid_ipv6_address PARAMS ((const char *, const char *)); +bool is_valid_ipv6_address (const char *, const char *); #endif -int accept_domain PARAMS ((struct url *)); -int sufmatch PARAMS ((const char **, const char *)); +bool accept_domain (struct url *); +bool sufmatch (const char **, const char *); -void host_cleanup PARAMS ((void)); +void host_cleanup (void); #endif /* HOST_H */ diff -urN wget-1.10.2/src/html-parse.c wget-1.10.2_new/src/html-parse.c --- wget-1.10.2/src/html-parse.c 2005-03-19 18:25:44.000000000 +0100 +++ wget-1.10.2_new/src/html-parse.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* HTML parser for Wget. - Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc. + Copyright (C) 1998-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -96,11 +96,7 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #include "wget.h" @@ -157,7 +153,7 @@ char *contents; /* pointer to the contents. */ int size; /* size of the pool. */ int tail; /* next available position index. */ - int resized; /* whether the pool has been resized + bool resized; /* whether the pool has been resized using malloc. */ char *orig_contents; /* original pool contents, usually @@ -174,7 +170,7 @@ P->contents = (initial_storage); \ P->size = (initial_size); \ P->tail = 0; \ - P->resized = 0; \ + P->resized = false; \ P->orig_contents = P->contents; \ P->orig_size = P->size; \ } while (0) @@ -222,7 +218,7 @@ P->contents = P->orig_contents; \ P->size = P->orig_size; \ P->tail = 0; \ - P->resized = 0; \ + P->resized = false; \ } while (0) /* Used for small stack-allocated memory chunks that might grow. Like @@ -245,13 +241,13 @@ if (ga_newsize != (sizevar)) \ { \ if (resized) \ - basevar = (type *)xrealloc (basevar, ga_newsize * sizeof (type)); \ + basevar = xrealloc (basevar, ga_newsize * sizeof (type)); \ else \ { \ void *ga_new = xmalloc (ga_newsize * sizeof (type)); \ memcpy (ga_new, basevar, (sizevar) * sizeof (type)); \ (basevar) = ga_new; \ - resized = 1; \ + resized = true; \ } \ (sizevar) = ga_newsize; \ } \ @@ -389,7 +385,7 @@ never lengthen it. */ const char *from = beg; char *to; - int squash_newlines = flags & AP_TRIM_BLANKS; + bool squash_newlines = !!(flags & AP_TRIM_BLANKS); POOL_GROW (pool, end - beg); to = pool->contents + pool->tail; @@ -684,15 +680,15 @@ return NULL; } -/* Return non-zero of the string inside [b, e) are present in hash - table HT. */ +/* Return true if the string containing of characters inside [b, e) is + present in hash table HT. */ -static int +static bool name_allowed (const struct hash_table *ht, const char *b, const char *e) { char *copy; if (!ht) - return 1; + return true; BOUNDED_TO_ALLOCA (b, e, copy); return hash_table_get (ht, copy) != NULL; } @@ -757,7 +753,7 @@ struct attr_pair attr_pair_initial_storage[8]; int attr_pair_size = countof (attr_pair_initial_storage); - int attr_pair_resized = 0; + bool attr_pair_resized = false; struct attr_pair *pairs = attr_pair_initial_storage; if (!size) @@ -769,7 +765,7 @@ int nattrs, end_tag; const char *tag_name_begin, *tag_name_end; const char *tag_start_position; - int uninteresting_tag; + bool uninteresting_tag; look_for_tag: POOL_REWIND (&pool); @@ -832,10 +828,10 @@ if (!name_allowed (allowed_tags, tag_name_begin, tag_name_end)) /* We can't just say "goto look_for_tag" here because we need the loop below to properly advance over the tag's attributes. */ - uninteresting_tag = 1; + uninteresting_tag = true; else { - uninteresting_tag = 0; + uninteresting_tag = false; convert_and_copy (&pool, tag_name_begin, tag_name_end, AP_DOWNCASE); } @@ -894,7 +890,7 @@ SKIP_WS (p); if (*p == '\"' || *p == '\'') { - int newline_seen = 0; + bool newline_seen = false; char quote_char = *p; attr_raw_value_begin = p; ADVANCE (p); @@ -912,7 +908,7 @@ comes first. Such a tag terminated at `>' is discarded. */ p = attr_value_begin; - newline_seen = 1; + newline_seen = true; continue; } else if (newline_seen && *p == '>') @@ -1014,8 +1010,7 @@ taginfo.attrs = pairs; taginfo.start_position = tag_start_position; taginfo.end_position = p + 1; - /* Ta-dam! */ - (*mapfun) (&taginfo, maparg); + mapfun (&taginfo, maparg); ADVANCE (p); } goto look_for_tag; @@ -1056,7 +1051,7 @@ int main () { int size = 256; - char *x = (char *)xmalloc (size); + char *x = xmalloc (size); int length = 0; int read_count; int tag_counter = 0; @@ -1065,7 +1060,7 @@ { length += read_count; size <<= 1; - x = (char *)xrealloc (x, size); + x = xrealloc (x, size); } map_html_tags (x, length, test_mapper, &tag_counter, 0, NULL, NULL); diff -urN wget-1.10.2/src/html-parse.h wget-1.10.2_new/src/html-parse.h --- wget-1.10.2/src/html-parse.h 2003-10-09 17:01:58.000000000 +0200 +++ wget-1.10.2_new/src/html-parse.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for html-parse.c. - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -60,9 +60,8 @@ #define MHT_TRIM_VALUES 2 /* trim attribute values, e.g. interpret as "foo" */ -void map_html_tags PARAMS ((const char *, int, - void (*) (struct taginfo *, void *), void *, int, - const struct hash_table *, - const struct hash_table *)); +void map_html_tags (const char *, int, + void (*) (struct taginfo *, void *), void *, int, + const struct hash_table *, const struct hash_table *); #endif /* HTML_PARSE_H */ diff -urN wget-1.10.2/src/html-url.c wget-1.10.2_new/src/html-url.c --- wget-1.10.2/src/html-url.c 2005-06-19 15:47:10.000000000 +0200 +++ wget-1.10.2_new/src/html-url.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Collect URLs from HTML source. - Copyright (C) 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -30,11 +30,7 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #include #include @@ -47,17 +43,12 @@ #include "convert.h" #include "recur.h" /* declaration of get_urls_html */ -#ifndef errno -extern int errno; -#endif - struct map_context; -typedef void (*tag_handler_t) PARAMS ((int, struct taginfo *, - struct map_context *)); +typedef void (*tag_handler_t) (int, struct taginfo *, struct map_context *); -#define DECLARE_TAG_HANDLER(fun) \ - static void fun PARAMS ((int, struct taginfo *, struct map_context *)) +#define DECLARE_TAG_HANDLER(fun) \ + static void fun (int, struct taginfo *, struct map_context *) DECLARE_TAG_HANDLER (tag_find_urls); DECLARE_TAG_HANDLER (tag_handle_base); @@ -179,8 +170,8 @@ "action" /* used by tag_handle_form */ }; -struct hash_table *interesting_tags; -struct hash_table *interesting_attributes; +static struct hash_table *interesting_tags; +static struct hash_table *interesting_attributes; static void init_interesting (void) @@ -261,7 +252,7 @@ changed through . */ const char *parent_base; /* Base of the current document. */ const char *document_file; /* File name of this document. */ - int nofollow; /* whether NOFOLLOW was specified in a + bool nofollow; /* whether NOFOLLOW was specified in a tag. */ struct urlpos *head, *tail; /* List of URLs that is being @@ -550,7 +541,7 @@ if (!content) return; if (!strcasecmp (content, "none")) - ctx->nofollow = 1; + ctx->nofollow = true; else { while (*content) @@ -563,7 +554,7 @@ else end = content + strlen (content); if (!strncasecmp (content, "nofollow", end - content)) - ctx->nofollow = 1; + ctx->nofollow = true; content = end; } } @@ -591,7 +582,7 @@ and does the right thing. */ struct urlpos * -get_urls_html (const char *file, const char *url, int *meta_disallow_follow) +get_urls_html (const char *file, const char *url, bool *meta_disallow_follow) { struct file_memory *fm; struct map_context ctx; @@ -611,7 +602,7 @@ ctx.base = NULL; ctx.parent_base = url ? url : opt.base_href; ctx.document_file = file; - ctx.nofollow = 0; + ctx.nofollow = false; if (!interesting_tags) init_interesting (); @@ -710,7 +701,6 @@ xfree (url_text); entry = xnew0 (struct urlpos); - entry->next = NULL; entry->url = url; if (!head) diff -urN wget-1.10.2/src/http.c wget-1.10.2_new/src/http.c --- wget-1.10.2/src/http.c 2005-08-09 00:54:16.000000000 +0200 +++ wget-1.10.2_new/src/http.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* HTTP support. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,32 +31,17 @@ #include #include -#include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #ifdef HAVE_UNISTD_H # include #endif #include #include -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifndef errno -extern int errno; -#endif +#include +#include #include "wget.h" +#include "http.h" #include "utils.h" #include "url.h" #include "host.h" @@ -75,18 +60,18 @@ #endif #include "convert.h" -extern char *version_string; -extern SUM_SIZE_INT total_downloaded_bytes; +#ifdef TESTING +#include "test.h" +#endif -extern FILE *output_stream; -extern int output_stream_regular; +extern char *version_string; #ifndef MIN # define MIN(x, y) ((x) > (y) ? (y) : (x)) #endif -static int cookies_loaded_p; +static bool cookies_loaded_p; static struct cookie_jar *wget_cookie_jar; #define TEXTHTML_S "text/html" @@ -95,39 +80,39 @@ /* Some status code validation macros: */ #define H_20X(x) (((x) >= 200) && ((x) < 300)) #define H_PARTIAL(x) ((x) == HTTP_STATUS_PARTIAL_CONTENTS) -#define H_REDIRECTED(x) ((x) == HTTP_STATUS_MOVED_PERMANENTLY \ - || (x) == HTTP_STATUS_MOVED_TEMPORARILY \ - || (x) == HTTP_STATUS_SEE_OTHER \ - || (x) == HTTP_STATUS_TEMPORARY_REDIRECT) +#define H_REDIRECTED(x) ((x) == HTTP_STATUS_MOVED_PERMANENTLY \ + || (x) == HTTP_STATUS_MOVED_TEMPORARILY \ + || (x) == HTTP_STATUS_SEE_OTHER \ + || (x) == HTTP_STATUS_TEMPORARY_REDIRECT) /* HTTP/1.0 status codes from RFC1945, provided for reference. */ /* Successful 2xx. */ -#define HTTP_STATUS_OK 200 -#define HTTP_STATUS_CREATED 201 -#define HTTP_STATUS_ACCEPTED 202 -#define HTTP_STATUS_NO_CONTENT 204 -#define HTTP_STATUS_PARTIAL_CONTENTS 206 +#define HTTP_STATUS_OK 200 +#define HTTP_STATUS_CREATED 201 +#define HTTP_STATUS_ACCEPTED 202 +#define HTTP_STATUS_NO_CONTENT 204 +#define HTTP_STATUS_PARTIAL_CONTENTS 206 /* Redirection 3xx. */ -#define HTTP_STATUS_MULTIPLE_CHOICES 300 -#define HTTP_STATUS_MOVED_PERMANENTLY 301 -#define HTTP_STATUS_MOVED_TEMPORARILY 302 -#define HTTP_STATUS_SEE_OTHER 303 /* from HTTP/1.1 */ -#define HTTP_STATUS_NOT_MODIFIED 304 -#define HTTP_STATUS_TEMPORARY_REDIRECT 307 /* from HTTP/1.1 */ +#define HTTP_STATUS_MULTIPLE_CHOICES 300 +#define HTTP_STATUS_MOVED_PERMANENTLY 301 +#define HTTP_STATUS_MOVED_TEMPORARILY 302 +#define HTTP_STATUS_SEE_OTHER 303 /* from HTTP/1.1 */ +#define HTTP_STATUS_NOT_MODIFIED 304 +#define HTTP_STATUS_TEMPORARY_REDIRECT 307 /* from HTTP/1.1 */ /* Client error 4xx. */ -#define HTTP_STATUS_BAD_REQUEST 400 -#define HTTP_STATUS_UNAUTHORIZED 401 -#define HTTP_STATUS_FORBIDDEN 403 -#define HTTP_STATUS_NOT_FOUND 404 +#define HTTP_STATUS_BAD_REQUEST 400 +#define HTTP_STATUS_UNAUTHORIZED 401 +#define HTTP_STATUS_FORBIDDEN 403 +#define HTTP_STATUS_NOT_FOUND 404 #define HTTP_STATUS_RANGE_NOT_SATISFIABLE 416 /* Server errors 5xx. */ -#define HTTP_STATUS_INTERNAL 500 -#define HTTP_STATUS_NOT_IMPLEMENTED 501 -#define HTTP_STATUS_BAD_GATEWAY 502 -#define HTTP_STATUS_UNAVAILABLE 503 +#define HTTP_STATUS_INTERNAL 500 +#define HTTP_STATUS_NOT_IMPLEMENTED 501 +#define HTTP_STATUS_BAD_GATEWAY 502 +#define HTTP_STATUS_UNAVAILABLE 503 enum rp { rel_none, rel_name, rel_value, rel_both @@ -224,12 +209,12 @@ // Value freshly allocated, free it when done. request_set_header (req, "Range", aprintf ("bytes=%s-", number_to_static_string (hs->restval)), - rel_value); + rel_value); */ static void request_set_header (struct request *req, char *name, char *value, - enum rp release_policy) + enum rp release_policy) { struct request_header *hdr; int i; @@ -237,9 +222,9 @@ if (!value) { /* A NULL value is a no-op; if freeing the name is requested, - free it now to avoid leaks. */ + free it now to avoid leaks. */ if (release_policy == rel_name || release_policy == rel_both) - xfree (name); + xfree (name); return; } @@ -247,14 +232,14 @@ { hdr = &req->headers[i]; if (0 == strcasecmp (name, hdr->name)) - { - /* Replace existing header. */ - release_header (hdr); - hdr->name = name; - hdr->value = value; - hdr->release_policy = release_policy; - return; - } + { + /* Replace existing header. */ + release_header (hdr); + hdr->name = name; + hdr->value = value; + hdr->release_policy = release_policy; + return; + } } /* Install new header. */ @@ -289,10 +274,10 @@ request_set_header (req, xstrdup (name), (char *) p, rel_name); } -/* Remove the header with specified name from REQ. Returns 1 if the - header was actually removed, 0 otherwise. */ +/* Remove the header with specified name from REQ. Returns true if + the header was actually removed, false otherwise. */ -static int +static bool request_remove_header (struct request *req, char *name) { int i; @@ -300,22 +285,22 @@ { struct request_header *hdr = &req->headers[i]; if (0 == strcasecmp (name, hdr->name)) - { - release_header (hdr); - /* Move the remaining headers by one. */ - if (i < req->hcount - 1) - memmove (hdr, hdr + 1, (req->hcount - i - 1) * sizeof (*hdr)); - --req->hcount; - return 1; - } - } - return 0; -} - -#define APPEND(p, str) do { \ - int A_len = strlen (str); \ - memcpy (p, str, A_len); \ - p += A_len; \ + { + release_header (hdr); + /* Move the remaining headers by one. */ + if (i < req->hcount - 1) + memmove (hdr, hdr + 1, (req->hcount - i - 1) * sizeof (*hdr)); + --req->hcount; + return true; + } + } + return false; +} + +#define APPEND(p, str) do { \ + int A_len = strlen (str); \ + memcpy (p, str, A_len); \ + p += A_len; \ } while (0) /* Construct the request and write it to FD using fd_write. */ @@ -368,10 +353,10 @@ /* Send the request to the server. */ - write_error = fd_write (fd, request_string, size - 1, -1.0); + write_error = fd_write (fd, request_string, size - 1, -1); if (write_error < 0) logprintf (LOG_VERBOSE, _("Failed writing HTTP request: %s.\n"), - strerror (errno)); + fd_errstr (fd)); return write_error; } @@ -410,14 +395,14 @@ int towrite; int length = fread (chunk, 1, sizeof (chunk), fp); if (length == 0) - break; + break; towrite = MIN (promised_size - written, length); - write_error = fd_write (sock, chunk, towrite, -1.0); + write_error = fd_write (sock, chunk, towrite, -1); if (write_error < 0) - { - fclose (fp); - return -1; - } + { + fclose (fp); + return -1; + } written += towrite; } fclose (fp); @@ -435,40 +420,51 @@ return 0; } +/* Determine whether [START, PEEKED + PEEKLEN) contains an empty line. + If so, return the pointer to the position after the line, otherwise + return NULL. This is used as callback to fd_read_hunk. The data + between START and PEEKED has been read and cannot be "unread"; the + data after PEEKED has only been peeked. */ + static const char * -response_head_terminator (const char *hunk, int oldlen, int peeklen) +response_head_terminator (const char *start, const char *peeked, int peeklen) { - const char *start, *end; + const char *p, *end; /* If at first peek, verify whether HUNK starts with "HTTP". If not, this is a HTTP/0.9 request and we must bail out without reading anything. */ - if (oldlen == 0 && 0 != memcmp (hunk, "HTTP", MIN (peeklen, 4))) - return hunk; + if (start == peeked && 0 != memcmp (start, "HTTP", MIN (peeklen, 4))) + return start; - if (oldlen < 4) - start = hunk; - else - start = hunk + oldlen - 4; - end = hunk + oldlen + peeklen; - - for (; start < end - 1; start++) - if (*start == '\n') + /* Look for "\n[\r]\n", and return the following position if found. + Start two chars before the current to cover the possibility that + part of the terminator (e.g. "\n\r") arrived in the previous + batch. */ + p = peeked - start < 2 ? start : peeked - 2; + end = peeked + peeklen; + + /* Check for \n\r\n or \n\n anywhere in [p, end-2). */ + for (; p < end - 2; p++) + if (*p == '\n') { - if (start < end - 2 - && start[1] == '\r' - && start[2] == '\n') - return start + 3; - if (start[1] == '\n') - return start + 2; + if (p[1] == '\r' && p[2] == '\n') + return p + 3; + else if (p[1] == '\n') + return p + 2; } + /* p==end-2: check for \n\n directly preceding END. */ + if (p[0] == '\n' && p[1] == '\n') + return p + 2; + return NULL; } -/* The maximum size of a single HTTP response we care to read. This - is not meant to impose an arbitrary limit, but to protect the user - from Wget slurping up available memory upon encountering malicious - or buggy server output. Define it to 0 to remove the limit. */ +/* The maximum size of a single HTTP response we care to read. Rather + than being a limit of the reader implementation, this limit + prevents Wget from slurping all available memory upon encountering + malicious or buggy server output, thus protecting the user. Define + it to 0 to remove the limit. */ #define HTTP_RESPONSE_MAX_SIZE 65536 @@ -484,7 +480,7 @@ read_http_response_head (int fd) { return fd_read_hunk (fd, response_head_terminator, 512, - HTTP_RESPONSE_MAX_SIZE); + HTTP_RESPONSE_MAX_SIZE); } struct response { @@ -529,8 +525,8 @@ if (*head == '\0') { /* Empty head means that we're dealing with a headerless - (HTTP/0.9) response. In that case, don't set HEADERS at - all. */ + (HTTP/0.9) response. In that case, don't set HEADERS at + all. */ return resp; } @@ -546,17 +542,17 @@ /* Break upon encountering an empty line. */ if (!hdr[0] || (hdr[0] == '\r' && hdr[1] == '\n') || hdr[0] == '\n') - break; + break; /* Find the end of HDR, including continuations. */ do - { - const char *end = strchr (hdr, '\n'); - if (end) - hdr = end + 1; - else - hdr += strlen (hdr); - } + { + const char *end = strchr (hdr, '\n'); + if (end) + hdr = end + 1; + else + hdr += strlen (hdr); + } while (*hdr == ' ' || *hdr == '\t'); } DO_REALLOC (resp->headers, size, count + 1, const char *); @@ -579,7 +575,7 @@ static int resp_header_locate (const struct response *resp, const char *name, int start, - const char **begptr, const char **endptr) + const char **begptr, const char **endptr) { int i; const char **headers = resp->headers; @@ -599,32 +595,32 @@ const char *b = headers[i]; const char *e = headers[i + 1]; if (e - b > name_len - && b[name_len] == ':' - && 0 == strncasecmp (b, name, name_len)) - { - b += name_len + 1; - while (b < e && ISSPACE (*b)) - ++b; - while (b < e && ISSPACE (e[-1])) - --e; - *begptr = b; - *endptr = e; - return i; - } + && b[name_len] == ':' + && 0 == strncasecmp (b, name, name_len)) + { + b += name_len + 1; + while (b < e && ISSPACE (*b)) + ++b; + while (b < e && ISSPACE (e[-1])) + --e; + *begptr = b; + *endptr = e; + return i; + } } return -1; } /* Find and retrieve the header named NAME in the request data. If found, set *BEGPTR to its starting, and *ENDPTR to its ending - position, and return 1. Otherwise return 0. + position, and return true. Otherwise return false. This function is used as a building block for resp_header_copy and resp_header_strdup. */ -static int +static bool resp_header_get (const struct response *resp, const char *name, - const char **begptr, const char **endptr) + const char **begptr, const char **endptr) { int pos = resp_header_locate (resp, name, 0, begptr, endptr); return pos != -1; @@ -632,26 +628,26 @@ /* Copy the response header named NAME to buffer BUF, no longer than BUFSIZE (BUFSIZE includes the terminating 0). If the header - exists, 1 is returned, otherwise 0. If there should be no limit on - the size of the header, use resp_header_strdup instead. + exists, true is returned, false otherwise. If there should be no + limit on the size of the header, use resp_header_strdup instead. If BUFSIZE is 0, no data is copied, but the boolean indication of whether the header is present is still returned. */ -static int +static bool resp_header_copy (const struct response *resp, const char *name, - char *buf, int bufsize) + char *buf, int bufsize) { const char *b, *e; if (!resp_header_get (resp, name, &b, &e)) - return 0; + return false; if (bufsize) { int len = MIN (e - b, bufsize - 1); memcpy (buf, b, len); buf[len] = '\0'; } - return 1; + return true; } /* Return the value of header named NAME in RESP, allocated with @@ -684,7 +680,7 @@ { /* For a HTTP/0.9 response, assume status 200. */ if (message) - *message = xstrdup (_("No headers, assuming HTTP/0.9")); + *message = xstrdup (_("No headers, assuming HTTP/0.9")); return 200; } @@ -705,11 +701,11 @@ { ++p; while (p < end && ISDIGIT (*p)) - ++p; + ++p; if (p < end && *p == '.') - ++p; + ++p; while (p < end && ISDIGIT (*p)) - ++p; + ++p; } while (p < end && ISSPACE (*p)) @@ -723,9 +719,9 @@ if (message) { while (p < end && ISSPACE (*p)) - ++p; + ++p; while (p < end && ISSPACE (end[-1])) - --end; + --end; *message = strdupdelim (p, end); } @@ -756,56 +752,56 @@ const char *e = resp->headers[i + 1]; /* Skip CRLF */ if (b < e && e[-1] == '\n') - --e; + --e; if (b < e && e[-1] == '\r') - --e; + --e; /* This is safe even on printfs with broken handling of "%.s" - because resp->headers ends with \0. */ + because resp->headers ends with \0. */ logprintf (LOG_VERBOSE, "%s%.*s\n", prefix, e - b, b); } } /* Parse the `Content-Range' header and extract the information it - contains. Returns 1 if successful, -1 otherwise. */ -static int + contains. Returns true if successful, false otherwise. */ +static bool parse_content_range (const char *hdr, wgint *first_byte_ptr, - wgint *last_byte_ptr, wgint *entity_length_ptr) + wgint *last_byte_ptr, wgint *entity_length_ptr) { wgint num; /* Ancient versions of Netscape proxy server, presumably predating rfc2068, sent out `Content-Range' without the "bytes" specifier. */ - if (!strncasecmp (hdr, "bytes", 5)) + if (0 == strncasecmp (hdr, "bytes", 5)) { hdr += 5; /* "JavaWebServer/1.1.1" sends "bytes: x-y/z", contrary to the - HTTP spec. */ + HTTP spec. */ if (*hdr == ':') - ++hdr; + ++hdr; while (ISSPACE (*hdr)) - ++hdr; + ++hdr; if (!*hdr) - return 0; + return false; } if (!ISDIGIT (*hdr)) - return 0; + return false; for (num = 0; ISDIGIT (*hdr); hdr++) num = 10 * num + (*hdr - '0'); if (*hdr != '-' || !ISDIGIT (*(hdr + 1))) - return 0; + return false; *first_byte_ptr = num; ++hdr; for (num = 0; ISDIGIT (*hdr); hdr++) num = 10 * num + (*hdr - '0'); if (*hdr != '/' || !ISDIGIT (*(hdr + 1))) - return 0; + return false; *last_byte_ptr = num; ++hdr; for (num = 0; ISDIGIT (*hdr); hdr++) num = 10 * num + (*hdr - '0'); *entity_length_ptr = num; - return 1; + return true; } /* Read the body of the request, but don't store it anywhere and don't @@ -814,18 +810,18 @@ request. The response is not useful to the user, but reading it allows us to continue using the same connection to the server. - If reading fails, 0 is returned, non-zero otherwise. In debug + If reading fails, false is returned, true otherwise. In debug mode, the body is displayed for debugging purposes. */ -static int +static bool skip_short_body (int fd, wgint contlen) { enum { - SKIP_SIZE = 512, /* size of the download buffer */ - SKIP_THRESHOLD = 4096 /* the largest size we read */ + SKIP_SIZE = 512, /* size of the download buffer */ + SKIP_THRESHOLD = 4096 /* the largest size we read */ }; char dlbuf[SKIP_SIZE + 1]; - dlbuf[SKIP_SIZE] = '\0'; /* so DEBUGP can safely print it */ + dlbuf[SKIP_SIZE] = '\0'; /* so DEBUGP can safely print it */ /* We shouldn't get here with unknown contlen. (This will change with HTTP/1.1, which supports "chunked" transfer.) */ @@ -834,29 +830,145 @@ /* If the body is too large, it makes more sense to simply close the connection than to try to read the body. */ if (contlen > SKIP_THRESHOLD) - return 0; + return false; DEBUGP (("Skipping %s bytes of body: [", number_to_static_string (contlen))); while (contlen > 0) { - int ret = fd_read (fd, dlbuf, MIN (contlen, SKIP_SIZE), -1.0); + int ret = fd_read (fd, dlbuf, MIN (contlen, SKIP_SIZE), -1); if (ret <= 0) - { - /* Don't normally report the error since this is an - optimization that should be invisible to the user. */ - DEBUGP (("] aborting (%s).\n", - ret < 0 ? strerror (errno) : "EOF received")); - return 0; - } + { + /* Don't normally report the error since this is an + optimization that should be invisible to the user. */ + DEBUGP (("] aborting (%s).\n", + ret < 0 ? fd_errstr (fd) : "EOF received")); + return false; + } contlen -= ret; /* Safe even if %.*s bogusly expects terminating \0 because - we've zero-terminated dlbuf above. */ + we've zero-terminated dlbuf above. */ DEBUGP (("%.*s", ret, dlbuf)); } DEBUGP (("] done.\n")); - return 1; + return true; +} + +/* Extract a parameter from the string (typically an HTTP header) at + **SOURCE and advance SOURCE to the next parameter. Return false + when there are no more parameters to extract. The name of the + parameter is returned in NAME, and the value in VALUE. If the + parameter has no value, the token's value is zeroed out. + + For example, if *SOURCE points to the string "attachment; + filename=\"foo bar\"", the first call to this function will return + the token named "attachment" and no value, and the second call will + return the token named "filename" and value "foo bar". The third + call will return false, indicating no more valid tokens. */ + +bool +extract_param (const char **source, param_token *name, param_token *value, + char separator) +{ + const char *p = *source; + + while (ISSPACE (*p)) ++p; + if (!*p) + { + *source = p; + return false; /* no error; nothing more to extract */ + } + + /* Extract name. */ + name->b = p; + while (*p && !ISSPACE (*p) && *p != '=' && *p != separator) ++p; + name->e = p; + if (name->b == name->e) + return false; /* empty name: error */ + while (ISSPACE (*p)) ++p; + if (*p == separator || !*p) /* no value */ + { + xzero (*value); + if (*p == separator) ++p; + *source = p; + return true; + } + if (*p != '=') + return false; /* error */ + + /* *p is '=', extract value */ + ++p; + while (ISSPACE (*p)) ++p; + if (*p == '"') /* quoted */ + { + value->b = ++p; + while (*p && *p != '"') ++p; + if (!*p) + return false; + value->e = p++; + /* Currently at closing quote; find the end of param. */ + while (ISSPACE (*p)) ++p; + while (*p && *p != separator) ++p; + if (*p == separator) + ++p; + else if (*p) + /* garbage after closed quote, e.g. foo="bar"baz */ + return false; + } + else /* unquoted */ + { + value->b = p; + while (*p && *p != separator) ++p; + value->e = p; + while (value->e != value->b && ISSPACE (value->e[-1])) + --value->e; + if (*p == separator) ++p; + } + *source = p; + return true; +} + +#undef MAX +#define MAX(p, q) ((p) > (q) ? (p) : (q)) + +/* Parse the contents of the `Content-Disposition' header, extracting + the information useful to Wget. Content-Disposition is a header + borrowed from MIME; when used in HTTP, it typically serves for + specifying the desired file name of the resource. For example: + + Content-Disposition: attachment; filename="flora.jpg" + + Wget will skip the tokens it doesn't care about, such as + "attachment" in the previous example; it will also skip other + unrecognized params. If the header is syntactically correct and + contains a file name, a copy of the file name is stored in + *filename and true is returned. Otherwise, the function returns + false. + + The file name is stripped of directory components and must not be + empty. */ + +static bool +parse_content_disposition (const char *hdr, char **filename) +{ + param_token name, value; + while (extract_param (&hdr, &name, &value, ';')) + if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, "filename") && value.b != NULL) + { + /* Make the file name begin at the last slash or backslash. */ + const char *last_slash = memrchr (value.b, '/', value.e - value.b); + const char *last_bs = memrchr (value.b, '\\', value.e - value.b); + if (last_slash && last_bs) + value.b = 1 + MAX (last_slash, last_bs); + else if (last_slash || last_bs) + value.b = 1 + (last_slash ? last_slash : last_bs); + if (value.b == value.e) + continue; + *filename = strdupdelim (value.b, value.e); + return true; + } + return false; } /* Persistent connections. Currently, we cache the most recently used @@ -866,7 +978,7 @@ number of these connections. */ /* Whether a persistent connection is active. */ -static int pconn_active; +static bool pconn_active; static struct { /* The socket of the connection. */ @@ -877,13 +989,13 @@ int port; /* Whether a ssl handshake has occoured on this connection. */ - int ssl; + bool ssl; /* Whether the connection was authorized. This is only done by NTLM, which authorizes *connections* rather than individual requests. (That practice is peculiar for HTTP, but it is a useful optimization.) */ - int authorized; + bool authorized; #ifdef ENABLE_NTLM /* NTLM data of the current connection. */ @@ -899,7 +1011,7 @@ invalidate_persistent (void) { DEBUGP (("Disabling further reuse of socket %d.\n", pconn.socket)); - pconn_active = 0; + pconn_active = false; fd_close (pconn.socket); xfree (pconn.host); xzero (pconn); @@ -914,114 +1026,120 @@ If a previous connection was persistent, it is closed. */ static void -register_persistent (const char *host, int port, int fd, int ssl) +register_persistent (const char *host, int port, int fd, bool ssl) { if (pconn_active) { if (pconn.socket == fd) - { - /* The connection FD is already registered. */ - return; - } + { + /* The connection FD is already registered. */ + return; + } else - { - /* The old persistent connection is still active; close it - first. This situation arises whenever a persistent - connection exists, but we then connect to a different - host, and try to register a persistent connection to that - one. */ - invalidate_persistent (); - } + { + /* The old persistent connection is still active; close it + first. This situation arises whenever a persistent + connection exists, but we then connect to a different + host, and try to register a persistent connection to that + one. */ + invalidate_persistent (); + } } - pconn_active = 1; + pconn_active = true; pconn.socket = fd; pconn.host = xstrdup (host); pconn.port = port; pconn.ssl = ssl; - pconn.authorized = 0; + pconn.authorized = false; DEBUGP (("Registered socket %d for persistent reuse.\n", fd)); } -/* Return non-zero if a persistent connection is available for - connecting to HOST:PORT. */ +/* Return true if a persistent connection is available for connecting + to HOST:PORT. */ -static int -persistent_available_p (const char *host, int port, int ssl, - int *host_lookup_failed) +static bool +persistent_available_p (const char *host, int port, bool ssl, + bool *host_lookup_failed) { /* First, check whether a persistent connection is active at all. */ if (!pconn_active) - return 0; + return false; /* If we want SSL and the last connection wasn't or vice versa, don't use it. Checking for host and port is not enough because HTTP and HTTPS can apparently coexist on the same port. */ if (ssl != pconn.ssl) - return 0; + return false; /* If we're not connecting to the same port, we're not interested. */ if (port != pconn.port) - return 0; + return false; /* If the host is the same, we're in business. If not, there is still hope -- read below. */ if (0 != strcasecmp (host, pconn.host)) { /* Check if pconn.socket is talking to HOST under another name. - This happens often when both sites are virtual hosts - distinguished only by name and served by the same network - interface, and hence the same web server (possibly set up by - the ISP and serving many different web sites). This - admittedly unconventional optimization does not contradict - HTTP and works well with popular server software. */ + This happens often when both sites are virtual hosts + distinguished only by name and served by the same network + interface, and hence the same web server (possibly set up by + the ISP and serving many different web sites). This + admittedly unconventional optimization does not contradict + HTTP and works well with popular server software. */ - int found; + bool found; ip_address ip; struct address_list *al; if (ssl) - /* Don't try to talk to two different SSL sites over the same - secure connection! (Besides, it's not clear that - name-based virtual hosting is even possible with SSL.) */ - return 0; + /* Don't try to talk to two different SSL sites over the same + secure connection! (Besides, it's not clear that + name-based virtual hosting is even possible with SSL.) */ + return false; /* If pconn.socket's peer is one of the IP addresses HOST - resolves to, pconn.socket is for all intents and purposes - already talking to HOST. */ + resolves to, pconn.socket is for all intents and purposes + already talking to HOST. */ if (!socket_ip_address (pconn.socket, &ip, ENDPOINT_PEER)) - { - /* Can't get the peer's address -- something must be very - wrong with the connection. */ - invalidate_persistent (); - return 0; - } + { + /* Can't get the peer's address -- something must be very + wrong with the connection. */ + invalidate_persistent (); + return false; + } al = lookup_host (host, 0); if (!al) - { - *host_lookup_failed = 1; - return 0; - } + { + *host_lookup_failed = true; + return false; + } found = address_list_contains (al, &ip); address_list_release (al); if (!found) - return 0; + return false; /* The persistent connection's peer address was found among the - addresses HOST resolved to; therefore, pconn.sock is in fact - already talking to HOST -- no need to reconnect. */ + addresses HOST resolved to; therefore, pconn.sock is in fact + already talking to HOST -- no need to reconnect. */ } /* Finally, check whether the connection is still open. This is - important because most server implement a liberal (short) timeout + important because most servers implement liberal (short) timeout on persistent connections. Wget can of course always reconnect if the connection doesn't work out, but it's nicer to know in advance. This test is a logical followup of the first test, but - is "expensive" and therefore placed at the end of the list. */ + is "expensive" and therefore placed at the end of the list. + + (Current implementation of test_socket_open has a nice side + effect that it treats sockets with pending data as "closed". + This is exactly what we want: if a broken server sends message + body in response to HEAD, or if it sends more than conent-length + data, we won't reuse the corrupted connection.) */ if (!test_socket_open (pconn.socket)) { @@ -1029,10 +1147,10 @@ let's invalidate the persistent connection before returning 0. */ invalidate_persistent (); - return 0; + return false; } - return 1; + return true; } /* The idea behind these two CLOSE macros is to distinguish between @@ -1050,41 +1168,49 @@ `pc_active_p && (fd) == pc_last_fd' is "we're *now* using an active, registered connection". */ -#define CLOSE_FINISH(fd) do { \ - if (!keep_alive) \ - { \ - if (pconn_active && (fd) == pconn.socket) \ - invalidate_persistent (); \ - else \ - { \ - fd_close (fd); \ - fd = -1; \ - } \ - } \ +#define CLOSE_FINISH(fd) do { \ + if (!keep_alive) \ + { \ + if (pconn_active && (fd) == pconn.socket) \ + invalidate_persistent (); \ + else \ + { \ + fd_close (fd); \ + fd = -1; \ + } \ + } \ } while (0) -#define CLOSE_INVALIDATE(fd) do { \ - if (pconn_active && (fd) == pconn.socket) \ - invalidate_persistent (); \ - else \ - fd_close (fd); \ - fd = -1; \ +#define CLOSE_INVALIDATE(fd) do { \ + if (pconn_active && (fd) == pconn.socket) \ + invalidate_persistent (); \ + else \ + fd_close (fd); \ + fd = -1; \ } while (0) struct http_stat { - wgint len; /* received length */ - wgint contlen; /* expected length */ - wgint restval; /* the restart value */ - int res; /* the result of last read */ - char *newloc; /* new location (redirection) */ - char *remote_time; /* remote time-stamp string */ - char *error; /* textual HTTP error */ - int statcode; /* status code */ - wgint rd_size; /* amount of data read from socket */ - double dltime; /* time it took to download the data */ - const char *referer; /* value of the referer header. */ - char **local_file; /* local file. */ + wgint len; /* received length */ + wgint contlen; /* expected length */ + wgint restval; /* the restart value */ + int res; /* the result of last read */ + char *rderrmsg; /* error message from read error */ + char *newloc; /* new location (redirection) */ + char *remote_time; /* remote time-stamp string */ + char *error; /* textual HTTP error */ + int statcode; /* status code */ + wgint rd_size; /* amount of data read from socket */ + double dltime; /* time it took to download the data */ + const char *referer; /* value of the referer header. */ + char *local_file; /* local file name. */ + bool timestamp_checked; /* true if pre-download time-stamping checks + * have already been performed */ + char *orig_file_name; /* name of file to compare for time-stamping + * (might be != local_file if -K is set) */ + wgint orig_file_size; /* size of file to compare for time-stamping */ + time_t orig_file_tstamp; /* time-stamp of file to compare for + * time-stamping */ }; static void @@ -1093,6 +1219,9 @@ xfree_null (hs->newloc); xfree_null (hs->remote_time); xfree_null (hs->error); + xfree_null (hs->rderrmsg); + xfree_null (hs->local_file); + xfree_null (hs->orig_file_name); /* Guard against being called twice. */ hs->newloc = NULL; @@ -1100,32 +1229,31 @@ hs->error = NULL; } -static char *create_authorization_line PARAMS ((const char *, const char *, - const char *, const char *, - const char *, int *)); -static char *basic_authentication_encode PARAMS ((const char *, const char *)); -static int known_authentication_scheme_p PARAMS ((const char *, const char *)); - -time_t http_atotm PARAMS ((const char *)); - -#define BEGINS_WITH(line, string_constant) \ - (!strncasecmp (line, string_constant, sizeof (string_constant) - 1) \ - && (ISSPACE (line[sizeof (string_constant) - 1]) \ +static char *create_authorization_line (const char *, const char *, + const char *, const char *, + const char *, bool *); +static char *basic_authentication_encode (const char *, const char *); +static bool known_authentication_scheme_p (const char *, const char *); +static void load_cookies (void); + +#define BEGINS_WITH(line, string_constant) \ + (!strncasecmp (line, string_constant, sizeof (string_constant) - 1) \ + && (ISSPACE (line[sizeof (string_constant) - 1]) \ || !line[sizeof (string_constant) - 1])) -#define SET_USER_AGENT(req) do { \ - if (!opt.useragent) \ - request_set_header (req, "User-Agent", \ - aprintf ("Wget/%s", version_string), rel_value); \ - else if (*opt.useragent) \ - request_set_header (req, "User-Agent", opt.useragent, rel_none); \ +#define SET_USER_AGENT(req) do { \ + if (!opt.useragent) \ + request_set_header (req, "User-Agent", \ + aprintf ("Wget/%s", version_string), rel_value); \ + else if (*opt.useragent) \ + request_set_header (req, "User-Agent", opt.useragent, rel_none); \ } while (0) /* The flags that allow clobbering the file (opening with "wb"). Defined here to avoid repetition later. #### This will require rework. */ #define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \ - || opt.dirstruct || opt.output_document) + || opt.dirstruct || opt.output_document) /* Retrieve a document through HTTP protocol. It recognizes status code, and correctly handles redirections. It closes the network @@ -1156,17 +1284,17 @@ /* Set to 1 when the authorization has failed permanently and should not be tried again. */ - int auth_finished = 0; + bool auth_finished = false; /* Whether NTLM authentication is used for this request. */ - int ntlm_seen = 0; + bool ntlm_seen = false; /* Whether our connection to the remote host is through SSL. */ - int using_ssl = 0; + bool using_ssl = false; /* Whether a HEAD request will be issued (as opposed to GET or POST). */ - int head_only = *dt & HEAD_ONLY; + bool head_only = !!(*dt & HEAD_ONLY); char *head; struct response *resp; @@ -1175,7 +1303,7 @@ /* Whether this connection will be kept alive after the HTTP request is done. */ - int keep_alive; + bool keep_alive; /* Whether keep-alive should be inhibited. @@ -1184,38 +1312,34 @@ the Connection header and transfer it to the remote server, causing it to not close the connection and leave both the proxy and the client hanging. */ - int inhibit_keep_alive = + bool inhibit_keep_alive = !opt.http_keep_alive || opt.ignore_length || proxy != NULL; /* Headers sent when using POST. */ wgint post_data_size = 0; - int host_lookup_failed = 0; + bool host_lookup_failed = false; #ifdef HAVE_SSL if (u->scheme == SCHEME_HTTPS) { /* Initialize the SSL context. After this has once been done, - it becomes a no-op. */ + it becomes a no-op. */ if (!ssl_init ()) - { - scheme_disable (SCHEME_HTTPS); - logprintf (LOG_NOTQUIET, - _("Disabling SSL due to encountered errors.\n")); - return SSLINITFAILED; - } + { + scheme_disable (SCHEME_HTTPS); + logprintf (LOG_NOTQUIET, + _("Disabling SSL due to encountered errors.\n")); + return SSLINITFAILED; + } } #endif /* HAVE_SSL */ - if (!head_only) - /* If we're doing a GET on the URL, as opposed to just a HEAD, we need to - know the local filename so we can save to it. */ - assert (*hs->local_file != NULL); - /* Initialize certain elements of struct http_stat. */ hs->len = 0; hs->contlen = -1; hs->res = -1; + hs->rderrmsg = NULL; hs->newloc = NULL; hs->remote_time = NULL; hs->error = NULL; @@ -1237,12 +1361,12 @@ "param=value", full_path will be "/foo/bar?param=value". */ if (proxy #ifdef HAVE_SSL - /* When using SSL over proxy, CONNECT establishes a direct - connection to the HTTPS server. Therefore use the same - argument as when talking to the server directly. */ - && u->scheme != SCHEME_HTTPS + /* When using SSL over proxy, CONNECT establishes a direct + connection to the HTTPS server. Therefore use the same + argument as when talking to the server directly. */ + && u->scheme != SCHEME_HTTPS #endif - ) + ) meth_arg = xstrdup (u->url); else meth_arg = url_full_path (u); @@ -1254,9 +1378,9 @@ request_set_header (req, "Pragma", "no-cache", rel_none); if (hs->restval) request_set_header (req, "Range", - aprintf ("bytes=%s-", - number_to_static_string (hs->restval)), - rel_value); + aprintf ("bytes=%s-", + number_to_static_string (hs->restval)), + rel_value); SET_USER_AGENT (req); request_set_header (req, "Accept", "*/*", rel_none); @@ -1270,28 +1394,28 @@ if (user && passwd) { /* We have the username and the password, but haven't tried - any authorization yet. Let's see if the "Basic" method - works. If not, we'll come back here and construct a - proper authorization method with the right challenges. - - If we didn't employ this kind of logic, every URL that - requires authorization would have to be processed twice, - which is very suboptimal and generates a bunch of false - "unauthorized" errors in the server log. - - #### But this logic also has a serious problem when used - with stronger authentications: we *first* transmit the - username and the password in clear text, and *then* attempt a - stronger authentication scheme. That cannot be right! We - are only fortunate that almost everyone still uses the - `Basic' scheme anyway. - - There should be an option to prevent this from happening, for - those who use strong authentication schemes and value their - passwords. */ + any authorization yet. Let's see if the "Basic" method + works. If not, we'll come back here and construct a + proper authorization method with the right challenges. + + If we didn't employ this kind of logic, every URL that + requires authorization would have to be processed twice, + which is very suboptimal and generates a bunch of false + "unauthorized" errors in the server log. + + #### But this logic also has a serious problem when used + with stronger authentications: we *first* transmit the + username and the password in clear text, and *then* attempt a + stronger authentication scheme. That cannot be right! We + are only fortunate that almost everyone still uses the + `Basic' scheme anyway. + + There should be an option to prevent this from happening, for + those who use strong authentication schemes and value their + passwords. */ request_set_header (req, "Authorization", - basic_authentication_encode (user, passwd), - rel_value); + basic_authentication_encode (user, passwd), + rel_value); } proxyauth = NULL; @@ -1299,50 +1423,55 @@ { char *proxy_user, *proxy_passwd; /* For normal username and password, URL components override - command-line/wgetrc parameters. With proxy - authentication, it's the reverse, because proxy URLs are - normally the "permanent" ones, so command-line args - should take precedence. */ + command-line/wgetrc parameters. With proxy + authentication, it's the reverse, because proxy URLs are + normally the "permanent" ones, so command-line args + should take precedence. */ if (opt.proxy_user && opt.proxy_passwd) - { - proxy_user = opt.proxy_user; - proxy_passwd = opt.proxy_passwd; - } + { + proxy_user = opt.proxy_user; + proxy_passwd = opt.proxy_passwd; + } else - { - proxy_user = proxy->user; - proxy_passwd = proxy->passwd; - } + { + proxy_user = proxy->user; + proxy_passwd = proxy->passwd; + } /* #### This does not appear right. Can't the proxy request, - say, `Digest' authentication? */ + say, `Digest' authentication? */ if (proxy_user && proxy_passwd) - proxyauth = basic_authentication_encode (proxy_user, proxy_passwd); + proxyauth = basic_authentication_encode (proxy_user, proxy_passwd); /* If we're using a proxy, we will be connecting to the proxy - server. */ + server. */ conn = proxy; /* Proxy authorization over SSL is handled below. */ #ifdef HAVE_SSL if (u->scheme != SCHEME_HTTPS) #endif - request_set_header (req, "Proxy-Authorization", proxyauth, rel_value); + request_set_header (req, "Proxy-Authorization", proxyauth, rel_value); } + /* Generate the Host header, HOST:PORT. Take into account that: + + - Broken server-side software often doesn't recognize the PORT + argument, so we must generate "Host: www.server.com" instead of + "Host: www.server.com:80" (and likewise for https port). + + - IPv6 addresses contain ":", so "Host: 3ffe:8100:200:2::2:1234" + becomes ambiguous and needs to be rewritten as "Host: + [3ffe:8100:200:2::2]:1234". */ { - /* Whether we need to print the host header with braces around - host, e.g. "Host: [3ffe:8100:200:2::2]:1234" instead of the - usual "Host: symbolic-name:1234". */ - int squares = strchr (u->host, ':') != NULL; - if (u->port == scheme_default_port (u->scheme)) - request_set_header (req, "Host", - aprintf (squares ? "[%s]" : "%s", u->host), - rel_value); - else - request_set_header (req, "Host", - aprintf (squares ? "[%s]:%d" : "%s:%d", - u->host, u->port), - rel_value); + /* Formats arranged for hfmt[add_port][add_squares]. */ + static const char *hfmt[][2] = { + { "%s", "[%s]" }, { "%s:%d", "[%s]:%d" } + }; + int add_port = u->port != scheme_default_port (u->scheme); + int add_squares = strchr (u->host, ':') != NULL; + request_set_header (req, "Host", + aprintf (hfmt[add_port][add_squares], u->host, u->port), + rel_value); } if (!inhibit_keep_alive) @@ -1350,35 +1479,35 @@ if (opt.cookies) request_set_header (req, "Cookie", - cookie_header (wget_cookie_jar, - u->host, u->port, u->path, + cookie_header (wget_cookie_jar, + u->host, u->port, u->path, #ifdef HAVE_SSL - u->scheme == SCHEME_HTTPS + u->scheme == SCHEME_HTTPS #else - 0 + 0 #endif - ), - rel_value); + ), + rel_value); if (opt.post_data || opt.post_file_name) { request_set_header (req, "Content-Type", - "application/x-www-form-urlencoded", rel_none); + "application/x-www-form-urlencoded", rel_none); if (opt.post_data) - post_data_size = strlen (opt.post_data); + post_data_size = strlen (opt.post_data); else - { - post_data_size = file_size (opt.post_file_name); - if (post_data_size == -1) - { - logprintf (LOG_NOTQUIET, _("POST data file `%s' missing: %s\n"), - opt.post_file_name, strerror (errno)); - post_data_size = 0; - } - } + { + post_data_size = file_size (opt.post_file_name); + if (post_data_size == -1) + { + logprintf (LOG_NOTQUIET, _("POST data file `%s' missing: %s\n"), + opt.post_file_name, strerror (errno)); + post_data_size = 0; + } + } request_set_header (req, "Content-Length", - xstrdup (number_to_static_string (post_data_size)), - rel_value); + xstrdup (number_to_static_string (post_data_size)), + rel_value); } /* Add the user headers. */ @@ -1386,7 +1515,7 @@ { int i; for (i = 0; opt.user_headers[i]; i++) - request_set_user_header (req, opt.user_headers[i]); + request_set_user_header (req, opt.user_headers[i]); } retry_with_auth: @@ -1394,143 +1523,143 @@ without authorization header fails. (Expected to happen at least for the Digest authorization scheme.) */ - keep_alive = 0; + keep_alive = false; /* Establish the connection. */ if (!inhibit_keep_alive) { /* Look for a persistent connection to target host, unless a - 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. */ + 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; #ifdef HAVE_SSL if (u->scheme == SCHEME_HTTPS) - relevant = u; + relevant = u; #endif if (persistent_available_p (relevant->host, relevant->port, #ifdef HAVE_SSL - relevant->scheme == SCHEME_HTTPS, + relevant->scheme == SCHEME_HTTPS, #else - 0, + 0, #endif - &host_lookup_failed)) - { - sock = pconn.socket; - using_ssl = pconn.ssl; - logprintf (LOG_VERBOSE, _("Reusing existing connection to %s:%d.\n"), - escnonprint (pconn.host), pconn.port); - DEBUGP (("Reusing fd %d.\n", sock)); - if (pconn.authorized) - /* If the connection is already authorized, the "Basic" - authorization added by code above is unnecessary and - only hurts us. */ - request_remove_header (req, "Authorization"); - } + &host_lookup_failed)) + { + sock = pconn.socket; + using_ssl = pconn.ssl; + logprintf (LOG_VERBOSE, _("Reusing existing connection to %s:%d.\n"), + escnonprint (pconn.host), pconn.port); + DEBUGP (("Reusing fd %d.\n", sock)); + if (pconn.authorized) + /* If the connection is already authorized, the "Basic" + authorization added by code above is unnecessary and + only hurts us. */ + request_remove_header (req, "Authorization"); + } } if (sock < 0) { /* In its current implementation, persistent_available_p will - look up conn->host in some cases. If that lookup failed, we - don't need to bother with connect_to_host. */ + look up conn->host in some cases. If that lookup failed, we + don't need to bother with connect_to_host. */ if (host_lookup_failed) - { - request_free (req); - return HOSTERR; - } + { + request_free (req); + return HOSTERR; + } sock = connect_to_host (conn->host, conn->port); if (sock == E_HOST) - { - request_free (req); - return HOSTERR; - } + { + request_free (req); + return HOSTERR; + } else if (sock < 0) - { - request_free (req); - return (retryable_socket_connect_error (errno) - ? CONERROR : CONIMPOSSIBLE); - } + { + request_free (req); + return (retryable_socket_connect_error (errno) + ? CONERROR : CONIMPOSSIBLE); + } #ifdef HAVE_SSL if (proxy && u->scheme == SCHEME_HTTPS) - { - /* When requesting SSL URLs through proxies, use the - CONNECT method to request passthrough. */ - struct request *connreq = request_new (); - request_set_method (connreq, "CONNECT", - aprintf ("%s:%d", u->host, u->port)); - SET_USER_AGENT (connreq); - if (proxyauth) - { - request_set_header (connreq, "Proxy-Authorization", - proxyauth, rel_value); - /* Now that PROXYAUTH is part of the CONNECT request, - zero it out so we don't send proxy authorization with - the regular request below. */ - proxyauth = NULL; - } - /* Examples in rfc2817 use the Host header in CONNECT - requests. I don't see how that gains anything, given - that the contents of Host would be exactly the same as - the contents of CONNECT. */ - - write_error = request_send (connreq, sock); - request_free (connreq); - if (write_error < 0) - { - CLOSE_INVALIDATE (sock); - return WRITEFAILED; - } - - head = read_http_response_head (sock); - if (!head) - { - logprintf (LOG_VERBOSE, _("Failed reading proxy response: %s\n"), - strerror (errno)); - CLOSE_INVALIDATE (sock); - return HERR; - } - message = NULL; - if (!*head) - { - xfree (head); - goto failed_tunnel; - } - DEBUGP (("proxy responded with: [%s]\n", head)); - - resp = resp_new (head); - statcode = resp_status (resp, &message); - resp_free (resp); - xfree (head); - if (statcode != 200) - { - failed_tunnel: - logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"), - message ? escnonprint (message) : "?"); - xfree_null (message); - return CONSSLERR; - } - xfree_null (message); - - /* SOCK is now *really* connected to u->host, so update CONN - to reflect this. That way register_persistent will - register SOCK as being connected to u->host:u->port. */ - conn = u; - } + { + /* When requesting SSL URLs through proxies, use the + CONNECT method to request passthrough. */ + struct request *connreq = request_new (); + request_set_method (connreq, "CONNECT", + aprintf ("%s:%d", u->host, u->port)); + SET_USER_AGENT (connreq); + if (proxyauth) + { + request_set_header (connreq, "Proxy-Authorization", + proxyauth, rel_value); + /* Now that PROXYAUTH is part of the CONNECT request, + zero it out so we don't send proxy authorization with + the regular request below. */ + proxyauth = NULL; + } + /* Examples in rfc2817 use the Host header in CONNECT + requests. I don't see how that gains anything, given + that the contents of Host would be exactly the same as + the contents of CONNECT. */ + + write_error = request_send (connreq, sock); + request_free (connreq); + if (write_error < 0) + { + CLOSE_INVALIDATE (sock); + return WRITEFAILED; + } + + head = read_http_response_head (sock); + if (!head) + { + logprintf (LOG_VERBOSE, _("Failed reading proxy response: %s\n"), + fd_errstr (sock)); + CLOSE_INVALIDATE (sock); + return HERR; + } + message = NULL; + if (!*head) + { + xfree (head); + goto failed_tunnel; + } + DEBUGP (("proxy responded with: [%s]\n", head)); + + resp = resp_new (head); + statcode = resp_status (resp, &message); + resp_free (resp); + xfree (head); + if (statcode != 200) + { + failed_tunnel: + logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"), + message ? escnonprint (message) : "?"); + xfree_null (message); + return CONSSLERR; + } + xfree_null (message); + + /* SOCK is now *really* connected to u->host, so update CONN + to reflect this. That way register_persistent will + register SOCK as being connected to u->host:u->port. */ + conn = u; + } if (conn->scheme == SCHEME_HTTPS) - { - if (!ssl_connect (sock) || !ssl_check_certificate (sock, u->host)) - { - fd_close (sock); - return CONSSLERR; - } - using_ssl = 1; - } + { + if (!ssl_connect (sock) || !ssl_check_certificate (sock, u->host)) + { + fd_close (sock); + return CONSSLERR; + } + using_ssl = true; + } #endif /* HAVE_SSL */ } @@ -1540,12 +1669,12 @@ if (write_error >= 0) { if (opt.post_data) - { - DEBUGP (("[POST data: %s]\n", opt.post_data)); - write_error = fd_write (sock, opt.post_data, post_data_size, -1.0); - } + { + DEBUGP (("[POST data: %s]\n", opt.post_data)); + write_error = fd_write (sock, opt.post_data, post_data_size, -1); + } else if (opt.post_file_name && post_data_size != 0) - write_error = post_file (sock, opt.post_file_name, post_data_size); + write_error = post_file (sock, opt.post_file_name, post_data_size); } if (write_error < 0) @@ -1555,7 +1684,7 @@ return WRITEFAILED; } logprintf (LOG_VERBOSE, _("%s request sent, awaiting response... "), - proxy ? "Proxy" : "HTTP"); + proxy ? "Proxy" : "HTTP"); contlen = -1; contrange = 0; *dt &= ~RETROKF; @@ -1564,20 +1693,20 @@ if (!head) { if (errno == 0) - { - logputs (LOG_NOTQUIET, _("No data received.\n")); - CLOSE_INVALIDATE (sock); - request_free (req); - return HEOF; - } + { + logputs (LOG_NOTQUIET, _("No data received.\n")); + CLOSE_INVALIDATE (sock); + request_free (req); + return HEOF; + } else - { - logprintf (LOG_NOTQUIET, _("Read error (%s) in headers.\n"), - strerror (errno)); - CLOSE_INVALIDATE (sock); - request_free (req); - return HERR; - } + { + logprintf (LOG_NOTQUIET, _("Read error (%s) in headers.\n"), + fd_errstr (sock)); + CLOSE_INVALIDATE (sock); + request_free (req); + return HERR; + } } DEBUGP (("\n---response begin---\n%s---response end---\n", head)); @@ -1588,13 +1717,121 @@ statcode = resp_status (resp, &message); if (!opt.server_response) logprintf (LOG_VERBOSE, "%2d %s\n", statcode, - message ? escnonprint (message) : ""); + message ? escnonprint (message) : ""); else { logprintf (LOG_VERBOSE, "\n"); print_server_response (resp, " "); } + /* Determine the local filename if needed. Notice that if -O is used + * hstat.local_file is set by http_loop to the argument of -O. */ + if (!hs->local_file) + { + /* Honor Content-Disposition whether possible. */ + if (!opt.content_disposition + || !resp_header_copy (resp, "Content-Disposition", + hdrval, sizeof (hdrval)) + || !parse_content_disposition (hdrval, &hs->local_file)) + { + /* The Content-Disposition header is missing or broken. + * Choose unique file name according to given URL. */ + hs->local_file = url_file_name (u); + } + } + + DEBUGP (("hs->local_file is: %s %s\n", hs->local_file, + file_exists_p (hs->local_file) ? "(existing)" : "(not existing)")); + + /* TODO: perform this check only once. */ + if (file_exists_p (hs->local_file)) + { + if (opt.noclobber) + { + /* If opt.noclobber is turned on and file already exists, do not + retrieve the file */ + logprintf (LOG_VERBOSE, _("\ +File `%s' already there; not retrieving.\n\n"), hs->local_file); + /* If the file is there, we suppose it's retrieved OK. */ + *dt |= RETROKF; + + /* #### Bogusness alert. */ + /* If its suffix is "html" or "htm" or similar, assume text/html. */ + if (has_html_suffix_p (hs->local_file)) + *dt |= TEXTHTML; + + return RETROK; + } + else + { + char *unique = unique_name (hs->local_file, true); + if (unique != hs->local_file) + xfree (hs->local_file); + hs->local_file = unique; + } + } + + /* Support timestamping */ + /* TODO: move this code out of gethttp. */ + if (opt.timestamping && !hs->timestamp_checked) + { + size_t filename_len = strlen (hs->local_file); + char *filename_plus_orig_suffix = alloca (filename_len + sizeof (".orig")); + bool local_dot_orig_file_exists = false; + char *local_filename = NULL; + struct_stat st; + + if (opt.backup_converted) + /* If -K is specified, we'll act on the assumption that it was specified + last time these files were downloaded as well, and instead of just + comparing local file X against server file X, we'll compare local + file X.orig (if extant, else X) against server file X. If -K + _wasn't_ specified last time, or the server contains files called + *.orig, -N will be back to not operating correctly with -k. */ + { + /* Would a single s[n]printf() call be faster? --dan + + Definitely not. sprintf() is horribly slow. It's a + different question whether the difference between the two + affects a program. Usually I'd say "no", but at one + point I profiled Wget, and found that a measurable and + non-negligible amount of time was lost calling sprintf() + in url.c. Replacing sprintf with inline calls to + strcpy() and number_to_string() made a difference. + --hniksic */ + memcpy (filename_plus_orig_suffix, hs->local_file, filename_len); + memcpy (filename_plus_orig_suffix + filename_len, + ".orig", sizeof (".orig")); + + /* Try to stat() the .orig file. */ + if (stat (filename_plus_orig_suffix, &st) == 0) + { + local_dot_orig_file_exists = 1; + local_filename = filename_plus_orig_suffix; + } + } + + if (!local_dot_orig_file_exists) + /* Couldn't stat() .orig, so try to stat() . */ + if (stat (hs->local_file, &st) == 0) + local_filename = hs->local_file; + + if (local_filename != NULL) + /* There was a local file, so we'll check later to see if the version + the server has is the same version we already have, allowing us to + skip a download. */ + { + hs->orig_file_name = xstrdup (local_filename); + hs->orig_file_size = st.st_size; + hs->orig_file_tstamp = st.st_mtime; +#ifdef WINDOWS + /* Modification time granularity is 2 seconds for Windows, so + increase local time by 1 second for later comparison. */ + ++hs->orig_file_tstamp; +#endif + } + } + if (!opt.ignore_length && resp_header_copy (resp, "Content-Length", hdrval, sizeof (hdrval))) { @@ -1602,26 +1839,26 @@ errno = 0; parsed = str_to_wgint (hdrval, NULL, 10); if (parsed == WGINT_MAX && errno == ERANGE) - /* Out of range. - #### If Content-Length is out of range, it most likely - means that the file is larger than 2G and that we're - compiled without LFS. In that case we should probably - refuse to even attempt to download the file. */ - contlen = -1; + /* Out of range. + #### If Content-Length is out of range, it most likely + means that the file is larger than 2G and that we're + compiled without LFS. In that case we should probably + refuse to even attempt to download the file. */ + contlen = -1; else - contlen = parsed; + contlen = parsed; } /* Check for keep-alive related responses. */ if (!inhibit_keep_alive && contlen != -1) { if (resp_header_copy (resp, "Keep-Alive", NULL, 0)) - keep_alive = 1; + keep_alive = true; else if (resp_header_copy (resp, "Connection", hdrval, sizeof (hdrval))) - { - if (0 == strcasecmp (hdrval, "Keep-Alive")) - keep_alive = 1; - } + { + if (0 == strcasecmp (hdrval, "Keep-Alive")) + keep_alive = true; + } } if (keep_alive) /* The server has promised that it will not close the connection @@ -1632,55 +1869,55 @@ { /* Authorization is required. */ if (keep_alive && !head_only && skip_short_body (sock, contlen)) - CLOSE_FINISH (sock); + CLOSE_FINISH (sock); else - CLOSE_INVALIDATE (sock); - pconn.authorized = 0; + CLOSE_INVALIDATE (sock); + pconn.authorized = false; if (!auth_finished && (user && passwd)) - { - /* IIS sends multiple copies of WWW-Authenticate, one with - the value "negotiate", and other(s) with data. Loop over - all the occurrences and pick the one we recognize. */ - int wapos; - const char *wabeg, *waend; - char *www_authenticate = NULL; - for (wapos = 0; - (wapos = resp_header_locate (resp, "WWW-Authenticate", wapos, - &wabeg, &waend)) != -1; - ++wapos) - if (known_authentication_scheme_p (wabeg, waend)) - { - BOUNDED_TO_ALLOCA (wabeg, waend, www_authenticate); - break; - } - - if (!www_authenticate) - /* If the authentication header is missing or - unrecognized, there's no sense in retrying. */ - logputs (LOG_NOTQUIET, _("Unknown authentication scheme.\n")); - else if (BEGINS_WITH (www_authenticate, "Basic")) - /* If the authentication scheme is "Basic", which we send - by default, there's no sense in retrying either. (This - should be changed when we stop sending "Basic" data by - default.) */ - ; - else - { - char *pth; - pth = url_full_path (u); - request_set_header (req, "Authorization", - create_authorization_line (www_authenticate, - user, passwd, - request_method (req), - pth, - &auth_finished), - rel_value); - if (BEGINS_WITH (www_authenticate, "NTLM")) - ntlm_seen = 1; - xfree (pth); - goto retry_with_auth; - } - } + { + /* IIS sends multiple copies of WWW-Authenticate, one with + the value "negotiate", and other(s) with data. Loop over + all the occurrences and pick the one we recognize. */ + int wapos; + const char *wabeg, *waend; + char *www_authenticate = NULL; + for (wapos = 0; + (wapos = resp_header_locate (resp, "WWW-Authenticate", wapos, + &wabeg, &waend)) != -1; + ++wapos) + if (known_authentication_scheme_p (wabeg, waend)) + { + BOUNDED_TO_ALLOCA (wabeg, waend, www_authenticate); + break; + } + + if (!www_authenticate) + /* If the authentication header is missing or + unrecognized, there's no sense in retrying. */ + logputs (LOG_NOTQUIET, _("Unknown authentication scheme.\n")); + else if (BEGINS_WITH (www_authenticate, "Basic")) + /* If the authentication scheme is "Basic", which we send + by default, there's no sense in retrying either. (This + should be changed when we stop sending "Basic" data by + default.) */ + ; + else + { + char *pth; + pth = url_full_path (u); + request_set_header (req, "Authorization", + create_authorization_line (www_authenticate, + user, passwd, + request_method (req), + pth, + &auth_finished), + rel_value); + if (BEGINS_WITH (www_authenticate, "NTLM")) + ntlm_seen = true; + xfree (pth); + goto retry_with_auth; + } + } logputs (LOG_NOTQUIET, _("Authorization failed.\n")); request_free (req); return AUTHFAILED; @@ -1689,7 +1926,7 @@ { /* Kludge: if NTLM is used, mark the TCP connection as authorized. */ if (ntlm_seen) - pconn.authorized = 1; + pconn.authorized = true; } request_free (req); @@ -1707,11 +1944,11 @@ { char *tmp = strchr (type, ';'); if (tmp) - { - while (tmp > type && ISSPACE (tmp[-1])) - --tmp; - *tmp = '\0'; - } + { + while (tmp > type && ISSPACE (tmp[-1])) + --tmp; + *tmp = '\0'; + } } hs->newloc = resp_header_strdup (resp, "Location"); hs->remote_time = resp_header_strdup (resp, "Last-Modified"); @@ -1724,22 +1961,22 @@ /* The jar should have been created by now. */ assert (wget_cookie_jar != NULL); for (scpos = 0; - (scpos = resp_header_locate (resp, "Set-Cookie", scpos, - &scbeg, &scend)) != -1; - ++scpos) - { - char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie); - cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port, - u->path, set_cookie); - } + (scpos = resp_header_locate (resp, "Set-Cookie", scpos, + &scbeg, &scend)) != -1; + ++scpos) + { + char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie); + cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port, + u->path, set_cookie); + } } if (resp_header_copy (resp, "Content-Range", hdrval, sizeof (hdrval))) { wgint first_byte_pos, last_byte_pos, entity_length; if (parse_content_range (hdrval, &first_byte_pos, &last_byte_pos, - &entity_length)) - contrange = first_byte_pos; + &entity_length)) + contrange = first_byte_pos; } resp_free (resp); @@ -1751,25 +1988,25 @@ if (H_REDIRECTED (statcode) || statcode == HTTP_STATUS_MULTIPLE_CHOICES) { /* RFC2068 says that in case of the 300 (multiple choices) - response, the server can output a preferred URL through - `Location' header; otherwise, the request should be treated - like GET. So, if the location is set, it will be a - redirection; otherwise, just proceed normally. */ + response, the server can output a preferred URL through + `Location' header; otherwise, the request should be treated + like GET. So, if the location is set, it will be a + redirection; otherwise, just proceed normally. */ if (statcode == HTTP_STATUS_MULTIPLE_CHOICES && !hs->newloc) - *dt |= RETROKF; + *dt |= RETROKF; else - { - logprintf (LOG_VERBOSE, - _("Location: %s%s\n"), - hs->newloc ? escnonprint_uri (hs->newloc) : _("unspecified"), - hs->newloc ? _(" [following]") : ""); - if (keep_alive && !head_only && skip_short_body (sock, contlen)) - CLOSE_FINISH (sock); - else - CLOSE_INVALIDATE (sock); - xfree_null (type); - return NEWLOCATION; - } + { + logprintf (LOG_VERBOSE, + _("Location: %s%s\n"), + hs->newloc ? escnonprint_uri (hs->newloc) : _("unspecified"), + hs->newloc ? _(" [following]") : ""); + if (keep_alive && !head_only && skip_short_body (sock, contlen)) + CLOSE_FINISH (sock); + else + CLOSE_INVALIDATE (sock); + xfree_null (type); + return NEWLOCATION; + } } /* If content-type is not given, assume text/html. This is because @@ -1777,47 +2014,49 @@ content-type. */ if (!type || 0 == strncasecmp (type, TEXTHTML_S, strlen (TEXTHTML_S)) || - 0 == strncasecmp (type, TEXTXHTML_S, strlen (TEXTXHTML_S))) + 0 == strncasecmp (type, TEXTXHTML_S, strlen (TEXTXHTML_S))) *dt |= TEXTHTML; else *dt &= ~TEXTHTML; + DEBUGP (("TEXTHTML is %s.\n", *dt | TEXTHTML ? "on": "off")); + if (opt.html_extension && (*dt & TEXTHTML)) /* -E / --html-extension / html_extension = on was specified, and this is a text/html file. If some case-insensitive variation on ".htm[l]" isn't already the file's suffix, tack on ".html". */ { - char *last_period_in_local_filename = strrchr (*hs->local_file, '.'); + char *last_period_in_local_filename = strrchr (hs->local_file, '.'); if (last_period_in_local_filename == NULL - || !(0 == strcasecmp (last_period_in_local_filename, ".htm") - || 0 == strcasecmp (last_period_in_local_filename, ".html"))) - { - int local_filename_len = strlen (*hs->local_file); - /* Resize the local file, allowing for ".html" preceded by - optional ".NUMBER". */ - *hs->local_file = xrealloc (*hs->local_file, - local_filename_len + 24 + sizeof (".html")); - strcpy(*hs->local_file + local_filename_len, ".html"); - /* If clobbering is not allowed and the file, as named, - exists, tack on ".NUMBER.html" instead. */ - if (!ALLOW_CLOBBER) - { - int ext_num = 1; - do - sprintf (*hs->local_file + local_filename_len, - ".%d.html", ext_num++); - while (file_exists_p (*hs->local_file)); - } - *dt |= ADDED_HTML_EXTENSION; - } + || !(0 == strcasecmp (last_period_in_local_filename, ".htm") + || 0 == strcasecmp (last_period_in_local_filename, ".html"))) + { + int local_filename_len = strlen (hs->local_file); + /* Resize the local file, allowing for ".html" preceded by + optional ".NUMBER". */ + hs->local_file = xrealloc (hs->local_file, + local_filename_len + 24 + sizeof (".html")); + strcpy(hs->local_file + local_filename_len, ".html"); + /* If clobbering is not allowed and the file, as named, + exists, tack on ".NUMBER.html" instead. */ + if (!ALLOW_CLOBBER && file_exists_p (hs->local_file)) + { + int ext_num = 1; + do + sprintf (hs->local_file + local_filename_len, + ".%d.html", ext_num++); + while (file_exists_p (hs->local_file)); + } + *dt |= ADDED_HTML_EXTENSION; + } } if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE) { /* If `-c' is in use and the file has been fully downloaded (or - the remote file has shrunk), Wget effectively requests bytes - after the end of file and the server response with 416. */ + the remote file has shrunk), Wget effectively requests bytes + after the end of file and the server response with 416. */ logputs (LOG_VERBOSE, _("\ \n The file is already fully retrieved; nothing to do.\n\n")); /* In case the caller inspects. */ @@ -1826,15 +2065,15 @@ /* Mark as successfully retrieved. */ *dt |= RETROKF; xfree_null (type); - CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there - might be more bytes in the body. */ + CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there + might be more bytes in the body. */ return RETRUNNEEDED; } if ((contrange != 0 && contrange != hs->restval) || (H_PARTIAL (statcode) && !contrange)) { /* The Range request was somehow misunderstood by the server. - Bail out. */ + Bail out. */ xfree_null (type); CLOSE_INVALIDATE (sock); return RANGEERR; @@ -1844,39 +2083,39 @@ if (opt.verbose) { if (*dt & RETROKF) - { - /* No need to print this output if the body won't be - downloaded at all, or if the original server response is - printed. */ - logputs (LOG_VERBOSE, _("Length: ")); - if (contlen != -1) - { - logputs (LOG_VERBOSE, with_thousand_seps (contlen + contrange)); - if (contlen + contrange >= 1024) - logprintf (LOG_VERBOSE, " (%s)", - human_readable (contlen + contrange)); - if (contrange) - { - if (contlen >= 1024) - logprintf (LOG_VERBOSE, _(", %s (%s) remaining"), - with_thousand_seps (contlen), - human_readable (contlen)); - else - logprintf (LOG_VERBOSE, _(", %s remaining"), - with_thousand_seps (contlen)); - } - } - else - logputs (LOG_VERBOSE, - opt.ignore_length ? _("ignored") : _("unspecified")); - if (type) - logprintf (LOG_VERBOSE, " [%s]\n", escnonprint (type)); - else - logputs (LOG_VERBOSE, "\n"); - } + { + /* No need to print this output if the body won't be + downloaded at all, or if the original server response is + printed. */ + logputs (LOG_VERBOSE, _("Length: ")); + if (contlen != -1) + { + logputs (LOG_VERBOSE, number_to_static_string (contlen + contrange)); + if (contlen + contrange >= 1024) + logprintf (LOG_VERBOSE, " (%s)", + human_readable (contlen + contrange)); + if (contrange) + { + if (contlen >= 1024) + logprintf (LOG_VERBOSE, _(", %s (%s) remaining"), + number_to_static_string (contlen), + human_readable (contlen)); + else + logprintf (LOG_VERBOSE, _(", %s remaining"), + number_to_static_string (contlen)); + } + } + else + logputs (LOG_VERBOSE, + opt.ignore_length ? _("ignored") : _("unspecified")); + if (type) + logprintf (LOG_VERBOSE, " [%s]\n", escnonprint (type)); + else + logputs (LOG_VERBOSE, "\n"); + } } xfree_null (type); - type = NULL; /* We don't need it any more. */ + type = NULL; /* We don't need it any more. */ /* Return if we have no intention of further downloading. */ if (!(*dt & RETROKF) || head_only) @@ -1886,58 +2125,66 @@ hs->res = 0; xfree_null (type); if (head_only) - /* Pre-1.10 Wget used CLOSE_INVALIDATE here. Now we trust the - servers not to send body in response to a HEAD request. If - you encounter such a server (more likely a broken CGI), use - `--no-http-keep-alive'. */ - CLOSE_FINISH (sock); + /* Pre-1.10 Wget used CLOSE_INVALIDATE here. Now we trust the + servers not to send body in response to a HEAD request, and + those that do will likely be caught by test_socket_open. + If not, they can be worked around using + `--no-http-keep-alive'. */ + CLOSE_FINISH (sock); else if (keep_alive && skip_short_body (sock, contlen)) - /* Successfully skipped the body; also keep using the socket. */ - CLOSE_FINISH (sock); + /* Successfully skipped the body; also keep using the socket. */ + CLOSE_FINISH (sock); else - CLOSE_INVALIDATE (sock); + CLOSE_INVALIDATE (sock); return RETRFINISHED; } /* Open the local file. */ if (!output_stream) { - mkalldirs (*hs->local_file); + mkalldirs (hs->local_file); if (opt.backups) - rotate_backups (*hs->local_file); + rotate_backups (hs->local_file); if (hs->restval) - fp = fopen (*hs->local_file, "ab"); + fp = fopen (hs->local_file, "ab"); else if (ALLOW_CLOBBER) - fp = fopen (*hs->local_file, "wb"); + fp = fopen (hs->local_file, "wb"); else - { - fp = fopen_excl (*hs->local_file, 1); - if (!fp && errno == EEXIST) - { - /* We cannot just invent a new name and use it (which is - what functions like unique_create typically do) - because we told the user we'd use this name. - Instead, return and retry the download. */ - logprintf (LOG_NOTQUIET, - _("%s has sprung into existence.\n"), - *hs->local_file); - CLOSE_INVALIDATE (sock); - return FOPEN_EXCL_ERR; - } - } + { + fp = fopen_excl (hs->local_file, true); + if (!fp && errno == EEXIST) + { + /* We cannot just invent a new name and use it (which is + what functions like unique_create typically do) + because we told the user we'd use this name. + Instead, return and retry the download. */ + logprintf (LOG_NOTQUIET, + _("%s has sprung into existence.\n"), + hs->local_file); + CLOSE_INVALIDATE (sock); + return FOPEN_EXCL_ERR; + } + } if (!fp) - { - logprintf (LOG_NOTQUIET, "%s: %s\n", *hs->local_file, strerror (errno)); - CLOSE_INVALIDATE (sock); - return FOPENERR; - } + { + logprintf (LOG_NOTQUIET, "%s: %s\n", hs->local_file, strerror (errno)); + CLOSE_INVALIDATE (sock); + return FOPENERR; + } } else fp = output_stream; - /* #### This confuses the timestamping code that checks for file - size. Maybe we should save some additional information? */ - if (opt.save_headers) + /* Print fetch message, if opt.verbose. */ + if (opt.verbose) + { + logprintf (LOG_NOTQUIET, _("Saving to: `%s'\n"), + HYPHENP (hs->local_file) ? "STDOUT" : hs->local_file); + } + + /* This confuses the timestamping code that checks for file size. + #### The timestamping code should be smarter about file size. */ + if (opt.save_headers && hs->restval == 0) fwrite (head, 1, strlen (head), fp); /* Now we no longer need to store the response header. */ @@ -1957,26 +2204,20 @@ hs->len = hs->restval; hs->rd_size = 0; hs->res = fd_read_body (sock, fp, contlen != -1 ? contlen : 0, - hs->restval, &hs->rd_size, &hs->len, &hs->dltime, - flags); + hs->restval, &hs->rd_size, &hs->len, &hs->dltime, + flags); if (hs->res >= 0) CLOSE_FINISH (sock); else - CLOSE_INVALIDATE (sock); + { + if (hs->res < 0) + hs->rderrmsg = xstrdup (fd_errstr (sock)); + CLOSE_INVALIDATE (sock); + } - { - /* Close or flush the file. We have to be careful to check for - error here. Checking the result of fwrite() is not enough -- - errors could go unnoticed! */ - int flush_res; - if (!output_stream) - flush_res = fclose (fp); - else - flush_res = fflush (fp); - if (flush_res == EOF) - hs->res = -2; - } + if (!output_stream) + fclose (fp); if (hs->res == -2) return FWRITEERR; return RETRFINISHED; @@ -1986,504 +2227,397 @@ retried, and retried, and retried, and... */ uerr_t http_loop (struct url *u, char **newloc, char **local_file, const char *referer, - int *dt, struct url *proxy) + int *dt, struct url *proxy) { int count; - int use_ts, got_head = 0; /* time-stamping info */ - char *filename_plus_orig_suffix; - char *local_filename = NULL; - char *tms, *locf, *tmrate; - uerr_t err; - time_t tml = -1, tmr = -1; /* local and remote time-stamps */ - wgint local_size = 0; /* the size of the local file */ - size_t filename_len; - struct http_stat hstat; /* HTTP status */ - struct_stat st; - char *dummy = NULL; + bool got_head = false; /* used for time-stamping */ + char *tms; + const char *tmrate; + uerr_t err, ret = TRYLIMEXC; + time_t tmr = -1; /* remote time-stamp */ + wgint local_size = 0; /* the size of the local file */ + struct http_stat hstat; /* HTTP status */ + struct_stat st; + + /* Assert that no value for *LOCAL_FILE was passed. */ + assert (local_file == NULL || *local_file == NULL); + + /* Set LOCAL_FILE parameter. */ + if (local_file && opt.output_document) + *local_file = HYPHENP (opt.output_document) ? NULL : xstrdup (opt.output_document); + + /* Reset NEWLOC parameter. */ + *newloc = NULL; /* This used to be done in main(), but it's a better idea to do it here so that we don't go through the hoops if we're just using FTP or whatever. */ if (opt.cookies) - { - if (!wget_cookie_jar) - wget_cookie_jar = cookie_jar_new (); - if (opt.cookies_input && !cookies_loaded_p) - { - cookie_jar_load (wget_cookie_jar, opt.cookies_input); - cookies_loaded_p = 1; - } - } + load_cookies(); - *newloc = NULL; - - /* Warn on (likely bogus) wildcard usage in HTTP. */ + /* Warn on (likely bogus) wildcard usage in HTTP. */ if (opt.ftp_glob && has_wildcards_p (u->path)) logputs (LOG_VERBOSE, _("Warning: wildcards not supported in HTTP.\n")); + /* Setup hstat struct. */ xzero (hstat); - - /* Determine the local filename. */ - if (local_file && *local_file) - hstat.local_file = local_file; - else if (local_file && !opt.output_document) - { - *local_file = url_file_name (u); - hstat.local_file = local_file; - } - else - { - dummy = url_file_name (u); - hstat.local_file = &dummy; - /* be honest about where we will save the file */ - if (local_file && opt.output_document) - *local_file = HYPHENP (opt.output_document) ? NULL : xstrdup (opt.output_document); - } - - if (!opt.output_document) - locf = *hstat.local_file; - else - locf = opt.output_document; - hstat.referer = referer; - filename_len = strlen (*hstat.local_file); - filename_plus_orig_suffix = alloca (filename_len + sizeof (".orig")); - - if (opt.noclobber && file_exists_p (*hstat.local_file)) - { - /* If opt.noclobber is turned on and file already exists, do not - retrieve the file */ - logprintf (LOG_VERBOSE, _("\ -File `%s' already there; not retrieving.\n\n"), *hstat.local_file); - /* If the file is there, we suppose it's retrieved OK. */ - *dt |= RETROKF; - - /* #### Bogusness alert. */ - /* If its suffix is "html" or "htm" or similar, assume text/html. */ - if (has_html_suffix_p (*hstat.local_file)) - *dt |= TEXTHTML; + if (opt.output_document) + hstat.local_file = xstrdup (opt.output_document); - xfree_null (dummy); - return RETROK; - } - - use_ts = 0; - if (opt.timestamping) - { - int local_dot_orig_file_exists = 0; - - if (opt.backup_converted) - /* If -K is specified, we'll act on the assumption that it was specified - last time these files were downloaded as well, and instead of just - comparing local file X against server file X, we'll compare local - file X.orig (if extant, else X) against server file X. If -K - _wasn't_ specified last time, or the server contains files called - *.orig, -N will be back to not operating correctly with -k. */ - { - /* Would a single s[n]printf() call be faster? --dan - - Definitely not. sprintf() is horribly slow. It's a - different question whether the difference between the two - affects a program. Usually I'd say "no", but at one - point I profiled Wget, and found that a measurable and - non-negligible amount of time was lost calling sprintf() - in url.c. Replacing sprintf with inline calls to - strcpy() and number_to_string() made a difference. - --hniksic */ - memcpy (filename_plus_orig_suffix, *hstat.local_file, filename_len); - memcpy (filename_plus_orig_suffix + filename_len, - ".orig", sizeof (".orig")); - - /* Try to stat() the .orig file. */ - if (stat (filename_plus_orig_suffix, &st) == 0) - { - local_dot_orig_file_exists = 1; - local_filename = filename_plus_orig_suffix; - } - } - - if (!local_dot_orig_file_exists) - /* Couldn't stat() .orig, so try to stat() . */ - if (stat (*hstat.local_file, &st) == 0) - local_filename = *hstat.local_file; - - if (local_filename != NULL) - /* There was a local file, so we'll check later to see if the version - the server has is the same version we already have, allowing us to - skip a download. */ - { - use_ts = 1; - tml = st.st_mtime; -#ifdef WINDOWS - /* Modification time granularity is 2 seconds for Windows, so - increase local time by 1 second for later comparison. */ - tml++; -#endif - local_size = st.st_size; - got_head = 0; - } - } - /* Reset the counter. */ + /* Reset the counter. */ count = 0; + + /* Reset the document type. */ *dt = 0; + /* THE loop */ do { /* Increment the pass counter. */ ++count; sleep_between_retrievals (count); + /* Get the current time string. */ tms = time_str (NULL); + /* Print fetch message, if opt.verbose. */ if (opt.verbose) - { - char *hurl = url_string (u, 1); - char tmp[256]; - strcpy (tmp, " "); - if (count > 1) - sprintf (tmp, _("(try:%2d)"), count); - logprintf (LOG_VERBOSE, "--%s-- %s\n %s => `%s'\n", - tms, hurl, tmp, locf); + { + char *hurl = url_string (u, true); + + if (count > 1) + { + char tmp[256]; + sprintf (tmp, _("(try:%2d)"), count); + logprintf (LOG_NOTQUIET, "--%s-- %s %s\n", + tms, tmp, hurl); + } + else + { + logprintf (LOG_NOTQUIET, "--%s-- %s\n", + tms, hurl); + } + #ifdef WINDOWS - ws_changetitle (hurl); + ws_changetitle (hurl); #endif - xfree (hurl); - } + xfree (hurl); + } /* Default document type is empty. However, if spider mode is - on or time-stamping is employed, HEAD_ONLY commands is - encoded within *dt. */ - if (opt.spider || (use_ts && !got_head)) - *dt |= HEAD_ONLY; + on or time-stamping is employed, HEAD_ONLY commands is + encoded within *dt. */ + if ((opt.spider && !opt.recursive) || (opt.timestamping && !got_head)) + *dt |= HEAD_ONLY; else - *dt &= ~HEAD_ONLY; + *dt &= ~HEAD_ONLY; /* Decide whether or not to restart. */ if (opt.always_rest - && stat (locf, &st) == 0 - && S_ISREG (st.st_mode)) - /* When -c is used, continue from on-disk size. (Can't use - hstat.len even if count>1 because we don't want a failed - first attempt to clobber existing data.) */ - hstat.restval = st.st_size; + && stat (hstat.local_file, &st) == 0 + && S_ISREG (st.st_mode)) + /* When -c is used, continue from on-disk size. (Can't use + hstat.len even if count>1 because we don't want a failed + first attempt to clobber existing data.) */ + hstat.restval = st.st_size; else if (count > 1) - /* otherwise, continue where the previous try left off */ - hstat.restval = hstat.len; + /* otherwise, continue where the previous try left off */ + hstat.restval = hstat.len; else - hstat.restval = 0; + hstat.restval = 0; /* Decide whether to send the no-cache directive. We send it in - two cases: - a) we're using a proxy, and we're past our first retrieval. - Some proxies are notorious for caching incomplete data, so - we require a fresh get. - b) caching is explicitly inhibited. */ - if ((proxy && count > 1) /* a */ - || !opt.allow_cache /* b */ - ) - *dt |= SEND_NOCACHE; + two cases: + a) we're using a proxy, and we're past our first retrieval. + Some proxies are notorious for caching incomplete data, so + we require a fresh get. + b) caching is explicitly inhibited. */ + if ((proxy && count > 1) /* a */ + || !opt.allow_cache) /* b */ + *dt |= SEND_NOCACHE; else - *dt &= ~SEND_NOCACHE; + *dt &= ~SEND_NOCACHE; /* Try fetching the document, or at least its head. */ err = gethttp (u, &hstat, dt, proxy); - /* It's unfortunate that wget determines the local filename before finding - out the Content-Type of the file. Barring a major restructuring of the - code, we need to re-set locf here, since gethttp() may have xrealloc()d - *hstat.local_file to tack on ".html". */ - if (!opt.output_document) - locf = *hstat.local_file; - /* Time? */ tms = time_str (NULL); + /* Get the new location (with or without the redirection). */ if (hstat.newloc) - *newloc = xstrdup (hstat.newloc); + *newloc = xstrdup (hstat.newloc); + switch (err) - { - case HERR: case HEOF: case CONSOCKERR: case CONCLOSED: - case CONERROR: case READERR: case WRITEFAILED: - case RANGEERR: case FOPEN_EXCL_ERR: - /* Non-fatal errors continue executing the loop, which will - bring them to "while" statement at the end, to judge - whether the number of tries was exceeded. */ - free_hstat (&hstat); - printwhat (count, opt.ntry); - if (err == FOPEN_EXCL_ERR) - { - /* Re-determine the file name. */ - if (local_file && *local_file) - { - xfree (*local_file); - *local_file = url_file_name (u); - hstat.local_file = local_file; - } - else - { - xfree (dummy); - dummy = url_file_name (u); - hstat.local_file = &dummy; - } - /* be honest about where we will save the file */ - if (local_file && opt.output_document) - *local_file = HYPHENP (opt.output_document) ? NULL : xstrdup (opt.output_document); - if (!opt.output_document) - locf = *hstat.local_file; - else - locf = opt.output_document; - } - continue; - case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED: - case SSLINITFAILED: case CONTNOTSUPPORTED: - /* Fatal errors just return from the function. */ - free_hstat (&hstat); - xfree_null (dummy); - return err; - case FWRITEERR: case FOPENERR: - /* Another fatal error. */ - logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"), - *hstat.local_file, strerror (errno)); - free_hstat (&hstat); - xfree_null (dummy); - return err; - case CONSSLERR: - /* Another fatal error. */ - logprintf (LOG_NOTQUIET, _("Unable to establish SSL connection.\n")); - free_hstat (&hstat); - xfree_null (dummy); - return err; - case NEWLOCATION: - /* Return the new location to the caller. */ - if (!hstat.newloc) - { - logprintf (LOG_NOTQUIET, - _("ERROR: Redirection (%d) without location.\n"), - hstat.statcode); - free_hstat (&hstat); - xfree_null (dummy); - return WRONGCODE; - } - free_hstat (&hstat); - xfree_null (dummy); - return NEWLOCATION; - case RETRUNNEEDED: - /* The file was already fully retrieved. */ - free_hstat (&hstat); - xfree_null (dummy); - return RETROK; - case RETRFINISHED: - /* Deal with you later. */ - break; - default: - /* All possibilities should have been exhausted. */ - abort (); - } + { + case HERR: case HEOF: case CONSOCKERR: case CONCLOSED: + case CONERROR: case READERR: case WRITEFAILED: + case RANGEERR: case FOPEN_EXCL_ERR: + /* Non-fatal errors continue executing the loop, which will + bring them to "while" statement at the end, to judge + whether the number of tries was exceeded. */ + printwhat (count, opt.ntry); + continue; + case FWRITEERR: case FOPENERR: + /* Another fatal error. */ + logputs (LOG_VERBOSE, "\n"); + logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"), + hstat.local_file, strerror (errno)); + case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED: + case SSLINITFAILED: case CONTNOTSUPPORTED: + /* Fatal errors just return from the function. */ + ret = err; + goto exit; + case CONSSLERR: + /* Another fatal error. */ + logprintf (LOG_NOTQUIET, _("Unable to establish SSL connection.\n")); + ret = err; + goto exit; + case NEWLOCATION: + /* Return the new location to the caller. */ + if (!*newloc) + { + logprintf (LOG_NOTQUIET, + _("ERROR: Redirection (%d) without location.\n"), + hstat.statcode); + ret = WRONGCODE; + } + else + { + ret = NEWLOCATION; + } + goto exit; + case RETRUNNEEDED: + /* The file was already fully retrieved. */ + ret = RETROK; + goto exit; + case RETRFINISHED: + /* Deal with you later. */ + break; + default: + /* All possibilities should have been exhausted. */ + abort (); + } + if (!(*dt & RETROKF)) - { - if (!opt.verbose) - { - /* #### Ugly ugly ugly! */ - char *hurl = url_string (u, 1); - logprintf (LOG_NONVERBOSE, "%s:\n", hurl); - xfree (hurl); - } - logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"), - tms, hstat.statcode, escnonprint (hstat.error)); - logputs (LOG_VERBOSE, "\n"); - free_hstat (&hstat); - xfree_null (dummy); - return WRONGCODE; - } + { + char *hurl = NULL; + if (!opt.verbose) + { + /* #### Ugly ugly ugly! */ + hurl = url_string (u, true); + logprintf (LOG_NONVERBOSE, "%s:\n", hurl); + } + if (opt.spider && opt.recursive) + { + if (!hurl) hurl = url_string (u, true); + nonexisting_url (hurl, referer); + } + logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"), + tms, hstat.statcode, escnonprint (hstat.error)); + logputs (LOG_VERBOSE, "\n"); + ret = WRONGCODE; + xfree_null (hurl); + goto exit; + } - /* Did we get the time-stamp? */ + /* Did we get the time-stamp? */ if (!got_head) - { - if (opt.timestamping && !hstat.remote_time) - { - logputs (LOG_NOTQUIET, _("\ + { + if (opt.timestamping && !hstat.remote_time) + { + logputs (LOG_NOTQUIET, _("\ Last-modified header missing -- time-stamps turned off.\n")); - } - else if (hstat.remote_time) - { - /* Convert the date-string into struct tm. */ - tmr = http_atotm (hstat.remote_time); - if (tmr == (time_t) (-1)) - logputs (LOG_VERBOSE, _("\ + } + else if (hstat.remote_time) + { + /* Convert the date-string into struct tm. */ + tmr = http_atotm (hstat.remote_time); + if (tmr == (time_t) (-1)) + logputs (LOG_VERBOSE, _("\ Last-modified header invalid -- time-stamp ignored.\n")); - } - } + } + } /* The time-stamping section. */ - if (use_ts) - { - got_head = 1; - *dt &= ~HEAD_ONLY; - use_ts = 0; /* no more time-stamping */ - count = 0; /* the retrieve count for HEAD is - reset */ - if (hstat.remote_time && tmr != (time_t) (-1)) - { - /* Now time-stamping can be used validly. Time-stamping - means that if the sizes of the local and remote file - match, and local file is newer than the remote file, - it will not be retrieved. Otherwise, the normal - download procedure is resumed. */ - if (tml >= tmr && - (hstat.contlen == -1 || local_size == hstat.contlen)) - { - logprintf (LOG_VERBOSE, _("\ + if (opt.timestamping && !got_head) + { + got_head = true; /* no more time-stamping */ + *dt &= ~HEAD_ONLY; + count = 0; /* the retrieve count for HEAD is reset */ + + if (hstat.remote_time && tmr != (time_t) (-1)) + { + /* Now time-stamping can be used validly. Time-stamping + means that if the sizes of the local and remote file + match, and local file is newer than the remote file, + it will not be retrieved. Otherwise, the normal + download procedure is resumed. */ + if (hstat.orig_file_tstamp >= tmr) + { + if (hstat.contlen == -1 || hstat.orig_file_size == hstat.contlen) + { + logprintf (LOG_VERBOSE, _("\ Server file no newer than local file `%s' -- not retrieving.\n\n"), - local_filename); - free_hstat (&hstat); - xfree_null (dummy); - return RETROK; - } - else if (tml >= tmr) - logprintf (LOG_VERBOSE, _("\ + hstat.orig_file_name); + ret = RETROK; + goto exit; + } + else + { + logprintf (LOG_VERBOSE, _("\ The sizes do not match (local %s) -- retrieving.\n"), - number_to_static_string (local_size)); - else - logputs (LOG_VERBOSE, - _("Remote file is newer, retrieving.\n")); - } - free_hstat (&hstat); - continue; - } + number_to_static_string (local_size)); + } + } + else + logputs (LOG_VERBOSE, + _("Remote file is newer, retrieving.\n")); + + logputs (LOG_VERBOSE, "\n"); + } + + /* free_hstat (&hstat); */ + hstat.timestamp_checked = true; + continue; + } + if ((tmr != (time_t) (-1)) - && !opt.spider - && ((hstat.len == hstat.contlen) || - ((hstat.res == 0) && (hstat.contlen == -1)))) - { - /* #### This code repeats in http.c and ftp.c. Move it to a + && (!opt.spider || opt.recursive) + && ((hstat.len == hstat.contlen) || + ((hstat.res == 0) && (hstat.contlen == -1)))) + { + /* #### This code repeats in http.c and ftp.c. Move it to a function! */ - const char *fl = NULL; - if (opt.output_document) - { - if (output_stream_regular) - fl = opt.output_document; - } - else - fl = *hstat.local_file; - if (fl) - touch (fl, tmr); - } - /* End of time-stamping section. */ - - if (opt.spider) - { - logprintf (LOG_NOTQUIET, "%d %s\n\n", hstat.statcode, - escnonprint (hstat.error)); - xfree_null (dummy); - return RETROK; - } + const char *fl = NULL; + if (opt.output_document) + { + if (output_stream_regular) + fl = opt.output_document; + } + else + fl = hstat.local_file; + if (fl) + touch (fl, tmr); + } + /* End of time-stamping section. */ + + if (opt.spider && !opt.recursive) + { + logprintf (LOG_NOTQUIET, "%d %s\n\n", hstat.statcode, + escnonprint (hstat.error)); + ret = RETROK; + goto exit; + } - tmrate = retr_rate (hstat.rd_size, hstat.dltime, 0); + tmrate = retr_rate (hstat.rd_size, hstat.dltime); + total_download_time += hstat.dltime; if (hstat.len == hstat.contlen) - { - if (*dt & RETROKF) - { - logprintf (LOG_VERBOSE, - _("%s (%s) - `%s' saved [%s/%s]\n\n"), - tms, tmrate, locf, - number_to_static_string (hstat.len), - number_to_static_string (hstat.contlen)); - logprintf (LOG_NONVERBOSE, - "%s URL:%s [%s/%s] -> \"%s\" [%d]\n", - tms, u->url, - number_to_static_string (hstat.len), - number_to_static_string (hstat.contlen), - locf, count); - } - ++opt.numurls; - total_downloaded_bytes += hstat.len; - - /* Remember that we downloaded the file for later ".orig" code. */ - if (*dt & ADDED_HTML_EXTENSION) - downloaded_file(FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, locf); - else - downloaded_file(FILE_DOWNLOADED_NORMALLY, locf); - - free_hstat (&hstat); - xfree_null (dummy); - return RETROK; - } + { + if (*dt & RETROKF) + { + logprintf (LOG_VERBOSE, + _("%s (%s) - `%s' saved [%s/%s]\n\n"), + tms, tmrate, hstat.local_file, + number_to_static_string (hstat.len), + number_to_static_string (hstat.contlen)); + logprintf (LOG_NONVERBOSE, + "%s URL:%s [%s/%s] -> \"%s\" [%d]\n", + tms, u->url, + number_to_static_string (hstat.len), + number_to_static_string (hstat.contlen), + hstat.local_file, count); + } + ++opt.numurls; + total_downloaded_bytes += hstat.len; + + /* Remember that we downloaded the file for later ".orig" code. */ + if (*dt & ADDED_HTML_EXTENSION) + downloaded_file(FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, hstat.local_file); + else + downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file); + + ret = RETROK; + goto exit; + } else if (hstat.res == 0) /* No read error */ - { - if (hstat.contlen == -1) /* We don't know how much we were supposed - to get, so assume we succeeded. */ - { - if (*dt & RETROKF) - { - logprintf (LOG_VERBOSE, - _("%s (%s) - `%s' saved [%s]\n\n"), - tms, tmrate, locf, - number_to_static_string (hstat.len)); - logprintf (LOG_NONVERBOSE, - "%s URL:%s [%s] -> \"%s\" [%d]\n", - tms, u->url, number_to_static_string (hstat.len), - locf, count); - } - ++opt.numurls; - total_downloaded_bytes += hstat.len; - - /* Remember that we downloaded the file for later ".orig" code. */ - if (*dt & ADDED_HTML_EXTENSION) - downloaded_file(FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, locf); - else - downloaded_file(FILE_DOWNLOADED_NORMALLY, locf); - - free_hstat (&hstat); - xfree_null (dummy); - return RETROK; - } - else if (hstat.len < hstat.contlen) /* meaning we lost the - connection too soon */ - { - logprintf (LOG_VERBOSE, - _("%s (%s) - Connection closed at byte %s. "), - tms, tmrate, number_to_static_string (hstat.len)); - printwhat (count, opt.ntry); - free_hstat (&hstat); - continue; - } - else - /* Getting here would mean reading more data than - requested with content-length, which we never do. */ - abort (); - } - else /* now hstat.res can only be -1 */ - { - if (hstat.contlen == -1) - { - logprintf (LOG_VERBOSE, - _("%s (%s) - Read error at byte %s (%s)."), - tms, tmrate, number_to_static_string (hstat.len), - strerror (errno)); - printwhat (count, opt.ntry); - free_hstat (&hstat); - continue; - } - else /* hstat.res == -1 and contlen is given */ - { - logprintf (LOG_VERBOSE, - _("%s (%s) - Read error at byte %s/%s (%s). "), - tms, tmrate, - number_to_static_string (hstat.len), - number_to_static_string (hstat.contlen), - strerror (errno)); - printwhat (count, opt.ntry); - free_hstat (&hstat); - continue; - } - } + { + if (hstat.contlen == -1) /* We don't know how much we were supposed + to get, so assume we succeeded. */ + { + if (*dt & RETROKF) + { + logprintf (LOG_VERBOSE, + _("%s (%s) - `%s' saved [%s]\n\n"), + tms, tmrate, hstat.local_file, + number_to_static_string (hstat.len)); + logprintf (LOG_NONVERBOSE, + "%s URL:%s [%s] -> \"%s\" [%d]\n", + tms, u->url, number_to_static_string (hstat.len), + hstat.local_file, count); + } + ++opt.numurls; + total_downloaded_bytes += hstat.len; + + /* Remember that we downloaded the file for later ".orig" code. */ + if (*dt & ADDED_HTML_EXTENSION) + downloaded_file(FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, hstat.local_file); + else + downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file); + + ret = RETROK; + goto exit; + } + else if (hstat.len < hstat.contlen) /* meaning we lost the + connection too soon */ + { + logprintf (LOG_VERBOSE, + _("%s (%s) - Connection closed at byte %s. "), + tms, tmrate, number_to_static_string (hstat.len)); + printwhat (count, opt.ntry); + continue; + } + else + /* Getting here would mean reading more data than + requested with content-length, which we never do. */ + abort (); + } + else /* from now on hstat.res can only be -1 */ + { + if (hstat.contlen == -1) + { + logprintf (LOG_VERBOSE, + _("%s (%s) - Read error at byte %s (%s)."), + tms, tmrate, number_to_static_string (hstat.len), + hstat.rderrmsg); + printwhat (count, opt.ntry); + continue; + } + else /* hstat.res == -1 and contlen is given */ + { + logprintf (LOG_VERBOSE, + _("%s (%s) - Read error at byte %s/%s (%s). "), + tms, tmrate, + number_to_static_string (hstat.len), + number_to_static_string (hstat.contlen), + hstat.rderrmsg); + printwhat (count, opt.ntry); + continue; + } + } /* not reached */ } while (!opt.ntry || (count < opt.ntry)); - return TRYLIMEXC; + +exit: + if (ret == RETROK) + *local_file = xstrdup (hstat.local_file); + free_hstat (&hstat); + + return ret; } /* Check whether the result of strptime() indicates success. @@ -2494,19 +2628,19 @@ In extended regexp parlance, the function returns 1 if P matches "^ *(GMT|[+-][0-9]|$)", 0 otherwise. P being NULL (which strptime can return) is considered a failure and 0 is returned. */ -static int +static bool check_end (const char *p) { if (!p) - return 0; + return false; while (ISSPACE (*p)) ++p; if (!*p || (p[0] == 'G' && p[1] == 'M' && p[2] == 'T') || ((p[0] == '+' || p[0] == '-') && ISDIGIT (p[1]))) - return 1; + return true; else - return 0; + return false; } /* Convert the textual specification of time in TIME_STRING to the @@ -2546,37 +2680,43 @@ implementations I've tested. */ static const char *time_formats[] = { - "%a, %d %b %Y %T", /* rfc1123: Thu, 29 Jan 1998 22:12:57 */ - "%A, %d-%b-%y %T", /* rfc850: Thursday, 29-Jan-98 22:12:57 */ - "%a %b %d %T %Y", /* asctime: Thu Jan 29 22:12:57 1998 */ - "%a, %d-%b-%Y %T" /* cookies: Thu, 29-Jan-1998 22:12:57 - (used in Set-Cookie, defined in the - Netscape cookie specification.) */ + "%a, %d %b %Y %T", /* rfc1123: Thu, 29 Jan 1998 22:12:57 */ + "%A, %d-%b-%y %T", /* rfc850: Thursday, 29-Jan-98 22:12:57 */ + "%a %b %d %T %Y", /* asctime: Thu Jan 29 22:12:57 1998 */ + "%a, %d-%b-%Y %T" /* cookies: Thu, 29-Jan-1998 22:12:57 + (used in Set-Cookie, defined in the + Netscape cookie specification.) */ }; + const char *oldlocale; int i; + time_t ret = (time_t) -1; + + /* Solaris strptime fails to recognize English month names in + non-English locales, which we work around by temporarily setting + locale to C before invoking strptime. */ + oldlocale = setlocale (LC_TIME, NULL); + setlocale (LC_TIME, "C"); for (i = 0; i < countof (time_formats); i++) { struct tm t; /* Some versions of strptime use the existing contents of struct - tm to recalculate the date according to format. Zero it out - to prevent garbage from the stack influencing strptime. */ + tm to recalculate the date according to format. Zero it out + to prevent stack garbage from influencing strptime. */ xzero (t); - /* Solaris strptime fails to recognize English month names in - non-English locales, which we work around by not setting the - LC_TIME category. Another way would be to temporarily set - locale to C before invoking strptime, but that's slow and - messy. GNU strptime does not have this problem because it - recognizes English month names along with the local ones. */ - if (check_end (strptime (time_string, time_formats[i], &t))) - return timegm (&t); + { + ret = timegm (&t); + break; + } } - /* All formats have failed. */ - return -1; + /* Restore the previous locale. */ + setlocale (LC_TIME, oldlocale); + + return ret; } /* Authorization support: We support three authorization schemes: @@ -2612,57 +2752,18 @@ return concat_strings ("Basic ", t2, (char *) 0); } -#define SKIP_WS(x) do { \ - while (ISSPACE (*(x))) \ - ++(x); \ +#define SKIP_WS(x) do { \ + while (ISSPACE (*(x))) \ + ++(x); \ } while (0) #ifdef ENABLE_DIGEST -/* Parse HTTP `WWW-Authenticate:' header. AU points to the beginning - of a field in such a header. If the field is the one specified by - ATTR_NAME ("realm", "opaque", and "nonce" are used by the current - digest authorization code), extract its value in the (char*) - variable pointed by RET. Returns negative on a malformed header, - or number of bytes that have been parsed by this call. */ -static int -extract_header_attr (const char *au, const char *attr_name, char **ret) -{ - const char *ep; - const char *cp = au; - - if (strncmp (cp, attr_name, strlen (attr_name)) == 0) - { - cp += strlen (attr_name); - if (!*cp) - return -1; - SKIP_WS (cp); - if (*cp != '=') - return -1; - if (!*++cp) - return -1; - SKIP_WS (cp); - if (*cp != '\"') - return -1; - if (!*++cp) - return -1; - for (ep = cp; *ep && *ep != '\"'; ep++) - ; - if (!*ep) - return -1; - xfree_null (*ret); - *ret = strdupdelim (cp, ep); - return ep - au + 1; - } - else - return 0; -} - /* Dump the hexadecimal representation of HASH to BUF. HASH should be an array of 16 bytes containing the hash keys, and BUF should be a buffer of 33 writable characters (32 for hex digits plus one for zero termination). */ static void -dump_hash (unsigned char *buf, const unsigned char *hash) +dump_hash (char *buf, const unsigned char *hash) { int i; @@ -2678,8 +2779,8 @@ authorization header. See RFC2069 section 2.1.2. */ static char * digest_authentication_encode (const char *au, const char *user, - const char *passwd, const char *method, - const char *path) + const char *passwd, const char *method, + const char *path) { static char *realm, *opaque, *nonce; static struct { @@ -2691,53 +2792,21 @@ { "nonce", &nonce } }; char *res; + param_token name, value; realm = opaque = nonce = NULL; - au += 6; /* skip over `Digest' */ - while (*au) + au += 6; /* skip over `Digest' */ + while (extract_param (&au, &name, &value, ',')) { int i; - - SKIP_WS (au); for (i = 0; i < countof (options); i++) - { - int skip = extract_header_attr (au, options[i].name, - options[i].variable); - if (skip < 0) - { - xfree_null (realm); - xfree_null (opaque); - xfree_null (nonce); - return NULL; - } - else if (skip) - { - au += skip; - break; - } - } - if (i == countof (options)) - { - while (*au && *au != '=') - au++; - if (*au && *++au) - { - SKIP_WS (au); - if (*au == '\"') - { - au++; - while (*au && *au != '\"') - au++; - if (*au) - au++; - } - } - } - while (*au && *au != ',') - au++; - if (*au) - au++; + if (name.e - name.b == strlen (options[i].name) + && 0 == strncmp (name.b, options[i].name, name.e - name.b)) + { + *options[i].variable = strdupdelim (value.b, value.e); + break; + } } if (!realm || !nonce || !user || !passwd || !path || !method) { @@ -2751,8 +2820,8 @@ { ALLOCA_MD5_CONTEXT (ctx); unsigned char hash[MD5_HASHLEN]; - unsigned char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1]; - unsigned char response_digest[MD5_HASHLEN * 2 + 1]; + char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1]; + char response_digest[MD5_HASHLEN * 2 + 1]; /* A1BUF = H(user ":" realm ":" password) */ gen_md5_init (ctx); @@ -2774,31 +2843,31 @@ /* RESPONSE_DIGEST = H(A1BUF ":" nonce ":" A2BUF) */ gen_md5_init (ctx); - gen_md5_update (a1buf, MD5_HASHLEN * 2, ctx); + gen_md5_update ((unsigned char *)a1buf, MD5_HASHLEN * 2, ctx); gen_md5_update ((unsigned char *)":", 1, ctx); gen_md5_update ((unsigned char *)nonce, strlen (nonce), ctx); gen_md5_update ((unsigned char *)":", 1, ctx); - gen_md5_update (a2buf, MD5_HASHLEN * 2, ctx); + gen_md5_update ((unsigned char *)a2buf, MD5_HASHLEN * 2, ctx); gen_md5_finish (ctx, hash); dump_hash (response_digest, hash); - res = (char*) xmalloc (strlen (user) - + strlen (user) - + strlen (realm) - + strlen (nonce) - + strlen (path) - + 2 * MD5_HASHLEN /*strlen (response_digest)*/ - + (opaque ? strlen (opaque) : 0) - + 128); + res = xmalloc (strlen (user) + + strlen (user) + + strlen (realm) + + strlen (nonce) + + strlen (path) + + 2 * MD5_HASHLEN /*strlen (response_digest)*/ + + (opaque ? strlen (opaque) : 0) + + 128); sprintf (res, "Digest \ username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"", - user, realm, nonce, path, response_digest); + user, realm, nonce, path, response_digest); if (opaque) { - char *p = res + strlen (res); - strcat (p, ", opaque=\""); - strcat (p, opaque); - strcat (p, "\""); + char *p = res + strlen (res); + strcat (p, ", opaque=\""); + strcat (p, opaque); + strcat (p, "\""); } } return res; @@ -2812,13 +2881,13 @@ /* Whether chars in [b, e) begin with the literal string provided as first argument and are followed by whitespace or terminating \0. The comparison is case-insensitive. */ -#define STARTS(literal, b, e) \ - ((e) - (b) >= STRSIZE (literal) \ - && 0 == strncasecmp (b, literal, STRSIZE (literal)) \ - && ((e) - (b) == STRSIZE (literal) \ +#define STARTS(literal, b, e) \ + ((e) - (b) >= STRSIZE (literal) \ + && 0 == strncasecmp (b, literal, STRSIZE (literal)) \ + && ((e) - (b) == STRSIZE (literal) \ || ISSPACE (b[STRSIZE (literal)]))) -static int +static bool known_authentication_scheme_p (const char *hdrbeg, const char *hdrend) { return STARTS ("Basic", hdrbeg, hdrend) @@ -2840,37 +2909,49 @@ appropriate HTTP authorization request header. */ static char * create_authorization_line (const char *au, const char *user, - const char *passwd, const char *method, - const char *path, int *finished) + const char *passwd, const char *method, + const char *path, bool *finished) { /* We are called only with known schemes, so we can dispatch on the first letter. */ switch (TOUPPER (*au)) { - case 'B': /* Basic */ - *finished = 1; + case 'B': /* Basic */ + *finished = true; return basic_authentication_encode (user, passwd); #ifdef ENABLE_DIGEST - case 'D': /* Digest */ - *finished = 1; + case 'D': /* Digest */ + *finished = true; return digest_authentication_encode (au, user, passwd, method, path); #endif #ifdef ENABLE_NTLM - case 'N': /* NTLM */ + case 'N': /* NTLM */ if (!ntlm_input (&pconn.ntlm, au)) - { - *finished = 1; - return NULL; - } + { + *finished = true; + return NULL; + } return ntlm_output (&pconn.ntlm, user, passwd, finished); #endif default: /* We shouldn't get here -- this function should be only called - with values approved by known_authentication_scheme_p. */ + with values approved by known_authentication_scheme_p. */ abort (); } } +static void +load_cookies (void) +{ + if (!wget_cookie_jar) + wget_cookie_jar = cookie_jar_new (); + if (opt.cookies_input && !cookies_loaded_p) + { + cookie_jar_load (wget_cookie_jar, opt.cookies_input); + cookies_loaded_p = true; + } +} + void save_cookies (void) { @@ -2885,3 +2966,42 @@ if (wget_cookie_jar) cookie_jar_delete (wget_cookie_jar); } + + +#ifdef TESTING + +const char * +test_parse_content_disposition() +{ + int i; + struct { + char *hdrval; + char *filename; + bool result; + } test_array[] = { + { "filename=\"file.ext\"", "file.ext", true }, + { "attachment; filename=\"file.ext\"", "file.ext", true }, + { "attachment; filename=\"file.ext\"; dummy", "file.ext", true }, + { "attachment", NULL, false }, + }; + + for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i) + { + char *filename; + bool res = parse_content_disposition (test_array[i].hdrval, &filename); + + mu_assert ("test_parse_content_disposition: wrong result", + res == test_array[i].result + && (res == false + || 0 == strcmp (test_array[i].filename, filename))); + } + + return NULL; +} + +#endif /* TESTING */ + +/* + * vim: et ts=2 sw=2 + */ + diff -urN wget-1.10.2/src/http.h wget-1.10.2_new/src/http.h --- wget-1.10.2/src/http.h 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/src/http.h 2006-06-27 12:16:40.000000000 +0200 @@ -0,0 +1,48 @@ +/* Declarations for HTTP. + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Wget. + +GNU Wget is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GNU Wget is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +In addition, as a special exception, the Free Software Foundation +gives permission to link the code of its release of Wget with the +OpenSSL project's "OpenSSL" library (or with modified versions of it +that use the same license as the "OpenSSL" library), and distribute +the linked executables. You must obey the GNU General Public License +in all respects for all of the code used other than "OpenSSL". If you +modify this file, you may extend this exception to your version of the +file, but you are not obligated to do so. If you do not wish to do +so, delete this exception statement from your version. */ + +#ifndef HTTP_H +#define HTTP_H + +struct url; + +uerr_t http_loop (struct url *, char **, char **, const char *, int *, + struct url *); +void save_cookies (void); +void http_cleanup (void); +time_t http_atotm (const char *); + +typedef struct { + /* A token consists of characters in the [b, e) range. */ + const char *b, *e; +} param_token; +bool extract_param (const char **, param_token *, param_token *, char); + + +#endif /* HTTP_H */ diff -urN wget-1.10.2/src/http-ntlm.c wget-1.10.2_new/src/http-ntlm.c --- wget-1.10.2/src/http-ntlm.c 2005-10-13 10:52:21.000000000 +0200 +++ wget-1.10.2_new/src/http-ntlm.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,6 +1,6 @@ /* NTLM code. Copyright (C) 2005 Free Software Foundation, Inc. - Donated by Daniel Stenberg. + Contributed by Daniel Stenberg. This file is part of GNU Wget. @@ -15,8 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -37,13 +37,8 @@ */ -/* -- WIN32 approved -- */ #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #include @@ -118,12 +113,12 @@ beginning of the NTLM message, in bytes. */ -/* return 1 on success, 0 otherwise */ -int +/* return true on success, false otherwise */ +bool ntlm_input (struct ntlmdata *ntlm, const char *header) { if (0 != strncmp (header, "NTLM", 4)) - return 0; + return false; header += 4; while (*header && ISSPACE(*header)) @@ -151,7 +146,7 @@ size = base64_decode (header, buffer); if (size < 0) - return 0; /* malformed base64 from server */ + return false; /* malformed base64 from server */ ntlm->state = NTLMSTATE_TYPE2; /* we got a type-2 */ @@ -166,14 +161,14 @@ if (ntlm->state >= NTLMSTATE_TYPE1) { DEBUGP (("Unexpected empty NTLM message.\n")); - return 0; /* this is an error */ + return false; /* this is an error */ } DEBUGP (("Empty NTLM message, starting transaction.\n")); ntlm->state = NTLMSTATE_TYPE1; /* we should sent away a type-1 */ } - return 1; + return true; } /* @@ -304,7 +299,7 @@ /* this is for creating ntlm header output */ char * ntlm_output (struct ntlmdata *ntlm, const char *user, const char *passwd, - int *ready) + bool *ready) { const char *domain=""; /* empty */ const char *host=""; /* empty */ @@ -320,7 +315,7 @@ server, which is for a plain host or for a HTTP proxy */ char *output; - *ready = 0; + *ready = false; /* not set means empty */ if(!user) @@ -348,41 +343,38 @@ 24 Supplied Workstation security buffer(*) 32 start of data block - Format string (merged for pre-ANSI compilers): - "NTLMSSP%c" - "\x01%c%c%c" 32-bit type = 1 - "%c%c%c%c" 32-bit NTLM flag field - "%c%c" domain length - "%c%c" domain allocated space - "%c%c" domain name offset - "%c%c" 2 zeroes - "%c%c" host length - "%c%c" host allocated space - "%c%c" host name offset - "%c%c" 2 zeroes - "%s" host name - "%s" domain string */ - snprintf(ntlmbuf, sizeof(ntlmbuf), - "NTLMSSP%c\001%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s", - 0, /* trailing zero */ - 0,0,0, /* part of type-1 long */ - - LONGQUARTET( - NTLMFLAG_NEGOTIATE_OEM| /* 2 */ - NTLMFLAG_NEGOTIATE_NTLM_KEY /* 200 */ - /* equals 0x0202 */ - ), - SHORTPAIR(domlen), - SHORTPAIR(domlen), - SHORTPAIR(domoff), - 0,0, - SHORTPAIR(hostlen), - SHORTPAIR(hostlen), - SHORTPAIR(hostoff), - 0,0, - host, domain); + snprintf (ntlmbuf, sizeof(ntlmbuf), "NTLMSSP%c" + "\x01%c%c%c" /* 32-bit type = 1 */ + "%c%c%c%c" /* 32-bit NTLM flag field */ + "%c%c" /* domain length */ + "%c%c" /* domain allocated space */ + "%c%c" /* domain name offset */ + "%c%c" /* 2 zeroes */ + "%c%c" /* host length */ + "%c%c" /* host allocated space */ + "%c%c" /* host name offset */ + "%c%c" /* 2 zeroes */ + "%s" /* host name */ + "%s", /* domain string */ + 0, /* trailing zero */ + 0,0,0, /* part of type-1 long */ + + LONGQUARTET( + NTLMFLAG_NEGOTIATE_OEM| /* 2 */ + NTLMFLAG_NEGOTIATE_NTLM_KEY /* 200 */ + /* equals 0x0202 */ + ), + SHORTPAIR(domlen), + SHORTPAIR(domlen), + SHORTPAIR(domoff), + 0,0, + SHORTPAIR(hostlen), + SHORTPAIR(hostlen), + SHORTPAIR(hostoff), + 0,0, + host, domain); /* initial packet length */ size = 32 + hostlen + domlen; @@ -449,78 +441,84 @@ lmrespoff = hostoff + hostlen; ntrespoff = lmrespoff + 0x18; - /* Create the big type-3 message binary blob: - "NTLMSSP%c" - "\x03%c%c%c" type-3, 32 bits - - "%c%c%c%c" LanManager length + allocated space - "%c%c" LanManager offset - "%c%c" 2 zeroes - - "%c%c" NT-response length - "%c%c" NT-response allocated space - "%c%c" NT-response offset - "%c%c" 2 zeroes - - "%c%c" domain length - "%c%c" domain allocated space - "%c%c" domain name offset - "%c%c" 2 zeroes - - "%c%c" user length - "%c%c" user allocated space - "%c%c" user offset - "%c%c" 2 zeroes - - "%c%c" host length - "%c%c" host allocated space - "%c%c" host offset - "%c%c%c%c%c%c" 6 zeroes - - "\xff\xff" message length - "%c%c" 2 zeroes - - "\x01\x82" flags - "%c%c" 2 zeroes */ - - size = snprintf(ntlmbuf, sizeof(ntlmbuf), - "NTLMSSP%c\003%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\377\377%c%c\001\202%c%c", - 0, /* zero termination */ - 0,0,0, /* type-3 long, the 24 upper bits */ - - SHORTPAIR(0x18), /* LanManager response length, twice */ - SHORTPAIR(0x18), - SHORTPAIR(lmrespoff), - 0x0, 0x0, + /* Create the big type-3 message binary blob */ + + size = snprintf (ntlmbuf, sizeof(ntlmbuf), + "NTLMSSP%c" + "\x03%c%c%c" /* type-3, 32 bits */ + + "%c%c%c%c" /* LanManager length + allocated space */ + "%c%c" /* LanManager offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* NT-response length */ + "%c%c" /* NT-response allocated space */ + "%c%c" /* NT-response offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* domain length */ + "%c%c" /* domain allocated space */ + "%c%c" /* domain name offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* user length */ + "%c%c" /* user allocated space */ + "%c%c" /* user offset */ + "%c%c" /* 2 zeroes */ + + "%c%c" /* host length */ + "%c%c" /* host allocated space */ + "%c%c" /* host offset */ + "%c%c%c%c%c%c" /* 6 zeroes */ + "\xff\xff" /* message length */ + "%c%c" /* 2 zeroes */ + + "\x01\x82" /* flags */ + "%c%c" /* 2 zeroes */ + + /* domain string */ + /* user string */ + /* host string */ + /* LanManager response */ + /* NT response */ + , + 0, /* zero termination */ + 0,0,0, /* type-3 long, the 24 upper bits */ + + SHORTPAIR(0x18), /* LanManager response length, twice */ + SHORTPAIR(0x18), + SHORTPAIR(lmrespoff), + 0x0, 0x0, + #ifdef USE_NTRESPONSES - SHORTPAIR(0x18), /* NT-response length, twice */ - SHORTPAIR(0x18), + SHORTPAIR(0x18), /* NT-response length, twice */ + SHORTPAIR(0x18), #else - 0x0, 0x0, - 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, #endif - SHORTPAIR(ntrespoff), - 0x0, 0x0, + SHORTPAIR(ntrespoff), + 0x0, 0x0, - SHORTPAIR(domlen), - SHORTPAIR(domlen), - SHORTPAIR(domoff), - 0x0, 0x0, - - SHORTPAIR(userlen), - SHORTPAIR(userlen), - SHORTPAIR(useroff), - 0x0, 0x0, - - SHORTPAIR(hostlen), - SHORTPAIR(hostlen), - SHORTPAIR(hostoff), - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - - 0x0, 0x0, + SHORTPAIR(domlen), + SHORTPAIR(domlen), + SHORTPAIR(domoff), + 0x0, 0x0, + + SHORTPAIR(userlen), + SHORTPAIR(userlen), + SHORTPAIR(useroff), + 0x0, 0x0, + + SHORTPAIR(hostlen), + SHORTPAIR(hostlen), + SHORTPAIR(hostoff), + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + + 0x0, 0x0, - 0x0, 0x0); + 0x0, 0x0); /* size is now 64 */ size=64; @@ -560,14 +558,14 @@ output = concat_strings ("NTLM ", base64, (char *) 0); ntlm->state = NTLMSTATE_TYPE3; /* we sent a type-3 */ - *ready = 1; + *ready = true; } break; case NTLMSTATE_TYPE3: /* connection is already authenticated, * don't send a header in future requests */ - *ready = 1; + *ready = true; output = NULL; break; } diff -urN wget-1.10.2/src/http-ntlm.h wget-1.10.2_new/src/http-ntlm.h --- wget-1.10.2/src/http-ntlm.h 2005-04-06 22:42:22.000000000 +0200 +++ wget-1.10.2_new/src/http-ntlm.h 2006-06-27 12:16:40.000000000 +0200 @@ -2,6 +2,7 @@ #define __HTTP_NTLM_H /* Declarations for http_ntlm.c Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + Contributed by Daniel Stenberg. This file is part of GNU Wget. @@ -16,8 +17,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -44,9 +45,8 @@ }; /* this is for ntlm header input */ -int ntlm_input PARAMS ((struct ntlmdata *, const char *)); +bool ntlm_input (struct ntlmdata *, const char *); /* this is for creating ntlm header output */ -char *ntlm_output PARAMS ((struct ntlmdata *, - const char *, const char *, int *)); +char *ntlm_output (struct ntlmdata *, const char *, const char *, bool *); #endif diff -urN wget-1.10.2/src/init.c wget-1.10.2_new/src/init.c --- wget-1.10.2/src/init.c 2005-08-09 00:54:16.000000000 +0200 +++ wget-1.10.2_new/src/init.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Reading/parsing the initialization file. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -30,16 +30,11 @@ #include #include -#include #include #ifdef HAVE_UNISTD_H # include #endif -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #ifdef HAVE_PWD_H @@ -56,20 +51,21 @@ #include "recur.h" /* for INFINITE_RECURSION */ #include "convert.h" /* for convert_cleanup */ #include "res.h" /* for res_cleanup */ +#include "http.h" /* for http_cleanup */ +#include "retr.h" /* for output_stream */ -#ifndef errno -extern int errno; +#ifdef TESTING +#include "test.h" #endif /* We want tilde expansion enabled only when reading `.wgetrc' lines; otherwise, it will be performed by the shell. This variable will be set by the wgetrc-reading function. */ -static int enable_tilde_expansion; +static bool enable_tilde_expansion; -#define CMD_DECLARE(func) static int func \ - PARAMS ((const char *, const char *, void *)) +#define CMD_DECLARE(func) static bool func (const char *, const char *, void *) CMD_DECLARE (cmd_boolean); CMD_DECLARE (cmd_bytes); @@ -78,7 +74,6 @@ CMD_DECLARE (cmd_cert_type); #endif CMD_DECLARE (cmd_directory_vector); -CMD_DECLARE (cmd_lockable_boolean); CMD_DECLARE (cmd_number); CMD_DECLARE (cmd_number_inf); CMD_DECLARE (cmd_string); @@ -100,6 +95,7 @@ #endif CMD_DECLARE (cmd_spec_timeout); CMD_DECLARE (cmd_spec_useragent); +CMD_DECLARE (cmd_spec_verbose); /* List of recognized commands, each consisting of name, place and function. When adding a new command, simply add it to the list, @@ -111,7 +107,7 @@ static struct { const char *name; void *place; - int (*action) PARAMS ((const char *, const char *, void *)); + bool (*action) (const char *, const char *, void *); } commands[] = { { "accept", &opt.accepts, cmd_vector }, { "addhostdir", &opt.add_hostdir, cmd_boolean }, @@ -134,6 +130,7 @@ { "connecttimeout", &opt.connect_timeout, cmd_time }, { "continue", &opt.always_rest, cmd_boolean }, { "convertlinks", &opt.convert_links, cmd_boolean }, + { "contentdisposition", &opt.content_disposition, cmd_boolean }, { "cookies", &opt.cookies, cmd_boolean }, { "cutdirs", &opt.cut_dirs, cmd_number }, #ifdef ENABLE_DEBUG @@ -171,6 +168,7 @@ { "httpproxy", &opt.http_proxy, cmd_string }, { "httpsproxy", &opt.https_proxy, cmd_string }, { "httpuser", &opt.http_user, cmd_string }, + { "ignorecase", &opt.ignore_case, cmd_boolean }, { "ignorelength", &opt.ignore_length, cmd_boolean }, { "ignoretags", &opt.ignore_tags, cmd_vector }, { "includedirectories", &opt.includes, cmd_directory_vector }, @@ -192,7 +190,7 @@ { "numtries", &opt.ntry, cmd_number_inf },/* deprecated*/ { "outputdocument", &opt.output_document, cmd_file }, { "pagerequisites", &opt.page_requisites, cmd_boolean }, - { "passiveftp", &opt.ftp_pasv, cmd_lockable_boolean }, + { "passiveftp", &opt.ftp_pasv, cmd_boolean }, { "passwd", &opt.ftp_passwd, cmd_string },/* deprecated*/ { "password", &opt.passwd, cmd_string }, { "postdata", &opt.post_data, cmd_string }, @@ -240,7 +238,7 @@ { "useproxy", &opt.use_proxy, cmd_boolean }, { "user", &opt.user, cmd_string }, { "useragent", NULL, cmd_spec_useragent }, - { "verbose", &opt.verbose, cmd_boolean }, + { "verbose", NULL, cmd_spec_verbose }, { "wait", &opt.wait, cmd_time }, { "waitretry", &opt.waitretry, cmd_time } }; @@ -275,42 +273,42 @@ { char *tmp; - /* Most of the default values are 0. Just reset everything, and - fill in the non-zero values. Note that initializing pointers to - NULL this way is technically illegal, but porting Wget to a - machine where NULL is not all-zero bit pattern will be the least - of the implementors' worries. */ + /* Most of the default values are 0 (and 0.0, NULL, and false). + Just reset everything, and fill in the non-zero values. Note + that initializing pointers to NULL this way is technically + illegal, but porting Wget to a machine where NULL is not all-zero + bit pattern will be the least of the implementors' worries. */ xzero (opt); - opt.cookies = 1; + opt.cookies = true; opt.verbose = -1; opt.ntry = 20; opt.reclevel = 5; - opt.add_hostdir = 1; - opt.netrc = 1; - opt.ftp_glob = 1; - opt.htmlify = 1; - opt.http_keep_alive = 1; - opt.use_proxy = 1; + opt.add_hostdir = true; + opt.netrc = true; + opt.ftp_glob = true; + opt.htmlify = true; + opt.http_keep_alive = true; + opt.use_proxy = true; tmp = getenv ("no_proxy"); if (tmp) opt.no_proxy = sepstring (tmp); - opt.allow_cache = 1; + opt.allow_cache = true; opt.read_timeout = 900; - opt.use_robots = 1; + opt.use_robots = true; - opt.remove_listing = 1; + opt.remove_listing = true; opt.dot_bytes = 1024; opt.dot_spacing = 10; opt.dots_in_line = 50; - opt.dns_cache = 1; - opt.ftp_pasv = 1; + opt.dns_cache = true; + opt.ftp_pasv = true; #ifdef HAVE_SSL - opt.check_cert = 1; + opt.check_cert = true; #endif /* The default for file name restriction defaults to the OS type. */ @@ -319,7 +317,10 @@ #else opt.restrict_files_os = restrict_windows; #endif - opt.restrict_files_ctrl = 1; + opt.restrict_files_ctrl = true; + opt.restrict_files_case = restrict_no_case_restriction; + + opt.content_disposition = true; } /* Return the user's home directory (strdup-ed), or NULL if none is @@ -411,14 +412,13 @@ line_unknown_command }; -static enum parse_line parse_line PARAMS ((const char *, char **, - char **, int *)); -static int setval_internal PARAMS ((int, const char *, const char *)); +static enum parse_line parse_line (const char *, char **, char **, int *); +static bool setval_internal (int, const char *, const char *); /* Initialize variables from a wgetrc file. Returns zero (failure) if there were errors in the file. */ -static int +static bool run_wgetrc (const char *file) { FILE *fp; @@ -431,9 +431,9 @@ { fprintf (stderr, _("%s: Cannot read %s (%s).\n"), exec_name, file, strerror (errno)); - return 1; /* not a fatal error */ + return true; /* not a fatal error */ } - enable_tilde_expansion = 1; + enable_tilde_expansion = true; ln = 1; while ((line = read_whole_line (fp)) != NULL) { @@ -472,7 +472,7 @@ xfree (line); ++ln; } - enable_tilde_expansion = 0; + enable_tilde_expansion = false; fclose (fp); return errcnt == 0; @@ -484,7 +484,7 @@ initialize (void) { char *file; - int ok = 1; + int ok = true; /* Load the hard-coded defaults. */ defaults (); @@ -538,7 +538,6 @@ /* Parse the line pointed by line, with the syntax: * command * = * value * Uses malloc to allocate space for command and value. - If the line is invalid, data is freed and 0 is returned. Returns one of line_ok, line_empty, line_syntax_error, or line_unknown_command. @@ -607,12 +606,12 @@ /* Run commands[comind].action. */ -static int +static bool setval_internal (int comind, const char *com, const char *val) { assert (0 <= comind && comind < countof (commands)); DEBUGP (("Setting %s (%s) to %s\n", com, commands[comind].name, val)); - return ((*commands[comind].action) (com, val, commands[comind].place)); + return commands[comind].action (com, val, commands[comind].place); } /* Run command COM with value VAL. If running the command produces an @@ -670,10 +669,9 @@ const char *name; int code; }; -static int decode_string PARAMS ((const char *, const struct decode_item *, - int, int *)); -static int simple_atoi PARAMS ((const char *, const char *, int *)); -static int simple_atof PARAMS ((const char *, const char *, double *)); +static bool decode_string (const char *, const struct decode_item *, int, int *); +static bool simple_atoi (const char *, const char *, int *); +static bool simple_atof (const char *, const char *, double *); #define CMP1(p, c0) (TOLOWER((p)[0]) == (c0) && (p)[1] == '\0') @@ -689,85 +687,32 @@ /* Store the boolean value from VAL to PLACE. COM is ignored, except for error messages. */ -static int +static bool cmd_boolean (const char *com, const char *val, void *place) { - int bool_value; + bool value; if (CMP2 (val, 'o', 'n') || CMP3 (val, 'y', 'e', 's') || CMP1 (val, '1')) /* "on", "yes" and "1" mean true. */ - bool_value = 1; + value = true; else if (CMP3 (val, 'o', 'f', 'f') || CMP2 (val, 'n', 'o') || CMP1 (val, '0')) /* "off", "no" and "0" mean false. */ - bool_value = 0; + value = false; else { fprintf (stderr, _("%s: %s: Invalid boolean `%s'; use `on' or `off'.\n"), exec_name, com, val); - return 0; - } - - *(int *)place = bool_value; - return 1; -} - -/* Store the lockable_boolean {2, 1, 0, -1} value from VAL to PLACE. - COM is ignored, except for error messages. Values 2 and -1 - indicate that once defined, the value may not be changed by - successive wgetrc files or command-line arguments. - - Values: 2 - Enable a particular option for good ("always") - 1 - Enable an option ("on") - 0 - Disable an option ("off") - -1 - Disable an option for good ("never") - - #### This hack is currently only used for passive FTP because a - contributor had broken scripts specify --passive-ftp where he - didn't want it. It should be removed because the same can now be - achieved by replacing the wget executable with a script containing: - - exec wget "$@" --no-passive-ftp -*/ - -static int -cmd_lockable_boolean (const char *com, const char *val, void *place) -{ - int lockable_boolean_value; - - int oldval = *(int *)place; - - /* - * If a config file said "always" or "never", don't allow command line - * arguments to override the config file. - */ - if (oldval == -1 || oldval == 2) - return 1; - - if (CMP2 (val, 'o', 'n') || CMP3 (val, 'y', 'e', 's') || CMP1 (val, '1')) - lockable_boolean_value = 1; - else if (CMP3 (val, 'o', 'f', 'f') || CMP2 (val, 'n', 'o') || CMP1 (val, '0')) - lockable_boolean_value = 0; - else if (0 == strcasecmp (val, "always")) - lockable_boolean_value = 2; - else if (0 == strcasecmp (val, "never")) - lockable_boolean_value = -1; - else - { - fprintf (stderr, - _("%s: %s: Invalid extended boolean `%s';\n\ -use one of `on', `off', `always', or `never'.\n"), - exec_name, com, val); - return 0; + return false; } - *(int *)place = lockable_boolean_value; - return 1; + *(bool *) place = value; + return true; } /* Set the non-negative integer value from VAL to PLACE. With incorrect specification, the number remains unchanged. */ -static int +static bool cmd_number (const char *com, const char *val, void *place) { if (!simple_atoi (val, val + strlen (val), place) @@ -775,33 +720,33 @@ { fprintf (stderr, _("%s: %s: Invalid number `%s'.\n"), exec_name, com, val); - return 0; + return false; } - return 1; + return true; } /* Similar to cmd_number(), only accepts `inf' as a synonym for 0. */ -static int +static bool cmd_number_inf (const char *com, const char *val, void *place) { if (!strcasecmp (val, "inf")) { - *(int *)place = 0; - return 1; + *(int *) place = 0; + return true; } return cmd_number (com, val, place); } /* Copy (strdup) the string at COM to a new location and place a pointer to *PLACE. */ -static int +static bool cmd_string (const char *com, const char *val, void *place) { char **pstring = (char **)place; xfree_null (*pstring); *pstring = xstrdup (val); - return 1; + return true; } #ifndef WINDOWS @@ -813,7 +758,7 @@ /* Like the above, but handles tilde-expansion when reading a user's `.wgetrc'. In that case, and if VAL begins with `~', the tilde gets expanded to the user's home directory. */ -static int +static bool cmd_file (const char *com, const char *val, void *place) { char **pstring = (char **)place; @@ -854,11 +799,11 @@ *s = '/'; } #endif - return 1; + return true; } /* Like cmd_file, but strips trailing '/' characters. */ -static int +static bool cmd_directory (const char *com, const char *val, void *place) { char *s, *t; @@ -867,21 +812,21 @@ canonicalization (backslash -> slash under Windows). These things should perhaps be in a separate function. */ if (!cmd_file (com, val, place)) - return 0; + return false; s = *(char **)place; t = s + strlen (s); while (t > s && *--t == '/') *t = '\0'; - return 1; + return true; } /* Split VAL by space to a vector of values, and append those values to vector pointed to by the PLACE argument. If VAL is empty, the PLACE vector is cleared instead. */ -static int +static bool cmd_vector (const char *com, const char *val, void *place) { char ***pvec = (char ***)place; @@ -893,10 +838,10 @@ free_vec (*pvec); *pvec = NULL; } - return 1; + return true; } -static int +static bool cmd_directory_vector (const char *com, const char *val, void *place) { char ***pvec = (char ***)place; @@ -924,13 +869,13 @@ free_vec (*pvec); *pvec = NULL; } - return 1; + return true; } /* Engine for cmd_bytes and cmd_bytes_sum: converts a string such as "100k" or "2.5G" to a floating point number. */ -static int +static bool parse_bytes_helper (const char *val, double *result) { double number, mult; @@ -940,14 +885,14 @@ if (0 == strcmp (val, "inf")) { *result = 0; - return 1; + return true; } /* Strip trailing whitespace. */ while (val < end && ISSPACE (end[-1])) --end; if (val == end) - return 0; + return false; switch (TOLOWER (end[-1])) { @@ -975,13 +920,13 @@ while (val < end && ISSPACE (end[-1])) --end; if (val == end) - return 0; + return false; if (!simple_atof (val, end, &number) || number < 0) - return 0; + return false; *result = number * mult; - return 1; + return true; } /* Parse VAL as a number and set its value to PLACE (which should @@ -995,10 +940,10 @@ The string "inf" is returned as 0. - In case of error, 0 is returned and memory pointed to by PLACE + In case of error, false is returned and memory pointed to by PLACE remains unmodified. */ -static int +static bool cmd_bytes (const char *com, const char *val, void *place) { double byte_value; @@ -1006,10 +951,10 @@ { fprintf (stderr, _("%s: %s: Invalid byte value `%s'\n"), exec_name, com, val); - return 0; + return false; } *(wgint *)place = (wgint)byte_value; - return 1; + return true; } /* Like cmd_bytes, but PLACE is interpreted as a pointer to @@ -1017,7 +962,7 @@ working with values up to 2^53-1 without loss of precision. This value (8192 TB) is large enough to serve for a while. */ -static int +static bool cmd_bytes_sum (const char *com, const char *val, void *place) { double byte_value; @@ -1025,17 +970,17 @@ { fprintf (stderr, _("%s: %s: Invalid byte value `%s'\n"), exec_name, com, val); - return 0; + return false; } *(SUM_SIZE_INT *) place = (SUM_SIZE_INT) byte_value; - return 1; + return true; } /* Store the value of VAL to *OUT. The value is a time period, by default expressed in seconds, but also accepting suffixes "m", "h", "d", and "w" for minutes, hours, days, and weeks respectively. */ -static int +static bool cmd_time (const char *com, const char *val, void *place) { double number, mult; @@ -1050,7 +995,7 @@ err: fprintf (stderr, _("%s: %s: Invalid time period `%s'\n"), exec_name, com, val); - return 0; + return false; } switch (TOLOWER (end[-1])) @@ -1088,11 +1033,11 @@ goto err; *(double *)place = number * mult; - return 1; + return true; } #ifdef HAVE_SSL -static int +static bool cmd_cert_type (const char *com, const char *val, void *place) { static const struct decode_item choices[] = { @@ -1110,23 +1055,23 @@ /* Specialized helper functions, used by `commands' to handle some options specially. */ -static int check_user_specified_header PARAMS ((const char *)); +static bool check_user_specified_header (const char *); -static int +static bool cmd_spec_dirstruct (const char *com, const char *val, void *place_ignored) { if (!cmd_boolean (com, val, &opt.dirstruct)) - return 0; + return false; /* Since dirstruct behaviour is explicitly changed, no_dirstruct must be affected inversely. */ if (opt.dirstruct) - opt.no_dirstruct = 0; + opt.no_dirstruct = false; else - opt.no_dirstruct = 1; - return 1; + opt.no_dirstruct = true; + return true; } -static int +static bool cmd_spec_header (const char *com, const char *val, void *place_ignored) { /* Empty value means reset the list of headers. */ @@ -1134,54 +1079,54 @@ { free_vec (opt.user_headers); opt.user_headers = NULL; - return 1; + return true; } if (!check_user_specified_header (val)) { fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"), exec_name, com, val); - return 0; + return false; } opt.user_headers = vec_append (opt.user_headers, val); - return 1; + return true; } -static int +static bool cmd_spec_htmlify (const char *com, const char *val, void *place_ignored) { int flag = cmd_boolean (com, val, &opt.htmlify); if (flag && !opt.htmlify) - opt.remove_listing = 0; + opt.remove_listing = false; return flag; } /* Set the "mirror" mode. It means: recursive download, timestamping, no limit on max. recursion depth, and don't remove listings. */ -static int +static bool cmd_spec_mirror (const char *com, const char *val, void *place_ignored) { int mirror; if (!cmd_boolean (com, val, &mirror)) - return 0; + return false; if (mirror) { - opt.recursive = 1; + opt.recursive = true; if (!opt.no_dirstruct) - opt.dirstruct = 1; - opt.timestamping = 1; + opt.dirstruct = true; + opt.timestamping = true; opt.reclevel = INFINITE_RECURSION; - opt.remove_listing = 0; + opt.remove_listing = false; } - return 1; + return true; } /* Validate --prefer-family and set the choice. Allowed values are "IPv4", "IPv6", and "none". */ -static int +static bool cmd_spec_prefer_family (const char *com, const char *val, void *place_ignored) { static const struct decode_item choices[] = { @@ -1199,84 +1144,91 @@ /* Set progress.type to VAL, but verify that it's a valid progress implementation before that. */ -static int +static bool cmd_spec_progress (const char *com, const char *val, void *place_ignored) { if (!valid_progress_implementation_p (val)) { fprintf (stderr, _("%s: %s: Invalid progress type `%s'.\n"), exec_name, com, val); - return 0; + return false; } xfree_null (opt.progress_type); /* Don't call set_progress_implementation here. It will be called in main() when it becomes clear what the log output is. */ opt.progress_type = xstrdup (val); - return 1; + return true; } /* Set opt.recursive to VAL as with cmd_boolean. If opt.recursive is - set to true, also set opt.dirstruct to 1, unless opt.no_dirstruct + set to true, also set opt.dirstruct to true, unless opt.no_dirstruct is specified. */ -static int +static bool cmd_spec_recursive (const char *com, const char *val, void *place_ignored) { if (!cmd_boolean (com, val, &opt.recursive)) - return 0; + return false; else { if (opt.recursive && !opt.no_dirstruct) - opt.dirstruct = 1; + opt.dirstruct = true; } - return 1; + return true; } -static int +static bool cmd_spec_restrict_file_names (const char *com, const char *val, void *place_ignored) { int restrict_os = opt.restrict_files_os; int restrict_ctrl = opt.restrict_files_ctrl; + int restrict_case = opt.restrict_files_case; - const char *end = strchr (val, ','); - if (!end) - end = val + strlen (val); + const char *end; #define VAL_IS(string_literal) BOUNDED_EQUAL (val, end, string_literal) - if (VAL_IS ("unix")) - restrict_os = restrict_unix; - else if (VAL_IS ("windows")) - restrict_os = restrict_windows; - else if (VAL_IS ("nocontrol")) - restrict_ctrl = 0; - else + do { - err: - fprintf (stderr, - _("%s: %s: Invalid restriction `%s', use `unix' or `windows'.\n"), - exec_name, com, val); - return 0; + end = strchr (val, ','); + if (!end) + end = val + strlen (val); + + if (VAL_IS ("unix")) + restrict_os = restrict_unix; + else if (VAL_IS ("windows")) + restrict_os = restrict_windows; + else if (VAL_IS ("lowercase")) + restrict_case = restrict_lowercase; + else if (VAL_IS ("uppercase")) + restrict_case = restrict_uppercase; + else if (VAL_IS ("nocontrol")) + restrict_ctrl = false; + else + { + fprintf (stderr, + _("%s: %s: Invalid restriction `%s', use [unix|windows],[lowercase|uppercase],[nocontrol].\n"), + exec_name, com, val); + return false; + } + + if (*end) + val = end + 1; } + while (*val && *end); #undef VAL_IS - if (*end) - { - if (!strcmp (end + 1, "nocontrol")) - restrict_ctrl = 0; - else - goto err; - } - opt.restrict_files_os = restrict_os; opt.restrict_files_ctrl = restrict_ctrl; - return 1; + opt.restrict_files_case = restrict_case; + + return true; } #ifdef HAVE_SSL -static int +static bool cmd_spec_secure_protocol (const char *com, const char *val, void *place) { static const struct decode_item choices[] = { @@ -1294,19 +1246,19 @@ /* Set all three timeout values. */ -static int +static bool cmd_spec_timeout (const char *com, const char *val, void *place_ignored) { double value; if (!cmd_time (com, val, &value)) - return 0; + return false; opt.read_timeout = value; opt.connect_timeout = value; opt.dns_timeout = value; - return 1; + return true; } -static int +static bool cmd_spec_useragent (const char *com, const char *val, void *place_ignored) { /* Disallow embedded newlines. */ @@ -1314,24 +1266,40 @@ { fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), exec_name, com, val); - return 0; + return false; } xfree_null (opt.useragent); opt.useragent = xstrdup (val); - return 1; + return true; +} + +/* The "verbose" option cannot be cmd_boolean because the variable is + not bool -- it's of type int (-1 means uninitialized because of + some random hackery for disallowing -q -v). */ + +static bool +cmd_spec_verbose (const char *com, const char *val, void *place_ignored) +{ + bool flag; + if (cmd_boolean (com, val, &flag)) + { + opt.verbose = flag; + return true; + } + return false; } /* Miscellaneous useful routines. */ /* A very simple atoi clone, more useful than atoi because it works on - delimited strings, and has error reportage. Returns 1 on success, - 0 on failure. If successful, stores result to *DEST. */ + delimited strings, and has error reportage. Returns true on success, + false on failure. If successful, stores result to *DEST. */ -static int +static bool simple_atoi (const char *beg, const char *end, int *dest) { int result = 0; - int negative = 0; + bool negative = false; const char *p = beg; while (p < end && ISSPACE (*p)) @@ -1342,7 +1310,7 @@ ++p; } if (p == end) - return 0; + return false; /* Read negative numbers in a separate loop because the most negative integer cannot be represented as a positive number. */ @@ -1352,7 +1320,7 @@ { int next = (10 * result) + (*p - '0'); if (next < result) - return 0; /* overflow */ + return false; /* overflow */ result = next; } else @@ -1360,29 +1328,30 @@ { int next = (10 * result) - (*p - '0'); if (next > result) - return 0; /* underflow */ + return false; /* underflow */ result = next; } if (p != end) - return 0; + return false; *dest = result; - return 1; + return true; } /* Trivial atof, with error reporting. Handles "[.]", - doesn't handle exponential notation. Returns 1 on success, 0 on - failure. In case of success, stores its result to *DEST. */ + doesn't handle exponential notation. Returns true on success, + false on failure. In case of success, stores its result to + *DEST. */ -static int +static bool simple_atof (const char *beg, const char *end, double *dest) { double result = 0; - int negative = 0; - int seen_dot = 0; - int seen_digit = 0; + bool negative = false; + bool seen_dot = false; + bool seen_digit = false; double divider = 1; const char *p = beg; @@ -1404,50 +1373,51 @@ result = (10 * result) + (ch - '0'); else result += (ch - '0') / (divider *= 10); - seen_digit = 1; + seen_digit = true; } else if (ch == '.') { if (!seen_dot) - seen_dot = 1; + seen_dot = true; else - return 0; + return false; } else - return 0; + return false; } if (!seen_digit) - return 0; + return false; if (negative) result = -result; *dest = result; - return 1; + return true; } /* Verify that the user-specified header in S is valid. It must contain a colon preceded by non-white-space characters and must not contain newlines. */ -static int +static bool check_user_specified_header (const char *s) { const char *p; - for (p = s; *p && *p != ':' && !ISSPACE (*p); p++); + for (p = s; *p && *p != ':' && !ISSPACE (*p); p++) + ; /* The header MUST contain `:' preceded by at least one non-whitespace character. */ if (*p != ':' || p == s) - return 0; + return false; /* The header MUST NOT contain newlines. */ if (strchr (s, '\n')) - return 0; - return 1; + return false; + return true; } /* Decode VAL into a number, according to ITEMS. */ -static int +static bool decode_string (const char *val, const struct decode_item *items, int itemcount, int *place) { @@ -1456,14 +1426,13 @@ if (0 == strcasecmp (val, items[i].name)) { *place = items[i].code; - return 1; + return true; } - return 0; + return false; } -void cleanup_html_url PARAMS ((void)); -void http_cleanup PARAMS ((void)); +void cleanup_html_url (void); /* Free the memory allocated by global variables. */ @@ -1472,13 +1441,10 @@ { /* Free external resources, close files, etc. */ - { - extern FILE *output_stream; - if (output_stream) - fclose (output_stream); - /* No need to check for error because Wget flushes its output (and - checks for errors) after any data arrives. */ - } + if (output_stream) + fclose (output_stream); + /* No need to check for error because Wget flushes its output (and + checks for errors) after any data arrives. */ /* We're exiting anyway so there's no real need to call free() hundreds of times. Skipping the frees will make Wget exit @@ -1538,3 +1504,50 @@ xfree_null (opt.passwd); #endif /* DEBUG_MALLOC */ } + +/* Unit testing routines. */ + +#ifdef TESTING + +const char * +test_cmd_spec_restrict_file_names() +{ + int i; + struct { + char *val; + int expected_restrict_files_os; + int expected_restrict_files_ctrl; + int expected_restrict_files_case; + bool result; + } test_array[] = { + { "windows", restrict_windows, true, restrict_no_case_restriction, true }, + { "windows,", restrict_windows, true, restrict_no_case_restriction, true }, + { "windows,lowercase", restrict_windows, true, restrict_lowercase, true }, + { "unix,nocontrol,lowercase,", restrict_unix, false, restrict_lowercase, true }, + }; + + for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i) + { + bool res; + + defaults(); + res = cmd_spec_restrict_file_names ("dummy", test_array[i].val, NULL); + + /* + fprintf (stderr, "test_cmd_spec_restrict_file_names: TEST %d\n", i); fflush (stderr); + fprintf (stderr, "opt.restrict_files_os: %d\n", opt.restrict_files_os); fflush (stderr); + fprintf (stderr, "opt.restrict_files_ctrl: %d\n", opt.restrict_files_ctrl); fflush (stderr); + fprintf (stderr, "opt.restrict_files_case: %d\n", opt.restrict_files_case); fflush (stderr); + */ + mu_assert ("test_cmd_spec_restrict_file_names: wrong result", + res == test_array[i].result + && opt.restrict_files_os == test_array[i].expected_restrict_files_os + && opt.restrict_files_ctrl == test_array[i].expected_restrict_files_ctrl + && opt.restrict_files_case == test_array[i].expected_restrict_files_case); + } + + return NULL; +} + +#endif /* TESTING */ + diff -urN wget-1.10.2/src/init.h wget-1.10.2_new/src/init.h --- wget-1.10.2/src/init.h 2005-05-05 20:45:05.000000000 +0200 +++ wget-1.10.2_new/src/init.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for init.c. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -30,10 +30,10 @@ #ifndef INIT_H #define INIT_H -void initialize PARAMS ((void)); -void run_command PARAMS ((const char *)); -void setoptval PARAMS ((const char *, const char *, const char *)); -char *home_dir PARAMS ((void)); -void cleanup PARAMS ((void)); +void initialize (void); +void run_command (const char *); +void setoptval (const char *, const char *, const char *); +char *home_dir (void); +void cleanup (void); #endif /* INIT_H */ diff -urN wget-1.10.2/src/log.c wget-1.10.2_new/src/log.c --- wget-1.10.2/src/log.c 2005-05-15 15:15:08.000000000 +0200 +++ wget-1.10.2_new/src/log.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Messages logging. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 1998-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -30,17 +30,9 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include -#ifdef WGET_USE_STDARG -# include -#else -# include -#endif +#include #ifdef HAVE_UNISTD_H # include #endif @@ -51,10 +43,6 @@ #include "utils.h" #include "log.h" -#ifndef errno -extern int errno; -#endif - /* This file impplement support for "logging". Logging means printing output, plus several additional features: @@ -80,18 +68,18 @@ logging is inhibited, logfp is set back to NULL. */ static FILE *logfp; -/* If non-zero, it means logging is inhibited, i.e. nothing is printed - or stored. */ -static int inhibit_logging; +/* If true, it means logging is inhibited, i.e. nothing is printed or + stored. */ +static bool inhibit_logging; /* Whether the last output lines are stored for use as context. */ -static int save_context_p; +static bool save_context_p; /* Whether the log is flushed after each command. */ -static int flush_log_p = 1; +static bool flush_log_p = true; /* Whether any output has been received while flush_log_p was 0. */ -static int needs_flushing; +static bool needs_flushing; /* In the event of a hang-up, and if its output was on a TTY, Wget redirects its output to `wget-log'. @@ -135,9 +123,9 @@ finish with \n. This is an important piece of information because the code is always careful to append data to trailing lines, rather than create new ones. */ -static int trailing_line; +static bool trailing_line; -static void check_redirect_output PARAMS ((void)); +static void check_redirect_output (void); #define ROT_ADVANCE(num) do { \ if (++num >= SAVED_LOG_LINES) \ @@ -220,7 +208,7 @@ { /* Allocate memory and concatenate the old and the new contents. */ - ln->malloced_line = (char *)xmalloc (old_len + len + 1); + ln->malloced_line = xmalloc (old_len + len + 1); memcpy (ln->malloced_line, ln->static_line, old_len); memcpy (ln->malloced_line + old_len, start, len); @@ -325,7 +313,7 @@ if (flush_log_p) logflush (); else - needs_flushing = 1; + needs_flushing = true; } struct logvprintf_state { @@ -348,7 +336,7 @@ (An alternative approach would be to use va_copy, but that's not portable.) */ -static int +static bool log_vprintf_internal (struct logvprintf_state *state, const char *fmt, va_list args) { @@ -381,12 +369,12 @@ numwritten = vsnprintf (write_ptr, available_size, fmt, args); /* vsnprintf() will not step over the limit given by available_size. - If it fails, it will return either -1 (POSIX?) or the number of - characters that *would have* been written, if there had been - enough room (C99). In the former case, we double the - available_size and malloc to get a larger buffer, and try again. - In the latter case, we use the returned information to build a - buffer of the correct size. */ + If it fails, it returns either -1 (older implementations) or the + number of characters (not counting the terminating \0) that + *would have* been written if there had been enough room (C99). + In the former case, we double available_size and malloc to get a + larger buffer, and try again. In the latter case, we use the + returned information to build a buffer of the correct size. */ if (numwritten == -1) { @@ -395,7 +383,7 @@ int newsize = available_size << 1; state->bigmsg = xrealloc (state->bigmsg, newsize); state->allocated = newsize; - return 0; + return false; } else if (numwritten >= available_size) { @@ -404,7 +392,7 @@ int newsize = numwritten + 1; state->bigmsg = xrealloc (state->bigmsg, newsize); state->allocated = newsize; - return 0; + return false; } /* Writing succeeded. */ @@ -417,9 +405,9 @@ if (flush_log_p) logflush (); else - needs_flushing = 1; + needs_flushing = true; - return 1; + return true; } /* Flush LOGFP. Useful while flushing is disabled. */ @@ -429,20 +417,20 @@ FILE *fp = get_log_fp (); if (fp) fflush (fp); - needs_flushing = 0; + needs_flushing = false; } /* Enable or disable log flushing. */ void -log_set_flush (int flush) +log_set_flush (bool flush) { if (flush == flush_log_p) return; - if (flush == 0) + if (flush == false) { /* Disable flushing by setting flush_log_p to 0. */ - flush_log_p = 0; + flush_log_p = false; } else { @@ -450,7 +438,7 @@ flush the log now. */ if (needs_flushing) logflush (); - flush_log_p = 1; + flush_log_p = true; } } @@ -458,24 +446,14 @@ status of storing, with which this function can be called again to reestablish storing. */ -int -log_set_save_context (int savep) +bool +log_set_save_context (bool savep) { - int old = save_context_p; + bool old = save_context_p; save_context_p = savep; return old; } -/* Handle difference in va_start between pre-ANSI and ANSI C. Note - that we always use `...' in function definitions and let ansi2knr - convert it for us. */ - -#ifdef WGET_USE_STDARG -# define VA_START(args, arg1) va_start (args, arg1) -#else -# define VA_START(args, ignored) va_start (args) -#endif - /* Print a message to the screen or to the log. The first argument defines the verbosity of the message, and the rest are as in printf(3). */ @@ -485,7 +463,7 @@ { va_list args; struct logvprintf_state lpstate; - int done; + bool done; check_redirect_output (); if (inhibit_logging) @@ -495,7 +473,7 @@ xzero (lpstate); do { - VA_START (args, fmt); + va_start (args, fmt); done = log_vprintf_internal (&lpstate, fmt, args); va_end (args); } @@ -504,7 +482,7 @@ #ifdef ENABLE_DEBUG /* The same as logprintf(), but does anything only if opt.debug is - non-zero. */ + true. */ void debug_logprintf (const char *fmt, ...) { @@ -512,7 +490,7 @@ { va_list args; struct logvprintf_state lpstate; - int done; + bool done; check_redirect_output (); if (inhibit_logging) @@ -521,7 +499,7 @@ xzero (lpstate); do { - VA_START (args, fmt); + va_start (args, fmt); done = log_vprintf_internal (&lpstate, fmt, args); va_end (args); } @@ -533,7 +511,7 @@ /* Open FILE and set up a logging stream. If FILE cannot be opened, exit with status of 1. */ void -log_init (const char *file, int appendp) +log_init (const char *file, bool appendp) { if (file) { @@ -564,7 +542,7 @@ the most recent several messages ("context") and dump them to a log file in case SIGHUP or SIGUSR1 is received (or Ctrl+Break is pressed under Windows). */ - save_context_p = 1; + save_context_p = true; } } } @@ -579,13 +557,13 @@ if (logfp) fclose (logfp); logfp = NULL; - inhibit_logging = 1; - save_context_p = 0; + inhibit_logging = true; + save_context_p = false; for (i = 0; i < SAVED_LOG_LINES; i++) free_log_line (i); log_line_current = -1; - trailing_line = 0; + trailing_line = false; } /* Dump saved lines to logfp. */ @@ -791,7 +769,7 @@ /* When SIGHUP or SIGUSR1 are received, the output is redirected elsewhere. Such redirection is only allowed once. */ -enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE; +static enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE; static const char *redirect_request_signal_name; /* Redirect output to `wget-log'. */ @@ -800,7 +778,7 @@ redirect_output (void) { char *logfile; - logfp = unique_create (DEFAULT_LOGFILE, 0, &logfile); + logfp = unique_create (DEFAULT_LOGFILE, false, &logfile); if (logfp) { fprintf (stderr, _("\n%s received, redirecting output to `%s'.\n"), @@ -816,9 +794,9 @@ fprintf (stderr, _("\n%s received.\n"), redirect_request_signal_name); fprintf (stderr, _("%s: %s; disabling logging.\n"), logfile, strerror (errno)); - inhibit_logging = 1; + inhibit_logging = true; } - save_context_p = 0; + save_context_p = false; } /* Check whether a signal handler requested the output to be diff -urN wget-1.10.2/src/log.h wget-1.10.2_new/src/log.h --- wget-1.10.2/src/log.h 2005-03-20 16:07:40.000000000 +0100 +++ wget-1.10.2_new/src/log.h 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for log.c. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 1998-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -35,25 +35,20 @@ enum log_options { LOG_VERBOSE, LOG_NOTQUIET, LOG_NONVERBOSE, LOG_ALWAYS }; -#ifdef HAVE_STDARG_H -void logprintf PARAMS ((enum log_options, const char *, ...)) +void logprintf (enum log_options, const char *, ...) GCC_FORMAT_ATTR (2, 3); -void debug_logprintf PARAMS ((const char *, ...)) GCC_FORMAT_ATTR (1, 2); -#else /* not HAVE_STDARG_H */ -void logprintf (); -void debug_logprintf (); -#endif /* not HAVE_STDARG_H */ -void logputs PARAMS ((enum log_options, const char *)); -void logflush PARAMS ((void)); -void log_set_flush PARAMS ((int)); -int log_set_save_context PARAMS ((int)); - -void log_init PARAMS ((const char *, int)); -void log_close PARAMS ((void)); -void log_cleanup PARAMS ((void)); -void log_request_redirect_output PARAMS ((const char *)); +void debug_logprintf (const char *, ...) GCC_FORMAT_ATTR (1, 2); +void logputs (enum log_options, const char *); +void logflush (void); +void log_set_flush (bool); +bool log_set_save_context (bool); + +void log_init (const char *, bool); +void log_close (void); +void log_cleanup (void); +void log_request_redirect_output (const char *); -const char *escnonprint PARAMS ((const char *)); -const char *escnonprint_uri PARAMS ((const char *)); +const char *escnonprint (const char *); +const char *escnonprint_uri (const char *); #endif /* LOG_H */ diff -urN wget-1.10.2/src/main.c wget-1.10.2_new/src/main.c --- wget-1.10.2/src/main.c 2006-06-27 11:47:13.000000000 +0200 +++ wget-1.10.2_new/src/main.c 2006-06-27 12:16:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Command line parsing. - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -34,26 +34,13 @@ #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ -#include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ -#ifdef HAVE_SIGNAL_H -# include -#endif +#include +#include #ifdef HAVE_NLS -#ifdef HAVE_LOCALE_H # include -#endif /* HAVE_LOCALE_H */ -#endif /* HAVE_NLS */ +#endif #include - #include -#ifndef errno -extern int errno; -#endif #include "wget.h" #include "utils.h" @@ -64,6 +51,7 @@ #include "url.h" #include "progress.h" /* for progress_handle_sigwinch */ #include "convert.h" +#include "http.h" /* for save_cookies */ /* On GNU system this will include system-wide getopt.h. */ #include "getopt.h" @@ -74,12 +62,11 @@ struct options opt; -extern SUM_SIZE_INT total_downloaded_bytes; extern char *version_string; -extern struct cookie_jar *wget_cookie_jar; - -static RETSIGTYPE redirect_output_signal PARAMS ((int)); +#if defined(SIGHUP) || defined(SIGUSR1) +static void redirect_output_signal (int); +#endif const char *exec_name; @@ -93,20 +80,7 @@ /* HAVE_NLS implies existence of functions invoked here. */ #ifdef HAVE_NLS /* Set the current locale. */ - /* Where possible, sets only LC_MESSAGES and LC_CTYPE. Other - categories, such as numeric, time, or collation, break code that - parses data received from the network and relies on C-locale - behavior of libc functions. For example, Solaris strptime fails - to recognize English month names in non-English locales, which - breaks http_atotm. Some implementations of fnmatch perform - unwanted case folding in non-C locales. ctype macros, while they - were used, provided another example against LC_ALL. */ -#if defined(LC_MESSAGES) && defined(LC_CTYPE) - setlocale (LC_MESSAGES, ""); - setlocale (LC_CTYPE, ""); /* safe because we use safe-ctype */ -#else setlocale (LC_ALL, ""); -#endif /* Set the text message domain. */ bindtextdomain ("wget", LOCALEDIR); textdomain ("wget"); @@ -115,8 +89,8 @@ /* Definition of command-line options. */ -static void print_help PARAMS ((void)); -static void print_version PARAMS ((void)); +static void print_help (void); +static void print_version (void); #ifdef HAVE_SSL # define IF_SSL(x) x @@ -125,9 +99,9 @@ #endif #ifdef ENABLE_DEBUG -# define IF_DEBUG(x) x +# define WHEN_DEBUG(x) x #else -# define IF_DEBUG(x) NULL +# define WHEN_DEBUG(x) NULL #endif struct cmdline_option { @@ -150,7 +124,7 @@ int argtype; /* for non-standard options */ }; -struct cmdline_option option_data[] = +static struct cmdline_option option_data[] = { { "accept", 'A', OPT_VALUE, "accept", -1 }, { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument }, @@ -169,9 +143,10 @@ { "connect-timeout", 0, OPT_VALUE, "connecttimeout", -1 }, { "continue", 'c', OPT_BOOLEAN, "continue", -1 }, { "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 }, + { "content-disposition", 0, OPT_BOOLEAN, "contentdisposition", -1 }, { "cookies", 0, OPT_BOOLEAN, "cookies", -1 }, { "cut-dirs", 0, OPT_VALUE, "cutdirs", -1 }, - { IF_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 }, + { WHEN_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 }, { "delete-after", 0, OPT_BOOLEAN, "deleteafter", -1 }, { "directories", 0, OPT_BOOLEAN, "dirstruct", -1 }, { "directory-prefix", 'P', OPT_VALUE, "dirprefix", -1 }, @@ -200,6 +175,7 @@ { "http-passwd", 0, OPT_VALUE, "httppassword", -1 }, /* deprecated */ { "http-password", 0, OPT_VALUE, "httppassword", -1 }, { "http-user", 0, OPT_VALUE, "httpuser", -1 }, + { "ignore-case", 0, OPT_BOOLEAN, "ignorecase", -1 }, { "ignore-length", 0, OPT_BOOLEAN, "ignorelength", -1 }, { "ignore-tags", 0, OPT_VALUE, "ignoretags", -1 }, { "include-directories", 'I', OPT_VALUE, "includedirectories", -1 }, @@ -267,7 +243,7 @@ { "waitretry", 0, OPT_VALUE, "waitretry", -1 }, }; -#undef IF_DEBUG +#undef WHEN_DEBUG #undef IF_SSL /* Return a string that contains S with "no-" prepended. The string @@ -472,6 +448,8 @@ --no-dns-cache disable caching DNS lookups.\n"), N_("\ --restrict-file-names=OS restrict chars in file names to ones OS allows.\n"), + N_("\ + --ignore-case ignore case when matching files/directories.\n"), #ifdef ENABLE_IPV6 N_("\ -4, --inet4-only connect only to IPv4 addresses.\n"), @@ -532,15 +510,17 @@ N_("\ --no-cookies don't use cookies.\n"), N_("\ - --load-cookies FILE load cookies from FILE before session.\n"), + --load-cookies=FILE load cookies from FILE before session.\n"), N_("\ - --save-cookies FILE save cookies to FILE after session.\n"), + --save-cookies=FILE save cookies to FILE after session.\n"), N_("\ --keep-session-cookies load and save session (non-permanent) cookies.\n"), N_("\ --post-data=STRING use the POST method; send STRING as the data.\n"), N_("\ --post-file=FILE use the POST method; send contents of FILE.\n"), + N_("\ + --no-content-disposition don't honor Content-Disposition header.\n"), "\n", #ifdef HAVE_SSL @@ -651,6 +631,32 @@ exit (0); } +/* Return a human-readable printed representation of INTERVAL, + measured in seconds. */ + +static char * +secs_to_human_time (double interval) +{ + static char buf[32]; + int secs = (int) (interval + 0.5); + int hours, mins, days; + + days = secs / 86400, secs %= 86400; + hours = secs / 3600, secs %= 3600; + mins = secs / 60, secs %= 60; + + if (days) + sprintf (buf, "%dd %dh %dm %ds", days, hours, mins, secs); + else if (hours) + sprintf (buf, "%dh %dm %ds", hours, mins, secs); + else if (mins) + sprintf (buf, "%dm %ds", mins, secs); + else + sprintf (buf, "%ss", print_decimal (interval)); + + return buf; +} + static void print_version (void) { @@ -667,13 +673,14 @@ exit (0); } +#ifndef TESTING int main (int argc, char *const *argv) { char **url, **t; int i, ret, longindex; int nurl, status; - int append_to_log = 0; + bool append_to_log = false; i18n_initialize (); @@ -732,19 +739,19 @@ else { /* NEG is true for `--no-FOO' style boolean options. */ - int neg = val & BOOLEAN_NEG_MARKER; + bool neg = !!(val & BOOLEAN_NEG_MARKER); setoptval (opt->data, neg ? "0" : "1", opt->long_name); } break; case OPT_FUNCALL: { - void (*func) PARAMS ((void)) = (void (*) PARAMS ((void))) opt->data; + void (*func) (void) = (void (*) (void)) opt->data; func (); } break; case OPT__APPEND_OUTPUT: setoptval ("logfile", optarg, opt->long_name); - append_to_log = 1; + append_to_log = true; break; case OPT__EXECUTE: run_command (optarg); @@ -788,7 +795,7 @@ /* The wgetrc commands are named noparent and noclobber, so we must revert the meaning of the cmdline options before passing the value to setoptval. */ - int flag = 1; + bool flag = true; if (optarg) flag = (*optarg == '1' || TOLOWER (*optarg) == 'y' || (TOLOWER (optarg[0]) == 'o' @@ -889,9 +896,6 @@ /* Open the output filename if necessary. */ if (opt.output_document) { - extern FILE *output_stream; - extern int output_stream_regular; - if (HYPHENP (opt.output_document)) output_stream = stdout; else @@ -905,7 +909,7 @@ exit (1); } if (fstat (fileno (output_stream), &st) == 0 && S_ISREG (st.st_mode)) - output_stream_regular = 1; + output_stream_regular = true; } } @@ -913,21 +917,25 @@ ws_startup (); #endif +#ifdef SIGHUP /* Setup the signal handler to redirect output when hangup is received. */ -#ifdef HAVE_SIGNAL if (signal(SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, redirect_output_signal); +#endif /* ...and do the same for SIGUSR1. */ +#ifdef SIGUSR1 signal (SIGUSR1, redirect_output_signal); +#endif +#ifdef SIGPIPE /* Writing to a closed socket normally signals SIGPIPE, and the process exits. What we want is to ignore SIGPIPE and just check for the return value of write(). */ signal (SIGPIPE, SIG_IGN); +#endif #ifdef SIGWINCH signal (SIGWINCH, progress_handle_sigwinch); #endif -#endif /* HAVE_SIGNAL */ status = RETROK; /* initialize it, just-in-case */ /* Retrieve the URLs from argument list. */ @@ -937,10 +945,20 @@ int dt; if ((opt.recursive || opt.page_requisites) - && url_scheme (*t) != SCHEME_FTP) - status = retrieve_tree (*t); + && (url_scheme (*t) != SCHEME_FTP || opt.use_proxy)) + { + int old_follow_ftp = opt.follow_ftp; + + /* Turn opt.follow_ftp on in case of recursive FTP retrieval */ + if (url_scheme (*t) == SCHEME_FTP) + opt.follow_ftp = 1; + + status = retrieve_tree (*t); + + opt.follow_ftp = old_follow_ftp; + } else - status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt); + status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt, opt.recursive); if (opt.delete_after && file_exists_p(filename)) { @@ -963,21 +981,32 @@ logprintf (LOG_NOTQUIET, _("No URLs found in %s.\n"), opt.input_filename); } + + /* Print broken links. */ + if (opt.recursive && opt.spider) + { + print_broken_links(); + } + /* Print the downloaded sum. */ - if (opt.recursive || opt.page_requisites - || nurl > 1 - || (opt.input_filename && total_downloaded_bytes != 0)) + if ((opt.recursive || opt.page_requisites + || nurl > 1 + || (opt.input_filename && total_downloaded_bytes != 0)) + && + total_downloaded_bytes != 0) { logprintf (LOG_NOTQUIET, - _("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"), + _("FINISHED --%s--\nDownloaded: %d files, %s in %s (%s)\n"), time_str (NULL), - with_thousand_seps_sum (total_downloaded_bytes), - opt.numurls); + opt.numurls, + human_readable (total_downloaded_bytes), + secs_to_human_time (total_download_time), + retr_rate (total_downloaded_bytes, total_download_time)); /* Print quota warning, if exceeded. */ if (opt.quota && total_downloaded_bytes > opt.quota) logprintf (LOG_NOTQUIET, - _("Download quota (%s bytes) EXCEEDED!\n"), - with_thousand_seps_sum (opt.quota)); + _("Download quota of %s EXCEEDED!\n"), + human_readable (opt.quota)); } if (opt.cookies_output) @@ -999,17 +1028,23 @@ else return 1; } +#endif /* TESTING */ -#ifdef HAVE_SIGNAL +#if defined(SIGHUP) || defined(SIGUSR1) + +/* So the signal_name check doesn't blow when only one is available. */ +#ifndef SIGHUP +# define SIGHUP -1 +#endif +#ifndef SIGUSR1 +# define SIGUSR1 -1 +#endif + /* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it will proceed operation as usual, trying to write into a log file. - If that is impossible, the output will be turned off. - - #### It is unsafe to do call libc functions from a signal handler. - What we should do is, set a global variable, and have the code in - log.c pick it up. */ + If that is impossible, the output will be turned off. */ -static RETSIGTYPE +static void redirect_output_signal (int sig) { const char *signal_name = (sig == SIGHUP ? "SIGHUP" : @@ -1019,4 +1054,4 @@ progress_schedule_redirect (); signal (sig, redirect_output_signal); } -#endif /* HAVE_SIGNAL */ +#endif diff -urN wget-1.10.2/src/Makefile.in wget-1.10.2_new/src/Makefile.in --- wget-1.10.2/src/Makefile.in 2005-06-27 00:06:49.000000000 +0200 +++ wget-1.10.2_new/src/Makefile.in 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ # Makefile for `wget' utility -# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. +# Copyright (C) 1995-2005 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 @@ -12,8 +12,8 @@ # 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, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# along with Wget; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # In addition, as a special exception, the Free Software Foundation # gives permission to link the code of its release of Wget with the @@ -36,14 +36,13 @@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ -ANSI2KNR = @ANSI2KNR@ -o = .@U@o prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sysconfdir = @sysconfdir@ -localedir = $(prefix)/share/locale +datadir = @datadir@ +localedir = $(datadir)/locale DESTDIR = @@ -52,8 +51,8 @@ # The following line is losing on some versions of make! DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\" CFLAGS = @CFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ @LIBSSL@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ @LIBSSL@ @LIBGNUTLS@ exeext = @exeext@ INCLUDES = -I. -I$(srcdir) @@ -73,53 +72,35 @@ SSL_OBJ = @SSL_OBJ@ GETOPT_OBJ = @GETOPT_OBJ@ -OBJ = $(ALLOCA) cmpt$o connect$o convert$o cookies$o \ - ftp$o ftp-basic$o ftp-ls$o $(OPIE_OBJ) $(GETOPT_OBJ) hash$o \ - host$o html-parse$o html-url$o http$o $(NTLM_OBJ) init$o \ - log$o main$o $(MD5_OBJ) netrc$o progress$o ptimer$o recur$o \ - res$o retr$o safe-ctype$o snprintf$o $(SSL_OBJ) url$o \ - utils$o version$o xmalloc$o +OBJ = $(ALLOCA) cmpt.o connect.o convert.o cookies.o \ + ftp.o ftp-basic.o ftp-ls.o $(OPIE_OBJ) $(GETOPT_OBJ) hash.o \ + host.o html-parse.o html-url.o http.o $(NTLM_OBJ) init.o \ + log.o main.o $(MD5_OBJ) netrc.o progress.o ptimer.o recur.o \ + res.o retr.o safe-ctype.o snprintf.o $(SSL_OBJ) url.o \ + utils.o version.o xmalloc.o .SUFFIXES: -.SUFFIXES: .c .o ._c ._o +.SUFFIXES: .c .o .c.o: $(COMPILE) -c $< -.c._c: $(ANSI2KNR) - $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $@ - -._c._o: - @echo $(COMPILE) -c $< - @rm -f _$*.c - @ln $< _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c - -.c._o: $(ANSI2KNR) - $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $*._c - @echo $(COMPILE) -c $*._c - @rm -f _$*.c - @ln $*._c _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c - # Dependencies for building wget$(exeext): $(OBJ) $(LINK) $(OBJ) $(LIBS) -ansi2knr: ansi2knr.o - $(CC) -o ansi2knr ansi2knr.o $(LIBS) - # We make object files depend on every header. Rather than attempt to # track dependencies, everything gets recompiled when a header # changes. With a program of Wget's size this doesn't waste much # time, and it's a lot safer than attempting to get all the # dependencies right. -$(OBJ): $(ANSI2KNR) \ - config-post.h connect.h convert.h cookies.h ftp.h gen-md5.h \ - getopt.h gnu-md5.h hash.h host.h html-parse.h http-ntlm.h \ - init.h log.h mswindows.h netrc.h options.h progress.h \ - ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h sysdep.h \ - url.h utils.h wget.h xmalloc.h +$(OBJ): config-post.h config.h connect.h convert.h cookies.h ftp.h \ + gen-md5.h getopt.h gnu-md5.h hash.h host.h html-parse.h \ + http-ntlm.h init.h log.h mswindows.h netrc.h options.h \ + progress.h ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h \ + sysdep.h url.h utils.h wget.h xmalloc.h # # Dependencies for installing @@ -141,7 +122,7 @@ # clean: - $(RM) *.o wget$(exeext) *~ *.bak core core.[0-9]* $(ANSI2KNR) *._o *._c + $(RM) *.o wget$(exeext) *~ *.bak core core.[0-9]* distclean: clean $(RM) Makefile config.h diff -urN wget-1.10.2/src/mswindows.c wget-1.10.2_new/src/mswindows.c --- wget-1.10.2/src/mswindows.c 2005-08-11 23:35:27.000000000 +0200 +++ wget-1.10.2_new/src/mswindows.c 2006-06-27 12:18:18.000000000 +0200 @@ -1,6 +1,5 @@ /* mswindows.c -- Windows-specific support - Copyright (C) 1995, 1996, 1997, 1998, 2004 - Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -15,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -37,27 +36,12 @@ #include #include -#ifdef HACK_BCC_UTIME_BUG -# include -# include -# ifdef HAVE_UTIME_H -# include -# endif -# ifdef HAVE_SYS_UTIME_H -# include -# endif -#endif - #define INHIBIT_WRAP /* avoid wrapping of socket, bind, ... */ #include "wget.h" #include "utils.h" #include "url.h" -#ifndef errno -extern int errno; -#endif - #ifndef ES_SYSTEM_REQUIRED #define ES_SYSTEM_REQUIRED 0x00000001 #endif @@ -68,7 +52,7 @@ /* Defined in log.c. */ -void log_request_redirect_output PARAMS ((const char *)); +void log_request_redirect_output (const char *); /* Windows version of xsleep in utils.c. */ @@ -82,7 +66,7 @@ sleep (seconds); seconds -= (long) seconds; } - usleep (seconds * 1000000L); + usleep (seconds * 1000000); #else /* not HAVE_USLEEP */ SleepEx ((DWORD) (seconds * 1000 + .5), FALSE); #endif /* not HAVE_USLEEP */ @@ -133,7 +117,7 @@ struct fake_fork_info { HANDLE event; - int logfile_changed; + bool logfile_changed; char lfilename[MAX_PATH + 1]; }; @@ -168,14 +152,14 @@ event = info->event; - info->logfile_changed = 0; + info->logfile_changed = false; if (!opt.lfilename) { /* See utils:fork_to_background for explanation. */ - FILE *new_log_fp = unique_create (DEFAULT_LOGFILE, 0, &opt.lfilename); + FILE *new_log_fp = unique_create (DEFAULT_LOGFILE, false, &opt.lfilename); if (new_log_fp) { - info->logfile_changed = 1; + info->logfile_changed = true; strncpy (info->lfilename, opt.lfilename, sizeof (info->lfilename)); info->lfilename[sizeof (info->lfilename) - 1] = '\0'; fclose (new_log_fp); @@ -380,7 +364,7 @@ { xfree_null (title_buf); xfree_null (curr_url); - title_buf = (char *)xmalloc (strlen (url) + 20); + title_buf = xmalloc (strlen (url) + 20); curr_url = xstrdup (url); old_percentage = -1; sprintf (title_buf, "Wget %s", curr_url); @@ -488,34 +472,6 @@ set_sleep_mode (); SetConsoleCtrlHandler (ws_handler, TRUE); } - -/* Replacement utime function for buggy Borland C++Builder 5.5 compiler. - (The Borland utime function only works on Windows NT.) */ - -#ifdef HACK_BCC_UTIME_BUG -int -borland_utime (const char *path, const struct utimbuf *times) -{ - int fd; - int res; - struct ftime ft; - struct tm *ptr_tm; - - if ((fd = open (path, O_RDWR)) < 0) - return -1; - - ptr_tm = localtime (×->modtime); - ft.ft_tsec = ptr_tm->tm_sec >> 1; - ft.ft_min = ptr_tm->tm_min; - ft.ft_hour = ptr_tm->tm_hour; - ft.ft_day = ptr_tm->tm_mday; - ft.ft_month = ptr_tm->tm_mon + 1; - ft.ft_year = ptr_tm->tm_year - 80; - res = setftime (fd, &ft); - close (fd); - return res; -} -#endif /* run_with_timeout Windows implementation. */ @@ -558,19 +514,19 @@ } /* Call FUN(ARG), but don't allow it to run for more than TIMEOUT - seconds. Returns non-zero if the function was interrupted with a - timeout, zero otherwise. + seconds. Returns true if the function was interrupted with a + timeout, false otherwise. This works by running FUN in a separate thread and terminating the thread if it doesn't finish in the specified time. */ -int +bool run_with_timeout (double seconds, void (*fun) (void *), void *arg) { - static HANDLE thread_hnd = NULL; + HANDLE thread_hnd; struct thread_data thread_arg; DWORD thread_id; - int rc; + bool rc; DEBUGP (("seconds %.2f, ", seconds)); @@ -578,12 +534,9 @@ { blocking_fallback: fun (arg); - return 0; + return false; } - /* Should never happen, but test for recursivety anyway. */ - assert (thread_hnd == NULL); - thread_arg.fun = fun; thread_arg.arg = arg; thread_arg.ws_error = WSAGetLastError (); @@ -591,7 +544,7 @@ &thread_arg, 0, &thread_id); if (!thread_hnd) { - DEBUGP (("CreateThread() failed; %s\n", strerror (GetLastError ()))); + DEBUGP (("CreateThread() failed; [0x%x]\n", GetLastError ())); goto blocking_fallback; } @@ -602,12 +555,12 @@ so the caller can inspect it. */ WSASetLastError (thread_arg.ws_error); DEBUGP (("Winsock error: %d\n", WSAGetLastError ())); - rc = 0; + rc = false; } else { TerminateThread (thread_hnd, 1); - rc = 1; + rc = true; } CloseHandle (thread_hnd); /* Clear-up after TerminateThread(). */ @@ -731,3 +684,45 @@ return buf; } } + +#ifdef ENABLE_IPV6 +/* An inet_ntop implementation that uses WSAAddressToString. + Prototype complies with POSIX 1003.1-2004. This is only used under + IPv6 because Wget prints IPv4 addresses using inet_ntoa. */ + +const char * +inet_ntop (int af, const void *src, char *dst, socklen_t cnt) +{ + /* struct sockaddr can't accomodate struct sockaddr_in6. */ + union { + struct sockaddr_in6 sin6; + struct sockaddr_in sin; + } sa; + DWORD dstlen = cnt; + size_t srcsize; + + xzero (sa); + switch (af) + { + case AF_INET: + sa.sin.sin_family = AF_INET; + sa.sin.sin_addr = *(struct in_addr *) src; + srcsize = sizeof (sa.sin); + break; + case AF_INET6: + sa.sin6.sin6_family = AF_INET6; + sa.sin6.sin6_addr = *(struct in6_addr *) src; + srcsize = sizeof (sa.sin6); + break; + default: + abort (); + } + + if (WSAAddressToString ((struct sockaddr *) &sa, srcsize, NULL, dst, &dstlen) != 0) + { + errno = WSAGetLastError(); + return NULL; + } + return (const char *) dst; +} +#endif diff -urN wget-1.10.2/src/mswindows.h wget-1.10.2_new/src/mswindows.h --- wget-1.10.2/src/mswindows.h 2005-08-11 23:35:27.000000000 +0200 +++ wget-1.10.2_new/src/mswindows.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,6 +1,5 @@ /* Declarations for windows - Copyright (C) 1995, 1997, 1997, 1998, 2004 - Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -15,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -32,20 +31,20 @@ #define MSWINDOWS_H #ifndef WGET_H -#error Include mswindows.h inside or after "wget.h" +# error This file should not be included directly. #endif /* Prevent inclusion of in . */ #ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN #endif #include -/* Use the correct winsock header; includes only - on Watcom/MingW. We cannot use for IPv6. Using - getaddrinfo() requires . */ -#if defined(ENABLE_IPV6) || defined(HAVE_GETADDRINFO) +/* We need winsock2.h for IPv6 and ws2tcpip.h for getaddrinfo, so + include both in ENABLE_IPV6 case. (ws2tcpip.h includes winsock2.h + only on MinGW.) */ +#ifdef ENABLE_IPV6 # include # include #else @@ -56,14 +55,12 @@ # define EAI_SYSTEM -1 /* value doesn't matter */ #endif -/* Must include because of 'stat' define below. */ -#include - -/* Missing in several .c files. Include here. */ +/* Declares file access functions, such as open, creat, access, and + chmod. Unix declares these in unistd.h and fcntl.h. */ #include -/* Apparently needed for alloca(). */ -#include +/* Declares getpid(). */ +#include #ifndef S_ISDIR # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR)) @@ -72,9 +69,13 @@ # define S_ISLNK(a) 0 #endif -/* We have strcasecmp and strncasecmp, just under a different name. */ -#define strcasecmp stricmp -#define strncasecmp strnicmp +/* We have strcasecmp and strncasecmp, just under different names. */ +#ifndef HAVE_STRCASECMP +# define strcasecmp stricmp +#endif +#ifndef HAVE_STRNCASECMP +# define strncasecmp strnicmp +#endif /* The same for snprintf() and vsnprintf(). */ #define snprintf _snprintf @@ -83,70 +84,51 @@ /* Define a wgint type under Windows. */ typedef __int64 wgint; #define SIZEOF_WGINT 8 +#define WGINT_MAX LL (9223372036854775807) -#ifdef __GNUC__ -#define WGINT_MAX 9223372036854775807LL -#else -#define WGINT_MAX 9223372036854775807I64 -#endif - -#if defined __MINGW32__ +/* str_to_wgint is a function with the semantics of strtol[l], but + which works on wgint. */ +#if defined HAVE_STRTOLL # define str_to_wgint strtoll -#elif defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__BORLANDC__) +#elif defined HAVE__STRTOI64 # define str_to_wgint _strtoi64 #else # define str_to_wgint strtoll # define NEED_STRTOLL -# define strtoll_return __int64 +# define strtoll_type __int64 #endif /* Windows has no symlink, therefore no lstat. Without symlinks lstat is equivalent to stat anyway. */ #define lstat stat -/* Transparently support statting large files, like POSIX's LFS API - does. All Windows compilers we support use _stati64 (but have - different names for 2nd argument type, see below), so we use - that. */ -#define stat(fname, buf) _stati64 (fname, buf) - -/* On Windows the 64-bit stat requires an explicitly different type - for the 2nd argument, so we define a struct_stat macro that expands - to the appropriate type on Windows, and to the regular struct stat - on Unix. - - Note that Borland C 5.5 has 64-bit stat (_stati64), but not a - 64-bit fstat! Because of that we also need a struct_fstat that - points to struct_stat on Unix and on Windows, except under Borland, - where it points to the 32-bit struct stat. */ - -#ifndef __BORLANDC__ -# define fstat(fd, buf) _fstati64 (fd, buf) -# define struct_stat struct _stati64 -# define struct_fstat struct _stati64 -#else /* __BORLANDC__ */ -# define struct_stat struct stati64 -# define struct_fstat struct stat -#endif /* __BORLANDC__ */ - -#define PATH_SEPARATOR '\\' - -#ifdef HAVE_ISATTY -#ifdef _MSC_VER -# define isatty _isatty +/* Define LFS aliases for stat and fstat. */ +#ifdef stat_alias +# define stat(f, b) stat_alias (f, b) #endif +#ifdef fstat_alias +# define fstat(f, b) fstat_alias (f, b) #endif -/* #### Do we need this? */ +#define PATH_SEPARATOR '\\' + +/* Win32 doesn't support the MODE argument to mkdir. */ #include +#define mkdir(a, b) (mkdir) (a) -/* Windows compilers accept only one arg to mkdir. */ -#define mkdir(a, b) _mkdir(a) +/* Additional declarations needed for IPv6: */ +#ifdef ENABLE_IPV6 +const char *inet_ntop (int, const void *, char *, socklen_t); +#endif + +#ifdef NEED_GAI_STRERROR +# undef gai_strerror +# define gai_strerror windows_strerror +#endif #ifndef INHIBIT_WRAP -/* Winsock functions don't set errno, so we provide wrappers - that do. */ +/* Winsock functions don't set errno, so we provide wrappers that do. */ #define socket wrapped_socket #define bind wrapped_bind @@ -183,13 +165,6 @@ #endif const char *windows_strerror (int); -/* MingW 3.7 (or older) prototypes gai_strerror(), but is missing - from all import libraries. */ -#if defined(__MINGW32__) && defined(ENABLE_IPV6) -# undef gai_strerror -# define gai_strerror windows_strerror -#endif - /* Declarations of various socket errors: */ #define EWOULDBLOCK WSAEWOULDBLOCK @@ -236,11 +211,4 @@ char *ws_mypath (void); void windows_main (int *, char **, char **); -/* Things needed for IPv6; missing in . */ -#ifdef ENABLE_IPV6 -# ifndef HAVE_INET_NTOP -extern const char *inet_ntop (int af, const void *src, char *dst, size_t size); -# endif -#endif /* ENABLE_IPV6 */ - #endif /* MSWINDOWS_H */ diff -urN wget-1.10.2/src/netrc.c wget-1.10.2_new/src/netrc.c --- wget-1.10.2/src/netrc.c 2005-05-08 18:25:42.000000000 +0200 +++ wget-1.10.2_new/src/netrc.c 2006-06-27 12:18:18.000000000 +0200 @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -36,12 +36,7 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif -#include +#include #include #include "wget.h" @@ -49,15 +44,11 @@ #include "netrc.h" #include "init.h" -#ifndef errno -extern int errno; -#endif - #define NETRC_FILE_NAME ".netrc" -acc_t *netrc_list; +static acc_t *netrc_list; -static acc_t *parse_netrc PARAMS ((const char *)); +static acc_t *parse_netrc (const char *); /* Return the correct user and password, given the host, user (as given in the URL), and password (as given in the URL). May return @@ -173,7 +164,7 @@ { int length = 0; int bufsize = 81; - char *line = (char *)xmalloc (bufsize); + char *line = xmalloc (bufsize); while (fgets (line + length, bufsize - length, fp)) { @@ -229,7 +220,7 @@ } /* Allocate a new acc_t structure. */ - a = (acc_t *)xmalloc (sizeof (acc_t)); + a = xmalloc (sizeof (acc_t)); } /* Zero the structure, so that it is ready to use. */ diff -urN wget-1.10.2/src/netrc.h wget-1.10.2_new/src/netrc.h --- wget-1.10.2/src/netrc.h 2002-05-18 04:16:36.000000000 +0200 +++ wget-1.10.2_new/src/netrc.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for netrc.c - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1996, 1997 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -39,7 +39,7 @@ struct _acc_t *next; } acc_t; -void search_netrc PARAMS((const char *, const char **, const char **, int)); -void free_netrc PARAMS((acc_t *l)); +void search_netrc (const char *, const char **, const char **, int); +void free_netrc (acc_t *l); #endif /* NETRC_H */ diff -urN wget-1.10.2/src/openssl.c wget-1.10.2_new/src/openssl.c --- wget-1.10.2/src/openssl.c 2005-08-26 12:44:54.000000000 +0200 +++ wget-1.10.2_new/src/openssl.c 2006-06-27 12:18:18.000000000 +0200 @@ -15,8 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -35,11 +35,7 @@ #ifdef HAVE_UNISTD_H # include #endif -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #include @@ -52,13 +48,9 @@ #include "url.h" #include "ssl.h" -#ifndef errno -extern int errno; -#endif - /* Application-wide SSL context. This is common to all SSL connections. */ -SSL_CTX *ssl_ctx; +static SSL_CTX *ssl_ctx; /* Initialize the SSL's PRNG using various methods. */ @@ -134,9 +126,9 @@ static void print_errors (void) { - unsigned long curerr = 0; - while ((curerr = ERR_get_error ()) != 0) - logprintf (LOG_NOTQUIET, "OpenSSL: %s\n", ERR_error_string (curerr, NULL)); + unsigned long err; + while ((err = ERR_get_error ()) != 0) + logprintf (LOG_NOTQUIET, "OpenSSL: %s\n", ERR_error_string (err, NULL)); } /* Convert keyfile type as used by options.h to a type as accepted by @@ -162,16 +154,16 @@ /* Create an SSL Context and set default paths etc. Called the first time an HTTP download is attempted. - Returns 1 on success, 0 otherwise. */ + Returns true on success, false otherwise. */ -int +bool ssl_init () { SSL_METHOD *meth; if (ssl_ctx) /* The SSL has already been initialized. */ - return 1; + return true; /* Init the PRNG. If that fails, bail out. */ init_prng (); @@ -237,71 +229,133 @@ tell it to do so. */ SSL_CTX_set_mode (ssl_ctx, SSL_MODE_AUTO_RETRY); - return 1; + return true; error: if (ssl_ctx) SSL_CTX_free (ssl_ctx); print_errors (); - return 0; + return false; } +struct openssl_transport_context { + SSL *conn; /* SSL connection handle */ + char *last_error; /* last error printed with openssl_errstr */ +}; + static int -openssl_read (int fd, char *buf, int bufsize, void *ctx) +openssl_read (int fd, char *buf, int bufsize, void *arg) { int ret; - SSL *ssl = (SSL *) ctx; + struct openssl_transport_context *ctx = arg; + SSL *conn = ctx->conn; do - ret = SSL_read (ssl, buf, bufsize); + ret = SSL_read (conn, buf, bufsize); while (ret == -1 - && SSL_get_error (ssl, ret) == SSL_ERROR_SYSCALL + && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL && errno == EINTR); return ret; } static int -openssl_write (int fd, char *buf, int bufsize, void *ctx) +openssl_write (int fd, char *buf, int bufsize, void *arg) { int ret = 0; - SSL *ssl = (SSL *) ctx; + struct openssl_transport_context *ctx = arg; + SSL *conn = ctx->conn; do - ret = SSL_write (ssl, buf, bufsize); + ret = SSL_write (conn, buf, bufsize); while (ret == -1 - && SSL_get_error (ssl, ret) == SSL_ERROR_SYSCALL + && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL && errno == EINTR); return ret; } static int -openssl_poll (int fd, double timeout, int wait_for, void *ctx) +openssl_poll (int fd, double timeout, int wait_for, void *arg) { - SSL *ssl = (SSL *) ctx; + struct openssl_transport_context *ctx = arg; + SSL *conn = ctx->conn; if (timeout == 0) return 1; - if (SSL_pending (ssl)) + if (SSL_pending (conn)) return 1; return select_fd (fd, timeout, wait_for); } static int -openssl_peek (int fd, char *buf, int bufsize, void *ctx) +openssl_peek (int fd, char *buf, int bufsize, void *arg) { int ret; - SSL *ssl = (SSL *) ctx; + struct openssl_transport_context *ctx = arg; + SSL *conn = ctx->conn; do - ret = SSL_peek (ssl, buf, bufsize); + ret = SSL_peek (conn, buf, bufsize); while (ret == -1 - && SSL_get_error (ssl, ret) == SSL_ERROR_SYSCALL + && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL && errno == EINTR); return ret; } +static const char * +openssl_errstr (int fd, void *arg) +{ + struct openssl_transport_context *ctx = arg; + unsigned long errcode; + char *errmsg = NULL; + int msglen = 0; + + /* If there are no SSL-specific errors, just return NULL. */ + if ((errcode = ERR_get_error ()) == 0) + return NULL; + + /* Get rid of previous contents of ctx->last_error, if any. */ + xfree_null (ctx->last_error); + + /* Iterate over OpenSSL's error stack and accumulate errors in the + last_error buffer, separated by "; ". This is better than using + a static buffer, which *always* takes up space (and has to be + large, to fit more than one error message), whereas these + allocations are only performed when there is an actual error. */ + + for (;;) + { + const char *str = ERR_error_string (errcode, NULL); + int len = strlen (str); + + /* Allocate space for the existing message, plus two more chars + for the "; " separator and one for the terminating \0. */ + errmsg = xrealloc (errmsg, msglen + len + 2 + 1); + memcpy (errmsg + msglen, str, len); + msglen += len; + + /* Get next error and bail out if there are no more. */ + errcode = ERR_get_error (); + if (errcode == 0) + break; + + errmsg[msglen++] = ';'; + errmsg[msglen++] = ' '; + } + errmsg[msglen] = '\0'; + + /* Store the error in ctx->last_error where openssl_close will + eventually find it and free it. */ + ctx->last_error = errmsg; + + return errmsg; +} + static void -openssl_close (int fd, void *ctx) +openssl_close (int fd, void *arg) { - SSL *ssl = (SSL *) ctx; - SSL_shutdown (ssl); - SSL_free (ssl); + struct openssl_transport_context *ctx = arg; + SSL *conn = ctx->conn; + + SSL_shutdown (conn); + SSL_free (conn); + xfree_null (ctx->last_error); + xfree (ctx); #ifdef WINDOWS closesocket (fd); @@ -309,53 +363,64 @@ close (fd); #endif - DEBUGP (("Closed %d/SSL 0x%0lx\n", fd, (unsigned long) ssl)); + DEBUGP (("Closed %d/SSL 0x%0*lx\n", fd, PTR_FORMAT (conn))); } +/* openssl_transport is the singleton that describes the SSL transport + methods provided by this file. */ + +static struct transport_implementation openssl_transport = { + openssl_read, openssl_write, openssl_poll, + openssl_peek, openssl_errstr, openssl_close +}; + /* Perform the SSL handshake on file descriptor FD, which is assumed to be connected to an SSL server. The SSL handle provided by OpenSSL is registered with the file descriptor FD using fd_register_transport, so that subsequent calls to fd_read, fd_write, etc., will use the corresponding SSL functions. - Returns 1 on success, 0 on failure. */ + Returns true on success, false on failure. */ -int +bool ssl_connect (int fd) { - SSL *ssl; + SSL *conn; + struct openssl_transport_context *ctx; DEBUGP (("Initiating SSL handshake.\n")); assert (ssl_ctx != NULL); - ssl = SSL_new (ssl_ctx); - if (!ssl) + conn = SSL_new (ssl_ctx); + if (!conn) goto error; - if (!SSL_set_fd (ssl, fd)) + if (!SSL_set_fd (conn, fd)) goto error; - SSL_set_connect_state (ssl); - if (SSL_connect (ssl) <= 0 || ssl->state != SSL_ST_OK) + SSL_set_connect_state (conn); + if (SSL_connect (conn) <= 0 || conn->state != SSL_ST_OK) goto error; + ctx = xnew0 (struct openssl_transport_context); + ctx->conn = conn; + /* Register FD with Wget's transport layer, i.e. arrange that our functions are used for reading, writing, and polling. */ - fd_register_transport (fd, openssl_read, openssl_write, openssl_poll, - openssl_peek, openssl_close, ssl); + fd_register_transport (fd, &openssl_transport, ctx); DEBUGP (("Handshake successful; connected socket %d to SSL handle 0x%0*lx\n", - fd, PTR_FORMAT (ssl))); - return 1; + fd, PTR_FORMAT (conn))); + return true; error: DEBUGP (("SSL handshake failed.\n")); print_errors (); - if (ssl) - SSL_free (ssl); - return 0; + if (conn) + SSL_free (conn); + return false; } #define ASTERISK_EXCLUDES_DOT /* mandated by rfc2818 */ -/* Return 1 is STRING (case-insensitively) matches PATTERN, 0 +/* Return true is STRING (case-insensitively) matches PATTERN, false otherwise. The recognized wildcard character is "*", which matches any character in STRING except ".". Any number of the "*" wildcard may be present in the pattern. @@ -369,7 +434,7 @@ If the pattern contain no wildcards, pattern_match(a, b) is equivalent to !strcasecmp(a, b). */ -static int +static bool pattern_match (const char *pattern, const char *string) { const char *p = pattern, *n = string; @@ -381,17 +446,17 @@ ; for (; *n != '\0'; n++) if (TOLOWER (*n) == c && pattern_match (p, n)) - return 1; + return true; #ifdef ASTERISK_EXCLUDES_DOT else if (*n == '.') - return 0; + return false; #endif return c == '\0'; } else { if (c != TOLOWER (*n)) - return 0; + return false; } return *n == '\0'; } @@ -405,37 +470,37 @@ the SSL handshake has been performed and that FD is connected to an SSL handle. - If opt.check_cert is non-zero (the default), this returns 1 if the + If opt.check_cert is true (the default), this returns 1 if the certificate is valid, 0 otherwise. If opt.check_cert is 0, the function always returns 1, but should still be called because it warns the user about any problems with the certificate. */ -int +bool ssl_check_certificate (int fd, const char *host) { X509 *cert; char common_name[256]; long vresult; - int success = 1; + bool success = true; /* If the user has specified --no-check-cert, we still want to warn him about problems with the server's certificate. */ const char *severity = opt.check_cert ? _("ERROR") : _("WARNING"); - SSL *ssl = (SSL *) fd_transport_context (fd); - assert (ssl != NULL); + struct openssl_transport_context *ctx = fd_transport_context (fd); + SSL *conn = ctx->conn; + assert (conn != NULL); - cert = SSL_get_peer_certificate (ssl); + cert = SSL_get_peer_certificate (conn); if (!cert) { logprintf (LOG_NOTQUIET, _("%s: No certificate presented by %s.\n"), severity, escnonprint (host)); - success = 0; + success = false; goto no_cert; /* must bail out since CERT is NULL */ } -#ifdef ENABLE_DEBUG - if (opt.debug) + IF_DEBUG { char *subject = X509_NAME_oneline (X509_get_subject_name (cert), 0, 0); char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), 0, 0); @@ -444,25 +509,39 @@ OPENSSL_free (subject); OPENSSL_free (issuer); } -#endif - vresult = SSL_get_verify_result (ssl); + vresult = SSL_get_verify_result (conn); if (vresult != X509_V_OK) { - /* #### We might want to print saner (and translatable) error - messages for several frequently encountered errors. The - candidates would include - X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, - X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN, - X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, - X509_V_ERR_CERT_NOT_YET_VALID, X509_V_ERR_CERT_HAS_EXPIRED, - and possibly others. The current approach would still be - used for the less frequent failure cases. */ + char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), 0, 0); logprintf (LOG_NOTQUIET, - _("%s: Certificate verification error for %s: %s\n"), - severity, escnonprint (host), - X509_verify_cert_error_string (vresult)); - success = 0; + _("%s: cannot verify %s's certificate, issued by `%s':\n"), + severity, escnonprint (host), escnonprint (issuer)); + /* Try to print more user-friendly (and translated) messages for + the frequent verification errors. */ + switch (vresult) + { + case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: + logprintf (LOG_NOTQUIET, + _(" Unable to locally verify the issuer's authority.\n")); + break; + case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: + case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: + logprintf (LOG_NOTQUIET, _(" Self-signed certificate encountered.\n")); + break; + case X509_V_ERR_CERT_NOT_YET_VALID: + logprintf (LOG_NOTQUIET, _(" Issued certificate not yet valid.\n")); + break; + case X509_V_ERR_CERT_HAS_EXPIRED: + logprintf (LOG_NOTQUIET, _(" Issued certificate has expired.\n")); + break; + default: + /* For the less frequent error strings, simply provide the + OpenSSL error message. */ + logprintf (LOG_NOTQUIET, " %s\n", + X509_verify_cert_error_string (vresult)); + } + success = false; /* Fall through, so that the user is warned about *all* issues with the cert (important with --no-check-certificate.) */ } @@ -489,7 +568,7 @@ logprintf (LOG_NOTQUIET, _("\ %s: certificate common name `%s' doesn't match requested host name `%s'.\n"), severity, escnonprint (common_name), escnonprint (host)); - success = 0; + success = false; } if (success) @@ -504,5 +583,5 @@ escnonprint (host)); /* Allow --no-check-cert to disable certificate checking. */ - return opt.check_cert ? success : 1; + return opt.check_cert ? success : true; } diff -urN wget-1.10.2/src/options.h wget-1.10.2_new/src/options.h --- wget-1.10.2/src/options.h 2005-08-09 00:54:16.000000000 +0200 +++ wget-1.10.2_new/src/options.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* struct options. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -29,50 +29,53 @@ struct options { - int verbose; /* Are we verbose? */ - int quiet; /* Are we quiet? */ + int verbose; /* Are we verbose? (First set to -1, + hence not boolean.) */ + bool quiet; /* Are we quiet? */ int ntry; /* Number of tries per URL */ - int retry_connrefused; /* Treat CONNREFUSED as non-fatal. */ - int background; /* Whether we should work in background. */ - int ignore_length; /* Do we heed content-length at all? */ - int recursive; /* Are we recursive? */ - int spanhost; /* Do we span across hosts in + bool retry_connrefused; /* Treat CONNREFUSED as non-fatal. */ + bool background; /* Whether we should work in background. */ + bool ignore_length; /* Do we heed content-length at all? */ + bool recursive; /* Are we recursive? */ + bool spanhost; /* Do we span across hosts in recursion? */ - int relative_only; /* Follow only relative links. */ - int no_parent; /* Restrict access to the parent + bool relative_only; /* Follow only relative links. */ + bool no_parent; /* Restrict access to the parent directory. */ int reclevel; /* Maximum level of recursion */ - int dirstruct; /* Do we build the directory structure + bool dirstruct; /* Do we build the directory structure as we go along? */ - int no_dirstruct; /* Do we hate dirstruct? */ + bool no_dirstruct; /* Do we hate dirstruct? */ int cut_dirs; /* Number of directory components to cut. */ - int add_hostdir; /* Do we add hostname directory? */ - int protocol_directories; /* Whether to prepend "http"/"ftp" to dirs. */ - int noclobber; /* Disables clobbering of existing + bool add_hostdir; /* Do we add hostname directory? */ + bool protocol_directories; /* Whether to prepend "http"/"ftp" to dirs. */ + bool noclobber; /* Disables clobbering of existing data. */ char *dir_prefix; /* The top of directory tree */ char *lfilename; /* Log filename */ char *input_filename; /* Input filename */ - int force_html; /* Is the input file an HTML file? */ + bool force_html; /* Is the input file an HTML file? */ - int spider; /* Is Wget in spider mode? */ + bool spider; /* Is Wget in spider mode? */ char **accepts; /* List of patterns to accept. */ char **rejects; /* List of patterns to reject. */ char **excludes; /* List of excluded FTP directories. */ char **includes; /* List of FTP directories to follow. */ + bool ignore_case; /* Whether to ignore case when + matching dirs and files */ char **domains; /* See host.c */ char **exclude_domains; - int dns_cache; /* whether we cache DNS lookups. */ + bool dns_cache; /* whether we cache DNS lookups. */ char **follow_tags; /* List of HTML tags to recursively follow. */ char **ignore_tags; /* List of HTML tags to ignore if recursing. */ - int follow_ftp; /* Are FTP URL-s followed in recursive + bool follow_ftp; /* Are FTP URL-s followed in recursive retrieving? */ - int retr_symlinks; /* Whether we retrieve symlinks in + bool retr_symlinks; /* Whether we retrieve symlinks in FTP. */ char *output_document; /* The output file to which the documents will be printed. */ @@ -80,20 +83,20 @@ char *user; /* Generic username */ char *passwd; /* Generic password */ - int always_rest; /* Always use REST. */ + bool always_rest; /* Always use REST. */ char *ftp_user; /* FTP username */ char *ftp_passwd; /* FTP password */ - int netrc; /* Whether to read .netrc. */ - int ftp_glob; /* FTP globbing */ - int ftp_pasv; /* Passive FTP. */ + bool netrc; /* Whether to read .netrc. */ + bool ftp_glob; /* FTP globbing */ + bool ftp_pasv; /* Passive FTP. */ char *http_user; /* HTTP username. */ char *http_passwd; /* HTTP password. */ char **user_headers; /* User-defined header(s). */ - int http_keep_alive; /* whether we use keep-alive */ + bool http_keep_alive; /* whether we use keep-alive */ - int use_proxy; /* Do we use proxy? */ - int allow_cache; /* Do we allow server-side caching? */ + bool use_proxy; /* Do we use proxy? */ + bool allow_cache; /* Do we allow server-side caching? */ char *http_proxy, *ftp_proxy, *https_proxy; char **no_proxy; char *base_href; @@ -105,42 +108,43 @@ double dns_timeout; /* The DNS timeout. */ double connect_timeout; /* The connect timeout. */ - int random_wait; /* vary from 0 .. wait secs by random()? */ + bool random_wait; /* vary from 0 .. wait secs by random()? */ double wait; /* The wait period between retrievals. */ double waitretry; /* The wait period between retries. - HEH */ - int use_robots; /* Do we heed robots.txt? */ + bool use_robots; /* Do we heed robots.txt? */ wgint limit_rate; /* Limit the download rate to this many bps. */ SUM_SIZE_INT quota; /* Maximum file size to download and store. */ + int numurls; /* Number of successfully downloaded - URLs */ + URLs #### should be removed because + it's not a setting, but a global var */ - int server_response; /* Do we print server response? */ - int save_headers; /* Do we save headers together with + bool server_response; /* Do we print server response? */ + bool save_headers; /* Do we save headers together with file? */ #ifdef ENABLE_DEBUG - int debug; /* Debugging on/off */ + bool debug; /* Debugging on/off */ #endif - int timestamping; /* Whether to use time-stamping. */ + bool timestamping; /* Whether to use time-stamping. */ - int backup_converted; /* Do we save pre-converted files as *.orig? */ - int backups; /* Are numeric backups made? */ + bool backup_converted; /* Do we save pre-converted files as *.orig? */ + bool backups; /* Are numeric backups made? */ - char *useragent; /* Naughty User-Agent, which can be - set to something other than - Wget. */ + char *useragent; /* User-Agent string, which can be set + to something other than Wget. */ char *referer; /* Naughty Referer, which can be set to something other than NULL. */ - int convert_links; /* Will the links be converted + bool convert_links; /* Will the links be converted locally? */ - int remove_listing; /* Do we remove .listing files + bool remove_listing; /* Do we remove .listing files generated by FTP? */ - int htmlify; /* Do we HTML-ify the OS-dependent + bool htmlify; /* Do we HTML-ify the OS-dependent listings? */ char *dot_style; @@ -149,12 +153,12 @@ int dots_in_line; /* How many dots in one line. */ int dot_spacing; /* How many dots between spacings. */ - int delete_after; /* Whether the files will be deleted + bool delete_after; /* Whether the files will be deleted after download. */ - int html_extension; /* Use ".html" extension on all text/html? */ + bool html_extension; /* Use ".html" extension on all text/html? */ - int page_requisites; /* Whether we need to download all files + bool page_requisites; /* Whether we need to download all files necessary to display a page properly. */ char *bind_address; /* What local IP address to bind to. */ @@ -165,7 +169,7 @@ secure_protocol_sslv3, secure_protocol_tlsv1 } secure_protocol; /* type of secure protocol to use. */ - int check_cert; /* whether to validate the server's cert */ + bool check_cert; /* whether to validate the server's cert */ char *cert_file; /* external client certificate to use. */ char *private_key; /* private key file (if not internal). */ enum keyfile_type { @@ -183,10 +187,10 @@ char *egd_file; /* file name of the egd daemon socket */ #endif /* HAVE_SSL */ - int cookies; /* whether cookies are used. */ + 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. */ - int keep_session_cookies; /* whether session cookies should be + bool keep_session_cookies; /* whether session cookies should be saved and loaded. */ char *post_data; /* POST query string */ @@ -196,19 +200,24 @@ restrict_unix, restrict_windows } restrict_files_os; /* file name restriction ruleset. */ - int restrict_files_ctrl; /* non-zero if control chars in URLs + bool restrict_files_ctrl; /* non-zero if control chars in URLs are restricted from appearing in generated file names. */ + enum { + restrict_no_case_restriction, + restrict_lowercase, + restrict_uppercase + } restrict_files_case; /* file name case restriction. */ - int strict_comments; /* whether strict SGML comments are + bool strict_comments; /* whether strict SGML comments are enforced. */ - int preserve_perm; /* whether remote permissions are used + bool preserve_perm; /* whether remote permissions are used or that what is set by umask. */ #ifdef ENABLE_IPV6 - int ipv4_only; /* IPv4 connections have been requested. */ - int ipv6_only; /* IPv4 connections have been requested. */ + bool ipv4_only; /* IPv4 connections have been requested. */ + bool ipv6_only; /* IPv4 connections have been requested. */ #endif enum { prefer_ipv4, @@ -216,6 +225,8 @@ prefer_none } prefer_family; /* preferred address family when more than one type is available */ + + bool content_disposition; /* Honor HTTP Content-Disposition header. */ }; extern struct options opt; diff -urN wget-1.10.2/src/progress.c wget-1.10.2_new/src/progress.c --- wget-1.10.2/src/progress.c 2005-06-26 03:37:14.000000000 +0200 +++ wget-1.10.2_new/src/progress.c 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Download progress. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,18 +31,12 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ +#include #include #ifdef HAVE_UNISTD_H # include #endif -#ifdef HAVE_SIGNAL_H -# include -#endif +#include #include "wget.h" #include "progress.h" @@ -51,24 +45,24 @@ struct progress_implementation { const char *name; - int interactive; - void *(*create) PARAMS ((wgint, wgint)); - void (*update) PARAMS ((void *, wgint, double)); - void (*finish) PARAMS ((void *, double)); - void (*set_params) PARAMS ((const char *)); + bool interactive; + void *(*create) (wgint, wgint); + void (*update) (void *, wgint, double); + void (*finish) (void *, double); + void (*set_params) (const char *); }; /* Necessary forward declarations. */ -static void *dot_create PARAMS ((wgint, wgint)); -static void dot_update PARAMS ((void *, wgint, double)); -static void dot_finish PARAMS ((void *, double)); -static void dot_set_params PARAMS ((const char *)); - -static void *bar_create PARAMS ((wgint, wgint)); -static void bar_update PARAMS ((void *, wgint, double)); -static void bar_finish PARAMS ((void *, double)); -static void bar_set_params PARAMS ((const char *)); +static void *dot_create (wgint, wgint); +static void dot_update (void *, wgint, double); +static void dot_finish (void *, double); +static void dot_set_params (const char *); + +static void *bar_create (wgint, wgint); +static void bar_update (void *, wgint, double); +static void bar_finish (void *, double); +static void bar_set_params (const char *); static struct progress_implementation implementations[] = { { "dot", 0, dot_create, dot_update, dot_finish, dot_set_params }, @@ -82,7 +76,7 @@ #define DEFAULT_PROGRESS_IMPLEMENTATION "bar" -/* Fallnback progress implementation should be something that works +/* Fallback progress implementation should be something that works under all display types. If you put something other than "dot" here, remember that bar_set_params tries to switch to this if we're not running on a TTY. So changing this to "bar" could cause @@ -90,10 +84,10 @@ #define FALLBACK_PROGRESS_IMPLEMENTATION "dot" -/* Return non-zero if NAME names a valid progress bar implementation. - The characters after the first : will be ignored. */ +/* Return true if NAME names a valid progress bar implementation. The + characters after the first : will be ignored. */ -int +bool valid_progress_implementation_p (const char *name) { int i; @@ -103,8 +97,8 @@ for (i = 0; i < countof (implementations); i++, pi++) if (!strncmp (pi->name, name, namelen)) - return 1; - return 0; + return true; + return false; } /* Set the progress implementation to NAME. */ @@ -114,7 +108,7 @@ { int i, namelen; struct progress_implementation *pi = implementations; - char *colon; + const char *colon; if (!name) name = DEFAULT_PROGRESS_IMPLEMENTATION; @@ -169,19 +163,19 @@ return current_impl->create (initial, total); } -/* Return non-zero if the progress gauge is "interactive", i.e. if it - can profit from being called regularly even in absence of data. - The progress bar is interactive because it regularly updates the - ETA and current update. */ +/* Return true if the progress gauge is "interactive", i.e. if it can + profit from being called regularly even in absence of data. The + progress bar is interactive because it regularly updates the ETA + and current update. */ -int +bool progress_interactive_p (void *progress) { return current_impl->interactive; } /* Inform the progress gauge of newly received bytes. DLTIME is the - time in milliseconds since the beginning of the download. */ + time since the beginning of the download. */ void progress_update (void *progress, wgint howmuch, double dltime) @@ -206,10 +200,12 @@ wgint total_length; /* expected total byte count when the download finishes */ - int accumulated; + int accumulated; /* number of bytes accumulated after + the last printed dot */ int rows; /* number of rows printed so far */ int dots; /* number of dots printed in this row */ + double last_timer_value; }; @@ -225,26 +221,28 @@ if (dp->initial_length) { int dot_bytes = opt.dot_bytes; - wgint row_bytes = opt.dot_bytes * opt.dots_in_line; + const wgint ROW_BYTES = opt.dot_bytes * opt.dots_in_line; - int remainder = (int) (dp->initial_length % row_bytes); + int remainder = dp->initial_length % ROW_BYTES; wgint skipped = dp->initial_length - remainder; if (skipped) { - int skipped_k = (int) (skipped / 1024); /* skipped amount in K */ + wgint skipped_k = skipped / 1024; /* skipped amount in K */ int skipped_k_len = numdigit (skipped_k); - if (skipped_k_len < 5) - skipped_k_len = 5; + if (skipped_k_len < 6) + skipped_k_len = 6; /* Align the [ skipping ... ] line with the dots. To do that, insert the number of spaces equal to the number of digits in the skipped amount in K. */ - logprintf (LOG_VERBOSE, _("\n%*s[ skipping %dK ]"), - 2 + skipped_k_len, "", skipped_k); + logprintf (LOG_VERBOSE, _("\n%*s[ skipping %sK ]"), + 2 + skipped_k_len, "", + number_to_static_string (skipped_k)); } - logprintf (LOG_VERBOSE, "\n%5ldK", (long) (skipped / 1024)); + logprintf (LOG_VERBOSE, "\n%6sK", + number_to_static_string (skipped / 1024)); for (; remainder >= dot_bytes; remainder -= dot_bytes) { if (dp->dots % opt.dot_spacing == 0) @@ -255,25 +253,86 @@ assert (dp->dots < opt.dots_in_line); dp->accumulated = remainder; - dp->rows = skipped / row_bytes; + dp->rows = skipped / ROW_BYTES; } return dp; } -static void -print_percentage (wgint bytes, wgint expected) -{ - int percentage = (int)(100.0 * bytes / expected); - logprintf (LOG_VERBOSE, "%3d%%", percentage); -} +static const char *eta_to_human_short (int, bool); + +/* Prints the stats (percentage of completion, speed, ETA) for current + row. DLTIME is the time spent downloading the data in current + row. + + #### This function is somewhat uglified by the fact that current + row and last row have somewhat different stats requirements. It + might be worthwhile to split it to two different functions. */ static void -print_download_speed (struct dot_progress *dp, wgint bytes, double dltime) +print_row_stats (struct dot_progress *dp, double dltime, bool last) { - logprintf (LOG_VERBOSE, " %s", - retr_rate (bytes, dltime - dp->last_timer_value, 1)); - dp->last_timer_value = dltime; + const wgint ROW_BYTES = opt.dot_bytes * opt.dots_in_line; + + /* bytes_displayed is the number of bytes indicated to the user by + dots printed so far, includes the initially "skipped" amount */ + wgint bytes_displayed = dp->rows * ROW_BYTES + dp->dots * opt.dot_bytes; + + if (last) + /* For last row also count bytes accumulated after last dot */ + bytes_displayed += dp->accumulated; + + if (dp->total_length) + { + /* Round to floor value to provide gauge how much data *has* + been retrieved. 12.8% will round to 12% because the 13% mark + has not yet been reached. 100% is only shown when done. */ + int percentage = 100.0 * bytes_displayed / dp->total_length; + logprintf (LOG_VERBOSE, "%3d%%", percentage); + } + + { + static char names[] = {' ', 'K', 'M', 'G'}; + int units; + double rate; + wgint bytes_this_row; + if (!last) + bytes_this_row = ROW_BYTES; + else + /* For last row also include bytes accumulated after last dot. */ + bytes_this_row = dp->dots * opt.dot_bytes + dp->accumulated; + /* Don't count the portion of the row belonging to initial_length */ + if (dp->rows == dp->initial_length / ROW_BYTES) + bytes_this_row -= dp->initial_length % ROW_BYTES; + rate = calc_rate (bytes_this_row, dltime - dp->last_timer_value, &units); + logprintf (LOG_VERBOSE, " %4.*f%c", + rate >= 99.95 ? 0 : rate >= 9.995 ? 1 : 2, + rate, names[units]); + dp->last_timer_value = dltime; + } + + if (!last) + { + /* Display ETA based on average speed. Inspired by Vladi + Belperchinov-Shabanski's "wget-new-percentage" patch. */ + if (dp->total_length) + { + wgint bytes_remaining = dp->total_length - bytes_displayed; + /* The quantity downloaded in this download run. */ + wgint bytes_sofar = bytes_displayed - dp->initial_length; + int eta = (int) (dltime * bytes_remaining / bytes_sofar + 0.5); + logprintf (LOG_VERBOSE, " %s", eta_to_human_short (eta, true)); + } + } + else + { + /* When done, print the total download time */ + if (dltime >= 10) + logprintf (LOG_VERBOSE, "=%s", + eta_to_human_short ((int) (dltime + 0.5), true)); + else + logprintf (LOG_VERBOSE, "=%ss", print_decimal (dltime)); + } } /* Dot-progress backend for progress_update. */ @@ -283,15 +342,16 @@ { struct dot_progress *dp = progress; int dot_bytes = opt.dot_bytes; - wgint row_bytes = opt.dot_bytes * opt.dots_in_line; + wgint ROW_BYTES = opt.dot_bytes * opt.dots_in_line; - log_set_flush (0); + log_set_flush (false); dp->accumulated += howmuch; for (; dp->accumulated >= dot_bytes; dp->accumulated -= dot_bytes) { if (dp->dots == 0) - logprintf (LOG_VERBOSE, "\n%5ldK", (long) (dp->rows * row_bytes / 1024)); + logprintf (LOG_VERBOSE, "\n%6sK", + number_to_static_string (dp->rows * ROW_BYTES / 1024)); if (dp->dots % opt.dot_spacing == 0) logputs (LOG_VERBOSE, " "); @@ -300,20 +360,14 @@ ++dp->dots; if (dp->dots >= opt.dots_in_line) { - wgint row_qty = row_bytes; - if (dp->rows == dp->initial_length / row_bytes) - row_qty -= dp->initial_length % row_bytes; - ++dp->rows; dp->dots = 0; - if (dp->total_length) - print_percentage (dp->rows * row_bytes, dp->total_length); - print_download_speed (dp, row_qty, dltime); + print_row_stats (dp, dltime, false); } } - log_set_flush (1); + log_set_flush (true); } /* Dot-progress backend for progress_finish. */ @@ -322,37 +376,24 @@ dot_finish (void *progress, double dltime) { struct dot_progress *dp = progress; - int dot_bytes = opt.dot_bytes; - wgint row_bytes = opt.dot_bytes * opt.dots_in_line; + wgint ROW_BYTES = opt.dot_bytes * opt.dots_in_line; int i; - log_set_flush (0); + log_set_flush (false); if (dp->dots == 0) - logprintf (LOG_VERBOSE, "\n%5ldK", (long) (dp->rows * row_bytes / 1024)); + logprintf (LOG_VERBOSE, "\n%6sK", + number_to_static_string (dp->rows * ROW_BYTES / 1024)); for (i = dp->dots; i < opt.dots_in_line; i++) { if (i % opt.dot_spacing == 0) logputs (LOG_VERBOSE, " "); logputs (LOG_VERBOSE, " "); } - if (dp->total_length) - { - print_percentage (dp->rows * row_bytes - + dp->dots * dot_bytes - + dp->accumulated, - dp->total_length); - } - - { - wgint row_qty = dp->dots * dot_bytes + dp->accumulated; - if (dp->rows == dp->initial_length / row_bytes) - row_qty -= dp->initial_length % row_bytes; - print_download_speed (dp, row_qty, dltime); - } + print_row_stats (dp, dltime, true); logputs (LOG_VERBOSE, "\n\n"); - log_set_flush (0); + log_set_flush (false); xfree (dp); } @@ -435,12 +476,20 @@ sample is at least 150ms long, which means that, over the course of 20 samples, "current" download speed spans at least 3s into the past. */ -#define DLSPEED_SAMPLE_MIN 150 +#define DLSPEED_SAMPLE_MIN 0.15 /* The time after which the download starts to be considered "stalled", i.e. the current bandwidth is not printed and the recent download speeds are scratched. */ -#define STALL_START_TIME 5000 +#define STALL_START_TIME 5 + +/* Time between screen refreshes will not be shorter than this, so + that Wget doesn't swamp the TTY with output. */ +#define REFRESH_INTERVAL 0.2 + +/* Don't refresh the ETA too often to avoid jerkiness in predictions. + This allows ETA to change approximately once per second. */ +#define ETA_REFRESH_INTERVAL 0.99 struct bar_progress { wgint initial_length; /* how many bytes have been downloaded @@ -470,12 +519,12 @@ details. */ struct bar_progress_hist { int pos; - wgint times[DLSPEED_HISTORY_SIZE]; + double times[DLSPEED_HISTORY_SIZE]; wgint bytes[DLSPEED_HISTORY_SIZE]; /* The sum of times and bytes respectively, maintained for efficiency. */ - wgint total_time; + double total_time; wgint total_bytes; } hist; @@ -483,7 +532,7 @@ position. */ wgint recent_bytes; /* bytes downloaded so far. */ - int stalled; /* set when no data arrives for longer + bool stalled; /* set when no data arrives for longer than STALL_START_TIME, then reset when new data arrives. */ @@ -492,11 +541,11 @@ double last_eta_time; /* time of the last update to download speed and ETA, measured since the beginning of download. */ - wgint last_eta_value; + int last_eta_value; }; -static void create_image PARAMS ((struct bar_progress *, double)); -static void display_image PARAMS ((char *)); +static void create_image (struct bar_progress *, double, bool); +static void display_image (char *); static void * bar_create (wgint initial, wgint total) @@ -530,19 +579,19 @@ logputs (LOG_VERBOSE, "\n"); - create_image (bp, 0.0); + create_image (bp, 0, false); display_image (bp->buffer); return bp; } -static void update_speed_ring PARAMS ((struct bar_progress *, wgint, double)); +static void update_speed_ring (struct bar_progress *, wgint, double); static void bar_update (void *progress, wgint howmuch, double dltime) { struct bar_progress *bp = progress; - int force_screen_update = 0; + bool force_screen_update = false; bp->count += howmuch; if (bp->total_length > 0 @@ -570,16 +619,16 @@ { bp->width = screen_width - 1; bp->buffer = xrealloc (bp->buffer, bp->width + 1); - force_screen_update = 1; + force_screen_update = true; } received_sigwinch = 0; } - if (dltime - bp->last_screen_update < 200 && !force_screen_update) + if (dltime - bp->last_screen_update < REFRESH_INTERVAL && !force_screen_update) /* Don't update more often than five times per second. */ return; - create_image (bp, dltime); + create_image (bp, dltime, false); display_image (bp->buffer); bp->last_screen_update = dltime; } @@ -594,7 +643,7 @@ /* See bar_update() for explanation. */ bp->total_length = bp->initial_length + bp->count; - create_image (bp, dltime); + create_image (bp, dltime, true); display_image (bp->buffer); logputs (LOG_VERBOSE, "\n\n"); @@ -647,7 +696,7 @@ /* If we're stalling, reset the ring contents because it's stale and because it will make bar_update stop printing the (bogus) current bandwidth. */ - bp->stalled = 1; + bp->stalled = true; xzero (*hist); bp->recent_bytes = 0; } @@ -659,13 +708,13 @@ /* If the stall status was acquired, reset it. */ if (bp->stalled) { - bp->stalled = 0; + bp->stalled = false; /* "recent_age" includes the the entired stalled period, which could be very long. Don't update the speed ring with that value because the current bandwidth would start too small. Start with an arbitrary (but more reasonable) time value and let it level out. */ - recent_age = 1000; + recent_age = 1; } /* Store "recent" bytes and download time to history ring at the @@ -700,8 +749,14 @@ sumt += hist->times[i]; sumb += hist->bytes[i]; } - assert (sumt == hist->total_time); assert (sumb == hist->total_bytes); + /* We can't use assert(sumt==hist->total_time) because some + precision is lost by adding and subtracting floating-point + numbers. But during a download this precision should not be + detectable, i.e. no larger than 1ns. */ + double diff = sumt - hist->total_time; + if (diff < 0) diff = -diff; + assert (diff < 1e-9); } #endif } @@ -711,23 +766,28 @@ 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'); + #ifndef MAX # define MAX(a, b) ((a) >= (b) ? (a) : (b)) #endif static void -create_image (struct bar_progress *bp, double dl_total_time) +create_image (struct bar_progress *bp, double dl_total_time, bool done) { char *p = bp->buffer; wgint size = bp->initial_length + bp->count; - char *size_legible = with_thousand_seps (size); - int size_legible_len = strlen (size_legible); + const char *size_grouped = with_thousand_seps (size); + int size_grouped_len = strlen (size_grouped); struct bar_progress_hist *hist = &bp->hist; /* The progress bar should look like this: - xx% [=======> ] nn,nnn 12.34K/s ETA 00:00 + xx% [=======> ] nn,nnn 12.34K/s eta 36m 51s Calculate the geometry. The idea is to assign as much room as possible to the progress bar. The other idea is to never let @@ -739,13 +799,13 @@ "xx% " or "100%" - percentage - 4 chars "[]" - progress bar decorations - 2 chars " nnn,nnn,nnn" - downloaded bytes - 12 chars or very rarely more - " 1012.56K/s" - dl rate - 11 chars - " ETA xx:xx:xx" - ETA - 13 chars + " 12.5K/s" - download rate - 8 chars + " eta 36m 51s" - ETA - 13 chars "=====>..." - progress bar - the rest */ - int dlbytes_size = 1 + MAX (size_legible_len, 11); - int progress_size = bp->width - (4 + 2 + dlbytes_size + 11 + 13); + int dlbytes_size = 1 + MAX (size_grouped_len, 11); + int progress_size = bp->width - (4 + 2 + dlbytes_size + 8 + 13); if (progress_size < 5) progress_size = 0; @@ -753,8 +813,7 @@ /* "xx% " */ if (bp->total_length > 0) { - int percentage = (int)(100.0 * size / bp->total_length); - + int percentage = 100.0 * size / bp->total_length; assert (percentage <= 100); if (percentage < 100) @@ -828,11 +887,11 @@ } /* " 234,567,890" */ - sprintf (p, " %-11s", size_legible); - p += strlen (p); + sprintf (p, " %-11s", size_grouped); + move_to_end (p); - /* " 1012.45K/s" */ - if (hist->total_time && hist->total_bytes) + /* " 12.52K/s" */ + if (hist->total_time > 0 && hist->total_bytes) { static const char *short_units[] = { "B/s", "K/s", "M/s", "G/s" }; int units = 0; @@ -841,68 +900,66 @@ wgint dlquant = hist->total_bytes + bp->recent_bytes; double dltime = hist->total_time + (dl_total_time - bp->recent_start); double dlspeed = calc_rate (dlquant, dltime, &units); - sprintf (p, " %7.2f%s", dlspeed, short_units[units]); - p += strlen (p); + sprintf (p, " %4.*f%s", dlspeed >= 99.95 ? 0 : dlspeed >= 9.995 ? 1 : 2, + dlspeed, short_units[units]); + move_to_end (p); } else - APPEND_LITERAL (" --.--K/s"); + APPEND_LITERAL (" --.-K/s"); - /* " ETA xx:xx:xx"; wait for three seconds before displaying the ETA. - That's because the ETA value needs a while to become - reliable. */ - if (bp->total_length > 0 && bp->count > 0 && dl_total_time > 3000) - { - wgint eta; - int eta_hrs, eta_min, eta_sec; - - /* Don't change the value of ETA more than approximately once - per second; doing so would cause flashing without providing - any value to the user. */ - if (bp->total_length != size - && bp->last_eta_value != 0 - && dl_total_time - bp->last_eta_time < 900) - eta = bp->last_eta_value; - else + if (!done) + { + /* " eta ..m ..s"; wait for three seconds before displaying the ETA. + That's because the ETA value needs a while to become + reliable. */ + if (bp->total_length > 0 && bp->count > 0 && dl_total_time > 3) { - /* Calculate ETA using the average download speed to predict - the future speed. If you want to use a speed averaged - over a more recent period, replace dl_total_time with - hist->total_time and bp->count with hist->total_bytes. - I found that doing that results in a very jerky and - ultimately unreliable ETA. */ - double time_sofar = (double)dl_total_time / 1000; - wgint bytes_remaining = bp->total_length - size; - eta = (wgint) (time_sofar * bytes_remaining / bp->count); - bp->last_eta_value = eta; - bp->last_eta_time = dl_total_time; - } - - eta_hrs = eta / 3600, eta %= 3600; - eta_min = eta / 60, eta %= 60; - eta_sec = eta; + int eta; - if (eta_hrs > 99) - goto no_eta; - - if (eta_hrs == 0) - { - /* Hours not printed: pad with three spaces. */ - APPEND_LITERAL (" "); - sprintf (p, " ETA %02d:%02d", eta_min, eta_sec); + /* Don't change the value of ETA more than approximately once + per second; doing so would cause flashing without providing + any value to the user. */ + if (bp->total_length != size + && bp->last_eta_value != 0 + && dl_total_time - bp->last_eta_time < ETA_REFRESH_INTERVAL) + eta = bp->last_eta_value; + else + { + /* Calculate ETA using the average download speed to predict + the future speed. If you want to use a speed averaged + over a more recent period, replace dl_total_time with + hist->total_time and bp->count with hist->total_bytes. + I found that doing that results in a very jerky and + ultimately unreliable ETA. */ + wgint bytes_remaining = bp->total_length - size; + eta = (int) (dl_total_time * bytes_remaining / bp->count + 0.5); + bp->last_eta_value = eta; + bp->last_eta_time = dl_total_time; + } + + /* Translation note: "ETA" is English-centric, but this must + be short, ideally 3 chars. Abbreviate if necessary. */ + sprintf (p, _(" eta %s"), eta_to_human_short (eta, false)); + move_to_end (p); } - else + else if (bp->total_length > 0) { - if (eta_hrs < 10) - /* Hours printed with one digit: pad with one space. */ - *p++ = ' '; - sprintf (p, " ETA %d:%02d:%02d", eta_hrs, eta_min, eta_sec); + APPEND_LITERAL (" "); } - p += strlen (p); } - else if (bp->total_length > 0) + else { - no_eta: - APPEND_LITERAL (" "); + /* When the download is done, print the elapsed time. */ + + /* Note to translators: this should not take up more room than + available here. Abbreviate if necessary. */ + strcpy (p, _(" in ")); + move_to_end (p); /* not p+=6, think translations! */ + if (dl_total_time >= 10) + strcpy (p, eta_to_human_short ((int) (dl_total_time + 0.5), false)); + else + sprintf (p, "%ss", print_decimal (dl_total_time)); + move_to_end (p); } assert (p - bp->buffer <= bp->width); @@ -918,7 +975,7 @@ static void display_image (char *buf) { - int old = log_set_save_context (0); + bool old = log_set_save_context (false); logputs (LOG_VERBOSE, "\r"); logputs (LOG_VERBOSE, buf); log_set_save_context (old); @@ -960,10 +1017,55 @@ } #ifdef SIGWINCH -RETSIGTYPE +void progress_handle_sigwinch (int sig) { received_sigwinch = 1; signal (SIGWINCH, progress_handle_sigwinch); } #endif + +/* Provide a short human-readable rendition of the ETA. This is like + secs_to_human_time in main.c, except the output doesn't include + fractions (which would look silly in by nature imprecise ETA) and + takes less room. If the time is measured in hours, hours and + minutes (but not seconds) are shown; if measured in days, then days + and hours are shown. This ensures brevity while still displaying + as much as possible. + + If CONDENSED is true, the separator between minutes and seconds + (and hours and minutes, etc.) is not included, shortening the + display by one additional character. This is used for dot + progress. + + The display never occupies more than 7 characters of screen + space. */ + +static const char * +eta_to_human_short (int secs, bool condensed) +{ + static char buf[10]; /* 8 should be enough, but just in case */ + static int last = -1; + const char *space = condensed ? "" : " "; + + /* Trivial optimization. create_image can call us every 200 msecs + (see bar_update) for fast downloads, but ETA will only change + once per 900 msecs. */ + if (secs == last) + return buf; + last = secs; + + if (secs < 100) + sprintf (buf, "%ds", secs); + else if (secs < 100 * 60) + sprintf (buf, "%dm%s%ds", secs / 60, space, secs % 60); + else if (secs < 48 * 3600) + sprintf (buf, "%dh%s%dm", secs / 3600, space, (secs / 60) % 60); + else if (secs < 100 * 86400) + sprintf (buf, "%dd%s%dh", secs / 86400, space, (secs / 3600) % 60); + else + /* even (2^31-1)/86400 doesn't overflow BUF. */ + sprintf (buf, "%dd", secs / 86400); + + return buf; +} diff -urN wget-1.10.2/src/progress.h wget-1.10.2_new/src/progress.h --- wget-1.10.2/src/progress.h 2005-02-23 23:21:04.000000000 +0100 +++ wget-1.10.2_new/src/progress.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Download progress. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -30,15 +30,15 @@ #ifndef PROGRESS_H #define PROGRESS_H -int valid_progress_implementation_p PARAMS ((const char *)); -void set_progress_implementation PARAMS ((const char *)); -void progress_schedule_redirect PARAMS ((void)); - -void *progress_create PARAMS ((wgint, wgint)); -int progress_interactive_p PARAMS ((void *)); -void progress_update PARAMS ((void *, wgint, double)); -void progress_finish PARAMS ((void *, double)); +bool valid_progress_implementation_p (const char *); +void set_progress_implementation (const char *); +void progress_schedule_redirect (void); + +void *progress_create (wgint, wgint); +bool progress_interactive_p (void *); +void progress_update (void *, wgint, double); +void progress_finish (void *, double); -RETSIGTYPE progress_handle_sigwinch PARAMS ((int)); +void progress_handle_sigwinch (int); #endif /* PROGRESS_H */ diff -urN wget-1.10.2/src/ptimer.c wget-1.10.2_new/src/ptimer.c --- wget-1.10.2/src/ptimer.c 2005-07-06 17:26:18.000000000 +0200 +++ wget-1.10.2_new/src/ptimer.c 2006-06-27 12:18:18.000000000 +0200 @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -39,32 +39,30 @@ ptimer_destroy -- destroy the timer. ptimer_granularity -- returns the approximate granularity of the timers. - Timers measure time in milliseconds, but the timings they return - are floating point numbers, so they can carry as much precision as - the underlying system timer supports. For example, to measure the - time it takes to run a loop, you can use something like: + Timers measure time in seconds, returning the timings as floating + point numbers, so they can carry as much precision as the + underlying system timer supports. For example, to measure the time + it takes to run a loop, you can use something like: ptimer *tmr = ptimer_new (); while (...) ... loop ... - double msecs = ptimer_measure (); - printf ("The loop took %.2f ms\n", msecs); */ + double secs = ptimer_measure (); + printf ("The loop took %.2fs\n", secs); */ #include #include #include -#ifdef HAVE_STRING_H -# include -#else /* not HAVE_STRING_H */ -# include -#endif /* not HAVE_STRING_H */ -#include +#include #include #ifdef HAVE_UNISTD_H # include #endif -#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif /* Cygwin currently (as of 2005-04-08, Cygwin 1.5.14) lacks clock_getres, but still defines _POSIX_TIMERS! Because of that we simply use the @@ -76,31 +74,19 @@ #include "wget.h" #include "ptimer.h" -#ifndef errno -extern int errno; -#endif - -/* Depending on the OS and availability of gettimeofday(), one and - only one of PTIMER_POSIX, PTIMER_GETTIMEOFDAY, PTIMER_WINDOWS, or - PTIMER_TIME will be defined. */ +/* Depending on the OS, one and only one of PTIMER_POSIX, + PTIMER_GETTIMEOFDAY, or PTIMER_WINDOWS will be defined. */ #undef PTIMER_POSIX #undef PTIMER_GETTIMEOFDAY -#undef PTIMER_TIME #undef PTIMER_WINDOWS #if defined(WINDOWS) || defined(__CYGWIN__) # define PTIMER_WINDOWS /* use Windows timers */ +#elif _POSIX_TIMERS - 0 > 0 +# define PTIMER_POSIX /* use POSIX timers (clock_gettime) */ #else -# if _POSIX_TIMERS - 0 > 0 -# define PTIMER_POSIX /* use POSIX timers (clock_gettime) */ -# else -# ifdef HAVE_GETTIMEOFDAY -# define PTIMER_GETTIMEOFDAY /* use gettimeofday */ -# else -# define PTIMER_TIME -# endif -# endif +# define PTIMER_GETTIMEOFDAY /* use gettimeofday */ #endif #ifdef PTIMER_POSIX @@ -122,8 +108,8 @@ CLOCK_MONOTONIC where available, CLOCK_REALTIME otherwise. */ static int posix_clock_id; -/* Resolution of the clock, in milliseconds. */ -static double posix_millisec_resolution; +/* Resolution of the clock, initialized in posix_init. */ +static double posix_clock_resolution; /* Decide which clock_id to use. */ @@ -162,11 +148,10 @@ if (clock_getres (clocks[i].id, &r) < 0) continue; /* clock_getres doesn't work for this clock */ posix_clock_id = clocks[i].id; - posix_millisec_resolution = r.tv_sec * 1000.0 + r.tv_nsec / 1000000.0; - /* Guard against broken clock_getres returning nonsensical - values. */ - if (posix_millisec_resolution == 0) - posix_millisec_resolution = 1; + posix_clock_resolution = (double) r.tv_sec + r.tv_nsec / 1e9; + /* Guard against nonsense returned by a broken clock_getres. */ + if (posix_clock_resolution == 0) + posix_clock_resolution = 1e-3; break; } if (i == countof (clocks)) @@ -177,7 +162,7 @@ strerror (errno)); /* Use CLOCK_REALTIME, but invent a plausible resolution. */ posix_clock_id = CLOCK_REALTIME; - posix_millisec_resolution = 1; + posix_clock_resolution = 1e-3; } } @@ -190,14 +175,14 @@ static inline double posix_diff (ptimer_system_time *pst1, ptimer_system_time *pst2) { - return ((pst1->tv_sec - pst2->tv_sec) * 1000.0 - + (pst1->tv_nsec - pst2->tv_nsec) / 1000000.0); + return ((pst1->tv_sec - pst2->tv_sec) + + (pst1->tv_nsec - pst2->tv_nsec) / 1e9); } static inline double posix_resolution (void) { - return posix_millisec_resolution; + return posix_clock_resolution; } #endif /* PTIMER_POSIX */ @@ -223,8 +208,8 @@ static inline double gettimeofday_diff (ptimer_system_time *pst1, ptimer_system_time *pst2) { - return ((pst1->tv_sec - pst2->tv_sec) * 1000.0 - + (pst1->tv_usec - pst2->tv_usec) / 1000.0); + return ((pst1->tv_sec - pst2->tv_sec) + + (pst1->tv_usec - pst2->tv_usec) / 1e6); } static inline double @@ -237,39 +222,6 @@ } #endif /* PTIMER_GETTIMEOFDAY */ -#ifdef PTIMER_TIME -/* Elapsed time measurement using the time(2) call: system time is - held in time_t, retrieved using time, and resolution is 1 second. - - This method is a catch-all for non-Windows systems without - gettimeofday -- e.g. DOS or really old or non-standard Unix - systems. */ - -typedef time_t ptimer_system_time; - -#define IMPL_measure time_measure -#define IMPL_diff time_diff -#define IMPL_resolution time_resolution - -static inline void -time_measure (ptimer_system_time *pst) -{ - time (pst); -} - -static inline double -time_diff (ptimer_system_time *pst1, ptimer_system_time *pst2) -{ - return 1000.0 * (*pst1 - *pst2); -} - -static inline double -time_resolution (void) -{ - return 1; -} -#endif /* PTIMER_TIME */ - #ifdef PTIMER_WINDOWS /* Elapsed time measurement on Windows: where high-resolution timers are available, time is stored in a LARGE_INTEGER and retrieved @@ -290,12 +242,12 @@ /* Whether high-resolution timers are used. Set by ptimer_initialize_once the first time ptimer_new is called. */ -static int windows_hires_timers; +static bool windows_hires_timers; /* Frequency of high-resolution timers -- number of updates per - millisecond. Calculated the first time ptimer_new is called - provided that high-resolution timers are available. */ -static double windows_hires_msfreq; + second. Calculated the first time ptimer_new is called provided + that high-resolution timers are available. */ +static double windows_hires_freq; static void windows_init (void) @@ -305,8 +257,8 @@ QueryPerformanceFrequency (&freq); if (freq.QuadPart != 0) { - windows_hires_timers = 1; - windows_hires_msfreq = (double) freq.QuadPart / 1000.0; + windows_hires_timers = true; + windows_hires_freq = (double) freq.QuadPart; } } @@ -328,7 +280,7 @@ windows_diff (ptimer_system_time *pst1, ptimer_system_time *pst2) { if (windows_hires_timers) - return (pst1->hires.QuadPart - pst2->hires.QuadPart) / windows_hires_msfreq; + return (pst1->hires.QuadPart - pst2->hires.QuadPart) / windows_hires_freq; else return pst1->lores - pst2->lores; } @@ -337,7 +289,7 @@ windows_resolution (void) { if (windows_hires_timers) - return 1.0 / windows_hires_msfreq; + return 1.0 / windows_hires_freq; else return 10; /* according to MSDN */ } @@ -350,8 +302,7 @@ time, yields elapsed time. */ ptimer_system_time start; - /* The most recent elapsed time, calculated by ptimer_measure(). - Measured in milliseconds. */ + /* The most recent elapsed time, calculated by ptimer_measure(). */ double elapsed_last; /* Approximately, the time elapsed between the true start of the @@ -367,10 +318,10 @@ { struct ptimer *pt = xnew0 (struct ptimer); #ifdef IMPL_init - static int init_done; + static bool init_done; if (!init_done) { - init_done = 1; + init_done = true; IMPL_init (); } #endif @@ -388,8 +339,8 @@ } /* Reset timer PT. This establishes the starting point from which - ptimer_measure() will return the number of elapsed milliseconds. - It is allowed to reset a previously used timer. */ + ptimer_measure() will return the elapsed time in seconds. It is + allowed to reset a previously used timer. */ void ptimer_reset (struct ptimer *pt) @@ -402,9 +353,8 @@ /* Measure the elapsed time since timer creation/reset. This causes the timer to internally call clock_gettime (or gettimeofday, etc.) - to update its idea of current time. The time in milliseconds is - returned, but is also stored for later access through - ptimer_read(). + to update its idea of current time. The time is returned, but is + also stored for later access through ptimer_read(). This function handles clock skew, i.e. time that moves backwards is ignored. */ @@ -445,9 +395,9 @@ return elapsed; } -/* Return the most recent elapsed time in milliseconds, as measured - with ptimer_measure. If ptimer_measure has not yet been called - since the timer was created or reset, this returns 0. */ +/* Return the most recent elapsed time measured with ptimer_measure. + If ptimer_measure has not yet been called since the timer was + created or reset, this returns 0. */ double ptimer_read (const struct ptimer *pt) @@ -456,8 +406,8 @@ } /* Return the assessed resolution of the timer implementation, in - milliseconds. This is used by code that tries to substitute a - better value for timers that have returned zero. */ + seconds. This is used by code that tries to substitute a better + value for timers that have returned zero. */ double ptimer_resolution (void) diff -urN wget-1.10.2/src/ptimer.h wget-1.10.2_new/src/ptimer.h --- wget-1.10.2/src/ptimer.h 2005-04-08 20:19:20.000000000 +0200 +++ wget-1.10.2_new/src/ptimer.h 2006-06-27 12:18:18.000000000 +0200 @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -33,13 +33,13 @@ struct ptimer; /* forward declaration; all struct members are private */ -struct ptimer *ptimer_new PARAMS ((void)); -void ptimer_destroy PARAMS ((struct ptimer *)); +struct ptimer *ptimer_new (void); +void ptimer_destroy (struct ptimer *); -void ptimer_reset PARAMS ((struct ptimer *)); -double ptimer_measure PARAMS ((struct ptimer *)); -double ptimer_read PARAMS ((const struct ptimer *)); +void ptimer_reset (struct ptimer *); +double ptimer_measure (struct ptimer *); +double ptimer_read (const struct ptimer *); -double ptimer_resolution PARAMS ((void)); +double ptimer_resolution (void); #endif /* PTIMER_H */ diff -urN wget-1.10.2/src/recur.c wget-1.10.2_new/src/recur.c --- wget-1.10.2/src/recur.c 2005-06-25 16:47:52.000000000 +0200 +++ wget-1.10.2_new/src/recur.c 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Handling of recursive HTTP retrieving. - Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,17 +31,12 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ +#include #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #include #include -#include #include "wget.h" #include "url.h" @@ -53,16 +48,6 @@ #include "hash.h" #include "res.h" #include "convert.h" - -#ifndef errno -extern int errno; -#endif - -extern char *version_string; -extern SUM_SIZE_INT total_downloaded_bytes; - -extern struct hash_table *dl_url_file_map; -extern struct hash_table *downloaded_html_set; /* Functions for maintaining the URL queue. */ @@ -70,7 +55,7 @@ const char *url; /* the URL to download */ const char *referer; /* the referring document */ int depth; /* the depth */ - unsigned int html_allowed :1; /* whether the document is allowed to + bool html_allowed; /* whether the document is allowed to be treated as HTML. */ struct queue_element *next; /* next element in queue */ @@ -105,7 +90,7 @@ static void url_enqueue (struct url_queue *queue, - const char *url, const char *referer, int depth, int html_allowed) + const char *url, const char *referer, int depth, bool html_allowed) { struct queue_element *qel = xnew (struct queue_element); qel->url = url; @@ -129,18 +114,18 @@ queue->head = queue->tail; } -/* Take a URL out of the queue. Return 1 if this operation succeeded, - or 0 if the queue is empty. */ +/* Take a URL out of the queue. Return true if this operation + succeeded, or false if the queue is empty. */ -static int +static bool url_dequeue (struct url_queue *queue, const char **url, const char **referer, int *depth, - int *html_allowed) + bool *html_allowed) { struct queue_element *qel = queue->head; if (!qel) - return 0; + return false; queue->head = queue->head->next; if (!queue->head) @@ -157,13 +142,13 @@ DEBUGP (("Queue count %d, maxcount %d.\n", queue->count, queue->maxcount)); xfree (qel); - return 1; + return true; } -static int download_child_p PARAMS ((const struct urlpos *, struct url *, int, - struct url *, struct hash_table *)); -static int descend_redirect_p PARAMS ((const char *, const char *, int, - struct url *, struct hash_table *)); +static bool download_child_p (const struct urlpos *, struct url *, int, + struct url *, struct hash_table *); +static bool descend_redirect_p (const char *, const char *, int, + struct url *, struct hash_table *); /* Retrieve a part of the web beginning with START_URL. This used to @@ -214,15 +199,16 @@ /* Enqueue the starting URL. Use start_url_parsed->url rather than just URL so we enqueue the canonical form of the URL. */ - url_enqueue (queue, xstrdup (start_url_parsed->url), NULL, 0, 1); + url_enqueue (queue, xstrdup (start_url_parsed->url), NULL, 0, true); string_set_add (blacklist, start_url_parsed->url); while (1) { - int descend = 0; + bool descend = false; char *url, *referer, *file = NULL; - int depth, html_allowed; - int dash_p_leaf_HTML = 0; + int depth; + bool html_allowed; + bool dash_p_leaf_HTML = false; if (opt.quota && total_downloaded_bytes > opt.quota) break; @@ -254,21 +240,18 @@ if (html_allowed && downloaded_html_set && string_set_contains (downloaded_html_set, file)) - descend = 1; + descend = true; } else { int dt = 0; char *redirected = NULL; - int oldrec = opt.recursive; - opt.recursive = 0; - status = retrieve_url (url, &file, &redirected, referer, &dt); - opt.recursive = oldrec; + status = retrieve_url (url, &file, &redirected, referer, &dt, false); if (html_allowed && file && status == RETROK && (dt & RETROKF) && (dt & TEXTHTML)) - descend = 1; + descend = true; if (redirected) { @@ -279,7 +262,7 @@ { if (!descend_redirect_p (redirected, url, depth, start_url_parsed, blacklist)) - descend = 0; + descend = false; else /* Make sure that the old pre-redirect form gets blacklisted. */ @@ -304,7 +287,7 @@ one, but we allow one more level so that the leaf pages that contain frames can be loaded correctly. */ - dash_p_leaf_HTML = 1; + dash_p_leaf_HTML = true; } else { @@ -313,7 +296,7 @@ affords us, so we need to bail out. */ DEBUGP (("Not descending further; at depth %d, max. %d.\n", depth, opt.reclevel)); - descend = 0; + descend = false; } } @@ -322,7 +305,7 @@ if (descend) { - int meta_disallow_follow = 0; + bool meta_disallow_follow = false; struct urlpos *children = get_urls_html (file, url, &meta_disallow_follow); @@ -362,17 +345,21 @@ } } - if (opt.delete_after || (file && !acceptable (file))) + if (file + && (opt.delete_after + || opt.spider /* opt.recursive is implicitely true */ + || !acceptable (file))) { /* Either --delete-after was specified, or we loaded this - otherwise rejected (e.g. by -R) HTML file just so we - could harvest its hyperlinks -- in either case, delete - the local file. */ + (otherwise unneeded because of --spider or rejected by -R) + HTML file just to harvest its hyperlinks -- in either case, + delete the local file. */ DEBUGP (("Removing file due to %s in recursive_retrieve():\n", opt.delete_after ? "--delete-after" : - "recursive rejection criteria")); + (opt.spider ? "--spider" : + "recursive rejection criteria"))); logprintf (LOG_VERBOSE, - (opt.delete_after + (opt.delete_after || opt.spider ? _("Removing %s.\n") : _("Removing %s since it should be rejected.\n")), file); @@ -390,7 +377,8 @@ now. */ { char *d1, *d2; - int d3, d4; + int d3; + bool d4; while (url_dequeue (queue, (const char **)&d1, (const char **)&d2, &d3, &d4)) { @@ -420,13 +408,13 @@ by storing these URLs to BLACKLIST. This may or may not help. It will help if those URLs are encountered many times. */ -static int +static bool download_child_p (const struct urlpos *upos, struct url *parent, int depth, struct url *start_url_parsed, struct hash_table *blacklist) { struct url *u = upos->url; const char *url = u->url; - int u_scheme_like_http; + bool u_scheme_like_http; DEBUGP (("Deciding whether to enqueue \"%s\".\n", url)); @@ -495,7 +483,7 @@ && u->port == start_url_parsed->port && !(opt.page_requisites && upos->link_inline_p)) { - if (!frontcmp (start_url_parsed->dir, u->dir)) + if (!subdir_p (start_url_parsed->dir, u->dir)) { DEBUGP (("Going to \"%s\" would escape \"%s\" with no_parent on.\n", u->dir, start_url_parsed->dir)); @@ -508,7 +496,7 @@ exclusion and inclusion lists. */ if (opt.includes || opt.excludes) { - if (!accdir (u->dir, ALLABS)) + if (!accdir (u->dir)) { DEBUGP (("%s (%s) is excluded/not-included.\n", url, u->dir)); goto out; @@ -585,12 +573,12 @@ download queue. */ DEBUGP (("Decided to load it.\n")); - return 1; + return true; out: DEBUGP (("Decided NOT to load it.\n")); - return 0; + return false; } /* This function determines whether we will consider downloading the @@ -598,13 +586,13 @@ possibly to another host, etc. It is needed very rarely, and thus it is merely a simple-minded wrapper around download_child_p. */ -static int +static bool descend_redirect_p (const char *redirected, const char *original, int depth, struct url *start_url_parsed, struct hash_table *blacklist) { struct url *orig_parsed, *new_parsed; struct urlpos *upos; - int success; + bool success; orig_parsed = url_parse (original, NULL); assert (orig_parsed != NULL); diff -urN wget-1.10.2/src/recur.h wget-1.10.2_new/src/recur.h --- wget-1.10.2/src/recur.h 2003-11-02 20:56:37.000000000 +0100 +++ wget-1.10.2_new/src/recur.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for recur.c. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -40,12 +40,12 @@ struct urlpos; -void recursive_cleanup PARAMS ((void)); -uerr_t retrieve_tree PARAMS ((const char *)); +void recursive_cleanup (void); +uerr_t retrieve_tree (const char *); /* These are really in html-url.c. */ -struct urlpos *get_urls_file PARAMS ((const char *)); -struct urlpos *get_urls_html PARAMS ((const char *, const char *, int *)); -void free_urlpos PARAMS ((struct urlpos *)); +struct urlpos *get_urls_file (const char *); +struct urlpos *get_urls_html (const char *, const char *, bool *); +void free_urlpos (struct urlpos *); #endif /* RECUR_H */ diff -urN wget-1.10.2/src/res.c wget-1.10.2_new/src/res.c --- wget-1.10.2/src/res.c 2005-06-19 15:47:10.000000000 +0200 +++ wget-1.10.2_new/src/res.c 2006-06-27 12:18:18.000000000 +0200 @@ -14,8 +14,8 @@ General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -73,11 +73,7 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ +#include #include #include @@ -90,8 +86,8 @@ struct path_info { char *path; - int allowedp; - int user_agent_exact_p; + bool allowedp; + bool user_agent_exact_p; }; struct robot_specs { @@ -108,22 +104,22 @@ static void match_user_agent (const char *agent, int length, - int *matches, int *exact_match) + bool *matches, bool *exact_match) { if (length == 1 && *agent == '*') { - *matches = 1; - *exact_match = 0; + *matches = true; + *exact_match = false; } else if (BOUNDED_EQUAL_NO_CASE (agent, agent + length, "wget")) { - *matches = 1; - *exact_match = 1; + *matches = true; + *exact_match = true; } else { - *matches = 0; - *exact_match = 0; + *matches = false; + *exact_match = false; } } @@ -132,7 +128,7 @@ static void add_path (struct robot_specs *specs, const char *path_b, const char *path_e, - int allowedp, int exactp) + bool allowedp, bool exactp) { struct path_info pp; if (path_b < path_e && *path_b == '/') @@ -155,8 +151,8 @@ specs->paths[specs->count - 1] = pp; } -/* Recreate SPECS->paths with only those paths that have non-zero - user_agent_exact_p. */ +/* Recreate SPECS->paths with only those paths that have + user_agent_exact_p set to true. */ static void prune_non_exact (struct robot_specs *specs) @@ -226,15 +222,15 @@ const char *p = source; const char *end = source + length; - /* non-zero if last applicable user-agent field matches Wget. */ - int user_agent_applies = 0; + /* true if last applicable user-agent field matches Wget. */ + bool user_agent_applies = false; - /* non-zero if last applicable user-agent field *exactly* matches + /* true if last applicable user-agent field *exactly* matches Wget. */ - int user_agent_exact = 0; + bool user_agent_exact = false; /* whether we ever encountered exact user agent. */ - int found_exact = 0; + bool found_exact = false; /* count of allow/disallow lines in the current "record", i.e. after the last `user-agent' instructions. */ @@ -324,18 +320,18 @@ until it matches, and if that happens, we must not call it any more, until the next record. Hence the other part of the condition. */ - if (record_count != 0 || user_agent_applies == 0) + if (record_count != 0 || user_agent_applies == false) match_user_agent (value_b, value_e - value_b, &user_agent_applies, &user_agent_exact); if (user_agent_exact) - found_exact = 1; + found_exact = true; record_count = 0; } else if (FIELD_IS ("allow")) { if (user_agent_applies) { - add_path (specs, value_b, value_e, 1, user_agent_exact); + add_path (specs, value_b, value_e, true, user_agent_exact); } ++record_count; } @@ -343,11 +339,10 @@ { if (user_agent_applies) { - int allowed = 0; + bool allowed = false; if (value_b == value_e) - /* Empty "disallow" line means everything is - *allowed*! */ - allowed = 1; + /* Empty "disallow" line means everything is *allowed*! */ + allowed = true; add_path (specs, value_b, value_e, allowed, user_agent_exact); } ++record_count; @@ -428,11 +423,11 @@ } \ } while (0) -/* The inner matching engine: return non-zero if RECORD_PATH matches +/* The inner matching engine: return true if RECORD_PATH matches URL_PATH. The rules for matching are described at , section 3.2.2. */ -static int +static bool matches (const char *record_path, const char *url_path) { const char *rp = record_path; @@ -443,13 +438,13 @@ char rc = *rp; char uc = *up; if (!rc) - return 1; + return true; if (!uc) - return 0; + return false; DECODE_MAYBE(rc, rp); DECODE_MAYBE(uc, up); if (rc != uc) - return 0; + return false; } } @@ -457,22 +452,22 @@ matches, return its allow/reject status. If none matches, retrieval is by default allowed. */ -int +bool res_match_path (const struct robot_specs *specs, const char *path) { int i; if (!specs) - return 1; + return true; for (i = 0; i < specs->count; i++) if (matches (specs->paths[i].path, path)) { - int allowedp = specs->paths[i].allowedp; + bool allowedp = specs->paths[i].allowedp; DEBUGP (("%s path %s because of rule `%s'.\n", allowedp ? "Allowing" : "Rejecting", path, specs->paths[i].path)); return allowedp; } - return 1; + return true; } /* Registering the specs. */ @@ -533,9 +528,9 @@ serves URL. The file will be named according to the currently active rules, and the file name will be returned in *file. - Return non-zero if robots were retrieved OK, zero otherwise. */ + Return true if robots were retrieved OK, false otherwise. */ -int +bool res_retrieve_file (const char *url, char **file) { uerr_t err; @@ -543,7 +538,7 @@ logputs (LOG_VERBOSE, _("Loading robots.txt; please ignore errors.\n")); *file = NULL; - err = retrieve_url (robots_url, file, NULL, NULL, NULL); + err = retrieve_url (robots_url, file, NULL, NULL, NULL, false); xfree (robots_url); if (err != RETROK && *file != NULL) @@ -557,20 +552,19 @@ return err == RETROK; } -static int -cleanup_hash_table_mapper (void *key, void *value, void *arg_ignored) -{ - xfree (key); - free_specs (value); - return 0; -} - void res_cleanup (void) { if (registered_specs) { - hash_table_map (registered_specs, cleanup_hash_table_mapper, NULL); + hash_table_iterator iter; + for (hash_table_iterate (registered_specs, &iter); + hash_table_iter_next (&iter); + ) + { + xfree (iter.key); + free_specs (iter.value); + } hash_table_destroy (registered_specs); registered_specs = NULL; } diff -urN wget-1.10.2/src/res.h wget-1.10.2_new/src/res.h --- wget-1.10.2/src/res.h 2002-05-18 04:16:36.000000000 +0200 +++ wget-1.10.2_new/src/res.h 2006-06-27 12:18:18.000000000 +0200 @@ -14,8 +14,8 @@ 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, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -32,16 +32,16 @@ struct robot_specs; -struct robot_specs *res_parse PARAMS ((const char *, int)); -struct robot_specs *res_parse_from_file PARAMS ((const char *)); +struct robot_specs *res_parse (const char *, int); +struct robot_specs *res_parse_from_file (const char *); -int res_match_path PARAMS ((const struct robot_specs *, const char *)); +bool res_match_path (const struct robot_specs *, const char *); -void res_register_specs PARAMS ((const char *, int, struct robot_specs *)); -struct robot_specs *res_get_specs PARAMS ((const char *, int)); +void res_register_specs (const char *, int, struct robot_specs *); +struct robot_specs *res_get_specs (const char *, int); -int res_retrieve_file PARAMS ((const char *, char **)); +bool res_retrieve_file (const char *, char **); -void res_cleanup PARAMS ((void)); +void res_cleanup (void); #endif /* RES_H */ diff -urN wget-1.10.2/src/retr.c wget-1.10.2_new/src/retr.c --- wget-1.10.2/src/retr.c 2005-06-25 17:07:11.000000000 +0200 +++ wget-1.10.2_new/src/retr.c 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* File retrieval. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,16 +31,11 @@ #include #include -#include #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif /* HAVE_STRING_H */ +#include #include #include "wget.h" @@ -50,26 +45,26 @@ #include "url.h" #include "recur.h" #include "ftp.h" +#include "http.h" #include "host.h" #include "connect.h" #include "hash.h" #include "convert.h" #include "ptimer.h" -#ifndef errno -extern int errno; -#endif - /* Total size of downloaded files. Used to enforce quota. */ SUM_SIZE_INT total_downloaded_bytes; +/* Total download time in seconds. */ +double total_download_time; + /* If non-NULL, the stream to which output should be written. This stream is initialized when `-O' is used. */ FILE *output_stream; /* Whether output_document is a regular file we can manipulate, i.e. not `-' or a device file. */ -int output_stream_regular; +bool output_stream_regular; static struct { wgint chunk_bytes; @@ -80,9 +75,7 @@ static void limit_bandwidth_reset (void) { - limit_data.chunk_bytes = 0; - limit_data.chunk_start = 0; - limit_data.sleep_adjust = 0; + xzero (limit_data); } /* Limit the bandwidth by pausing the download for an amount of time. @@ -100,25 +93,25 @@ /* Calculate the amount of time we expect downloading the chunk should take. If in reality it took less time, sleep to compensate for the difference. */ - expected = 1000.0 * limit_data.chunk_bytes / opt.limit_rate; + expected = (double) limit_data.chunk_bytes / opt.limit_rate; if (expected > delta_t) { double slp = expected - delta_t + limit_data.sleep_adjust; double t0, t1; - if (slp < 200) + if (slp < 0.2) { DEBUGP (("deferring a %.2f ms sleep (%s/%.2f).\n", - slp, number_to_static_string (limit_data.chunk_bytes), + slp * 1000, number_to_static_string (limit_data.chunk_bytes), delta_t)); return; } DEBUGP (("\nsleeping %.2f ms for %s bytes, adjust %.2f ms\n", - slp, number_to_static_string (limit_data.chunk_bytes), + slp * 1000, number_to_static_string (limit_data.chunk_bytes), limit_data.sleep_adjust)); t0 = ptimer_read (timer); - xsleep (slp / 1000); + xsleep (slp); t1 = ptimer_measure (timer); /* Due to scheduling, we probably slept slightly longer (or @@ -128,10 +121,10 @@ limit_data.sleep_adjust = slp - (t1 - t0); /* If sleep_adjust is very large, it's likely due to suspension and not clock inaccuracy. Don't enforce those. */ - if (limit_data.sleep_adjust > 500) - limit_data.sleep_adjust = 500; - else if (limit_data.sleep_adjust < -500) - limit_data.sleep_adjust = -500; + if (limit_data.sleep_adjust > 0.5) + limit_data.sleep_adjust = 0.5; + else if (limit_data.sleep_adjust < -0.5) + limit_data.sleep_adjust = -0.5; } limit_data.chunk_bytes = 0; @@ -190,7 +183,7 @@ is incremented by the amount of data read from the network. If QTYWRITTEN is non-NULL, the value it points to is incremented by the amount of data written to disk. The time it took to download - the data (in milliseconds) is stored to ELAPSED. + the data is stored to ELAPSED. The function exits and returns the amount of data read. In case of error while reading data, -1 is returned. In case of error while @@ -215,9 +208,9 @@ continually update the display. When true, smaller timeout values are used so that the gauge can update the display when data arrives slowly. */ - int progress_interactive = 0; + bool progress_interactive = false; - int exact = flags & rb_read_exactly; + bool exact = !!(flags & rb_read_exactly); wgint skip = 0; /* How much data we've read/written. */ @@ -272,7 +265,7 @@ if (opt.read_timeout) { double waittm; - waittm = (ptimer_read (timer) - last_successful_read_tm) / 1000; + waittm = ptimer_read (timer) - last_successful_read_tm; if (waittm + tmout > opt.read_timeout) { /* Don't let total idle time exceed read timeout. */ @@ -306,7 +299,7 @@ if (!write_data (out, dlbuf, ret, &skip, &sum_written)) { ret = -2; - goto out_; + goto out; } } @@ -324,7 +317,7 @@ if (ret < -1) ret = -1; - out_: + out: if (progress) progress_finish (progress, ptimer_read (timer)); @@ -341,22 +334,35 @@ return ret; } -/* Read a hunk of data from FD, up until a terminator. The terminator - is whatever the TERMINATOR function determines it to be; for - example, it can be a line of data, or the head of an HTTP response. - The function returns the data read allocated with malloc. - - In case of error, NULL is returned. In case of EOF and no data - read, NULL is returned and errno set to 0. In case of EOF with - data having been read, the data is returned, but it will - (obviously) not contain the terminator. +/* Read a hunk of data from FD, up until a terminator. The hunk is + limited by whatever the TERMINATOR callback chooses as its + terminator. For example, if terminator stops at newline, the hunk + will consist of a line of data; if terminator stops at two + newlines, it can be used to read the head of an HTTP response. + Upon determining the boundary, the function returns the data (up to + the terminator) in malloc-allocated storage. + + In case of read error, NULL is returned. In case of EOF and no + data read, NULL is returned and errno set to 0. In case of having + read some data, but encountering EOF before seeing the terminator, + the data that has been read is returned, but it will (obviously) + not contain the terminator. + + The TERMINATOR function is called with three arguments: the + beginning of the data read so far, the beginning of the current + block of peeked-at data, and the length of the current block. + Depending on its needs, the function is free to choose whether to + analyze all data or just the newly arrived data. If TERMINATOR + returns NULL, it means that the terminator has not been seen. + Otherwise it should return a pointer to the charactre immediately + following the terminator. The idea is to be able to read a line of input, or otherwise a hunk of text, such as the head of an HTTP request, without crossing the boundary, so that the next call to fd_read etc. reads the data after the hunk. To achieve that, this function does the following: - 1. Peek at available data. + 1. Peek at incoming data. 2. Determine whether the peeked data, along with the previously read data, includes the terminator. @@ -395,18 +401,19 @@ /* First, peek at the available data. */ - pklen = fd_peek (fd, hunk + tail, bufsize - 1 - tail, -1.0); + pklen = fd_peek (fd, hunk + tail, bufsize - 1 - tail, -1); if (pklen < 0) { xfree (hunk); return NULL; } - end = terminator (hunk, tail, pklen); + end = terminator (hunk, hunk + tail, pklen); if (end) { /* The data contains the terminator: we'll drain the data up to the end of the terminator. */ remain = end - (hunk + tail); + assert (remain >= 0); if (remain == 0) { /* No more data needs to be read. */ @@ -428,7 +435,7 @@ how much data we'll get. (Some TCP stacks are notorious for read returning less data than the previous MSG_PEEK.) */ - rdlen = fd_read (fd, hunk + tail, remain, 0.0); + rdlen = fd_read (fd, hunk + tail, remain, 0); if (rdlen < 0) { xfree_null (hunk); @@ -476,11 +483,11 @@ } static const char * -line_terminator (const char *hunk, int oldlen, int peeklen) +line_terminator (const char *start, const char *peeked, int peeklen) { - const char *p = memchr (hunk + oldlen, '\n', peeklen); + const char *p = memchr (peeked, '\n', peeklen); if (p) - /* p+1 because we want the line to include '\n' */ + /* p+1 because the line must include '\n' */ return p + 1; return NULL; } @@ -504,18 +511,22 @@ return fd_read_hunk (fd, line_terminator, 128, FD_READ_LINE_MAX); } -/* Return a printed representation of the download rate, as - appropriate for the speed. If PAD is non-zero, strings will be - padded to the width of 7 characters (xxxx.xx). */ -char * -retr_rate (wgint bytes, double msecs, int pad) +/* Return a printed representation of the download rate, along with + the units appropriate for the download speed. */ + +const char * +retr_rate (wgint bytes, double secs) { static char res[20]; static const char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" }; - int units = 0; + int units; - double dlrate = calc_rate (bytes, msecs, &units); - sprintf (res, pad ? "%7.2f %s" : "%.2f %s", dlrate, rate_names[units]); + 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", + dlrate >= 99.95 ? 0 : dlrate >= 9.995 ? 1 : 2, + dlrate, rate_names[units]); return res; } @@ -527,22 +538,23 @@ UNITS is zero for B/s, one for KB/s, two for MB/s, and three for GB/s. */ + double -calc_rate (wgint bytes, double msecs, int *units) +calc_rate (wgint bytes, double secs, int *units) { double dlrate; - assert (msecs >= 0); + assert (secs >= 0); assert (bytes >= 0); - if (msecs == 0) + if (secs == 0) /* If elapsed time is exactly zero, it means we're under the resolution of the timer. This can easily happen on systems that use time() for the timer. Since the interval lies between 0 and the timer's resolution, assume half the resolution. */ - msecs = ptimer_resolution () / 2.0; + secs = ptimer_resolution () / 2.0; - dlrate = 1000.0 * bytes / msecs; + dlrate = bytes / secs; if (dlrate < 1024.0) *units = 0; else if (dlrate < 1024.0 * 1024.0) @@ -564,7 +576,7 @@ #define MAX_REDIRECTIONS 20 #define SUSPEND_POST_DATA do { \ - post_data_suspended = 1; \ + post_data_suspended = true; \ saved_post_data = opt.post_data; \ saved_post_file_name = opt.post_file_name; \ opt.post_data = NULL; \ @@ -576,11 +588,11 @@ { \ opt.post_data = saved_post_data; \ opt.post_file_name = saved_post_file_name; \ - post_data_suspended = 0; \ + post_data_suspended = false; \ } \ } while (0) -static char *getproxy PARAMS ((struct url *)); +static char *getproxy (struct url *); /* Retrieve the given URL. Decides which loop to call -- HTTP, FTP, FTP, proxy, etc. */ @@ -590,18 +602,19 @@ uerr_t retrieve_url (const char *origurl, char **file, char **newloc, - const char *refurl, int *dt) + const char *refurl, int *dt, bool recursive) { uerr_t result; char *url; - int location_changed, dummy; + bool location_changed; + int dummy; char *mynewloc, *proxy; struct url *u, *proxy_url; int up_error_code; /* url parse error code */ char *local_file; int redirection_count = 0; - int post_data_suspended = 0; + bool post_data_suspended = false; char *saved_post_data = NULL; char *saved_post_file_name = NULL; @@ -671,13 +684,12 @@ /* If this is a redirection, temporarily turn off opt.ftp_glob and opt.recursive, both being undesirable when following redirects. */ - int oldrec = opt.recursive, oldglob = opt.ftp_glob; + bool oldrec = recursive, glob = opt.ftp_glob; if (redirection_count) - opt.recursive = opt.ftp_glob = 0; + oldrec = glob = false; - result = ftp_loop (u, dt, proxy_url); - opt.recursive = oldrec; - opt.ftp_glob = oldglob; + result = ftp_loop (u, dt, proxy_url, recursive, glob); + recursive = oldrec; /* There is a possibility of having HTTP being redirected to FTP. In these cases we must decide whether the text is HTML @@ -801,14 +813,14 @@ return result; } -/* Find the URLs in the file and call retrieve_url() for each of - them. If HTML is non-zero, treat the file as HTML, and construct - the URLs accordingly. +/* Find the URLs in the file and call retrieve_url() for each of them. + If HTML is true, treat the file as HTML, and construct the URLs + accordingly. If opt.recursive is set, call retrieve_tree() for each file. */ uerr_t -retrieve_from_file (const char *file, int html, int *count) +retrieve_from_file (const char *file, bool html, int *count) { uerr_t status; struct urlpos *url_list, *cur_url; @@ -832,10 +844,20 @@ break; } if ((opt.recursive || opt.page_requisites) - && cur_url->url->scheme != SCHEME_FTP) - status = retrieve_tree (cur_url->url->url); + && (cur_url->url->scheme != SCHEME_FTP || opt.use_proxy)) + { + int old_follow_ftp = opt.follow_ftp; + + /* Turn opt.follow_ftp on in case of recursive FTP retrieval */ + if (cur_url->url->scheme == SCHEME_FTP) + opt.follow_ftp = 1; + + status = retrieve_tree (cur_url->url->url); + + opt.follow_ftp = old_follow_ftp; + } else - status = retrieve_url (cur_url->url->url, &filename, &new_file, NULL, &dt); + status = retrieve_url (cur_url->url->url, &filename, &new_file, NULL, &dt, opt.recursive); if (filename && opt.delete_after && file_exists_p (filename)) { @@ -874,12 +896,12 @@ void sleep_between_retrievals (int count) { - static int first_retrieval = 1; + static bool first_retrieval = true; if (first_retrieval) { /* Don't sleep before the very first retrieval. */ - first_retrieval = 0; + first_retrieval = false; return; } @@ -888,7 +910,7 @@ /* If opt.waitretry is specified and this is a retry, wait for COUNT-1 number of seconds, or for opt.waitretry seconds. */ if (count <= opt.waitretry) - xsleep (count - 1.0); + xsleep (count - 1); else xsleep (opt.waitretry); } @@ -902,9 +924,9 @@ else { /* Sleep a random amount of time averaging in opt.wait - seconds. The sleeping amount ranges from 0 to - opt.wait*2, inclusive. */ - double waitsecs = 2 * opt.wait * random_float (); + seconds. The sleeping amount ranges from 0.5*opt.wait to + 1.5*opt.wait. */ + double waitsecs = (0.5 + random_float ()) * opt.wait; DEBUGP (("sleep_between_retrievals: avg=%f,sleep=%f\n", opt.wait, waitsecs)); xsleep (waitsecs); @@ -952,7 +974,7 @@ rename(fname, to); } -static int no_proxy_match PARAMS ((const char *, const char **)); +static bool no_proxy_match (const char *, const char **); /* Return the URL of the proxy appropriate for url U. */ @@ -965,7 +987,7 @@ if (!opt.use_proxy) return NULL; - if (!no_proxy_match (u->host, (const char **)opt.no_proxy)) + if (no_proxy_match (u->host, (const char **)opt.no_proxy)) return NULL; switch (u->scheme) @@ -1001,11 +1023,11 @@ } /* Should a host be accessed through proxy, concerning no_proxy? */ -static int +static bool no_proxy_match (const char *host, const char **no_proxy) { if (!no_proxy) - return 1; + return false; else - return !sufmatch (no_proxy, host); + return sufmatch (no_proxy, host); } diff -urN wget-1.10.2/src/retr.h wget-1.10.2_new/src/retr.h --- wget-1.10.2/src/retr.h 2005-03-20 16:07:40.000000000 +0100 +++ wget-1.10.2_new/src/retr.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for retr.c. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -30,39 +30,35 @@ #ifndef RETR_H #define RETR_H +/* These global vars should be made static to retr.c and exported via + functions! */ +extern SUM_SIZE_INT total_downloaded_bytes; +extern double total_download_time; +extern FILE *output_stream; +extern bool output_stream_regular; + /* Flags for fd_read_body. */ enum { rb_read_exactly = 1, rb_skip_startpos = 2 }; -int fd_read_body PARAMS ((int, FILE *, wgint, wgint, wgint *, wgint *, double *, - int)); - -typedef const char *(*hunk_terminator_t) PARAMS ((const char *, int, int)); - -char *fd_read_hunk PARAMS ((int, hunk_terminator_t, long, long)); -char *fd_read_line PARAMS ((int)); - -uerr_t retrieve_url PARAMS ((const char *, char **, char **, - const char *, int *)); -uerr_t retrieve_from_file PARAMS ((const char *, int, int *)); - -char *retr_rate PARAMS ((wgint, double, int)); -double calc_rate PARAMS ((wgint, double, int *)); -void printwhat PARAMS ((int, int)); +int fd_read_body (int, FILE *, wgint, wgint, wgint *, wgint *, double *, int); -void sleep_between_retrievals PARAMS ((int)); +typedef const char *(*hunk_terminator_t) (const char *, const char *, int); -void rotate_backups PARAMS ((const char *)); +char *fd_read_hunk (int, hunk_terminator_t, long, long); +char *fd_read_line (int); -/* Because there's no http.h. */ +uerr_t retrieve_url (const char *, char **, char **, const char *, int *, bool); +uerr_t retrieve_from_file (const char *, bool, int *); -struct url; +const char *retr_rate (wgint, double); +double calc_rate (wgint, double, int *); +void printwhat (int, int); -uerr_t http_loop PARAMS ((struct url *, char **, char **, const char *, - int *, struct url *)); -void save_cookies PARAMS ((void)); +void sleep_between_retrievals (int); +void rotate_backups (const char *); #endif /* RETR_H */ diff -urN wget-1.10.2/src/snprintf.c wget-1.10.2_new/src/snprintf.c --- wget-1.10.2/src/snprintf.c 2005-04-17 18:53:55.000000000 +0200 +++ wget-1.10.2_new/src/snprintf.c 2006-06-27 12:18:18.000000000 +0200 @@ -78,7 +78,6 @@ * actually print args for %g and %e * * Hrvoje Niksic 2005-04-15 - * use the PARAMS macro to handle prototypes. * write function definitions in the ansi2knr-friendly way. * if string precision is specified, don't read VALUE past it. * fix bug in fmtfp that caused 0.01 to be printed as 0.1. @@ -105,31 +104,11 @@ #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #include /* for NULL */ -/* varargs declarations: */ - -#if defined(HAVE_STDARG_H) -# include -# define HAVE_STDARGS /* let's hope that works everywhere (mj) */ -# define VA_LOCAL_DECL va_list ap -# define VA_START(f) va_start(ap, f) -# define VA_SHIFT(v,t) ; /* no-op for ANSI */ -# define VA_END va_end(ap) -#else -# include -# undef HAVE_STDARGS -# define VA_LOCAL_DECL va_list ap -# define VA_START(f) va_start(ap) /* f is ignored! */ -# define VA_SHIFT(v,t) v = va_arg(ap,t) -# define VA_END va_end(ap) -#endif +#include #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double @@ -150,28 +129,18 @@ # define vsnprintf test_vsnprintf #endif -#ifdef HAVE_STDARGS int snprintf (char *str, size_t count, const char *fmt, ...); int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); -#else -int snprintf (); -int vsnprintf (); -#endif - -#ifndef PARAMS -# define PARAMS(x) x -#endif -static int dopr PARAMS ((char *buffer, size_t maxlen, const char *format, - va_list args)); -static int fmtstr PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - const char *value, int flags, int min, int max)); -static int fmtint PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - LLONG value, int base, int min, int max, int flags)); -static int fmtfp PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags)); -static int dopr_outch PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - char c)); +static int dopr (char *buffer, size_t maxlen, const char *format, + va_list args); +static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, + const char *value, int flags, int min, int max); +static int fmtint (char *buffer, size_t *currlen, size_t maxlen, + LLONG value, int base, int min, int max, int flags); +static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c); /* * dopr(): poor man's version of doprintf @@ -208,8 +177,7 @@ #define MAX(p,q) ((p >= q) ? p : q) #define MIN(p,q) ((p <= q) ? p : q) -static int -dopr (char *buffer, size_t maxlen, const char *format, va_list args) +static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) { char ch; LLONG value; @@ -500,9 +468,8 @@ return total; } -static int -fmtstr (char *buffer, size_t *currlen, size_t maxlen, - const char *value, int flags, int min, int max) +static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, + const char *value, int flags, int min, int max) { int padlen, strln; /* amount to pad */ int cnt = 0; @@ -518,7 +485,8 @@ else /* When precision is specified, don't read VALUE past precision. */ /*strln = strnlen (value, max);*/ - for (strln = 0; strln < max && value[strln]; ++strln); + for (strln = 0; strln < max && value[strln]; ++strln) + ; padlen = min - strln; if (padlen < 0) padlen = 0; @@ -545,9 +513,8 @@ /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ -static int -fmtint (char *buffer, size_t *currlen, size_t maxlen, - LLONG value, int base, int min, int max, int flags) +static int fmtint (char *buffer, size_t *currlen, size_t maxlen, + LLONG value, int base, int min, int max, int flags) { int signvalue = 0; unsigned LLONG uvalue; @@ -641,8 +608,7 @@ return total; } -static LDOUBLE -abs_val (LDOUBLE value) +static LDOUBLE abs_val (LDOUBLE value) { LDOUBLE result = value; @@ -652,8 +618,7 @@ return result; } -static LDOUBLE -pow10 (int exp) +static LDOUBLE pow10_int (int exp) { LDOUBLE result = 1; @@ -666,8 +631,7 @@ return result; } -static LLONG -round (LDOUBLE value) +static LLONG round_int (LDOUBLE value) { LLONG intpart; @@ -679,9 +643,8 @@ return intpart; } -static int -fmtfp (char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags) +static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; LDOUBLE ufvalue; @@ -766,12 +729,12 @@ max = MAX_DIGITS; /* Factor of 10 with the needed number of digits, e.g. 1000 for max==3 */ - mask10 = pow10 (max); + mask10 = pow10_int (max); /* We "cheat" by converting the fractional part to integer by * multiplying by a factor of 10 */ - fracpart = round (mask10 * (ufvalue - intpart)); + fracpart = round_int (mask10 * (ufvalue - intpart)); if (fracpart >= mask10) { @@ -876,8 +839,7 @@ return total; } -static int -dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) +static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) { if (*currlen + 1 < maxlen) buffer[(*currlen)++] = c; @@ -885,8 +847,7 @@ } #ifndef HAVE_VSNPRINTF -int -vsnprintf (char *str, size_t count, const char *fmt, va_list args) +int vsnprintf (char *str, size_t count, const char *fmt, va_list args) { if (str != NULL) str[0] = 0; @@ -895,23 +856,14 @@ #endif /* !HAVE_VSNPRINTF */ #ifndef HAVE_SNPRINTF -int -snprintf (char *str, size_t count,const char *fmt,...) +int snprintf (char *str, size_t count, const char *fmt,...) { -#ifndef HAVE_STDARGS - char *str; - size_t count; - char *fmt; -#endif - VA_LOCAL_DECL; + va_list ap; int total; - - VA_START (fmt); - VA_SHIFT (str, char *); - VA_SHIFT (count, size_t ); - VA_SHIFT (fmt, char *); - total = vsnprintf(str, count, fmt, ap); - VA_END; + + va_start (ap, fmt); + total = vsnprintf (str, count, fmt, ap); + va_end (ap); return total; } #endif /* !HAVE_SNPRINTF */ @@ -923,8 +875,7 @@ # define LONG_STRING 1024 # endif -int -main (void) +int main (void) { char buf1[LONG_STRING]; char buf2[LONG_STRING]; diff -urN wget-1.10.2/src/ssl.h wget-1.10.2_new/src/ssl.h --- wget-1.10.2/src/ssl.h 2005-05-11 17:52:27.000000000 +0200 +++ wget-1.10.2_new/src/ssl.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,6 +1,6 @@ /* SSL support. - Copyright (C) 2000 Free Software Foundation, Inc. - Contributed by Christian Fraenkel. + Copyright (C) 2000-2005 Free Software Foundation, Inc. + Originally contributed by Christian Fraenkel. This file is part of GNU Wget. @@ -31,8 +31,8 @@ #ifndef GEN_SSLFUNC_H #define GEN_SSLFUNC_H -int ssl_init PARAMS ((void)); -int ssl_connect PARAMS ((int)); -int ssl_check_certificate PARAMS ((int, const char *)); +bool ssl_init (void); +bool ssl_connect (int); +bool ssl_check_certificate (int, const char *); #endif /* GEN_SSLFUNC_H */ diff -urN wget-1.10.2/src/sysdep.h wget-1.10.2_new/src/sysdep.h --- wget-1.10.2/src/sysdep.h 2005-07-05 19:36:35.000000000 +0200 +++ wget-1.10.2_new/src/sysdep.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Dirty system-dependent hacks. - Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -33,18 +33,8 @@ #ifndef SYSDEP_H #define SYSDEP_H -/* We need these to be playing with various stuff. */ -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else /* not TIME_WITH_SYS_TIME_H */ -#ifdef HAVE_SYS_TIME_H -# include -#else /* not HAVE_SYS_TIME_H */ -# include -#endif /* HAVE_SYS_TIME_H */ -#endif /* TIME_WITH_SYS_TIME_H */ - +/* Must include these, so we can test for the missing stat macros and + define them as necessary. */ #include #include @@ -53,34 +43,41 @@ #endif #ifdef WINDOWS -/* Windows doesn't have some functions. Include mswindows.h so we get - their declarations, as well as some additional declarations and - macros. This must come first, so it can set things up. */ -#include -#endif /* WINDOWS */ - -/* Watcom-specific stuff. In practice this is probably specific to - Windows, although Watcom exists under other OS's too. For that - reason, we keep this here. */ - -#ifdef __WATCOMC__ -/* Watcom has its own alloca() defined in malloc.h malloc.h needs to - be included in the sources to prevent 'undefined external' errors - at the link phase. */ -# include -/* io.h defines unlink() and chmod(). We put this here because it's - way too obscure to require all the .c files to observe. */ -# include -#endif /* __WATCOMC__ */ +/* Windows doesn't have some functions normally found on Unix-like + systems, such as strcasecmp, strptime, etc. Include mswindows.h so + we get the declarations for their replacements in mswindows.c, as + well as to pick up Windows-specific includes and constants. To be + able to test for such features, the file must be included as early + as possible. */ +# include "mswindows.h" +#endif + +/* Provide support for C99-type boolean type "bool". This blurb comes + straight from the Autoconf 2.59 manual. */ +#if HAVE_STDBOOL_H +# include +#else +# if ! HAVE__BOOL +# ifdef __cplusplus +typedef bool _Bool; +# else +typedef unsigned char _Bool; +# endif +# endif +# define bool _Bool +# define false 0 +# define true 1 +# define __bool_true_false_are_defined 1 +#endif /* Needed for compilation under OS/2: */ #ifdef __EMX__ -#ifndef S_ISLNK -# define S_ISLNK(m) 0 -#endif -#ifndef lstat -# define lstat stat -#endif +# ifndef S_ISLNK +# define S_ISLNK(m) 0 +# endif +# ifndef lstat +# define lstat stat +# endif #endif /* __EMX__ */ /* Reportedly, stat() macros are broken on some old systems. Those @@ -88,7 +85,7 @@ new code to handle it. However, I will add code for *missing* macros, and the following - are missing from many systems. */ + are reportedly missing from many systems. */ #ifndef S_ISLNK # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) #endif @@ -99,15 +96,6 @@ # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) #endif -/* Bletch! SPARC compiler doesn't define sparc (needed by - arpa/nameser.h) when in -Xc mode. Luckily, it always defines - __sparc. */ -#ifdef __sparc -#ifndef sparc -#define sparc -#endif -#endif - /* These are needed so we can #define struct_stat to struct _stati64 under Windows. */ #ifndef struct_stat @@ -117,14 +105,14 @@ # define struct_fstat struct stat #endif -#ifdef HAVE_LIMITS_H -# include -#endif +/* For CHAR_BIT, LONG_MAX, etc. */ +#include #ifndef CHAR_BIT # define CHAR_BIT 8 #endif +/* Used by wget.h to define SIZEOF_WGINT. */ #ifndef LONG_MAX # define LONG_MAX ((long) ~((unsigned long)1 << (CHAR_BIT * sizeof (long) - 1))) #endif @@ -132,57 +120,33 @@ # define LLONG_MAX ((long long) ~((unsigned long long)1 << (CHAR_BIT * sizeof (long long) - 1))) #endif -/* These are defined in cmpt.c if missing, therefore it's generally - safe to declare their parameters. */ -#ifndef HAVE_STRERROR -char *strerror (); -#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_STRSTR -char *strstr (); -#endif #ifndef HAVE_STRPTIME char *strptime (); #endif +#ifndef HAVE_TIMEGM +# include +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 (); #endif #ifndef HAVE_VSNPRINTF int vsnprintf (); #endif -#ifndef HAVE_MEMMOVE -void *memmove (); -#endif -#ifndef HAVE_TIMEGM -time_t timegm (struct tm *); -#endif - -/* SunOS brain damage -- for some reason, SunOS header files fail to - declare the functions below, which causes all kinds of problems, - most notably compilation errors when using pointer arithmetic on - their return values. - - This used to be only within `#ifdef STDC_HEADERS', but it got - tripped on other systems (AIX), thus causing havoc. Fortunately, - SunOS appears to be the only system braindamaged that badly, so I - added an extra `#ifdef sun' guard. */ -#ifndef STDC_HEADERS -#ifdef sun -#ifndef __SVR4 /* exclude Solaris */ -char *strstr (); -char *strchr (); -char *strrchr (); -char *strtok (); -char *strdup (); -void *memcpy (); -#endif /* not __SVR4 */ -#endif /* sun */ -#endif /* not STDC_HEADERS */ /* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't provide MAP_FAILED, a symbolic constant for the value returned by @@ -194,19 +158,12 @@ # define MAP_FAILED ((void *) -1) #endif -/* Enable system fnmatch only on systems where fnmatch.h is usable and - which are known to have a non-broken fnmatch implementation. - Currently those include glibc-based systems and Solaris. One could - add more, but fnmatch is not that large, so it might be better to - play it safe. */ +/* 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 -# if defined __GLIBC__ && __GLIBC__ >= 2 -# define SYSTEM_FNMATCH -# endif -# ifdef solaris -# define SYSTEM_FNMATCH -# endif -#endif /* HAVE_WORKING_FNMATCH_H */ +# define SYSTEM_FNMATCH +#endif #ifdef SYSTEM_FNMATCH # include @@ -223,8 +180,7 @@ # define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ # define FNM_NOMATCH 1 -/* Declare the function minimally. */ -int fnmatch (); +int fnmatch (const char *, const char *, int); #endif /* Provide sig_atomic_t if the system doesn't. */ @@ -254,4 +210,9 @@ # endif #endif +/* If uintptr_t isn't defined, simply typedef it to unsigned long. */ +#ifndef HAVE_UINTPTR_T +typedef unsigned long uintptr_t; +#endif + #endif /* SYSDEP_H */ diff -urN wget-1.10.2/src/test.c wget-1.10.2_new/src/test.c --- wget-1.10.2/src/test.c 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/src/test.c 2006-06-27 12:18:18.000000000 +0200 @@ -0,0 +1,81 @@ +/* Unit testing. + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Wget. + +GNU Wget is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GNU Wget is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +In addition, as a special exception, the Free Software Foundation +gives permission to link the code of its release of Wget with the +OpenSSL project's "OpenSSL" library (or with modified versions of it +that use the same license as the "OpenSSL" library), and distribute +the linked executables. You must obey the GNU General Public License +in all respects for all of the code used other than "OpenSSL". If you +modify this file, you may extend this exception to your version of the +file, but you are not obligated to do so. If you do not wish to do +so, delete this exception statement from your version. */ + +#include + +#include "test.h" + +#ifndef TESTING +#error "TESTING not set!!!" +#endif + +const char *test_parse_content_disposition(); +const char *test_subdir_p(); +const char *test_dir_matches_p(); +const char *test_cmd_spec_restrict_file_names(); +const char *test_append_uri_pathel(); + +int tests_run; + +static const char * +all_tests() +{ + mu_run_test (test_parse_content_disposition); + mu_run_test (test_subdir_p); + mu_run_test (test_dir_matches_p); + mu_run_test (test_cmd_spec_restrict_file_names); + mu_run_test (test_append_uri_pathel); + + return NULL; +} + + +int +main (void) +{ + const char *result = all_tests(); + + if (result != NULL) + { + puts (result); + } + else + { + printf ("ALL TESTS PASSED\n"); + } + + printf ("Tests run: %d\n", tests_run); + + return result != 0; +} + +/* + * vim: et ts=2 sw=2 + */ + diff -urN wget-1.10.2/src/test.h wget-1.10.2_new/src/test.h --- wget-1.10.2/src/test.h 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/src/test.h 2006-06-27 12:18:18.000000000 +0200 @@ -0,0 +1,45 @@ +/* Unit testing declarations. + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Wget. + +GNU Wget is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GNU Wget is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +In addition, as a special exception, the Free Software Foundation +gives permission to link the code of its release of Wget with the +OpenSSL project's "OpenSSL" library (or with modified versions of it +that use the same license as the "OpenSSL" library), and distribute +the linked executables. You must obey the GNU General Public License +in all respects for all of the code used other than "OpenSSL". If you +modify this file, you may extend this exception to your version of the +file, but you are not obligated to do so. If you do not wish to do +so, delete this exception statement from your version. */ + +#ifndef TEST_H +#define TEST_H + +/* from MinUnit */ +#define mu_assert(message, test) do { if (!(test)) return message; } while (0) +#define mu_run_test(test) do { const char *message = test(); tests_run++; \ + if (message) return message; } while (0) + +extern int tests_run; + +#endif /* TEST_H */ + +/* + * vim: et ts=2 sw=2 + */ + diff -urN wget-1.10.2/src/url.c wget-1.10.2_new/src/url.c --- wget-1.10.2/src/url.c 2005-07-01 19:16:07.000000000 +0200 +++ wget-1.10.2_new/src/url.c 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* URL handling. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,12 +31,7 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif -#include +#include #ifdef HAVE_UNISTD_H # include #endif @@ -48,26 +43,37 @@ #include "url.h" #include "host.h" /* for is_valid_ipv6_address */ -#ifndef errno -extern int errno; +#ifdef TESTING +#include "test.h" #endif +enum { + scm_disabled = 1, /* for https when OpenSSL fails to init. */ + scm_has_params = 2, /* whether scheme has ;params */ + scm_has_query = 4, /* whether scheme has ?query */ + scm_has_fragment = 8 /* whether scheme has #fragment */ +}; + struct scheme_data { + /* Short name of the scheme, such as "http" or "ftp". */ const char *name; + /* Leading string that identifies the scheme, such as "https://". */ const char *leading_string; + /* Default port of the scheme when none is specified. */ int default_port; - int enabled; + /* Various flags. */ + int flags; }; /* Supported schemes: */ static struct scheme_data supported_schemes[] = { - { "http", "http://", DEFAULT_HTTP_PORT, 1 }, + { "http", "http://", DEFAULT_HTTP_PORT, scm_has_query|scm_has_fragment }, #ifdef HAVE_SSL - { "https", "https://", DEFAULT_HTTPS_PORT, 1 }, + { "https", "https://", DEFAULT_HTTPS_PORT, scm_has_query|scm_has_fragment }, #endif - { "ftp", "ftp://", DEFAULT_FTP_PORT, 1 }, + { "ftp", "ftp://", DEFAULT_FTP_PORT, scm_has_params|scm_has_fragment }, /* SCHEME_INVALID */ { NULL, NULL, -1, 0 } @@ -75,7 +81,7 @@ /* Forward declarations: */ -static int path_simplify PARAMS ((char *)); +static bool path_simplify (char *); /* Support for escaping and unescaping of URL strings. */ @@ -194,12 +200,12 @@ /* The core of url_escape_* functions. Escapes the characters that match the provided mask in urlchr_table. - If ALLOW_PASSTHROUGH is non-zero, a string with no unsafe chars - will be returned unchanged. If ALLOW_PASSTHROUGH is zero, a - freshly allocated string will be returned in all cases. */ + If ALLOW_PASSTHROUGH is true, a string with no unsafe chars will be + returned unchanged. If ALLOW_PASSTHROUGH is false, a freshly + allocated string will be returned in all cases. */ static char * -url_escape_1 (const char *s, unsigned char mask, int allow_passthrough) +url_escape_1 (const char *s, unsigned char mask, bool allow_passthrough) { const char *p1; char *p2, *newstr; @@ -214,7 +220,7 @@ return allow_passthrough ? (char *)s : xstrdup (s); newlen = (p1 - s) + addition; - newstr = (char *)xmalloc (newlen + 1); + newstr = xmalloc (newlen + 1); p1 = s; p2 = newstr; @@ -243,7 +249,7 @@ char * url_escape (const char *s) { - return url_escape_1 (s, urlchr_unsafe, 0); + return url_escape_1 (s, urlchr_unsafe, false); } /* URL-escape the unsafe characters (see urlchr_table) in a given @@ -252,30 +258,30 @@ static char * url_escape_allow_passthrough (const char *s) { - return url_escape_1 (s, urlchr_unsafe, 1); + return url_escape_1 (s, urlchr_unsafe, true); } /* Decide whether the char at position P needs to be encoded. (It is not enough to pass a single char *P because the function may need to inspect the surrounding context.) - Return 1 if the char should be escaped as %XX, 0 otherwise. */ + Return true if the char should be escaped as %XX, false otherwise. */ -static inline int +static inline bool char_needs_escaping (const char *p) { if (*p == '%') { if (ISXDIGIT (*(p + 1)) && ISXDIGIT (*(p + 2))) - return 0; + return false; else /* Garbled %.. sequence: encode `%'. */ - return 1; + return true; } else if (URL_UNSAFE_CHAR (*p) && !URL_RESERVED_CHAR (*p)) - return 1; + return true; else - return 0; + return false; } /* Translate a %-escaped (but possibly non-conformant) input string S @@ -413,7 +419,7 @@ if (0 == strncasecmp (url, supported_schemes[i].leading_string, strlen (supported_schemes[i].leading_string))) { - if (supported_schemes[i].enabled) + if (!(supported_schemes[i].flags & scm_disabled)) return (enum url_scheme) i; else return SCHEME_INVALID; @@ -428,14 +434,14 @@ currently implemented, it returns true if URL begins with [-+a-zA-Z0-9]+: . */ -int +bool url_has_scheme (const char *url) { const char *p = url; /* The first char must be a scheme char. */ if (!*p || !SCHEME_CHAR (*p)) - return 0; + return false; ++p; /* Followed by 0 or more scheme chars. */ while (*p && SCHEME_CHAR (*p)) @@ -453,7 +459,7 @@ void scheme_disable (enum url_scheme scheme) { - supported_schemes[scheme].enabled = 0; + supported_schemes[scheme].flags |= scm_disabled; } /* Skip the username and password, if present in the URL. The @@ -476,18 +482,18 @@ /* Parse credentials contained in [BEG, END). The region is expected to have come from a URL and is unescaped. */ -static int +static bool parse_credentials (const char *beg, const char *end, char **user, char **passwd) { char *colon; const char *userend; if (beg == end) - return 0; /* empty user name */ + return false; /* empty user name */ colon = memchr (beg, ':', end - beg); if (colon == beg) - return 0; /* again empty user name */ + return false; /* again empty user name */ if (colon) { @@ -502,11 +508,12 @@ } *user = strdupdelim (beg, userend); url_unescape (*user); - return 1; + return true; } /* Used by main.c: detect URLs written using the "shorthand" URL forms - popularized by Netscape and NcFTP. HTTP shorthands look like this: + originally popularized by Netscape and NcFTP. HTTP shorthands look + like this: www.foo.com[:port]/dir/file -> http://www.foo.com[:port]/dir/file www.foo.com[:port] -> http://www.foo.com[:port] @@ -522,78 +529,49 @@ rewrite_shorthand_url (const char *url) { const char *p; + char *ret; if (url_scheme (url) != SCHEME_INVALID) return NULL; /* Look for a ':' or '/'. The former signifies NcFTP syntax, the latter Netscape. */ - for (p = url; *p && *p != ':' && *p != '/'; p++) - ; - + p = strpbrk (url, ":/"); if (p == url) return NULL; /* If we're looking at "://", it means the URL uses a scheme we don't support, which may include "https" when compiled without SSL support. Don't bogusly rewrite such URLs. */ - if (p[0] == ':' && p[1] == '/' && p[2] == '/') + if (p && p[0] == ':' && p[1] == '/' && p[2] == '/') return NULL; - if (*p == ':') + if (p && *p == ':') { - const char *pp; - char *res; - /* If the characters after the colon and before the next slash - or end of string are all digits, it's HTTP. */ - int digits = 0; - for (pp = p + 1; ISDIGIT (*pp); pp++) - ++digits; - if (digits > 0 && (*pp == '/' || *pp == '\0')) + /* Colon indicates ftp, as in foo.bar.com:path. Check for + special case of http port number ("localhost:10000"). */ + int digits = strspn (p + 1, "0123456789"); + if (digits && (p[1 + digits] == '/' || p[1 + digits] == '\0')) goto http; - /* Prepend "ftp://" to the entire URL... */ - res = xmalloc (6 + strlen (url) + 1); - sprintf (res, "ftp://%s", url); - /* ...and replace ':' with '/'. */ - res[6 + (p - url)] = '/'; - return res; + /* Turn "foo.bar.com:path" to "ftp://foo.bar.com/path". */ + ret = aprintf ("ftp://%s", url); + ret[6 + (p - url)] = '/'; } else { - char *res; http: - /* Just prepend "http://" to what we have. */ - res = xmalloc (7 + strlen (url) + 1); - sprintf (res, "http://%s", url); - return res; + /* Just prepend "http://" to URL. */ + ret = aprintf ("http://%s", url); } + return ret; } -static void split_path PARAMS ((const char *, char **, char **)); +static void split_path (const char *, char **, char **); /* Like strpbrk, with the exception that it returns the pointer to the terminating zero (end-of-string aka "eos") if no matching character - is found. - - Although I normally balk at Gcc-specific optimizations, it probably - makes sense here: glibc has optimizations that detect strpbrk being - called with literal string as ACCEPT and inline the search. That - optimization is defeated if strpbrk is hidden within the call to - another function. (And no, making strpbrk_or_eos inline doesn't - help because the check for literal accept is in the - preprocessor.) */ - -#if defined(__GNUC__) && __GNUC__ >= 3 - -#define strpbrk_or_eos(s, accept) ({ \ - char *SOE_p = strpbrk (s, accept); \ - if (!SOE_p) \ - SOE_p = strchr (s, '\0'); \ - SOE_p; \ -}) - -#else /* not __GNUC__ or old gcc */ + is found. */ static inline char * strpbrk_or_eos (const char *s, const char *accept) @@ -603,22 +581,38 @@ p = strchr (s, '\0'); return p; } -#endif /* not __GNUC__ or old gcc */ -/* Turn STR into lowercase; return non-zero if a character was - actually changed. */ +/* Turn STR into lowercase; return true if a character was actually + changed. */ -static int +static bool lowercase_str (char *str) { - int change = 0; + bool changed = false; for (; *str; str++) if (ISUPPER (*str)) { - change = 1; + changed = true; *str = TOLOWER (*str); } - return change; + return changed; +} + +static const char * +init_seps (enum url_scheme scheme) +{ + static char seps[8] = ":/"; + char *p = seps + 2; + int flags = supported_schemes[scheme].flags; + + if (flags & scm_has_params) + *p++ = ';'; + if (flags & scm_has_query) + *p++ = '?'; + if (flags & scm_has_fragment) + *p++ = '#'; + *p++ = '\0'; + return seps; } static const char *parse_errors[] = { @@ -650,9 +644,10 @@ { struct url *u; const char *p; - int path_modified, host_modified; + bool path_modified, host_modified; enum url_scheme scheme; + const char *seps; const char *uname_b, *uname_e; const char *host_b, *host_e; @@ -672,7 +667,7 @@ if (scheme == SCHEME_INVALID) { error_code = PE_UNSUPPORTED_SCHEME; - goto err; + goto error; } url_encoded = reencode_escapes (url); @@ -691,10 +686,16 @@ scheme://host[:port][/path][;params][?query][#fragment] */ + path_b = path_e = NULL; params_b = params_e = NULL; query_b = query_e = NULL; fragment_b = fragment_e = NULL; + /* Initialize separators for optional parts of URL, depending on the + scheme. For example, FTP has params, and HTTP and HTTPS have + query string and fragment. */ + seps = init_seps (scheme); + host_b = p; if (*p == '[') @@ -710,7 +711,7 @@ if (!host_e) { error_code = PE_UNTERMINATED_IPV6_ADDRESS; - goto err; + goto error; } #ifdef ENABLE_IPV6 @@ -718,37 +719,38 @@ if (!is_valid_ipv6_address(host_b, host_e)) { error_code = PE_INVALID_IPV6_ADDRESS; - goto err; + goto error; } /* Continue parsing after the closing ']'. */ p = host_e + 1; #else error_code = PE_IPV6_NOT_SUPPORTED; - goto err; + goto error; #endif /* The closing bracket must be followed by a separator or by the null char. */ /* http://[::1]... */ /* ^ */ - if (!strchr (":/;?#", *p)) + if (!strchr (seps, *p)) { /* Trailing garbage after []-delimited IPv6 address. */ error_code = PE_INVALID_HOST_NAME; - goto err; + goto error; } } else { - p = strpbrk_or_eos (p, ":/;?#"); + p = strpbrk_or_eos (p, seps); host_e = p; } + ++seps; /* advance to '/' */ if (host_b == host_e) { error_code = PE_INVALID_HOST_NAME; - goto err; + goto error; } port = scheme_default_port (scheme); @@ -760,76 +762,51 @@ /* ^ */ ++p; port_b = p; - p = strpbrk_or_eos (p, "/;?#"); + p = strpbrk_or_eos (p, seps); port_e = p; /* Allow empty port, as per rfc2396. */ if (port_b != port_e) - { - for (port = 0, pp = port_b; pp < port_e; pp++) - { - if (!ISDIGIT (*pp)) - { - /* http://host:12randomgarbage/blah */ - /* ^ */ - error_code = PE_BAD_PORT_NUMBER; - goto err; - } - port = 10 * port + (*pp - '0'); - /* Check for too large port numbers here, before we have - a chance to overflow on bogus port values. */ - if (port > 65535) - { - error_code = PE_BAD_PORT_NUMBER; - goto err; - } - } - } + for (port = 0, pp = port_b; pp < port_e; pp++) + { + if (!ISDIGIT (*pp)) + { + /* http://host:12randomgarbage/blah */ + /* ^ */ + error_code = PE_BAD_PORT_NUMBER; + goto error; + } + port = 10 * port + (*pp - '0'); + /* Check for too large port numbers here, before we have + a chance to overflow on bogus port values. */ + if (port > 0xffff) + { + error_code = PE_BAD_PORT_NUMBER; + goto error; + } + } } + /* Advance to the first separator *after* '/' (either ';' or '?', + depending on the scheme). */ + ++seps; + + /* Get the optional parts of URL, each part being delimited by + current location and the position of the next separator. */ +#define GET_URL_PART(sepchar, var) do { \ + if (*p == sepchar) \ + var##_b = ++p, var##_e = p = strpbrk_or_eos (p, seps); \ + ++seps; \ +} while (0) - if (*p == '/') - { - ++p; - path_b = p; - p = strpbrk_or_eos (p, ";?#"); - path_e = p; - } - else - { - /* Path is not allowed not to exist. */ - path_b = path_e = p; - } + GET_URL_PART ('/', path); + if (supported_schemes[scheme].flags & scm_has_params) + GET_URL_PART (';', params); + if (supported_schemes[scheme].flags & scm_has_query) + GET_URL_PART ('?', query); + if (supported_schemes[scheme].flags & scm_has_fragment) + GET_URL_PART ('#', fragment); - if (*p == ';') - { - ++p; - params_b = p; - p = strpbrk_or_eos (p, "?#"); - params_e = p; - } - if (*p == '?') - { - ++p; - query_b = p; - p = strpbrk_or_eos (p, "#"); - query_e = p; - - /* Hack that allows users to use '?' (a wildcard character) in - FTP URLs without it being interpreted as a query string - delimiter. */ - if (scheme == SCHEME_FTP) - { - query_b = query_e = NULL; - path_e = p; - } - } - if (*p == '#') - { - ++p; - fragment_b = p; - p += strlen (p); - fragment_e = p; - } +#undef GET_URL_PART assert (*p == 0); if (uname_b != uname_e) @@ -840,7 +817,7 @@ if (!parse_credentials (uname_b, uname_e - 1, &user, &passwd)) { error_code = PE_INVALID_USER_NAME; - goto err; + goto error; } } @@ -864,7 +841,7 @@ if (strchr (u->host, '%')) { url_unescape (u->host); - host_modified = 1; + host_modified = true; } if (params_b) @@ -879,7 +856,7 @@ /* If we suspect that a transformation has rendered what url_string might return different from URL_ENCODED, rebuild u->url using url_string. */ - u->url = url_string (u, 0); + u->url = url_string (u, false); if (url_encoded != url) xfree ((char *) url_encoded); @@ -894,7 +871,7 @@ return u; - err: + error: /* Cleanup in case of error: */ if (url_encoded && url_encoded != url) xfree (url_encoded); @@ -1004,7 +981,7 @@ url_full_path (const struct url *url) { int length = full_path_length (url); - char *full_path = (char *) xmalloc (length + 1); + char *full_path = xmalloc (length + 1); full_path_write (url, full_path); full_path[length] = '\0'; @@ -1095,7 +1072,7 @@ /* Regenerate u->url as well. */ xfree (u->url); - u->url = url_string (u, 0); + u->url = url_string (u, false); } /* Mutators. Code in ftp.c insists on changing u->dir and u->file. @@ -1315,11 +1292,11 @@ the quoted string to DEST. Each character is quoted as per file_unsafe_char and the corresponding table. - If ESCAPED_P is non-zero, the path element is considered to be + If ESCAPED is true, the path element is considered to be URL-escaped and will be unescaped prior to inspection. */ static void -append_uri_pathel (const char *b, const char *e, int escaped_p, +append_uri_pathel (const char *b, const char *e, bool escaped, struct growable *dest) { const char *p; @@ -1334,7 +1311,7 @@ mask |= filechr_control; /* Copy [b, e) to PATHEL and URL-unescape it. */ - if (escaped_p) + if (escaped) { char *unescaped; BOUNDED_TO_ALLOCA (b, e, unescaped); @@ -1387,6 +1364,21 @@ } assert (q - TAIL (dest) == outlen); } + + /* Perform inline case transformation if required. */ + if (opt.restrict_files_case == restrict_lowercase + || opt.restrict_files_case == restrict_uppercase) + { + char *q; + for (q = TAIL (dest); *q; ++q) + { + if (opt.restrict_files_case == restrict_lowercase) + *q = TOLOWER (*q); + else + *q = TOUPPER (*q); + } + } + TAIL_INCR (dest, outlen); } @@ -1424,7 +1416,7 @@ if (dest->tail) append_char ('/', dest); - append_uri_pathel (pathel, next, 1, dest); + append_uri_pathel (pathel, next, true, dest); } } @@ -1485,14 +1477,14 @@ if (fnres.tail) append_char ('/', &fnres); u_file = *u->file ? u->file : "index.html"; - append_uri_pathel (u_file, u_file + strlen (u_file), 0, &fnres); + append_uri_pathel (u_file, u_file + strlen (u_file), false, &fnres); /* Append "?query" to the file name. */ u_query = u->query && *u->query ? u->query : NULL; if (u_query) { append_char (FN_QUERY_SEP, &fnres); - append_uri_pathel (u_query, u_query + strlen (u_query), 1, &fnres); + append_uri_pathel (u_query, u_query + strlen (u_query), true, &fnres); } /* Zero-terminate the file name. */ @@ -1513,14 +1505,14 @@ && !(file_exists_p (fname) && !file_non_directory_p (fname))) return fname; - unique = unique_name (fname, 1); + unique = unique_name (fname, true); if (unique != fname) xfree (fname); return unique; } /* Resolve "." and ".." elements of PATH by destructively modifying - PATH and return non-zero if PATH has been modified, zero otherwise. + PATH and return true if PATH has been modified, false otherwise. The algorithm is in spirit similar to the one described in rfc1808, although implemented differently, in one pass. To recap, path @@ -1533,13 +1525,12 @@ function, run test_path_simplify to make sure you haven't broken a test case. */ -static int +static bool path_simplify (char *path) { char *h = path; /* hare */ char *t = path; /* tortoise */ - char *beg = path; /* boundary for backing the tortoise */ - char *end = path + strlen (path); + char *end = strchr (path, '\0'); while (h < end) { @@ -1554,26 +1545,17 @@ { /* Handle "../" by retreating the tortoise by one path element -- but not past beggining. */ - if (t > beg) + if (t > path) { /* Move backwards until T hits the beginning of the previous path element or the beginning of path. */ - for (--t; t > beg && t[-1] != '/'; t--) + for (--t; t > path && t[-1] != '/'; t--) ; } - else - { - /* If we're at the beginning, copy the "../" literally - move the beginning so a later ".." doesn't remove - it. */ - beg = t + 3; - goto regular; - } h += 3; } else { - regular: /* A regular path element. If H hasn't advanced past T, simply skip to the next path element. Otherwise, copy the path element until the next slash. */ @@ -1603,28 +1585,24 @@ } /* Return the length of URL's path. Path is considered to be - terminated by one of '?', ';', '#', or by the end of the - string. */ + terminated by one or more of the ?query or ;params or #fragment, + depending on the scheme. */ -static int -path_length (const char *url) +static const char * +path_end (const char *url) { - const char *q = strpbrk_or_eos (url, "?;#"); - return q - url; + enum url_scheme scheme = url_scheme (url); + const char *seps; + if (scheme == SCHEME_INVALID) + scheme = SCHEME_HTTP; /* use http semantics for rel links */ + /* +2 to ignore the first two separators ':' and '/' */ + seps = init_seps (scheme) + 2; + return strpbrk_or_eos (url, seps); } /* Find the last occurrence of character C in the range [b, e), or - NULL, if none are present. We might want to use memrchr (a GNU - extension) under GNU libc. */ - -static const char * -find_last_char (const char *b, const char *e, char c) -{ - for (; e > b; e--) - if (*e == c) - return e; - return NULL; -} + NULL, if none are present. */ +#define find_last_char(b, e, c) memrchr ((b), (c), (e) - (b)) /* Merge BASE with LINK and return the resulting URI. @@ -1649,7 +1627,7 @@ return xstrdup (link); /* We may not examine BASE past END. */ - end = base + path_length (base); + end = path_end (base); linklength = strlen (link); if (!*link) @@ -1712,7 +1690,7 @@ start_insert = base; span = start_insert - base; - merge = (char *)xmalloc (span + linklength + 1); + merge = xmalloc (span + linklength + 1); if (span) memcpy (merge, base, span); memcpy (merge + span, link, linklength); @@ -1730,7 +1708,7 @@ const char *slash; const char *start_insert = NULL; /* for gcc to shut up. */ const char *pos = base; - int seen_slash_slash = 0; + bool seen_slash_slash = false; /* We're looking for the first slash, but want to ignore double slash. */ again: @@ -1739,7 +1717,7 @@ if (*(slash + 1) == '/') { pos = slash + 2; - seen_slash_slash = 1; + seen_slash_slash = true; goto again; } @@ -1767,7 +1745,7 @@ start_insert = slash; span = start_insert - base; - merge = (char *)xmalloc (span + linklength + 1); + merge = xmalloc (span + linklength + 1); if (span) memcpy (merge, base, span); memcpy (merge + span, link, linklength); @@ -1780,7 +1758,7 @@ So, if BASE is "whatever/foo/bar", and LINK is "qux/xyzzy", our result should be "whatever/foo/qux/xyzzy". */ - int need_explicit_slash = 0; + bool need_explicit_slash = false; int span; const char *start_insert; const char *last_slash = find_last_char (base, end, '/'); @@ -1795,7 +1773,7 @@ /* example: http://host" */ /* ^ */ start_insert = end + 1; - need_explicit_slash = 1; + need_explicit_slash = true; } else { @@ -1805,7 +1783,7 @@ } span = start_insert - base; - merge = (char *)xmalloc (span + linklength + 1); + merge = xmalloc (span + linklength + 1); if (span) memcpy (merge, base, span); if (need_explicit_slash) @@ -1831,23 +1809,23 @@ /* Recreate the URL string from the data in URL. - If HIDE is non-zero (as it is when we're calling this on a URL we - plan to print, but not when calling it to canonicalize a URL for - use within the program), password will be hidden. Unsafe - characters in the URL will be quoted. */ + If HIDE is true (as it is when we're calling this on a URL we plan + to print, but not when calling it to canonicalize a URL for use + within the program), password will be hidden. Unsafe characters in + the URL will be quoted. */ char * -url_string (const struct url *url, int hide_password) +url_string (const struct url *url, bool hide_password) { int size; char *result, *p; char *quoted_host, *quoted_user = NULL, *quoted_passwd = NULL; - int scheme_port = supported_schemes[url->scheme].default_port; + int scheme_port = supported_schemes[url->scheme].default_port; const char *scheme_str = supported_schemes[url->scheme].leading_string; int fplen = full_path_length (url); - int brackets_around_host; + bool brackets_around_host; assert (scheme_str != NULL); @@ -1930,22 +1908,22 @@ return result; } -/* Return non-zero if scheme a is similar to scheme b. +/* Return true if scheme a is similar to scheme b. Schemes are similar if they are equal. If SSL is supported, schemes are also similar if one is http (SCHEME_HTTP) and the other is https (SCHEME_HTTPS). */ -int +bool schemes_are_similar_p (enum url_scheme a, enum url_scheme b) { if (a == b) - return 1; + return true; #ifdef HAVE_SSL if ((a == SCHEME_HTTP && b == SCHEME_HTTPS) || (a == SCHEME_HTTPS && b == SCHEME_HTTP)) - return 1; + return true; #endif - return 0; + return false; } #if 0 @@ -1962,10 +1940,10 @@ } static void -run_test (char *test, char *expected_result, int expected_change) +run_test (char *test, char *expected_result, bool expected_change) { char *test_copy = xstrdup (test); - int modified = path_simplify (test_copy); + bool modified = path_simplify (test_copy); if (0 != strcmp (test_copy, expected_result)) { @@ -1974,7 +1952,7 @@ } if (modified != expected_change) { - if (expected_change == 1) + if (expected_change) printf ("Expected modification with path_simplify(\"%s\").\n", test); else @@ -1989,30 +1967,30 @@ { static struct { char *test, *result; - int should_modify; + bool should_modify; } tests[] = { - { "", "", 0 }, - { ".", "", 1 }, - { "./", "", 1 }, - { "..", "..", 0 }, - { "../", "../", 0 }, - { "foo", "foo", 0 }, - { "foo/bar", "foo/bar", 0 }, - { "foo///bar", "foo///bar", 0 }, - { "foo/.", "foo/", 1 }, - { "foo/./", "foo/", 1 }, - { "foo./", "foo./", 0 }, - { "foo/../bar", "bar", 1 }, - { "foo/../bar/", "bar/", 1 }, - { "foo/bar/..", "foo/", 1 }, - { "foo/bar/../x", "foo/x", 1 }, - { "foo/bar/../x/", "foo/x/", 1 }, - { "foo/..", "", 1 }, - { "foo/../..", "..", 1 }, - { "foo/../../..", "../..", 1 }, - { "foo/../../bar/../../baz", "../../baz", 1 }, - { "a/b/../../c", "c", 1 }, - { "./a/../b", "b", 1 } + { "", "", false }, + { ".", "", true }, + { "./", "", true }, + { "..", "", true }, + { "../", "", true }, + { "foo", "foo", false }, + { "foo/bar", "foo/bar", false }, + { "foo///bar", "foo///bar", false }, + { "foo/.", "foo/", true }, + { "foo/./", "foo/", true }, + { "foo./", "foo./", false }, + { "foo/../bar", "bar", true }, + { "foo/../bar/", "bar/", true }, + { "foo/bar/..", "foo/", true }, + { "foo/bar/../x", "foo/x", true }, + { "foo/bar/../x/", "foo/x/", true }, + { "foo/..", "", true }, + { "foo/../..", "", true }, + { "foo/../../..", "", true }, + { "foo/../../bar/../../baz", "baz", true }, + { "a/b/../../c", "c", true }, + { "./a/../b", "b", true } }; int i; @@ -2020,8 +1998,43 @@ { char *test = tests[i].test; char *expected_result = tests[i].result; - int expected_change = tests[i].should_modify; + bool expected_change = tests[i].should_modify; run_test (test, expected_result, expected_change); } } #endif + +#ifdef TESTING + +const char * +test_append_uri_pathel() +{ + int i; + struct { + char *original_url; + char *input; + bool escaped; + char *expected_result; + } test_array[] = { + { "http://www.yoyodyne.com/path/", "somepage.html", false, "http://www.yoyodyne.com/path/somepage.html" }, + }; + + for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i) + { + struct growable dest; + const char *p = test_array[i].input; + + memset (&dest, 0, sizeof (dest)); + + append_string (test_array[i].original_url, &dest); + append_uri_pathel (p, p + strlen(p), test_array[i].escaped, &dest); + + mu_assert ("test_append_uri_pathel: wrong result", + strcmp (dest.base, test_array[i].expected_result) == 0); + } + + return NULL; +} + +#endif /* TESTING */ + diff -urN wget-1.10.2/src/url.h wget-1.10.2_new/src/url.h --- wget-1.10.2/src/url.h 2003-09-22 00:47:14.000000000 +0200 +++ wget-1.10.2_new/src/url.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for url.c. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -73,28 +73,28 @@ /* Function declarations */ -char *url_escape PARAMS ((const char *)); +char *url_escape (const char *); -struct url *url_parse PARAMS ((const char *, int *)); -const char *url_error PARAMS ((int)); -char *url_full_path PARAMS ((const struct url *)); -void url_set_dir PARAMS ((struct url *, const char *)); -void url_set_file PARAMS ((struct url *, const char *)); -void url_free PARAMS ((struct url *)); +struct url *url_parse (const char *, int *); +const char *url_error (int); +char *url_full_path (const struct url *); +void url_set_dir (struct url *, const char *); +void url_set_file (struct url *, const char *); +void url_free (struct url *); -enum url_scheme url_scheme PARAMS ((const char *)); -int url_has_scheme PARAMS ((const char *)); -int scheme_default_port PARAMS ((enum url_scheme)); -void scheme_disable PARAMS ((enum url_scheme)); +enum url_scheme url_scheme (const char *); +bool url_has_scheme (const char *); +int scheme_default_port (enum url_scheme); +void scheme_disable (enum url_scheme); -char *url_string PARAMS ((const struct url *, int)); -char *url_file_name PARAMS ((const struct url *)); +char *url_string (const struct url *, bool); +char *url_file_name (const struct url *); -char *uri_merge PARAMS ((const char *, const char *)); +char *uri_merge (const char *, const char *); -int mkalldirs PARAMS ((const char *)); +int mkalldirs (const char *); -char *rewrite_shorthand_url PARAMS ((const char *)); -int schemes_are_similar_p PARAMS ((enum url_scheme a, enum url_scheme b)); +char *rewrite_shorthand_url (const char *); +bool schemes_are_similar_p (enum url_scheme a, enum url_scheme b); #endif /* URL_H */ diff -urN wget-1.10.2/src/utils.c wget-1.10.2_new/src/utils.c --- wget-1.10.2/src/utils.c 2005-06-27 16:12:20.000000000 +0200 +++ wget-1.10.2_new/src/utils.c 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Various utility functions. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,24 +31,17 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else /* not HAVE_STRING_H */ -# include -#endif /* not HAVE_STRING_H */ -#include +#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_MMAP # include #endif -#ifdef HAVE_PWD_H -# include -#endif -#ifdef HAVE_LIMITS_H -# include -#endif #ifdef HAVE_UTIME_H # include #endif @@ -56,19 +49,10 @@ # include #endif #include -#ifdef NeXT -# include /* for access() */ -#endif #include #include -#ifdef WGET_USE_STDARG -# include -#else -# include -#endif -#ifdef HAVE_LOCALE_H -# include -#endif +#include +#include /* For TIOCGWINSZ and friends: */ #ifdef HAVE_SYS_IOCTL_H @@ -78,14 +62,9 @@ # include #endif -/* Needed for run_with_timeout. */ -#undef USE_SIGNAL_TIMEOUT -#ifdef HAVE_SIGNAL_H -# include -#endif -#ifdef HAVE_SETJMP_H -# include -#endif +/* Needed for Unix version of run_with_timeout. */ +#include +#include #ifndef HAVE_SIGSETJMP /* If sigsetjmp is a macro, configure won't pick it up. */ @@ -94,22 +73,17 @@ # endif #endif -#ifdef HAVE_SIGNAL -# ifdef HAVE_SIGSETJMP -# define USE_SIGNAL_TIMEOUT -# endif -# ifdef HAVE_SIGBLOCK -# define USE_SIGNAL_TIMEOUT -# endif +#if defined HAVE_SIGSETJMP || defined HAVE_SIGBLOCK +# define USE_SIGNAL_TIMEOUT #endif #include "wget.h" #include "utils.h" #include "hash.h" -#ifndef errno -extern int errno; -#endif +#ifdef TESTING +#include "test.h" +#endif /* Utility function: like xstrdup(), but also lowercases S. */ @@ -129,7 +103,7 @@ char * strdupdelim (const char *beg, const char *end) { - char *res = (char *)xmalloc (end - beg + 1); + char *res = xmalloc (end - beg + 1); memcpy (res, beg, end - beg); res[end - beg] = '\0'; return res; @@ -153,7 +127,7 @@ { if (*s == ',') { - res = (char **)xrealloc (res, (i + 2) * sizeof (char *)); + res = xrealloc (res, (i + 2) * sizeof (char *)); res[i] = strdupdelim (p, s); res[++i] = NULL; ++s; @@ -165,41 +139,55 @@ else ++s; } - res = (char **)xrealloc (res, (i + 2) * sizeof (char *)); + res = xrealloc (res, (i + 2) * sizeof (char *)); res[i] = strdupdelim (p, s); res[i + 1] = NULL; return res; } -#ifdef WGET_USE_STDARG -# define VA_START(args, arg1) va_start (args, arg1) -#else -# define VA_START(args, ignored) va_start (args) -#endif - -/* Like sprintf, but allocates a string of sufficient size with malloc - and returns it. GNU libc has a similar function named asprintf, - which requires the pointer to the string to be passed. */ +/* Like sprintf, but prints into a string of sufficient size freshly + allocated with malloc, which is returned. If unable to print due + to invalid format, returns NULL. Inability to allocate needed + memory results in abort, as with xmalloc. This is in spirit + similar to the GNU/BSD extension asprintf, but somewhat easier to + use. + + Internally the function either calls vasprintf or loops around + vsnprintf until the correct size is found. Since Wget also ships a + fallback implementation of vsnprintf, this should be portable. */ char * aprintf (const char *fmt, ...) { - /* This function is implemented using vsnprintf, which we provide - for the systems that don't have it. Therefore, it should be 100% - portable. */ +#ifdef HAVE_VASPRINTF + /* Use vasprintf. */ + int ret; + va_list args; + char *str; + va_start (args, fmt); + ret = vasprintf (&str, fmt, args); + va_end (args); + if (ret < 0 && errno == ENOMEM) + abort (); /* for consistency with xmalloc/xrealloc */ + else if (ret < 0) + return NULL; + return str; +#else /* not HAVE_VASPRINTF */ + /* vasprintf is unavailable. snprintf into a small buffer and + resize it as necessary. */ int size = 32; char *str = xmalloc (size); + /* #### This code will infloop and eventually abort in xrealloc if + passed a FMT that causes snprintf to consistently return -1. */ + while (1) { int n; va_list args; - /* See log_vprintf_internal for explanation why it's OK to rely - on the return value of vsnprintf. */ - - VA_START (args, fmt); + va_start (args, fmt); n = vsnprintf (str, size, fmt, args); va_end (args); @@ -214,6 +202,7 @@ size <<= 1; /* twice the old size */ str = xrealloc (str, size); } +#endif /* not HAVE_VASPRINTF */ } /* Concatenate the NULL-terminated list of string arguments into @@ -233,7 +222,7 @@ /* Calculate the length of and allocate the resulting string. */ argcount = 0; - VA_START (args, str0); + va_start (args, str0); for (next_str = str0; next_str != NULL; next_str = va_arg (args, char *)) { int len = strlen (next_str); @@ -247,7 +236,7 @@ /* Copy the strings into the allocated space. */ argcount = 0; - VA_START (args, str0); + va_start (args, str0); for (next_str = str0; next_str != NULL; next_str = va_arg (args, char *)) { int len; @@ -320,7 +309,7 @@ { pid_t pid; /* Whether we arrange our own version of opt.lfilename here. */ - int logfile_changed = 0; + bool logfile_changed = false; if (!opt.lfilename) { @@ -329,10 +318,10 @@ use fopen_excl) or lying to the user about the log file name (which arises from using unique_name, printing the name, and using fopen_excl later on.) */ - FILE *new_log_fp = unique_create (DEFAULT_LOGFILE, 0, &opt.lfilename); + FILE *new_log_fp = unique_create (DEFAULT_LOGFILE, false, &opt.lfilename); if (new_log_fp) { - logfile_changed = 1; + logfile_changed = true; fclose (new_log_fp); } } @@ -346,7 +335,7 @@ else if (pid != 0) { /* parent, no error */ - printf (_("Continuing in background, pid %d.\n"), (int)pid); + printf (_("Continuing in background, pid %d.\n"), (int) pid); if (logfile_changed) printf (_("Output will be written to `%s'.\n"), opt.lfilename); exit (0); /* #### should we use _exit()? */ @@ -407,7 +396,7 @@ proper way should, of course, be to have a third, error state, other than true/false, but that would introduce uncalled-for additional complexity to the callers. */ -int +bool file_exists_p (const char *filename) { #ifdef HAVE_ACCESS @@ -420,15 +409,15 @@ /* Returns 0 if PATH is a directory, 1 otherwise (any kind of file). Returns 0 on error. */ -int +bool file_non_directory_p (const char *path) { struct_stat buf; /* Use lstat() rather than stat() so that symbolic links pointing to directories can be identified correctly. */ if (lstat (path, &buf) != 0) - return 0; - return S_ISDIR (buf.st_mode) ? 0 : 1; + return false; + return S_ISDIR (buf.st_mode) ? false : true; } /* Return the size of file named by FILENAME, or -1 if it cannot be @@ -496,7 +485,7 @@ (and therefore doesn't need changing). */ char * -unique_name (const char *file, int allow_passthrough) +unique_name (const char *file, bool allow_passthrough) { /* If the FILE itself doesn't exist, return it without modification. */ @@ -514,15 +503,15 @@ opening the file returned by unique_name. */ FILE * -unique_create (const char *name, int binary, char **opened_name) +unique_create (const char *name, bool binary, char **opened_name) { /* unique file name, based on NAME */ - char *uname = unique_name (name, 0); + char *uname = unique_name (name, false); FILE *fp; while ((fp = fopen_excl (uname, binary)) == NULL && errno == EEXIST) { xfree (uname); - uname = unique_name (name, 0); + uname = unique_name (name, false); } if (opened_name && fp != NULL) { @@ -550,7 +539,7 @@ appropriately. */ FILE * -fopen_excl (const char *fname, int binary) +fopen_excl (const char *fname, bool binary) { int fd; #ifdef O_EXCL @@ -623,7 +612,7 @@ file_merge("/foo/bar/", "baz") => "/foo/bar/baz" file_merge("foo", "bar") => "bar" - In other words, it's a simpler and gentler version of uri_merge_1. */ + In other words, it's a simpler and gentler version of uri_merge. */ char * file_merge (const char *base, const char *file) @@ -634,7 +623,7 @@ if (!cut) return xstrdup (file); - result = (char *)xmalloc (cut - base + 1 + strlen (file) + 1); + result = xmalloc (cut - base + 1 + strlen (file) + 1); memcpy (result, base, cut - base); result[cut - base] = '/'; strcpy (result + (cut - base) + 1, file); @@ -642,11 +631,35 @@ return result; } -static int in_acclist PARAMS ((const char *const *, const char *, int)); +/* Like fnmatch, but performs a case-insensitive match. */ + +int +fnmatch_nocase (const char *pattern, const char *string, int flags) +{ +#ifdef FNM_CASEFOLD + /* The FNM_CASEFOLD flag started as a GNU extension, but it is now + also present on *BSD platforms, and possibly elsewhere. */ + return fnmatch (pattern, string, flags | FNM_CASEFOLD); +#else + /* Turn PATTERN and STRING to lower case and call fnmatch on them. */ + char *patcopy = (char *) alloca (strlen (pattern) + 1); + char *strcopy = (char *) alloca (strlen (string) + 1); + char *p; + for (p = patcopy; *pattern; pattern++, p++) + *p = TOLOWER (*pattern); + *p = '\0'; + for (p = strcopy; *string; string++, p++) + *p = TOLOWER (*string); + *p = '\0'; + return fnmatch (patcopy, strcopy, flags); +#endif +} + +static bool in_acclist (const char *const *, const char *, bool); /* Determine whether a file is acceptable to be followed, according to lists of patterns to accept/reject. */ -int +bool acceptable (const char *s) { int l = strlen (s); @@ -658,92 +671,103 @@ if (opt.accepts) { if (opt.rejects) - return (in_acclist ((const char *const *)opt.accepts, s, 1) - && !in_acclist ((const char *const *)opt.rejects, s, 1)); + return (in_acclist ((const char *const *)opt.accepts, s, true) + && !in_acclist ((const char *const *)opt.rejects, s, true)); else - return in_acclist ((const char *const *)opt.accepts, s, 1); + return in_acclist ((const char *const *)opt.accepts, s, true); } else if (opt.rejects) - return !in_acclist ((const char *const *)opt.rejects, s, 1); - return 1; + return !in_acclist ((const char *const *)opt.rejects, s, true); + return true; } -/* Compare S1 and S2 frontally; S2 must begin with S1. E.g. if S1 is - `/something', frontcmp() will return 1 only if S2 begins with - `/something'. Otherwise, 0 is returned. */ -int -frontcmp (const char *s1, const char *s2) -{ - for (; *s1 && *s2 && (*s1 == *s2); ++s1, ++s2); - return !*s1; +/* Check if D2 is a subdirectory of D1. E.g. if D1 is `/something', subdir_p() + will return true if and only if D2 begins with `/something/' or is exactly + '/something'. */ +bool +subdir_p (const char *d1, const char *d2) +{ + if (!opt.ignore_case) + for (; *d1 && *d2 && (*d1 == *d2); ++d1, ++d2) + ; + else + for (; *d1 && *d2 && (TOLOWER (*d1) == TOLOWER (*d2)); ++d1, ++d2) + ; + + return *d1 == '\0' && (*d2 == '\0' || *d2 == '/'); } -/* Iterate through STRLIST, and return the first element that matches - S, through wildcards or front comparison (as appropriate). */ -static char * -proclist (char **strlist, const char *s, enum accd flags) +/* Iterate through DIRLIST (which must be NULL-terminated), and return the + first element that matches DIR, through wildcards or front comparison (as + appropriate). */ +static bool +dir_matches_p (char **dirlist, const char *dir) { char **x; - for (x = strlist; *x; x++) + int (*matcher) (const char *, const char *, int) + = opt.ignore_case ? fnmatch_nocase : fnmatch; + + for (x = dirlist; *x; x++) { - /* Remove leading '/' if ALLABS */ - char *p = *x + ((flags & ALLABS) && (**x == '/')); + /* Remove leading '/' */ + char *p = *x + (**x == '/'); if (has_wildcards_p (p)) { - if (fnmatch (p, s, FNM_PATHNAME) == 0) + if (matcher (p, dir, FNM_PATHNAME) == 0) break; } else { - if (frontcmp (p, s)) + if (subdir_p (p, dir)) break; } } - return *x; + + return *x ? true : false; } /* Returns whether DIRECTORY is acceptable for download, wrt the include/exclude lists. - If FLAGS is ALLABS, the leading `/' is ignored in paths; relative - and absolute paths may be freely intermixed. */ -int -accdir (const char *directory, enum accd flags) + The leading `/' is ignored in paths; relative and absolute paths + may be freely intermixed. */ + +bool +accdir (const char *directory) { /* Remove starting '/'. */ - if (flags & ALLABS && *directory == '/') + if (*directory == '/') ++directory; if (opt.includes) { - if (!proclist (opt.includes, directory, flags)) - return 0; + if (!dir_matches_p (opt.includes, directory)) + return false; } if (opt.excludes) { - if (proclist (opt.excludes, directory, flags)) - return 0; + if (dir_matches_p (opt.excludes, directory)) + return false; } - return 1; + return true; } -/* Return non-zero if STRING ends with TAIL. For instance: +/* Return true if STRING ends with TAIL. For instance: - match_tail ("abc", "bc", 0) -> 1 - match_tail ("abc", "ab", 0) -> 0 - match_tail ("abc", "abc", 0) -> 1 + match_tail ("abc", "bc", false) -> 1 + match_tail ("abc", "ab", false) -> 0 + match_tail ("abc", "abc", false) -> 1 - If FOLD_CASE_P is non-zero, the comparison will be - case-insensitive. */ + If FOLD_CASE is true, the comparison will be case-insensitive. */ -int -match_tail (const char *string, const char *tail, int fold_case_p) +bool +match_tail (const char *string, const char *tail, bool fold_case) { int i, j; /* We want this to be fast, so we code two loops, one with case-folding, one without. */ - if (!fold_case_p) + if (!fold_case) { for (i = strlen (string), j = strlen (tail); i >= 0 && j >= 0; i--, j--) if (string[i] != tail[j]) @@ -758,44 +782,47 @@ /* If the tail was exhausted, the match was succesful. */ if (j == -1) - return 1; + return true; else - return 0; + return false; } /* Checks whether string S matches each element of ACCEPTS. A list element are matched either with fnmatch() or match_tail(), according to whether the element contains wildcards or not. - If the BACKWARD is 0, don't do backward comparison -- just compare + If the BACKWARD is false, don't do backward comparison -- just compare them normally. */ -static int -in_acclist (const char *const *accepts, const char *s, int backward) +static bool +in_acclist (const char *const *accepts, const char *s, bool backward) { for (; *accepts; accepts++) { if (has_wildcards_p (*accepts)) { - /* fnmatch returns 0 if the pattern *does* match the - string. */ - if (fnmatch (*accepts, s, 0) == 0) - return 1; + int res = opt.ignore_case + ? fnmatch_nocase (*accepts, s, 0) : fnmatch (*accepts, s, 0); + /* fnmatch returns 0 if the pattern *does* match the string. */ + if (res == 0) + return true; } else { if (backward) { - if (match_tail (s, *accepts, 0)) - return 1; + if (match_tail (s, *accepts, opt.ignore_case)) + return true; } else { - if (!strcmp (s, *accepts)) - return 1; + int cmp = opt.ignore_case + ? strcasecmp (s, *accepts) : strcmp (s, *accepts); + if (cmp == 0) + return true; } } } - return 0; + return false; } /* Return the location of STR's suffix (file extension). Examples: @@ -817,20 +844,21 @@ return NULL; } -/* Return non-zero if S contains globbing wildcards (`*', `?', `[' or +/* Return true if S contains globbing wildcards (`*', `?', `[' or `]'). */ -int +bool has_wildcards_p (const char *s) { for (; *s; s++) if (*s == '*' || *s == '?' || *s == '[' || *s == ']') - return 1; - return 0; + return true; + return false; } -/* Return non-zero if FNAME ends with a typical HTML suffix. The - following (case-insensitive) suffixes are presumed to be HTML files: +/* Return true if FNAME ends with a typical HTML suffix. The + following (case-insensitive) suffixes are presumed to be HTML + files: html htm @@ -838,20 +866,20 @@ #### CAVEAT. This is not necessarily a good indication that FNAME refers to a file that contains HTML! */ -int +bool has_html_suffix_p (const char *fname) { char *suf; if ((suf = suffix (fname)) == NULL) - return 0; + return false; if (!strcasecmp (suf, "html")) - return 1; + return true; if (!strcasecmp (suf, "htm")) - return 1; + return true; if (suf[0] && !strcasecmp (suf + 1, "html")) - return 1; - return 0; + return true; + return false; } /* Read a line from FP and return the pointer to freshly allocated @@ -871,7 +899,7 @@ { int length = 0; int bufsize = 82; - char *line = (char *)xmalloc (bufsize); + char *line = xmalloc (bufsize); while (fgets (line + length, bufsize - length, fp)) { @@ -926,14 +954,14 @@ int fd; struct file_memory *fm; long size; - int inhibit_close = 0; + bool inhibit_close = false; /* Some magic in the finest tradition of Perl and its kin: if FILE is "-", just use stdin. */ if (HYPHENP (file)) { fd = fileno (stdin); - inhibit_close = 1; + inhibit_close = true; /* Note that we don't inhibit mmap() in this case. If stdin is redirected from a regular file, mmap() will still work. */ } @@ -1079,11 +1107,13 @@ return v1; } /* Count v1. */ - for (i = 0; v1[i]; i++); + for (i = 0; v1[i]; i++) + ; /* Count v2. */ - for (j = 0; v2[j]; j++); + for (j = 0; v2[j]; j++) + ; /* Reallocate v1. */ - v1 = (char **)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; @@ -1142,96 +1172,97 @@ return hash_table_contains (ht, s); } -static int -string_set_to_array_mapper (void *key, void *value_ignored, void *arg) -{ - char ***arrayptr = (char ***) arg; - *(*arrayptr)++ = (char *) key; - return 0; -} - /* Convert the specified string set to array. ARRAY should be large enough to hold hash_table_count(ht) char pointers. */ void string_set_to_array (struct hash_table *ht, char **array) { - hash_table_map (ht, string_set_to_array_mapper, &array); + hash_table_iterator iter; + for (hash_table_iterate (ht, &iter); hash_table_iter_next (&iter); ) + *array++ = iter.key; } -static int -string_set_free_mapper (void *key, void *value_ignored, void *arg_ignored) -{ - xfree (key); - return 0; -} +/* Free the string set. This frees both the storage allocated for + keys and the actual hash table. (hash_table_destroy would only + destroy the hash table.) */ void string_set_free (struct hash_table *ht) { - hash_table_map (ht, string_set_free_mapper, NULL); + hash_table_iterator iter; + for (hash_table_iterate (ht, &iter); hash_table_iter_next (&iter); ) + xfree (iter.key); hash_table_destroy (ht); } -static int -free_keys_and_values_mapper (void *key, void *value, void *arg_ignored) -{ - xfree (key); - xfree (value); - return 0; -} - -/* Another utility function: call free() on all keys and values of HT. */ +/* Utility function: simply call xfree() on all keys and values of HT. */ void free_keys_and_values (struct hash_table *ht) { - hash_table_map (ht, free_keys_and_values_mapper, NULL); + hash_table_iterator iter; + for (hash_table_iterate (ht, &iter); hash_table_iter_next (&iter); ) + { + xfree (iter.key); + xfree (iter.value); + } } +/* Get digit grouping data for thousand separors by calling + localeconv(). The data includes separator string and grouping info + and is cached after the first call to the function. + + In locales that don't set a thousand separator (such as the "C" + locale), this forces it to be ",". We are now only showing + thousand separators in one place, so this shouldn't be a problem in + practice. */ + static void get_grouping_data (const char **sep, const char **grouping) { static const char *cached_sep; static const char *cached_grouping; - static int initialized; + static bool initialized; if (!initialized) { - /* If locale.h is present and defines LC_NUMERIC, assume C89 - struct lconv with "thousand_sep" and "grouping" members. */ -#ifdef LC_NUMERIC /* Get the grouping info from the locale. */ - struct lconv *lconv; - const char *oldlocale = setlocale (LC_NUMERIC, NULL); - /* Temporarily switch to the current locale */ - setlocale (LC_NUMERIC, ""); - lconv = localeconv (); - cached_sep = xstrdup (lconv->thousands_sep); - cached_grouping = xstrdup (lconv->grouping); - /* Restore the locale to previous setting. */ - setlocale (LC_NUMERIC, oldlocale); + struct lconv *lconv = localeconv (); + cached_sep = lconv->thousands_sep; + cached_grouping = lconv->grouping; if (!*cached_sep) -#endif - /* Force separator for locales that specify no separators - ("C", "hr", and probably many more.) */ - cached_sep = ",", cached_grouping = "\x03"; - initialized = 1; + { + /* Many locales (such as "C" or "hr_HR") don't specify + grouping, which we still want to use it for legibility. + In those locales set the sep char to ',', unless that + character is used for decimal point, in which case set it + to ".". */ + if (*lconv->decimal_point != ',') + cached_sep = ","; + else + cached_sep = "."; + cached_grouping = "\x03"; + } + initialized = true; } *sep = cached_sep; *grouping = cached_grouping; } -/* Add thousand separators to a number already in string form. Used - by with_thousand_seps and with_thousand_seps_sum. */ +/* Return a printed representation of N with thousand separators. + This should respect locale settings, with the exception of the "C" + locale which mandates no separator, but we use one anyway. -char * -add_thousand_seps (const char *repr) + Unfortunately, we cannot use %'d (in fact it would be %'j) to get + the separators because it's too non-portable, and it's hard to test + for this feature at configure time. Besides, it wouldn't display + separators in the "C" locale, still used by many Unix users. */ + +const char * +with_thousand_seps (wgint n) { static char outbuf[48]; char *p = outbuf + sizeof outbuf; - const char *in = strchr (repr, '\0'); - const char *instart = repr + (*repr == '-'); /* don't group sign */ - /* Info received from locale */ const char *grouping, *sep; int seplen; @@ -1240,19 +1271,27 @@ int i = 0, groupsize; const char *atgroup; + bool negative = n < 0; + /* Initialize grouping data. */ get_grouping_data (&sep, &grouping); seplen = strlen (sep); atgroup = grouping; groupsize = *atgroup++; + /* This would overflow on WGINT_MIN, but printing negative numbers + is not an important goal of this fuinction. */ + if (negative) + n = -n; + /* Write the number into the buffer, backwards, inserting the separators as necessary. */ *--p = '\0'; while (1) { - *--p = *--in; - if (in == instart) + *--p = n % 10 + '0'; + n /= 10; + if (n == 0) break; /* Prepend SEP to every groupsize'd digit and get new groupsize. */ if (++i == groupsize) @@ -1266,44 +1305,12 @@ groupsize = *atgroup++; } } - if (*repr == '-') + if (negative) *--p = '-'; return p; } -/* Return a printed representation of N with thousand separators. - This should respect locale settings, with the exception of the "C" - locale which mandates no separator, but we use one anyway. - - Unfortunately, we cannot use %'d (in fact it would be %'j) to get - the separators because it's too non-portable, and it's hard to test - for this feature at configure time. Besides, it wouldn't work in - the "C" locale, which many Unix users still work in. */ - -char * -with_thousand_seps (wgint l) -{ - char inbuf[24]; - /* Print the number into the buffer. */ - number_to_string (inbuf, l); - return add_thousand_seps (inbuf); -} - -/* When SUM_SIZE_INT is wgint, with_thousand_seps_large is #defined to - with_thousand_seps. The function below is used on non-LFS systems - where SUM_SIZE_INT typedeffed to double. */ - -#ifndef with_thousand_seps_sum -char * -with_thousand_seps_sum (SUM_SIZE_INT l) -{ - char inbuf[32]; - snprintf (inbuf, sizeof (inbuf), "%.0f", l); - return add_thousand_seps (inbuf); -} -#endif /* not with_thousand_seps_sum */ - /* N, a byte quantity, is converted to a human-readable abberviated form a la sizes printed by `ls -lh'. The result is written to a static buffer, a pointer to which is returned. @@ -1315,14 +1322,13 @@ usually improves readability." This intentionally uses kilobyte (KB), megabyte (MB), etc. in their - original computer science meaning of "powers of 1024". Powers of - 1000 would be useless since Wget already displays sizes with - thousand separators. We don't use the "*bibyte" names invented in - 1998, and seldom used in practice. Wikipedia's entry on kilobyte - discusses this in some detail. */ + original computer-related meaning of "powers of 1024". We don't + use the "*bibyte" names invented in 1998, and seldom used in + practice. Wikipedia's entry on "binary prefix" discusses this in + some detail. */ char * -human_readable (wgint n) +human_readable (HR_NUMTYPE n) { /* These suffixes are compatible with those of GNU `ls -lh'. */ static char powers[] = @@ -1352,7 +1358,7 @@ /* At each iteration N is greater than the *subsequent* power. That way N/1024.0 produces a decimal number in the units of *this* power. */ - if ((n >> 10) < 1024 || i == countof (powers) - 1) + if ((n / 1024) < 1024 || i == countof (powers) - 1) { double val = n / 1024.0; /* Print values smaller than 10 with one decimal digits, and @@ -1361,7 +1367,7 @@ val < 10 ? 1 : 0, val, powers[i]); return buf; } - n >>= 10; + n /= 1024; } return NULL; /* unreached */ } @@ -1410,24 +1416,6 @@ #define DIGITS_18(mask) PR (mask), n %= (mask), DIGITS_17 ((mask) / 10) #define DIGITS_19(mask) PR (mask), n %= (mask), DIGITS_18 ((mask) / 10) -/* SPRINTF_WGINT is used by number_to_string to handle pathological - cases and to portably support strange sizes of wgint. Ideally this - would just use "%j" and intmax_t, but many systems don't support - it, so it's used only if nothing else works. */ -#if SIZEOF_LONG >= SIZEOF_WGINT -# define SPRINTF_WGINT(buf, n) sprintf (buf, "%ld", (long) (n)) -#else -# if SIZEOF_LONG_LONG >= SIZEOF_WGINT -# define SPRINTF_WGINT(buf, n) sprintf (buf, "%lld", (long long) (n)) -# else -# ifdef WINDOWS -# define SPRINTF_WGINT(buf, n) sprintf (buf, "%I64d", (__int64) (n)) -# else -# define SPRINTF_WGINT(buf, n) sprintf (buf, "%j", (intmax_t) (n)) -# endif -# endif -#endif - /* Shorthand for casting to wgint. */ #define W wgint @@ -1437,15 +1425,15 @@ The speedup may make a difference in programs that frequently convert numbers to strings. Some implementations of sprintf, - particularly the one in GNU libc, have been known to be extremely - slow when converting integers to strings. + particularly the one in some versions of GNU libc, have been known + to be quite slow when converting integers to strings. Return the pointer to the location where the terminating zero was printed. (Equivalent to calling buffer+strlen(buffer) after the function is done.) - BUFFER should be big enough to accept as many bytes as you expect - the number to take up. On machines with 64-bit longs the maximum + BUFFER should be large enough to accept as many bytes as you expect + the number to take up. On machines with 64-bit wgints the maximum needed size is 24 bytes. That includes the digits needed for the largest 64-bit number, the `-' sign in case it's negative, and the terminating '\0'. */ @@ -1456,21 +1444,29 @@ char *p = buffer; wgint n = number; + int last_digit_char = 0; + #if (SIZEOF_WGINT != 4) && (SIZEOF_WGINT != 8) - /* We are running in a strange or misconfigured environment. Let - sprintf cope with it. */ - SPRINTF_WGINT (buffer, n); - p += strlen (buffer); + /* We are running in a very strange environment. Leave the correct + printing to sprintf. */ + p += sprintf (buf, "%j", (intmax_t) (n)); #else /* (SIZEOF_WGINT == 4) || (SIZEOF_WGINT == 8) */ if (n < 0) { if (n < -WGINT_MAX) { - /* -n would overflow. Have sprintf deal with this. */ - SPRINTF_WGINT (buffer, n); - p += strlen (buffer); - return p; + /* n = -n would overflow because -n would evaluate to a + wgint value larger than WGINT_MAX. Need to make n + smaller and handle the last digit separately. */ + int last_digit = n % 10; + /* The sign of n%10 is implementation-defined. */ + if (last_digit < 0) + last_digit_char = '0' - last_digit; + else + last_digit_char = '0' + last_digit; + /* After n is made smaller, -n will not overflow. */ + n /= 10; } *p++ = '-'; @@ -1494,10 +1490,10 @@ /* wgint is 32 bits wide: no number has more than 10 digits. */ else DIGITS_10 (1000000000); #else - /* wgint is 64 bits wide: handle numbers with more than 9 decimal - digits. Constants are constructed by compile-time multiplication - to avoid dealing with different notations for 64-bit constants - (nnnL, nnnLL, and nnnI64, depending on the compiler). */ + /* wgint is 64 bits wide: handle numbers with 9-19 decimal digits. + Constants are constructed by compile-time multiplication to avoid + dealing with different notations for 64-bit constants + (nL/nLL/nI64, depending on the compiler and architecture). */ else if (n < 10*(W)1000000000) DIGITS_10 (1000000000); else if (n < 100*(W)1000000000) DIGITS_11 (10*(W)1000000000); else if (n < 1000*(W)1000000000) DIGITS_12 (100*(W)1000000000); @@ -1510,6 +1506,9 @@ else DIGITS_19 (1000000000*(W)1000000000); #endif + if (last_digit_char) + *p++ = last_digit_char; + *p = '\0'; #endif /* (SIZEOF_WGINT == 4) || (SIZEOF_WGINT == 8) */ @@ -1518,6 +1517,7 @@ #undef PR #undef W +#undef SPRINTF_WGINT #undef DIGITS_1 #undef DIGITS_2 #undef DIGITS_3 @@ -1602,79 +1602,83 @@ return 0; /* most likely ENOTTY */ return wsz.ws_col; -#else /* not TIOCGWINSZ */ -# ifdef WINDOWS +#elif defined(WINDOWS) CONSOLE_SCREEN_BUFFER_INFO csbi; if (!GetConsoleScreenBufferInfo (GetStdHandle (STD_ERROR_HANDLE), &csbi)) return 0; return csbi.dwSize.X; -# else /* neither WINDOWS nor TIOCGWINSZ */ +#else /* neither TIOCGWINSZ nor WINDOWS */ return 0; -#endif /* neither WINDOWS nor TIOCGWINSZ */ -#endif /* not TIOCGWINSZ */ +#endif /* neither TIOCGWINSZ nor WINDOWS */ } + +/* Whether the rnd system (either rand or [dl]rand48) has been + seeded. */ +static int rnd_seeded; /* Return a random number between 0 and MAX-1, inclusive. - If MAX is greater than the value of RAND_MAX+1 on the system, the - returned value will be in the range [0, RAND_MAX]. This may be - fixed in a future release. - + If the system does not support lrand48 and MAX is greater than the + value of RAND_MAX+1 on the system, the returned value will be in + the range [0, RAND_MAX]. This may be fixed in a future release. The random number generator is seeded automatically the first time it is called. - This uses rand() for portability. It has been suggested that - random() offers better randomness, but this is not required for - Wget, so I chose to go for simplicity and use rand - unconditionally. - - DO NOT use this for cryptographic purposes. It is only meant to be - used in situations where quality of the random numbers returned - doesn't really matter. */ + This uses lrand48 where available, rand elsewhere. DO NOT use it + for cryptography. It is only meant to be used in situations where + quality of the random numbers returned doesn't really matter. */ int random_number (int max) { - static int seeded; +#ifdef HAVE_DRAND48 + if (!rnd_seeded) + { + srand48 ((long) time (NULL) ^ (long) getpid ()); + rnd_seeded = 1; + } + return lrand48 () % max; +#else /* not HAVE_DRAND48 */ + double bounded; int rnd; - - if (!seeded) + if (!rnd_seeded) { - srand (time (NULL)); - seeded = 1; + srand ((unsigned) time (NULL) ^ (unsigned) getpid ()); + rnd_seeded = 1; } rnd = rand (); - /* On systems that don't define RAND_MAX, assume it to be 2**15 - 1, - and enforce that assumption by masking other bits. */ -#ifndef RAND_MAX -# define RAND_MAX 32767 - rnd &= RAND_MAX; -#endif + /* Like rand() % max, but uses the high-order bits for better + randomness on architectures where rand() is implemented using a + simple congruential generator. */ - /* This is equivalent to rand() % max, but uses the high-order bits - for better randomness on architecture where rand() is implemented - using a simple congruential generator. */ + bounded = (double) max * rnd / (RAND_MAX + 1.0); + return (int) bounded; - bounded = (double)max * rnd / (RAND_MAX + 1.0); - return (int)bounded; +#endif /* not HAVE_DRAND48 */ } /* Return a random uniformly distributed floating point number in the - [0, 1) range. The precision of returned numbers is 9 digits. - - Modify this to use erand48() where available! */ + [0, 1) range. Uses drand48 where available, and a really lame + kludge elsewhere. */ double random_float (void) { - /* We can't rely on any specific value of RAND_MAX, but I'm pretty - sure it's greater than 1000. */ - int rnd1 = random_number (1000); - int rnd2 = random_number (1000); - int rnd3 = random_number (1000); - return rnd1 / 1000.0 + rnd2 / 1000000.0 + rnd3 / 1000000000.0; +#ifdef HAVE_DRAND48 + if (!rnd_seeded) + { + srand48 ((long) time (NULL) ^ (long) getpid ()); + rnd_seeded = 1; + } + return drand48 (); +#else /* not HAVE_DRAND48 */ + return ( random_number (10000) / 10000.0 + + random_number (10000) / (10000.0 * 10000.0) + + random_number (10000) / (10000.0 * 10000.0 * 10000.0) + + random_number (10000) / (10000.0 * 10000.0 * 10000.0 * 10000.0)); +#endif /* not HAVE_DRAND48 */ } /* Implementation of run_with_timeout, a generic timeout-forcing @@ -1686,7 +1690,7 @@ static sigjmp_buf run_with_timeout_env; -static RETSIGTYPE +static void abort_run_with_timeout (int sig) { assert (sig == SIGALRM); @@ -1697,7 +1701,7 @@ static jmp_buf run_with_timeout_env; -static RETSIGTYPE +static void abort_run_with_timeout (int sig) { assert (sig == SIGALRM); @@ -1763,8 +1767,8 @@ } /* Call FUN(ARG), but don't allow it to run for more than TIMEOUT - seconds. Returns non-zero if the function was interrupted with a - timeout, zero otherwise. + seconds. Returns true if the function was interrupted with a + timeout, false otherwise. This works by setting up SIGALRM to be delivered in TIMEOUT seconds using setitimer() or alarm(). The timeout is enforced by @@ -1789,7 +1793,7 @@ are normally freed prior to exit from the functions, they will be lost in case of timeout. */ -int +bool run_with_timeout (double timeout, void (*fun) (void *), void *arg) { int saved_errno; @@ -1797,7 +1801,7 @@ if (timeout == 0) { fun (arg); - return 0; + return false; } signal (SIGALRM, abort_run_with_timeout); @@ -1805,7 +1809,7 @@ { /* Longjumped out of FUN with a timeout. */ signal (SIGALRM, SIG_DFL); - return 1; + return true; } alarm_set (timeout); fun (arg); @@ -1816,7 +1820,7 @@ signal (SIGALRM, SIG_DFL); errno = saved_errno; - return 0; + return false; } #else /* not USE_SIGNAL_TIMEOUT */ @@ -1830,7 +1834,7 @@ run_with_timeout (double timeout, void (*fun) (void *), void *arg) { fun (arg); - return 0; + return false; } #endif /* not WINDOWS */ #endif /* not USE_SIGNAL_TIMEOUT */ @@ -1856,8 +1860,7 @@ /* If nanosleep has been interrupted by a signal, adjust the sleeping period and return to sleep. */ sleep = remaining; -#else /* not HAVE_NANOSLEEP */ -#ifdef HAVE_USLEEP +#elif defined(HAVE_USLEEP) /* If usleep is available, use it in preference to select. */ if (seconds >= 1) { @@ -1868,13 +1871,11 @@ seconds -= (long) seconds; } usleep (seconds * 1000000); -#else /* not HAVE_USLEEP */ -#ifdef HAVE_SELECT - /* Note that, although Windows supports select, this sleeping - strategy doesn't work there because Winsock's select doesn't - implement timeout when it is passed NULL pointers for all fd - sets. (But it does work under Cygwin, which implements its own - select.) */ +#else /* fall back select */ + /* Note that, although Windows supports select, it can't be used to + implement sleeping because Winsock's select doesn't implement + timeout when it is passed NULL pointers for all fd sets. (But it + does under Cygwin, which implements Unix-compatible select.) */ struct timeval sleep; sleep.tv_sec = (long) seconds; sleep.tv_usec = 1000000 * (seconds - (long) seconds); @@ -1883,11 +1884,7 @@ interrupted by a signal. But without knowing how long we've actually slept, we can't return to sleep. Using gettimeofday to track sleeps is slow and unreliable due to clock skew. */ -#else /* not HAVE_SELECT */ - sleep (seconds); -#endif /* not HAVE_SELECT */ -#endif /* not HAVE_USLEEP */ -#endif /* not HAVE_NANOSLEEP */ +#endif } #endif /* not WINDOWS */ @@ -1941,19 +1938,17 @@ return p - b64store; } +/* Store in C the next non-whitespace character from the string, or \0 + when end of string is reached. */ +#define NEXT_CHAR(c, p) do { \ + c = (unsigned char) *p++; \ +} while (ISSPACE (c)) + #define IS_ASCII(c) (((c) & 0x80) == 0) -#define IS_BASE64(c) ((IS_ASCII (c) && base64_char_to_value[c] >= 0) || c == '=') -/* Get next character from the string, except that non-base64 - characters are ignored, as mandated by rfc2045. */ -#define NEXT_BASE64_CHAR(c, p) do { \ - c = *p++; \ -} while (c != '\0' && !IS_BASE64 (c)) - -/* Decode data from BASE64 (assumed to be encoded as base64) into - memory pointed to by TO. TO should be large enough to accomodate - the decoded data, which is guaranteed to be less than - strlen(base64). +/* Decode data from BASE64 (pointer to \0-terminated text) into memory + pointed to by TO. TO should be large enough to accomodate the + decoded data, which is guaranteed to be less than strlen(base64). Since TO is assumed to contain binary data, it is not NUL-terminated. The function returns the length of the data @@ -1965,7 +1960,7 @@ { /* Table of base64 values for first 128 characters. Note that this assumes ASCII (but so does Wget in other places). */ - static short base64_char_to_value[128] = + static signed char base64_char_to_value[128] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0- 9 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 10- 19 */ @@ -1981,6 +1976,8 @@ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, /* 110-119 */ 49, 50, 51, -1, -1, -1, -1, -1 /* 120-127 */ }; +#define BASE64_CHAR_TO_VALUE(c) ((int) base64_char_to_value[c]) +#define IS_BASE64(c) ((IS_ASCII (c) && BASE64_CHAR_TO_VALUE (c) >= 0) || c == '=') const char *p = base64; char *q = to; @@ -1991,30 +1988,32 @@ unsigned long value; /* Process first byte of a quadruplet. */ - NEXT_BASE64_CHAR (c, p); + NEXT_CHAR (c, p); if (!c) break; - if (c == '=') - return -1; /* illegal '=' while decoding base64 */ - value = base64_char_to_value[c] << 18; + if (c == '=' || !IS_BASE64 (c)) + return -1; /* illegal char while decoding base64 */ + value = BASE64_CHAR_TO_VALUE (c) << 18; - /* Process scond byte of a quadruplet. */ - NEXT_BASE64_CHAR (c, p); + /* Process second byte of a quadruplet. */ + NEXT_CHAR (c, p); if (!c) return -1; /* premature EOF while decoding base64 */ - if (c == '=') - return -1; /* illegal `=' while decoding base64 */ - value |= base64_char_to_value[c] << 12; + if (c == '=' || !IS_BASE64 (c)) + return -1; /* illegal char while decoding base64 */ + value |= BASE64_CHAR_TO_VALUE (c) << 12; *q++ = value >> 16; /* Process third byte of a quadruplet. */ - NEXT_BASE64_CHAR (c, p); + NEXT_CHAR (c, p); if (!c) return -1; /* premature EOF while decoding base64 */ + if (!IS_BASE64 (c)) + return -1; /* illegal char while decoding base64 */ if (c == '=') { - NEXT_BASE64_CHAR (c, p); + NEXT_CHAR (c, p); if (!c) return -1; /* premature EOF while decoding base64 */ if (c != '=') @@ -2022,33 +2021,36 @@ continue; } - value |= base64_char_to_value[c] << 6; + value |= BASE64_CHAR_TO_VALUE (c) << 6; *q++ = 0xff & value >> 8; /* Process fourth byte of a quadruplet. */ - NEXT_BASE64_CHAR (c, p); + NEXT_CHAR (c, p); if (!c) return -1; /* premature EOF while decoding base64 */ if (c == '=') continue; + if (!IS_BASE64 (c)) + return -1; /* illegal char while decoding base64 */ - value |= base64_char_to_value[c]; + value |= BASE64_CHAR_TO_VALUE (c); *q++ = 0xff & value; } +#undef IS_BASE64 +#undef BASE64_CHAR_TO_VALUE return q - to; } #undef IS_ASCII -#undef IS_BASE64 -#undef NEXT_BASE64_CHAR +#undef NEXT_CHAR /* Simple merge sort for use by stable_sort. Implementation courtesy Zeljko Vrba with additional debugging by Nenad Barbutov. */ static void mergesort_internal (void *base, void *temp, size_t size, size_t from, size_t to, - int (*cmpfun) PARAMS ((const void *, const void *))) + int (*cmpfun) (const void *, const void *)) { #define ELT(array, pos) ((char *)(array) + (pos) * size) if (from < to) @@ -2080,7 +2082,7 @@ void stable_sort (void *base, size_t nmemb, size_t size, - int (*cmpfun) PARAMS ((const void *, const void *))) + int (*cmpfun) (const void *, const void *)) { if (size > 1) { @@ -2088,3 +2090,95 @@ mergesort_internal (base, temp, size, 0, nmemb - 1, cmpfun); } } + +/* Print a decimal number. If it is equal to or larger than ten, the + number is rounded. Otherwise it is printed with one significant + digit without trailing zeros and with no more than three fractional + digits total. For example, 0.1 is printed as "0.1", 0.035 is + printed as "0.04", 0.0091 as "0.009", and 0.0003 as simply "0". + + This is useful for displaying durations because it provides + order-of-magnitude information without unnecessary clutter -- + long-running downloads are shown without the fractional part, and + short ones still retain one significant digit. */ + +const char * +print_decimal (double number) +{ + static char buf[32]; + double n = number >= 0 ? number : -number; + + if (n >= 9.95) + /* Cut off at 9.95 because the below %.1f would round 9.96 to + "10.0" instead of "10". OTOH 9.94 will print as "9.9". */ + snprintf (buf, sizeof buf, "%.0f", number); + else if (n >= 0.95) + snprintf (buf, sizeof buf, "%.1f", number); + else if (n >= 0.001) + snprintf (buf, sizeof buf, "%.1g", number); + else if (n >= 0.0005) + /* round [0.0005, 0.001) to 0.001 */ + snprintf (buf, sizeof buf, "%.3f", number); + else + /* print numbers close to 0 as 0, not 0.000 */ + strcpy (buf, "0"); + + return buf; +} + +#ifdef TESTING + +const char * +test_subdir_p() +{ + int i; + struct { + char *d1; + char *d2; + bool result; + } test_array[] = { + { "/somedir", "/somedir", true }, + { "/somedir", "/somedir/d2", true }, + { "/somedir/d1", "/somedir", false }, + }; + + for (i = 0; i < countof(test_array); ++i) + { + bool res = subdir_p (test_array[i].d1, test_array[i].d2); + + mu_assert ("test_subdir_p: wrong result", + res == test_array[i].result); + } + + return NULL; +} + +const char * +test_dir_matches_p() +{ + int i; + struct { + char *dirlist[3]; + char *dir; + bool result; + } test_array[] = { + { { "/somedir", "/someotherdir", NULL }, "somedir", true }, + { { "/somedir", "/someotherdir", NULL }, "anotherdir", false }, + { { "/somedir", "/*otherdir", NULL }, "anotherdir", true }, + { { "/somedir/d1", "/someotherdir", NULL }, "somedir/d1", true }, + { { "/somedir/d1", "/someotherdir", NULL }, "d1", false }, + }; + + for (i = 0; i < countof(test_array); ++i) + { + bool res = dir_matches_p (test_array[i].dirlist, test_array[i].dir); + + mu_assert ("test_dir_matches_p: wrong result", + res == test_array[i].result); + } + + return NULL; +} + +#endif /* TESTING */ + diff -urN wget-1.10.2/src/utils.h wget-1.10.2_new/src/utils.h --- wget-1.10.2/src/utils.h 2005-06-25 16:47:52.000000000 +0200 +++ wget-1.10.2_new/src/utils.h 2006-06-27 12:18:18.000000000 +0200 @@ -1,5 +1,5 @@ /* Declarations for utils.c. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -30,10 +30,6 @@ #ifndef UTILS_H #define UTILS_H -enum accd { - ALLABS = 1 -}; - struct hash_table; struct file_memory { @@ -44,85 +40,89 @@ #define HYPHENP(x) (*(x) == '-' && !*((x) + 1)) -char *time_str PARAMS ((time_t *)); -char *datetime_str PARAMS ((time_t *)); +char *time_str (time_t *); +char *datetime_str (time_t *); #ifdef DEBUG_MALLOC void print_malloc_debug_stats (); #endif -char *xstrdup_lower PARAMS ((const char *)); +char *xstrdup_lower (const char *); -char *strdupdelim PARAMS ((const char *, const char *)); -char **sepstring PARAMS ((const char *)); -int frontcmp PARAMS ((const char *, const char *)); -void fork_to_background PARAMS ((void)); - -#ifdef WGET_USE_STDARG -char *aprintf PARAMS ((const char *, ...)) - GCC_FORMAT_ATTR (1, 2); -char *concat_strings PARAMS ((const char *, ...)); -#else /* not WGET_USE_STDARG */ -char *aprintf (); -char *concat_strings (); -#endif /* not WGET_USE_STDARG */ - -void touch PARAMS ((const char *, time_t)); -int remove_link PARAMS ((const char *)); -int file_exists_p PARAMS ((const char *)); -int file_non_directory_p PARAMS ((const char *)); -wgint file_size PARAMS ((const char *)); -int make_directory PARAMS ((const char *)); -char *unique_name PARAMS ((const char *, int)); -FILE *unique_create PARAMS ((const char *, int, char **)); -FILE *fopen_excl PARAMS ((const char *, int)); -char *file_merge PARAMS ((const char *, const char *)); - -int acceptable PARAMS ((const char *)); -int accdir PARAMS ((const char *s, enum accd)); -char *suffix PARAMS ((const char *s)); -int match_tail PARAMS ((const char *, const char *, int)); -int has_wildcards_p PARAMS ((const char *)); - -int has_html_suffix_p PARAMS ((const char *)); - -char *read_whole_line PARAMS ((FILE *)); -struct file_memory *read_file PARAMS ((const char *)); -void read_file_free PARAMS ((struct file_memory *)); - -void free_vec PARAMS ((char **)); -char **merge_vecs PARAMS ((char **, char **)); -char **vec_append PARAMS ((char **, const char *)); - -void string_set_add PARAMS ((struct hash_table *, const char *)); -int string_set_contains PARAMS ((struct hash_table *, const char *)); -void string_set_to_array PARAMS ((struct hash_table *, char **)); -void string_set_free PARAMS ((struct hash_table *)); -void free_keys_and_values PARAMS ((struct hash_table *)); - -char *with_thousand_seps PARAMS ((wgint)); -#ifndef with_thousand_seps_sum -char *with_thousand_seps_sum PARAMS ((SUM_SIZE_INT)); +char *strdupdelim (const char *, const char *); +char **sepstring (const char *); +bool subdir_p (const char *, const char *); +void fork_to_background (void); + +char *aprintf (const char *, ...) GCC_FORMAT_ATTR (1, 2); +char *concat_strings (const char *, ...); + +void touch (const char *, time_t); +int remove_link (const char *); +bool file_exists_p (const char *); +bool file_non_directory_p (const char *); +wgint file_size (const char *); +int make_directory (const char *); +char *unique_name (const char *, bool); +FILE *unique_create (const char *, bool, char **); +FILE *fopen_excl (const char *, bool); +char *file_merge (const char *, const char *); + +int fnmatch_nocase (const char *, const char *, int); +bool acceptable (const char *); +bool accdir (const char *s); +char *suffix (const char *s); +bool match_tail (const char *, const char *, bool); +bool has_wildcards_p (const char *); + +bool has_html_suffix_p (const char *); + +char *read_whole_line (FILE *); +struct file_memory *read_file (const char *); +void read_file_free (struct file_memory *); + +void free_vec (char **); +char **merge_vecs (char **, char **); +char **vec_append (char **, const char *); + +void string_set_add (struct hash_table *, const char *); +int string_set_contains (struct hash_table *, const char *); +void string_set_to_array (struct hash_table *, char **); +void string_set_free (struct hash_table *); +void free_keys_and_values (struct hash_table *); + +const char *with_thousand_seps (wgint); + +/* human_readable must be able to accept wgint and SUM_SIZE_INT + arguments. On machines where wgint is 32-bit, declare it to accept + double. */ +#if SIZEOF_WGINT >= 8 +# define HR_NUMTYPE wgint +#else +# define HR_NUMTYPE double #endif -char *human_readable PARAMS ((wgint)); -int numdigit PARAMS ((wgint)); -char *number_to_string PARAMS ((char *, wgint)); -char *number_to_static_string PARAMS ((wgint)); - -int determine_screen_width PARAMS ((void)); -int random_number PARAMS ((int)); -double random_float PARAMS ((void)); +char *human_readable (HR_NUMTYPE); + -int run_with_timeout PARAMS ((double, void (*) (void *), void *)); -void xsleep PARAMS ((double)); +int numdigit (wgint); +char *number_to_string (char *, wgint); +char *number_to_static_string (wgint); + +int determine_screen_width (void); +int random_number (int); +double random_float (void); + +bool run_with_timeout (double, void (*) (void *), void *); +void xsleep (double); /* How many bytes it will take to store LEN bytes in base64. */ #define BASE64_LENGTH(len) (4 * (((len) + 2) / 3)) -int base64_encode PARAMS ((const char *, int, char *)); -int base64_decode PARAMS ((const char *, char *)); +int base64_encode (const char *, int, char *); +int base64_decode (const char *, char *); + +void stable_sort (void *, size_t, size_t, int (*) (const void *, const void *)); -void stable_sort PARAMS ((void *, size_t, size_t, - int (*) (const void *, const void *))); +const char *print_decimal (double); #endif /* UTILS_H */ diff -urN wget-1.10.2/src/wget.h wget-1.10.2_new/src/wget.h --- wget-1.10.2/src/wget.h 2005-08-11 23:35:27.000000000 +0200 +++ wget-1.10.2_new/src/wget.h 2006-06-27 12:19:56.000000000 +0200 @@ -1,5 +1,5 @@ /* Miscellaneous declarations. - Copyright (C) 1995, 1996, 1997, 1998, 2003 Free Software Foundation, Inc. + Copyright (C) 1996-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -40,12 +40,9 @@ # define NDEBUG #endif -#ifndef PARAMS -# if PROTOTYPES -# define PARAMS(args) args -# else -# define PARAMS(args) () -# endif +/* Is OpenSSL or GNUTLS available? */ +#if defined HAVE_LIBSSL || defined HAVE_LIBGNUTLS +# define HAVE_SSL #endif /* `gettext (FOO)' is long to write, so we use `_(FOO)'. If NLS is @@ -106,13 +103,21 @@ # define UNLIKELY(exp) (exp) #endif -/* Print X if debugging is enabled; a no-op otherwise. */ +/* Execute the following statement if debugging is both enabled at + compile-time and requested at run-time; a no-op otherwise. */ #ifdef ENABLE_DEBUG -# define DEBUGP(x) do if (UNLIKELY (opt.debug)) {debug_logprintf x;} while (0) -#else /* not ENABLE_DEBUG */ -# define DEBUGP(x) do {} while (0) -#endif /* not ENABLE_DEBUG */ +# define IF_DEBUG if (UNLIKELY (opt.debug)) +#else +# define IF_DEBUG if (0) +#endif + +/* Print ARGS if debugging is enabled and requested, otherwise do + nothing. This must be called with an extra level of parentheses + because it's not possible to pass a variable number of arguments to + a macro (in portable C89). ARGS are like arguments to printf. */ + +#define DEBUGP(args) do { IF_DEBUG { debug_logprintf args; } } while (0) /* Define an integer type that works for file sizes, content lengths, and such. Normally we could just use off_t, but off_t is always @@ -121,10 +126,8 @@ #ifndef WINDOWS typedef off_t wgint; # define SIZEOF_WGINT SIZEOF_OFF_T -#endif -/* Define a strtol/strtoll clone that works with wgint. */ -#ifndef str_to_wgint /* mswindows.h defines its own alias */ +/* Pick the strtol-like function that will work with wgint. */ # if SIZEOF_WGINT == SIZEOF_LONG # define str_to_wgint strtol # define WGINT_MAX LONG_MAX @@ -132,24 +135,22 @@ # define WGINT_MAX LLONG_MAX # ifdef HAVE_STRTOLL # define str_to_wgint strtoll +# elif defined HAVE_STRTOIMAX /* HPUX 11.0 has strtoimax, but no strtoll */ +# define str_to_wgint strtoimax # else -# ifdef HAVE_STRTOIMAX -# define str_to_wgint strtoimax -# else -# define str_to_wgint strtoll -# define NEED_STRTOLL -# define strtoll_return long long -# endif +# define str_to_wgint strtoll +# define NEED_STRTOLL +# define strtoll_type long long # endif # endif -#endif +#endif /* not WINDOWS */ /* Declare our strtoll replacement. */ #ifdef NEED_STRTOLL -strtoll_return strtoll PARAMS ((const char *, char **, int)); +strtoll_type strtoll (const char *, char **, int); #endif -/* Now define a large integral type useful for storing sizes of *sums* +/* Now define a large numeric type useful for storing sizes of *sums* of downloads, such as the value of the --quota option. This should be a type able to hold 2G+ values even on systems without large file support. (It is useful to limit Wget's download quota to say @@ -160,9 +161,8 @@ few places in Wget, this is acceptable.) */ #if SIZEOF_WGINT >= 8 -/* just use wgint, which we already know how to print */ +/* just use wgint */ typedef wgint SUM_SIZE_INT; -# define with_thousand_seps_sum with_thousand_seps #else /* On systems without LFS, use double, which buys us integers up to 2^53. */ typedef double SUM_SIZE_INT; @@ -255,14 +255,14 @@ (sizevar) = DR_newsize; \ } \ if (DR_newsize) \ - basevar = (type *)xrealloc (basevar, DR_newsize * sizeof (type)); \ + basevar = xrealloc (basevar, DR_newsize * sizeof (type)); \ } while (0) /* Used to print pointers (usually for debugging). Print pointers - using printf ("%0*lx", PTR_FORMAT (p)). (%p is too unpredictable; + using printf ("0x%0*lx", PTR_FORMAT (p)). (%p is too unpredictable; some implementations prepend 0x, while some don't, and most don't 0-pad the address.) */ -#define PTR_FORMAT(p) 2 * sizeof (void *), (unsigned long) (p) +#define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p) extern const char *exec_name; @@ -283,18 +283,23 @@ simplified. */ typedef enum { + /* 0 */ NOCONERROR, HOSTERR, CONSOCKERR, CONERROR, CONSSLERR, - CONIMPOSSIBLE, NEWLOCATION, NOTENOUGHMEM, CONPORTERR, - CONCLOSED, FTPOK, FTPLOGINC, FTPLOGREFUSED, FTPPORTERR, FTPSYSERR, - FTPNSFOD, FTPRETROK, FTPUNKNOWNTYPE, FTPRERR, - FTPREXC, FTPSRVERR, FTPRETRINT, FTPRESTFAIL, URLERROR, - FOPENERR, FOPEN_EXCL_ERR, FWRITEERR, HOK, HLEXC, HEOF, + CONIMPOSSIBLE, NEWLOCATION, NOTENOUGHMEM, CONPORTERR, CONCLOSED, + /* 10 */ + FTPOK, FTPLOGINC, FTPLOGREFUSED, FTPPORTERR, FTPSYSERR, + FTPNSFOD, FTPRETROK, FTPUNKNOWNTYPE, FTPRERR, FTPREXC, + /* 20 */ + FTPSRVERR, FTPRETRINT, FTPRESTFAIL, URLERROR, FOPENERR, + FOPEN_EXCL_ERR, FWRITEERR, HOK, HLEXC, HEOF, + /* 30 */ HERR, RETROK, RECLEVELEXC, FTPACCDENIED, WRONGCODE, - FTPINVPASV, FTPNOPASV, - CONTNOTSUPPORTED, RETRUNNEEDED, RETRFINISHED, READERR, TRYLIMEXC, - URLBADPATTERN, FILEBADFILE, RANGEERR, RETRBADPATTERN, - RETNOTSUP, ROBOTSOK, NOROBOTS, PROXERR, AUTHFAILED, - QUOTEXC, WRITEFAILED, SSLINITFAILED + FTPINVPASV, FTPNOPASV, CONTNOTSUPPORTED, RETRUNNEEDED, RETRFINISHED, + /* 40 */ + READERR, TRYLIMEXC, URLBADPATTERN, FILEBADFILE, RANGEERR, + RETRBADPATTERN, RETNOTSUP, ROBOTSOK, NOROBOTS, PROXERR, + /* 50 */ + AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED } uerr_t; #endif /* WGET_H */ diff -urN wget-1.10.2/src/xmalloc.c wget-1.10.2_new/src/xmalloc.c --- wget-1.10.2/src/xmalloc.c 2005-07-04 23:17:05.000000000 +0200 +++ wget-1.10.2_new/src/xmalloc.c 2006-06-27 12:19:56.000000000 +0200 @@ -1,5 +1,5 @@ /* Wrappers around malloc and memory debugging support. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -31,12 +31,7 @@ #include #include -#ifdef HAVE_STRING_H -# include -#else /* not HAVE_STRING_H */ -# include -#endif /* not HAVE_STRING_H */ -#include +#include #include #include @@ -44,10 +39,6 @@ #include "xmalloc.h" #include "hash.h" /* for hash_pointer */ -#ifndef errno -extern int errno; -#endif - /* This file implements several wrappers around the basic allocation routines. This is done for two reasons: first, so that the callers of these functions need not check for errors, which is easy to @@ -67,7 +58,7 @@ { /* Make sure we don't try to store part of the log line, and thus call malloc. */ - log_set_save_context (0); + log_set_save_context (false); logprintf (LOG_ALWAYS, _("%s: %s: Failed to allocate %ld bytes; memory exhausted.\n"), exec_name, context, attempted_size); @@ -261,15 +252,15 @@ malloc_table[i].line = line; } -/* Unregister PTR from malloc_table. Return 0 if PTR is not present - in malloc_table. */ +/* Unregister PTR from malloc_table. Return false if PTR is not + present in malloc_table. */ -static int +static bool unregister_ptr (void *ptr) { int i = ptr_position (ptr); if (malloc_table[i].ptr == NULL) - return 0; + return false; malloc_table[i].ptr = NULL; /* Relocate malloc_table entries immediately following PTR. */ @@ -288,7 +279,7 @@ cont_outer: ; } - return 1; + return true; } /* Print the malloc debug stats gathered from the above information. diff -urN wget-1.10.2/src/xmalloc.h wget-1.10.2_new/src/xmalloc.h --- wget-1.10.2/src/xmalloc.h 2005-04-11 02:41:20.000000000 +0200 +++ wget-1.10.2_new/src/xmalloc.h 2006-06-27 12:19:56.000000000 +0200 @@ -1,5 +1,5 @@ /* xmalloc.c declarations. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -14,8 +14,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the Free Software Foundation gives permission to link the code of its release of Wget with the @@ -56,11 +56,11 @@ #define xstrdup checking_strdup #define xfree checking_free -void *checking_malloc PARAMS ((size_t)); -void *checking_malloc0 PARAMS ((size_t)); -void *checking_realloc PARAMS ((void *, size_t)); -char *checking_strdup PARAMS ((const char *)); -void checking_free PARAMS ((void *)); +void *checking_malloc (size_t); +void *checking_malloc0 (size_t); +void *checking_realloc (void *, size_t); +char *checking_strdup (const char *); +void checking_free (void *); #else /* DEBUG_MALLOC */ @@ -70,11 +70,11 @@ #define xstrdup(p) debugging_strdup (p, __FILE__, __LINE__) #define xfree(p) debugging_free (p, __FILE__, __LINE__) -void *debugging_malloc PARAMS ((size_t, const char *, int)); -void *debugging_malloc0 PARAMS ((size_t, const char *, int)); -void *debugging_realloc PARAMS ((void *, size_t, const char *, int)); -char *debugging_strdup PARAMS ((const char *, const char *, int)); -void debugging_free PARAMS ((void *, const char *, int)); +void *debugging_malloc (size_t, const char *, int); +void *debugging_malloc0 (size_t, const char *, int); +void *debugging_realloc (void *, size_t, const char *, int); +char *debugging_strdup (const char *, const char *, int); +void debugging_free (void *, const char *, int); #endif /* DEBUG_MALLOC */ @@ -83,10 +83,10 @@ necessary in standard C, but Wget performs them anyway for the sake of pre-standard environments and possibly C++. */ -#define xnew(type) ((type *) xmalloc (sizeof (type))) -#define xnew0(type) ((type *) xmalloc0 (sizeof (type))) -#define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type))) -#define xnew0_array(type, len) ((type *) xmalloc0 ((len) * sizeof (type))) +#define xnew(type) (xmalloc (sizeof (type))) +#define xnew0(type) (xmalloc0 (sizeof (type))) +#define xnew_array(type, len) (xmalloc ((len) * sizeof (type))) +#define xnew0_array(type, len) (xmalloc0 ((len) * sizeof (type))) #define alloca_array(type, size) ((type *) alloca ((size) * sizeof (type))) diff -urN wget-1.10.2/tests/ChangeLog wget-1.10.2_new/tests/ChangeLog --- wget-1.10.2/tests/ChangeLog 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/ChangeLog 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,100 @@ +2006-06-13 Mauro Tortonesi + + * Test9.px: Added test for --restrict-file-names=lowercase option. + + * Test10.px: Added test for --restrict-file-names=uppercase option. + +2006-05-26 Mauro Tortonesi + + * HTTPServer.pm: Added synchronization between client and server + processes to prevent the test to start before the server is ready. + + * HTTPTest.pm: Ditto. + + * Test.pm: Ditto. + + * Test1.px: Removed unneeded ../src/ from command line. + + * Test2.px: Ditto. + + * Test3.px: Ditto. + + * Test4.px: Ditto. + + * Test5.px: Ditto. + + * Test6.px: Ditto. + + * Test7.px: Ditto. + + * Test8.px: Added test for recursive spider mode. + +2006-05-26 Mauro Tortonesi + + * HTTPServer.pm: Fixed bug when returning 404. Improved logging. + + * Test.pm: Added support for command lines which use an absolute path + for the Wget binary. + +2006-04-28 Mauro Tortonesi + + * Test5.px: Added test for HTTP Content-Disposition support. + + * Test6.px: Ditto. + + * Test7.px: Ditto. + +2006-04-27 Mauro Tortonesi + + * HTTPServer.pm: Serve index.html if no filename is given. + + * Test.pm: Added support for pre-existing files. + +2006-01-24 Mauro Tortonesi + + * HTTPServer.pm: Enhanced logging support. + + * HTTPTest.pm: Updated to new test format. + + * Test.pm: Improved test setup, verification and cleanup. Major + refactoring. + + * Test1.px: Updated to new test format. + + * Test2.px: Updated to new test format. + + * Test3.px: Added new test for quiet download of nonexistent URL. + + * Test4.px: Added new test for quiet download of nonexistent URL with + --output-document option. + +2005-12-05 Mauro Tortonesi + + * HTTPServer.pm: Refactored as a subclass of HTTP::Daemon. + Removed the old run method and renamed the old run_daemon + method to run. Added support for partial + + * Testing.pm: Renamed to HTTPTest.pm. + + * HTTPTest.pm: Refactored as a subclass of Test. Renamed + Run_HTTP_Test to run, verify_download to _verify_download + and added support for timestamp checking. + + * Test.pm: Added Test class as the super class of every + testcase. + + * test1: Renamed to Test1.px. + + * Test1.px: Refactored as an instance of the HTTPTest class. + + * Test2.px: Added -N HTTP test. + +2005-11-02 Mauro Tortonesi + + * HTTPServer.pm: Added basic support for HTTP testing. + + * Testing.pm: Added basic support for feature testing (only HTTP + testing is supported at the moment). + + * test1: Added basic HTTP test. + diff -urN wget-1.10.2/tests/HTTPServer.pm wget-1.10.2_new/tests/HTTPServer.pm --- wget-1.10.2/tests/HTTPServer.pm 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/HTTPServer.pm 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,93 @@ +#!/usr/bin/perl -w + +package HTTPServer; + +use strict; + +use HTTP::Daemon; +use HTTP::Status; +use HTTP::Headers; +use HTTP::Response; + +our @ISA=qw(HTTP::Daemon); +my $VERSION = 0.01; + +my $CRLF = "\015\012"; # "\r\n" is not portable +my $log = undef; + +sub run { + my ($self, $urls, $synch_callback) = @_; + my $initialized = 0; + + while (1) { + if (!$initialized) { + $synch_callback->(); + $initialized = 1; + } + + my $con = $self->accept(); + print STDERR "Accepted a new connection\n" if $log; + while (my $req = $con->get_request) { + my $url_path = $req->url->path; + if ($url_path =~ m{/$}) { + $url_path .= 'index.html'; + } + if ($log) { + print STDERR "Method: ", $req->method, "\n"; + print STDERR "Path: ", $url_path, "\n"; + print STDERR "Available URLs: ", "\n"; + foreach my $key (keys %$urls) { + print STDERR $key, "\n"; + } + } + if (exists($urls->{$url_path})) { + print STDERR "Serving requested URL: ", $url_path, "\n" if $log; + next unless ($req->method eq "HEAD" || $req->method eq "GET"); + + # create response + my $tmp = $urls->{$url_path}; + my $resp = HTTP::Response->new ($tmp->{code}, $tmp->{msg}); + print STDERR "HTTP::Response: \n", $resp->as_string if $log; + + #if (is_dynamic_url) { # dynamic resource + #} else { # static resource + # fill in headers + while (my ($name, $value) = each %{$tmp->{headers}}) { + # print STDERR "setting header: $name = $value\n"; + $resp->header($name => $value); + } + print STDERR "HTTP::Response with headers: \n", $resp->as_string if $log; + + if ($req->method eq "GET") { + if (exists($tmp->{headers}{"Content-Length"})) { + # Content-Length and length($tmp->{content}) don't match + # manually prepare the HTTP response + $con->send_basic_header($tmp->{code}, $resp->message, $resp->protocol); + print $con $resp->headers_as_string($CRLF); + print $con $CRLF; + print $con $tmp->{content}; + next; + } + # fill in content + $resp->content($tmp->{content}); + print STDERR "HTTP::Response with content: \n", $resp->as_string if $log; + } + #} + + $con->send_response($resp); + print STDERR "HTTP::Response sent: \n", $resp->as_string if $log; + } else { + print STDERR "Requested wrong URL: ", $url_path, "\n" if $log; + $con->send_error($HTTP::Status::RC_FORBIDDEN); + last; + } + } + print STDERR "Closing connection\n" if $log; + $con->close; + } +} + +1; + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/HTTPTest.pm wget-1.10.2_new/tests/HTTPTest.pm --- wget-1.10.2/tests/HTTPTest.pm 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/HTTPTest.pm 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,49 @@ +#!/usr/bin/perl -w + +package HTTPTest; + +use strict; + +use HTTPServer; +use Test; + +our @ISA = qw(Test); +my $VERSION = 0.01; + + +{ + my %_attr_data = ( # DEFAULT + ); + + sub _default_for + { + my ($self, $attr) = @_; + return $_attr_data{$attr} if exists $_attr_data{$attr}; + return $self->SUPER::_default_for($attr); + } + + sub _standard_keys + { + my ($self) = @_; + ($self->SUPER::_standard_keys(), keys %_attr_data); + } +} + + +sub _setup_server {} + + +sub _launch_server { + my $self = shift; + my $synch_func = shift; + + my $server = HTTPServer->new (LocalAddr => 'localhost', + LocalPort => '8080', + ReuseAddr => 1) or die "Cannot create server!!!"; + $server->run ($self->{_input}, $synch_func); +} + +1; + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Makefile.in wget-1.10.2_new/tests/Makefile.in --- wget-1.10.2/tests/Makefile.in 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Makefile.in 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,250 @@ +# Makefile for `wget' utility +# Copyright (C) 1995-2005 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 2 of the License, 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 Wget; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +# In addition, as a special exception, the Free Software Foundation +# gives permission to link the code of its release of Wget with the +# OpenSSL project's "OpenSSL" library (or with modified versions of it +# that use the same license as the "OpenSSL" library), and distribute +# the linked executables. You must obey the GNU General Public License +# in all respects for all of the code used other than "OpenSSL". If you +# modify this file, you may extend this exception to your version of the +# file, but you are not obligated to do so. If you do not wish to do +# so, delete this exception statement from your version. + +# +# Version: @VERSION@ +# + +SHELL = /bin/sh + +top_builddir = .. + +top_srcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +sysconfdir = @sysconfdir@ +datadir = @datadir@ +localedir = $(datadir)/locale + +DESTDIR = + +CC = @CC@ +CPPFLAGS = @CPPFLAGS@ +# The following line is losing on some versions of make! +DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\" +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ @LIBSSL@ @LIBGNUTLS@ +exeext = @exeext@ + +INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../src + +COMPILE = $(CC) $(INCLUDES) $(CPPFLAGS) $(DEFS) $(CFLAGS) +LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +RM = rm -f +ETAGS = etags + +# Conditional compiles +ALLOCA = @ALLOCA@ +MD5_OBJ = @MD5_OBJ@ +OPIE_OBJ = @OPIE_OBJ@ +NTLM_OBJ = @NTLM_OBJ@ +SSL_OBJ = @SSL_OBJ@ +GETOPT_OBJ = @GETOPT_OBJ@ + + +all: + +unittest: test$(exeext) + +# +# Dependencies for test binary +# + +TESTOBJ = $(ALLOCA) cmpt.o connect.o convert.o cookies.o \ + ftp.o ftp-basic.o ftp-ls.o $(OPIE_OBJ) $(GETOPT_OBJ) hash.o \ + host.o html-parse.o html-url.o http.o $(NTLM_OBJ) init.o \ + log.o main.o $(MD5_OBJ) netrc.o progress.o \ + ptimer.o recur.o res.o retr.o safe-ctype.o snprintf.o \ + $(SSL_OBJ) test.o url.o utils.o version.o xmalloc.o + +# We make object files depend on every header. Rather than attempt to +# track dependencies, everything gets recompiled when a header +# changes. With a program of Wget's size this doesn't waste much +# time, and it's a lot safer than attempting to get all the +# dependencies right. + +HEADERS = ../src/config-post.h ../src/config.h \ + ../src/connect.h ../src/convert.h ../src/cookies.h \ + ../src/ftp.h ../src/gen-md5.h ../src/getopt.h \ + ../src/gnu-md5.h ../src/hash.h ../src/host.h \ + ../src/html-parse.h ../src/http-ntlm.h ../src/init.h \ + ../src/log.h ../src/mswindows.h ../src/netrc.h \ + ../src/options.h ../src/progress.h \ + ../src/ptimer.h ../src/recur.h ../src/res.h \ + ../src/retr.h ../src/safe-ctype.h ../src/ssl.h \ + ../src/sysdep.h ../src/test.h ../src/url.h \ + ../src/utils.h ../src/wget.h ../src/xmalloc.h + +alloca.o: ../src/alloca.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +ccache.o: ../src/ccache.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +cmpt.o: ../src/cmpt.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +connect.o: ../src/connect.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +convert.o: ../src/convert.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +cookies.o: ../src/cookies.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +ftp-basic.o: ../src/ftp-basic.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +ftp.o: ../src/ftp.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +ftp-ls.o: ../src/ftp-ls.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +ftp-opie.o: ../src/ftp-opie.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +gen-md5.o: ../src/gen-md5.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +getopt.o: ../src/getopt.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +gnu-md5.o: ../src/gnu-md5.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +gnutls.o: ../src/gnutls.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +hash.o: ../src/hash.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +host.o: ../src/host.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +html-parse.o: ../src/html-parse.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +html-url.o: ../src/html-url.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +http.o: ../src/http.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +http-ntlm.o: ../src/http-ntlm.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +init.o: ../src/init.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +log.o: ../src/log.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +main.o: ../src/main.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +mswindows.o: ../src/mswindows.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +netrc.o: ../src/netrc.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +openssl.o: ../src/openssl.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +progress.o: ../src/progress.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +protocol.o: ../src/protocol.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +ptimer.o: ../src/ptimer.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +recur.o: ../src/recur.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +res.o: ../src/res.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +retr.o: ../src/retr.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +safe-ctype.o: ../src/safe-ctype.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +snprintf.o: ../src/snprintf.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +test.o: ../src/test.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +url.o: ../src/url.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +utils.o: ../src/utils.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +version.o: ../src/version.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + +xmalloc.o: ../src/xmalloc.c $(HEADERS) + $(COMPILE) -DTESTING -c $< + + +test$(exeext): $(TESTOBJ) + $(LINK) $(TESTOBJ) $(LIBS) + +# +# Dependencies for cleanup +# + +clean: + $(RM) *.o test$(exeext) *~ *.bak core core.[0-9]* + +distclean: clean + $(RM) Makefile + +realclean: distclean + +# +# Dependencies for maintenance +# + +subdir = tests + +Makefile: Makefile.in ../config.status + cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status + diff -urN wget-1.10.2/tests/Test10.px wget-1.10.2_new/tests/Test10.px --- wget-1.10.2/tests/Test10.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test10.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,55 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Some Page Title + + +

+ Some text... +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/SomePage.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + }, + content => $mainpage, + }, +); + +my $cmdline = "wget --restrict-file-names=uppercase http://localhost:8080/SomePage.html"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'SOMEPAGE.HTML' => { + content => $mainpage, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test9", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test1.px wget-1.10.2_new/tests/Test1.px --- wget-1.10.2/tests/Test1.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test1.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/plain", + }, + content => $dummyfile + }, +); + +my $cmdline = "wget http://localhost:8080/dummy.html"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'dummy.html' => { + content => $dummyfile, + } +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test1", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test2.px wget-1.10.2_new/tests/Test2.px --- wget-1.10.2/tests/Test2.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test2.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/plain", + "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT", + }, + content => $dummyfile + }, +); + +my $cmdline = "wget -N http://localhost:8080/dummy.html"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'dummy.html' => { + content => $dummyfile, + timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT" + } +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test2", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test3.px wget-1.10.2_new/tests/Test3.px --- wget-1.10.2/tests/Test3.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test3.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/plain", + }, + content => $dummyfile + }, +); + +my $cmdline = "wget --quiet http://localhost:8080/nonexistent"; + +my $expected_error_code = 256; + +my %expected_downloaded_files = ( +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test3", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test4.px wget-1.10.2_new/tests/Test4.px --- wget-1.10.2/tests/Test4.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test4.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/plain", + }, + content => $dummyfile + }, +); + +my $cmdline = "wget --quiet -O out http://localhost:8080/nonexistent"; + +my $expected_error_code = 11; + +my %expected_downloaded_files = ( +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test4", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test5.px wget-1.10.2_new/tests/Test5.px --- wget-1.10.2/tests/Test5.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test5.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,56 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < + + Page Title + + +

+ Some text. +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/dummy.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + "Content-Disposition" => "attachment; filename=\"filename.html\"", + }, + content => $dummyfile, + }, +); + +my $cmdline = "wget http://localhost:8080/dummy.html"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'filename.html' => { + content => $dummyfile, + } +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test5", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test6.px wget-1.10.2_new/tests/Test6.px --- wget-1.10.2/tests/Test6.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test6.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,76 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dontcare = < + + Page Title + + +

+ Some text. +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/dummy.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + "Content-Disposition" => "attachment; filename=\"filename.html\"", + }, + content => $dummyfile, + }, +); + +my $cmdline = "wget http://localhost:8080/dummy.html"; + +my $expected_error_code = 0; + +my %existing_files = ( + 'filename.html' => { + content => $dontcare, + }, + 'filename.html.1' => { + content => $dontcare, + }, +); + +my %expected_downloaded_files = ( + 'filename.html' => { + content => $dontcare, + }, + 'filename.html.1' => { + content => $dontcare, + }, + 'filename.html.2' => { + content => $dummyfile, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test6", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + existing => \%existing_files, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test7.px wget-1.10.2_new/tests/Test7.px --- wget-1.10.2/tests/Test7.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test7.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,76 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dontcare = < + + Page Title + + +

+ Some text. +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/dummy.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + "Content-Disposition" => "attachment; filename=\"filename.html\"", + }, + content => $dummyfile, + }, +); + +my $cmdline = "wget --no-content-disposition http://localhost:8080/dummy.html"; + +my $expected_error_code = 0; + +my %existing_files = ( + 'filename.html' => { + content => $dontcare, + }, + 'filename.html.1' => { + content => $dontcare, + }, +); + +my %expected_downloaded_files = ( + 'filename.html' => { + content => $dontcare, + }, + 'filename.html.1' => { + content => $dontcare, + }, + 'dummy.html' => { + content => $dummyfile, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test7", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + existing => \%existing_files, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test8.px wget-1.10.2_new/tests/Test8.px --- wget-1.10.2/tests/Test8.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test8.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,69 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page Title + + +
Secondary Page + + +EOF + +my $subpage = < + + Secondary Page Title + + + Broken Link + + +EOF + +# code, msg, headers, content +my %urls = ( + '/index.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + }, + content => $mainpage, + }, + '/subpage.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + }, + content => $subpage, + }, +); + +my $cmdline = "wget --spider -r http://localhost:8080/"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test8", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test9.px wget-1.10.2_new/tests/Test9.px --- wget-1.10.2/tests/Test9.px 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test9.px 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,55 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Some Page Title + + +

+ Some text... +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/SomePage.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + }, + content => $mainpage, + }, +); + +my $cmdline = "wget --restrict-file-names=lowercase http://localhost:8080/SomePage.html"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'somepage.html' => { + content => $mainpage, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test9", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +$the_test->run(); + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/tests/Test.pm wget-1.10.2_new/tests/Test.pm --- wget-1.10.2/tests/Test.pm 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/tests/Test.pm 2006-06-27 12:19:56.000000000 +0200 @@ -0,0 +1,240 @@ +#!/usr/bin/perl -w + +package Test; +$VERSION = 0.01; + +use strict; + +use Cwd; +use File::Path; + +my @unexpected_downloads = (); + +{ + my %_attr_data = ( # DEFAULT + _cmdline => "", + _workdir => Cwd::getcwd(), + _errcode => 0, + _existing => {}, + _input => {}, + _name => "", + _output => {}, + ); + + sub _default_for + { + my ($self, $attr) = @_; + $_attr_data{$attr}; + } + + sub _standard_keys + { + keys %_attr_data; + } +} + + +sub new { + my ($caller, %args) = @_; + my $caller_is_obj = ref($caller); + my $class = $caller_is_obj || $caller; + #print STDERR "class = ", $class, "\n"; + #print STDERR "_attr_data {workdir} = ", $Test::_attr_data{_workdir}, "\n"; + my $self = bless {}, $class; + foreach my $attrname ($self->_standard_keys()) { + #print STDERR "attrname = ", $attrname, " value = "; + my ($argname) = ($attrname =~ /^_(.*)/); + if (exists $args{$argname}) { + #printf STDERR "Setting up $attrname\n"; + $self->{$attrname} = $args{$argname}; + } elsif ($caller_is_obj) { + #printf STDERR "Copying $attrname\n"; + $self->{$attrname} = $caller->{$attrname}; + } else { + #printf STDERR "Using default for $attrname\n"; + $self->{$attrname} = $self->_default_for($attrname); + } + #print STDERR $attrname, '=', $self->{$attrname}, "\n"; + } + #printf STDERR "_workdir default = ", $self->_default_for("_workdir"); + return $self; +} + + +sub run { + my $self = shift; + my $result_message = "Test successful.\n"; + + printf "Running test $self->{_name}\n"; + + # Setup + $self->_setup(); + chdir ("$self->{_workdir}/$self->{_name}/input"); + + # Launch server + my $pid = $self->_fork_and_launch_server(); + + # Call wget + chdir ("$self->{_workdir}/$self->{_name}/output"); + # print "Calling $self->{_cmdline}\n"; + my $errcode = + ($self->{_cmdline} =~ m{^/.*}) + ? system ($self->{_cmdline}) + : system ("$self->{_workdir}/../src/$self->{_cmdline}"); + + # Shutdown server + # if we didn't explicitely kill the server, we would have to call + # waitpid ($pid, 0) here in order to wait for the child process to + # terminate + kill ('TERM', $pid); + + # Verify download + unless ($errcode == $self->{_errcode}) { + $result_message = "Test failed: wrong code returned (was: $errcode, expected: $self->{_errcode})\n"; + } + if (my $error_str = $self->_verify_download()) { + $result_message = $error_str; + } + + # Cleanup + $self->_cleanup(); + + print $result_message; +} + + +sub _setup { + my $self = shift; + + #print $self->{_name}, "\n"; + chdir ($self->{_workdir}); + + # Create temporary directory + mkdir ($self->{_name}); + chdir ($self->{_name}); + mkdir ("input"); + mkdir ("output"); + + # Setup existing files + chdir ("output"); + foreach my $filename (keys %{$self->{_existing}}) { + open (FILE, ">$filename") + or return "Test failed: cannot open pre-existing file $filename\n"; + + print FILE $self->{_existing}->{$filename}->{content} + or return "Test failed: cannot write pre-existing file $filename\n"; + + close (FILE); + } + + chdir ("input"); + $self->_setup_server(); + + chdir ($self->{_workdir}); +} + + +sub _cleanup { + my $self = shift; + + chdir ($self->{_workdir}); + File::Path::rmtree ($self->{_name}); +} + + +sub _verify_download { + my $self = shift; + + chdir ("$self->{_workdir}/$self->{_name}/output"); + + # use slurp mode to read file content + my $old_input_record_separator = $/; + undef $/; + + while (my ($filename, $filedata) = each %{$self->{_output}}) { + open (FILE, $filename) + or return "Test failed: file $filename not downloaded\n"; + + my $content = ; + $content eq $filedata->{'content'} + or return "Test failed: wrong content for file $filename\n"; + + if (exists($filedata->{'timestamp'})) { + my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, + $atime, $mtime, $ctime, $blksize, $blocks) = stat FILE; + + $mtime == $filedata->{'timestamp'} + or return "Test failed: wrong timestamp for file $filename\n"; + } + + close (FILE); + } + + $/ = $old_input_record_separator; + + # make sure no unexpected files were downloaded + chdir ("$self->{_workdir}/$self->{_name}/output"); + + __dir_walk('.', sub { push @unexpected_downloads, $_[0] unless (exists $self->{_output}{$_[0]}) }, sub { shift; return @_ } ); + if (@unexpected_downloads) { + return "Test failed: unexpected downloaded files [" . join(', ', @unexpected_downloads) . "]\n"; + } + + return ""; +} + + +sub __dir_walk { + my ($top, $filefunc, $dirfunc) = @_; + + my $DIR; + + if (-d $top) { + my $file; + unless (opendir $DIR, $top) { + warn "Couldn't open directory $DIR: $!; skipping.\n"; + return; + } + + my @results; + while ($file = readdir $DIR) { + next if $file eq '.' || $file eq '..'; + my $nextdir = $top eq '.' ? $file : "$top/$file"; + push @results, __dir_walk($nextdir, $filefunc, $dirfunc); + } + + return $dirfunc ? $dirfunc->($top, @results) : () ; + } else { + return $filefunc ? $filefunc->($top) : () ; + } +} + + +sub _fork_and_launch_server +{ + my $self = shift; + + pipe(FROM_CHILD, TO_PARENT) or die "Cannot create pipe!"; + select((select(TO_PARENT), $| = 1)[0]); + + my $pid = fork(); + if ($pid < 0) { + die "Cannot fork"; + } elsif ($pid == 0) { + # child + close FROM_CHILD; + $self->_launch_server(sub { print TO_PARENT "SYNC\n"; close TO_PARENT }); + } else { + # father + close TO_PARENT; + chomp(my $line = ); + close FROM_CHILD; + } + + return $pid; +} + +1; + +# vim: et ts=4 sw=4 + diff -urN wget-1.10.2/TODO wget-1.10.2_new/TODO --- wget-1.10.2/TODO 2003-12-01 00:39:04.000000000 +0100 +++ wget-1.10.2_new/TODO 2006-06-27 12:20:51.000000000 +0200 @@ -1,4 +1,4 @@ - Hey Emacs, this is -*- outline -*- mode + -*- outline -*- This is the to-do list for GNU Wget. There is no timetable of when we plan to implement these features -- this is just a list of features @@ -11,9 +11,46 @@ recently-added items may tend towards the top). Not all of these represent user-visible changes. -* Honor `Content-Disposition: XXX; filename="FILE"' when creating the - file name. If possible, try not to break `-nc' and friends when - doing that. +* Change the file name generation logic so that redirects can't dictate + file names (but redirects should still be followed). By default, file + names should be generated only from the URL the user provided. However, + with an appropriate flag, Wget will allow the remote server to specify + the file name, either through redirection (as is always the case now) + or via the increasingly popular header `Content-Disposition: XXX; + filename="FILE"'. + + The file name should be generated and displayed *after* processing + the server's response, not before, as it is done now. This will + allow trivial implementation of -nc, of O_EXCL when opening the + file, --html-extension will stop being a horrible hack, and so on. + +* -O should be respected, with no exceptions. It should work in + conjunction with -N and -k. (This is hard to achieve in the current + code base.) Ancillary files, such as directory listings and such, + should be downloaded either directly to memory, or to /tmp. + +* Implement digest and NTLM authorization for proxies. This is harder + than it seems because it requires some rethinking of the HTTP code. + +* Rethink the interaction between recur.c (the recursive download code) + and HTTP/FTP code. Ideally, the downloading code should have a way + to retrieve a file and, optionally, to specify a list of URLs for + continuing the "recursive" download. FTP code will surely benefit + from such a restructuring because its current incarnation is way too + smart for its own good. + +* Both HTTP and FTP connections should be first-class objects that can + be reused after a download is done. Currently information about both + is kept implicitly on the stack, and forgotten after each download. + +* Restructure the FTP code to remove massive amounts of code duplication + and repetition. Remove all the "intelligence" and make it work as + outlined in the previous bullet. + +* Add support for SFTP. Teach Wget about newer features of more + recent FTP servers in general, such as receiving reliable checksums + and timestamps. This can be used to implement really robust + downloads. * Wget shouldn't delete rejected files that were not downloaded, but just found on disk because of `-nc'. For example, `wget -r -nc @@ -21,38 +58,58 @@ removing any of the existing HTML files. * Be careful not to lose username/password information given for the - URL on the command line. + URL on the command line. For example, + wget -r http://username:password@server/path/ should send that + username and password to all content under /path/ (this is apparently + what browsers do). + +* Don't send credentials using "Basic" authorization before the server + has a chance to tell us that it supports Digest or NTLM! * Add a --range parameter allowing you to explicitly specify a range of bytes to get from a file over HTTP (FTP only supports ranges ending at the end of the file, though forcibly disconnecting from - the server at the desired endpoint might be workable). + the server at the desired endpoint would work). For example, + --range=n-m would specify inclusive range (a la the Range header), + and --range=n:m would specify exclusive range (a la Python's + slices). -c should work with --range by assuming the range is + partially downloaded on disk, and contuing from there (effectively + requesting a smaller range). * If multiple FTP URLs are specified that are on the same host, Wget should re-use the connection rather than opening a new one for each file. + This should be easy provided the above restructuring of FTP code that + would include the FTP connection becoming a first-class objects. * Try to devise a scheme so that, when password is unknown, Wget asks - the user for one. + the user for one. This is harder than it seems because the password + may be requested by some page encountered long after the user has + left Wget to run. * If -c used with -N, check to make sure a file hasn't changed on the server before "continuing" to download it (preventing a bogus hybrid file). * Generalize --html-extension to something like --mime-extensions and - have it look at mime.types/mimecap file for preferred extension. - Non-HTML files with filenames changed this way would be - re-downloaded each time despite -N unless .orig files were saved for - them. Since .orig would contain the same data as non-.orig, the - latter could be just a link to the former. Another possibility - would be to implement a per-directory database called something like + have consult mime.types for the preferred extension. Non-HTML files + with filenames changed this way would be re-downloaded each time + despite -N unless .orig files were saved for them. (#### Why? The + HEAD request we use to implement -N would still be able to construct + the correct file name based on the declared Content-Type.) + + Since .orig would contain the same data as non-.orig, the latter + could be just a link to the former. Another possibility would be to + implement a per-directory database called something like .wget_url_mapping containing URLs and their corresponding filenames. -* When spanning hosts, there's no way to say that you are only interested in - files in a certain directory on _one_ of the hosts (-I and -X apply to all). - Perhaps -I and -X should take an optional hostname before the directory? +* When spanning hosts, there's no way to say that you are only + interested in files in a certain directory on _one_ of the hosts (-I + and -X apply to all). Perhaps -I and -X should take an optional + "hostname:" before the directory? * --retr-symlinks should cause wget to traverse links to directories too. * Make wget return non-zero status in more situations, like incorrect HTTP auth. + Create and document different exit statuses for different errors. * Make -K compare X.orig to X and move the former on top of the latter if they're the same, rather than leaving identical .orig files laying around. @@ -60,31 +117,39 @@ * Make `-k' check for files that were downloaded in the past and convert links to them in newly-downloaded documents. +* Devise a way for options to have effect on a per-URL basis. This is very + natural for some options, such as --post-data. It could be implemented + simply by having more than one struct options. + * Add option to clobber existing file names (no `.N' suffixes). -* Add option to only list wildcard matches without doing the download. +* Add option to only list wildcard matches without doing the download. The same + could be generalized to support something like apt's --print-uri. * Handle MIME types correctly. There should be an option to (not) retrieve files based on MIME types, e.g. `--accept-types=image/*'. + This would work for FTP by translating file extensions to MIME types + using mime.types. -* Allow time-stamping by arbitrary date. +* Allow time-stamping by arbitrary date. For example, + wget --if-modified-after DATE URL. -* Allow size limit to files (perhaps with an option to download oversize files - up through the limit or not at all, to get more functionality than [u]limit. +* Make quota apply to single files, preferrably so that the download of an + oversized file is not attempted at all. -* Download to .in* when mirroring. +* When updating an existing mirror, download to temporary files (such as .in*) + and rename the file after the download is done. * Add an option to delete or move no-longer-existent files when mirroring. -* Implement uploading (--upload URL?) in FTP and HTTP. - -* Rewrite FTP code to allow for easy addition of new commands. It - should probably be coded as a simple DFA engine. +* Implement uploading (--upload=FILE URL?) in FTP and HTTP. A beginning of + this is available in the form of --post-file, but it should be expanded to + be really useful. * Make HTTP timestamping use If-Modified-Since facility. -* Add more protocols (e.g. gopher and news), implementing them in a - modular fashion. +* Add more protocols (such as news or possibly some of the streaming + protocols), implementing them in a modular fashion. * Add a "rollback" option to have continued retrieval throw away a configurable number of bytes at the end of a file before resuming diff -urN wget-1.10.2/windows/ChangeLog wget-1.10.2_new/windows/ChangeLog --- wget-1.10.2/windows/ChangeLog 2005-07-02 15:01:58.000000000 +0200 +++ wget-1.10.2_new/windows/ChangeLog 2006-06-27 12:20:51.000000000 +0200 @@ -1,11 +1,87 @@ -2005-07-02 Hrvoje Niksic +2006-04-07 Mauro Tortonesi - * config.h.mingw: Define HAVE_SELECT. + * config-compiler.h: Several fixes for MSVC 8 (Visual C 2005). + +2006-03-09 Hrvoje Niksic + + * config-compiler.h (HAVE_UINTPTR_T): Define to 1 under MinGW. + +2005-08-10 Hrvoje Niksic + + * config.h (HAVE_SOCKADDR_IN6_SCOPE_ID): According to MSDN, + Winsock supports sin6_scope_id. + +2005-07-08 Gisle Vanem + + * config-compiler.h: Reintroduced Watcom support. + +2005-07-08 Hrvoje Niksic + + * config.h: Comment out the #undef lines so that they don't undo + the flags set in the Makefiles. + +2005-07-07 Hrvoje Niksic + + * config-compiler.h (stat_alias): Don't directly redefine stat and + fstat here. Just define the alias symbols. + (gai_strerror): Just declare that it needs to be defined instead + of defining it directly. + +2005-07-07 Gisle Vanem + + * config-compiler.h: Define HAVE__BOOL, HAVE_INTTYPES_H, and + HAVE_STRTOLL for MinGW. + +2005-07-07 Hrvoje Niksic + + * config.h.mingw: Removed. + + * config.h.bor: Removed. + + * config.h.ms: Removed. + + * config-compiler.h: New file. + +2005-07-06 Hrvoje Niksic + + * config.h: New file. 2005-06-30 Hrvoje Niksic * Makefile.src.bor: Correct location of OBJS dependency. +2005-06-29 Hrvoje Niksic + + * config.h.ms: Ditto. + + * config.h.bor: Explicitly include config-post.h. + +2005-06-29 Gisle Vanem + + * config.h.mingw: MinGW has limits.h, uint32_t, and the + sin6_scope_id member of sockaddr_in6. Include config-post.h. + +2005-06-27 Hrvoje Niksic + + * config.h.bor: Ditto. + + * config.h.mingw: Don't explicitly include malloc.h, mswindows.h + does that. + +2005-06-23 Hrvoje Niksic + + * config.h.bor: Ditto. + + * config.h.ms: Remove obsolete symbols. + +2005-06-23 Hrvoje Niksic + + * Makefile.watcom: Removed. + +2005-06-22 Hrvoje Niksic + + * Makefile.src*: Add the config.h dependency. + 2005-06-22 Hrvoje Niksic * Makefile.src, Makefile.src.bor, Makefile.src.mingw: Make OBJS diff -urN wget-1.10.2/windows/config-compiler.h wget-1.10.2_new/windows/config-compiler.h --- wget-1.10.2/windows/config-compiler.h 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/windows/config-compiler.h 2006-06-27 12:20:51.000000000 +0200 @@ -0,0 +1,200 @@ +/* Support for various Windows compilation environments. + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Wget. + +GNU Wget is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GNU Wget is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Wget; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +In addition, as a special exception, the Free Software Foundation +gives permission to link the code of its release of Wget with the +OpenSSL project's "OpenSSL" library (or with modified versions of it +that use the same license as the "OpenSSL" library), and distribute +the linked executables. You must obey the GNU General Public License +in all respects for all of the code used other than "OpenSSL". If you +modify this file, you may extend this exception to your version of the +file, but you are not obligated to do so. If you do not wish to do +so, delete this exception statement from your version. */ + + +/* This file contains information about various compilers used to + build Wget on the Windows platform using its "native" API, + sometimes referred to as "Win32". (This excludes Cygwin, which + defines a Unix-compatible layer and is handled with configure.) + + The above "information about compilers" includes both actual + differences in compilers (such as how to construct 64-bit constants + or whether C99 `bool' is available) and the properties of the + compilation environment and run-time library shipped with the + compiler (such as whether stat handles large files or whether + strtoll is present). + + The file is divided into sections for each compiler/environment. + Being based on free software, MinGW's section comes first and + contains most of the explanatory comments. Things that apply to + *all* compilers, as well as things that are specific to Wget, + belong in src/mswindows.h. */ + +/* -------------------- */ +/* MinGW (GCC) section. */ +/* -------------------- */ +#if defined __MINGW32__ + +#define OS_TYPE "Windows-MinGW" + +#define LL(n) n##LL + +/* Transparently support statting large files, like POSIX's LFS API + does, by aliasing stat and fstat to their equivalents that do LFS. + Most Windows compilers we support use _stati64 (but have different + names for 2nd argument type, see below), so we use that. */ +#define stat_alias _stati64 +#define fstat_alias _fstati64 + +/* On Windows the 64-bit stat requires an explicitly different type + for the 2nd argument, so we define a struct_stat macro that expands + to the appropriate type on Windows, and to the regular struct stat + on Unix. + + Note that Borland C 5.5 has 64-bit stat (_stati64), but not a + 64-bit fstat! Because of that we also need a struct_fstat that + points to struct_stat on Unix and on Windows, except under Borland, + where it points to the 32-bit struct stat. */ + +#define struct_stat struct _stati64 +#define struct_fstat struct _stati64 + +/* MinGW 3.7 (or older) prototypes gai_strerror(), but is missing + from all import libraries. */ +#ifdef ENABLE_IPV6 +# define NEED_GAI_STRERROR +#endif + +/* MinGW and GCC support some POSIX and C99 features. */ +#define HAVE_INTTYPES_H 1 + +#define HAVE__BOOL 1 +#undef SIZEOF_LONG_LONG /* avoid redefinition warning */ +#define SIZEOF_LONG_LONG 8 +#define HAVE_UINTPTR_T 1 + +#define HAVE_STRTOLL 1 + +/* -------------------- */ +/* MS Visual C section. */ +/* -------------------- */ +#elif defined _MSC_VER + +#define OS_TYPE "Windows-MSVC" + +#define LL(n) n##I64 + +#define stat_alias _stati64 +#define fstat_alias _fstati64 +#define struct_stat struct _stati64 +#define struct_fstat struct _stati64 + +#define isatty _isatty + +#if _MSC_VER >= 1300 +# define HAVE__STRTOI64 1 +#endif + +#if _MSC_VER >= 1400 +#pragma warning ( disable : 4996 ) +#define _CRT_SECURE_NO_DEPRECATE +#define HAVE_SYS_UTIME_H 1 +#undef HAVE_UTIME_H +#endif + +/* ------------------ */ +/* Borland C section. */ +/* ------------------ */ +#elif defined __BORLANDC__ + +#define OS_TYPE "Windows-Borland" + +#define LL(n) n##I64 + +#define stat_alias _stati64 +#undef fstat_alias +#define struct_stat struct stati64 +#undef struct_fstat + +/* ------------------------------ */ +/* Digital Mars Compiler section. */ +/* ------------------------------ */ +#elif defined __DMC__ + +#define OS_TYPE "Windows-DMC" + +#define LL(n) n##LL + +/* DMC supports 64-bit types, including long long, but not statting + large files. */ +#undef stat_alias +#undef fstat_alias +/* If left undefined, sysdep.h will define these to struct stat. */ +#undef struct_stat +#undef struct_fstat + +/* DMC's runtime supports some POSIX and C99 headers, types, and + functions that we use. */ + +#define HAVE_STDINT_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDBOOL_H 1 + +#define HAVE_UINT32_T 1 +#undef SIZEOF_LONG_LONG +#define SIZEOF_LONG_LONG 8 +#define HAVE__BOOL 1 + +#define HAVE_USLEEP 1 +#define HAVE_STRTOLL 1 + + +/* -------------------- */ +/* OpenWatcom section. */ +/* -------------------- */ +#elif defined __WATCOMC__ + +#define OS_TYPE "Windows-Watcom" + +#define LL(n) n##LL + +#define stat_alias _stati64 +#define fstat_alias _fstati64 +#define struct_stat struct _stati64 +#define struct_fstat struct _stati64 + +#ifdef ENABLE_IPV6 +# define NEED_GAI_STRERROR +#endif + +#define HAVE_STDINT_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDBOOL_H 1 +#define HAVE_STRTOLL 1 +#define HAVE_UINT32_T 1 +#define HAVE_SYS_UTIME_H 1 +#undef HAVE_UTIME_H +#undef socklen_t /* avoid clash with */ + +#undef SIZEOF_LONG_LONG +#define SIZEOF_LONG_LONG 8 + +#else +# error Your compiler is not supported. +#endif diff -urN wget-1.10.2/windows/config.h wget-1.10.2_new/windows/config.h --- wget-1.10.2/windows/config.h 1970-01-01 01:00:00.000000000 +0100 +++ wget-1.10.2_new/windows/config.h 2006-06-27 12:20:51.000000000 +0200 @@ -0,0 +1,215 @@ +/* src/config.h. Manually generated from src/config.h.in to + accomodate the 32-bit Windows compilation environments. */ + +/* Define if you want the debug output support compiled in. */ +#define ENABLE_DEBUG 1 + +/* Define if you want the HTTP Digest Authorization compiled in. */ +#define ENABLE_DIGEST 1 + +/* Define if IPv6 support is enabled. */ +/* #undef ENABLE_IPV6 */ + +/* Define if you want the NTLM authorization support compiled in. */ +#ifdef HAVE_OPENSSL +# define ENABLE_NTLM 1 +#endif + +/* Define if you want the Opie support for FTP compiled in. */ +#define ENABLE_OPIE 1 + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +/* #undef HAVE_ALLOCA_H */ + +/* Define when using built-in MD5. */ +#define HAVE_BUILTIN_MD5 + +/* Define to 1 if you have the `drand48' function. */ +/* #undef HAVE_DRAND48 */ + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +/* #undef HAVE_FSEEKO */ + +/* Define to 1 if you have the `ftello' function. */ +/* #undef HAVE_FTELLO */ + +/* Define to 1 if you have the `getaddrinfo' function. */ +/* #undef HAVE_GETADDRINFO */ + +/* Define if support for the GnuTLS library is being compiled in. */ +/* #undef HAVE_GNUTLS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_INTTYPES_H */ + +/* Define to 1 if you have the `isatty' function. */ +#define HAVE_ISATTY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if we're compiling support for MD5. */ +/* #undef HAVE_MD5 */ + +/* Define to 1 if you have a working `mmap' system call. */ +/* #undef HAVE_MMAP */ + +/* Define if you have the nanosleep function. */ +/* #undef HAVE_NANOSLEEP */ + +/* Define this if you want the NLS support. */ +/* #undef HAVE_NLS */ + +/* Define if support for the OpenSSL library is being compiled in. */ +/* #undef HAVE_OPENSSL */ + +/* Define when using OpenSSL MD5. */ +/* #undef HAVE_OPENSSL_MD5 */ + +/* Define to 1 if you have the `sigblock' function. */ +/* #undef HAVE_SIGBLOCK */ + +/* Define to 1 if you have the `sigsetjmp' function. */ +/* #undef HAVE_SIGSETJMP */ + +/* Define to 1 if the system has the type `sig_atomic_t'. */ +#define HAVE_SIG_ATOMIC_T 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if struct sockaddr_in6 has the sin6_scope_id member */ +#define HAVE_SOCKADDR_IN6_SCOPE_ID 1 + +/* Define when using Solaris MD5. */ +/* #undef HAVE_SOLARIS_MD5 */ + +/* Define to 1 if stdbool.h conforms to C99. */ +/* #undef HAVE_STDBOOL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STDINT_H */ + +/* Define to 1 if you have the `strcasecmp' function. */ +/* #undef HAVE_STRCASECMP */ + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +/* #undef HAVE_STRNCASECMP */ + +/* Define to 1 if you have the `strptime' function. */ +/* #undef HAVE_STRPTIME */ + +/* Define to 1 if the system has the type `struct sockaddr_in6'. */ +/* #undef HAVE_STRUCT_SOCKADDR_IN6 */ + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE */ + +/* Define to 1 if the system has the type `struct utimbuf'. */ +#define HAVE_STRUCT_UTIMBUF 1 + +/* Define to 1 if you have the `symlink' function. */ +/* #undef HAVE_SYMLINK */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_IOCTL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TIME_H */ + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if the system has the type `uint32_t'. */ +/* #undef HAVE_UINT32_T */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define to 1 if you have the `usleep' function. */ +/* #undef HAVE_USLEEP */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define if fnmatch.h can be included. */ +/* #undef HAVE_WORKING_FNMATCH_H */ + +/* Define to 1 if the system has the type `_Bool'. */ +/* #undef HAVE__BOOL */ + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of a `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 0 + +/* The size of a `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of a `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* Define to 1 if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* # undef _ALL_SOURCE */ +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +# define inline __inline +#endif + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ + +/* Define to int or size_t on systems without socklen_t. */ +#define socklen_t int + +/* Define to empty if the keyword `volatile' does not work. Warning: valid + code using `volatile' can become incorrect without. Disable with care. */ +/* #undef volatile */ + +/* Include compiler-specific defines. */ +#include "config-compiler.h" + +#include "config-post.h" + diff -urN wget-1.10.2/windows/config.h.bor wget-1.10.2_new/windows/config.h.bor --- wget-1.10.2/windows/config.h.bor 2005-04-06 22:44:37.000000000 +0200 +++ wget-1.10.2_new/windows/config.h.bor 1970-01-01 01:00:00.000000000 +0100 @@ -1,209 +0,0 @@ -/* Configuration header file. - Copyright (C) 1995, 1996, 1997, 1998, 2004 - 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 2 of the License, 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - In addition, as a special exception, the Free Software Foundation - gives permission to link the code of its release of Wget with the - OpenSSL project's "OpenSSL" library (or with modified versions of it - that use the same license as the "OpenSSL" library), and distribute - the linked executables. You must obey the GNU General Public License - in all respects for all of the code used other than "OpenSSL". If you - modify this file, you may extend this exception to your version of the - file, but you are not obligated to do so. If you do not wish to do - so, delete this exception statement from your version. */ - - -#ifndef CONFIG_H -#define CONFIG_H - -#define HAVE_SNPRINTF 1 - -#define HAVE_MEMMOVE 1 -#define ftruncate chsize -#define inline __inline - -/* Flag that C files should include , not . */ -#define WGET_USE_STDARG - -/* Define if the free Borland C++Builder 5.5 command-line compiler is used, - because its utime() has a bug. */ -#define HACK_BCC_UTIME_BUG - -#ifdef HACK_BCC_UTIME_BUG -#define utime borland_utime -#endif - -/* Define if you have the header file. */ -#undef HAVE_ALLOCA_H - -/* For Borland C++ 5.5, alloca is defined in the header file. */ -#include - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE int - -/* Define if your architecture is big endian (with the most - significant byte first). */ -#undef WORDS_BIGENDIAN - -/* Define this if you want the NLS support. */ -#undef ENABLE_NLS - -/* Define if you want the FTP support for Opie compiled in. */ -#define ENABLE_OPIE 1 - -/* Define if you want the HTTP Digest Authorization compiled in. */ -#define ENABLE_DIGEST 1 - -/* Define if you want the NTLM authorization support compiled in. */ -#ifdef HAVE_SSL -# define ENABLE_NTLM -#endif - -/* Define if you want the debug output support compiled in. */ -#define ENABLE_DEBUG 1 - -/* Define if you have sys/time.h header. */ -#undef HAVE_SYS_TIME_H - -/* Define if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define if you have struct utimbuf. */ -#define HAVE_STRUCT_UTIMBUF 1 - -/* Define if you have the gethostbyname function. */ -/* #undef HAVE_GETHOSTBYNAME */ - -/* Define if you have the uname function. */ -#undef HAVE_UNAME - -/* Define if you have the gethostname function. */ -#define HAVE_GETHOSTNAME 1 - -/* Define if you have the select function. */ -#define HAVE_SELECT 1 - -/* Define if you have the gettimeofday function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define if you have the sys/utsname.h header. */ -#undef HAVE_SYS_UTSNAME_H - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the strstr function. */ -#define HAVE_STRSTR 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strncasecmp function. */ -#define HAVE_STRNCASECMP 1 - -/* Define if you have the strptime function. */ -#undef HAVE_STRPTIME - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME 1 - -/* Define if you have the symlink function. */ -#undef HAVE_SYMLINK - -/* Define if you have the signal function. */ -#undef HAVE_SIGNAL - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -/* #define HAVE_UNISTD_H 1 */ -#undef HAVE_UNISTD_H - -/* Define if you have the header file. */ -#define HAVE_UTIME_H 1 - -/* Define if you have the header file. */ -#undef HAVE_SYS_UTIME_H - -/* Define if you have the header file. */ -#undef HAVE_SYS_SELECT_H - -/* Define if you have the header file. */ -#undef HAVE_PWD_H - -/* Define if you have the header file. */ -#undef HAVE_SIGNAL_H - -/* Define to be the name of the operating system. */ -#define OS_TYPE "Windows" - -#define CTRLBREAK_BACKGND 1 - -/* Define if you wish to compile with socks support. */ -/* #undef HAVE_SOCKS */ - -/* Define to 1 if ANSI function prototypes are usable. */ -#define PROTOTYPES 1 - -/* Define if we're compiling in support for MD5. */ -#define HAVE_MD5 1 - -/* Define if we're using Solaris libmd5. */ -#undef HAVE_SOLARIS_MD5 - -/* Define if we're using builtin (GNU) md5.c. */ -#define HAVE_BUILTIN_MD5 1 - -/* Define if you have the isatty function. */ -#define HAVE_ISATTY 1 - -/* Define to the length of short. */ -#define SIZEOF_SHORT 2 - -/* Define to the length of int. */ -#define SIZEOF_INT 4 - -/* Define to the length of long. */ -#define SIZEOF_LONG 4 - -/* Defined to int or size_t on systems without socklen_t. */ -#define socklen_t int - -/* Define if you have uint32_t. */ -/* #define HAVE_UINT32_T */ - -#endif /* CONFIG_H */ diff -urN wget-1.10.2/windows/config.h.mingw wget-1.10.2_new/windows/config.h.mingw --- wget-1.10.2/windows/config.h.mingw 2005-07-02 15:01:58.000000000 +0200 +++ wget-1.10.2_new/windows/config.h.mingw 1970-01-01 01:00:00.000000000 +0100 @@ -1,273 +0,0 @@ -/* Configuration header file. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2004 - Free Software Foundation, Inc. - -This file is part of GNU Wget. - -GNU Wget is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -GNU Wget is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -In addition, as a special exception, the Free Software Foundation -gives permission to link the code of its release of Wget with the -OpenSSL project's "OpenSSL" library (or with modified versions of it -that use the same license as the "OpenSSL" library), and distribute -the linked executables. You must obey the GNU General Public License -in all respects for all of the code used other than "OpenSSL". If you -modify this file, you may extend this exception to your version of the -file, but you are not obligated to do so. If you do not wish to do -so, delete this exception statement from your version. */ - -#ifndef CONFIG_H -#define CONFIG_H - -/* Define if you have the header file. */ -/* #undef HAVE_ALLOCA_H */ - -/* For MinGW GCC/Win32, alloca is defined in the header file. */ -#include - -/* Flag that C files should include , not . */ -#define WGET_USE_STDARG - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to empty or __inline__ or __inline. */ -/* #undef inline */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if your architecture is big endian (with the most - significant byte first). */ -/* #undef WORDS_BIGENDIAN */ - -#define ftruncate chsize - -/* Define to the length of short. */ -#define SIZEOF_SHORT 2 - -/* Define to the length of int. */ -#define SIZEOF_INT 4 - -/* Define to the length of long. */ -#define SIZEOF_LONG 4 - -/* Define to the length of long long. */ -#define SIZEOF_LONG_LONG 8 - -/* Define this if you want the NLS support. */ -/* #undef HAVE_NLS */ - -/* Define if you want the FTP support for Opie compiled in. */ -#define ENABLE_OPIE 1 - -/* Define if you want the NTLM authorization support compiled in. */ -#ifdef HAVE_SSL -# define ENABLE_NTLM -#endif - -/* Define if you want the HTTP Digest Authorization compiled in. */ -#define ENABLE_DIGEST 1 - -/* Define if you want the debug output support compiled in. */ -#define ENABLE_DEBUG 1 - -/* Define to 1 if the system has the type `sig_atomic_t'. */ -#define HAVE_SIG_ATOMIC_T 1 - -/* Define if you have sys/time.h header. */ -#define HAVE_SYS_TIME_H 1 - -/* Define if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define if you have struct utimbuf. */ -#define HAVE_STRUCT_UTIMBUF 1 - -/* Define if you have the uname function. */ -/* #undef HAVE_UNAME */ - -/* Define if you have a working version of mmap. */ -/* #undef HAVE_MMAP */ - -/* Define if you have the gethostname function. */ -/* #undef HAVE_GETHOSTNAME */ - -/* Define if you have the select function. */ -#define HAVE_SELECT 1 - -/* Define if you have the gettimeofday function. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define if you have the sys/utsname.h header. */ -/* #undef HAVE_SYS_UTSNAME_H */ - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the snprintf function. */ -#define HAVE_SNPRINTF 1 - -/* Define if you have the vsnprintf function. */ -#define HAVE_VSNPRINTF 1 - -/* Define if you have the strstr function. */ -#define HAVE_STRSTR 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strncasecmp function. */ -#define HAVE_STRNCASECMP 1 - -/* Define if you have the strpbrk function. */ -#define HAVE_STRPBRK 1 - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE 1 - -/* Define if you have the strptime function. */ -/* #undef HAVE_STRPTIME */ - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME 1 - -/* Define if you have the symlink function. */ -/* #undef HAVE_SYMLINK */ - -/* Define if you have the access function. */ -#define HAVE_ACCESS 1 - -/* Define if you have the isatty function. */ -#define HAVE_ISATTY 1 - -/* Define if you have the signal function. */ -/* #undef HAVE_SIGNAL */ - -/* Define if you have the sigsetjmp function. */ -/* #undef HAVE_SIGSETJMP */ - -/* Define if you have the sigblock function. */ -/* #undef HAVE_SIGBLOCK */ - -/* Define if you have the gettext function. */ -/* #undef HAVE_GETTEXT */ - -/* Define if you have the usleep function. */ -/* #undef HAVE_USLEEP */ - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -#define HAVE_UTIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_UTIME_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIOS_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_IOCTL_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_SELECT_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PWD_H */ - -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SETJMP_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBINTL_H */ - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define to be the name of the operating system. */ -#define OS_TYPE "mingw32" - -/* Define if you wish to compile with socks support. */ -/* #undef HAVE_SOCKS */ - -/* Define to 1 if ANSI function prototypes are usable. */ -#define PROTOTYPES 1 - -/* Define if all libs needed for ssl support are existing */ -/* #undef HAVE_SSL */ - -/* Define if we're compiling in support for MD5. */ -#define HAVE_MD5 1 - -/* Define if we're using Solaris libmd5. */ -/* #undef HAVE_SOLARIS_MD5 */ - -/* Define if we're using OpenSSL md5. */ -/* #undef HAVE_OPENSSL_MD5 */ - -/* Define if we're using builtin (GNU) md5.c. */ -#define HAVE_BUILTIN_MD5 1 - -/* Define if you have the getaddrinfo function. */ -/* #undef HAVE_GETADDRINFO */ - -/* Define if the system headers support the AI_ADDRCONFIG flag. */ -/* #undef HAVE_GETADDRINFO_AI_ADDRCONFIG */ - -/* Define if the system headers support the AI_V4MAPPED flag. */ -/* #undef HAVE_GETADDRINFO_AI_V4MAPPED */ - -/* Define if the system headers support the AI_ALL flag. */ -/* #undef HAVE_GETADDRINFO_AI_ALL */ - -/* Define if the system supports struct sockaddr_in6 */ -/* #undef HAVE_HAVE_STRUCT_SOCKADDR_IN6 */ - -/* Define if struct sockaddr_in6 has the sin6_scope_id member */ -/* #undef HAVE_SOCKADDR_IN6_SCOPE_ID */ - -/* Define if you want to enable the IPv6 support. */ -/* #undef ENABLE_IPV6 */ - -/* Defined to int or size_t on systems without socklen_t. */ -#define socklen_t int - -/* Define if you have uint32_t. */ -#undef HAVE_UINT32_T - -#endif /* CONFIG_H */ diff -urN wget-1.10.2/windows/config.h.ms wget-1.10.2_new/windows/config.h.ms --- wget-1.10.2/windows/config.h.ms 2005-04-06 22:44:37.000000000 +0200 +++ wget-1.10.2_new/windows/config.h.ms 1970-01-01 01:00:00.000000000 +0100 @@ -1,220 +0,0 @@ -/* Configuration header file. - Copyright (C) 1995, 1996, 1997, 1998, 2004 - 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 2 of the License, 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - In addition, as a special exception, the Free Software Foundation - gives permission to link the code of its release of Wget with the - OpenSSL project's "OpenSSL" library (or with modified versions of it - that use the same license as the "OpenSSL" library), and distribute - the linked executables. You must obey the GNU General Public License - in all respects for all of the code used other than "OpenSSL". If you - modify this file, you may extend this exception to your version of the - file, but you are not obligated to do so. If you do not wish to do - so, delete this exception statement from your version. */ - - -#ifndef CONFIG_H -#define CONFIG_H - -/* Define if you have the header file. */ -#undef HAVE_ALLOCA_H - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE int - -/* Define if your architecture is big endian (with the most - significant byte first). */ -#undef WORDS_BIGENDIAN - -/* Define if you want the FTP support for Opie compiled in. */ -#define ENABLE_OPIE 1 - -/* Define if you want the HTTP Digest Authorization compiled in. */ -#define ENABLE_DIGEST 1 - -/* Define if you want the NTLM authorization support compiled in. */ -#ifdef HAVE_SSL -# define ENABLE_NTLM -#endif - -/* Define if you want the debug output support compiled in. */ -#define ENABLE_DEBUG 1 - -/* Define if you have sys/time.h header. */ -#undef HAVE_SYS_TIME_H - -/* Define if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define if you have struct utimbuf. */ -#define HAVE_STRUCT_UTIMBUF 1 - -/* Define if you have the gethostbyname function. */ -/* #undef HAVE_GETHOSTBYNAME */ - -/* Define if you have the uname function. */ -#undef HAVE_UNAME - -/* Define if you have the gethostname function. */ -#define HAVE_GETHOSTNAME 1 - -/* Define if you have the select function. */ -#define HAVE_SELECT 1 - -/* Define if you have the gettimeofday function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define if you have the sys/utsname.h header. */ -#undef HAVE_SYS_UTSNAME_H - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the snprintf function. */ -#define HAVE_SNPRINTF 1 - -/* Define if you have the vsnprintf function. */ -#define HAVE_VSNPRINTF 1 - -/* Define to 1 if you have the `strpbrk' function. */ -#define HAVE_STRPBRK 1 - -/* Define if you have the strstr function. */ -#define HAVE_STRSTR 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strncasecmp function. */ -#define HAVE_STRNCASECMP 1 - -/* Define if you have the strptime function. */ -#undef HAVE_STRPTIME - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME 1 - -/* Define if you have the symlink function. */ -#undef HAVE_SYMLINK - -/* Define if you have the signal function. */ -#undef HAVE_SIGNAL - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Use ANSI-style stdargs regardless of whether the compiler bothers - to define __STDC__. (Many don't when extensions are enabled.) - This define used to be in mswindows.h, but wheren't making any use there */ -#define WGET_USE_STDARG - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#if !defined(_MSC_VER) -#undef HAVE_UNISTD_H -#endif - -/* None except Digital Mars have sleep/usleep functions */ -#if defined(__DMC__) -#define HAVE_USLEEP 1 -#define HAVE_SLEEP 1 -#endif - -/* Define if you have the header file. */ -#undef HAVE_UTIME_H - -/* Define if you have the header file. */ -#define HAVE_SYS_UTIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#undef HAVE_SYS_SELECT_H - -/* Define if you have the header file. */ -#undef HAVE_PWD_H - -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define to be the name of the operating system. */ -#define OS_TYPE "Windows" - -#define CTRLBREAK_BACKGND 1 - -/* Define if you wish to compile with socks support. */ -/* #undef HAVE_SOCKS */ - -/* Define to 1 if ANSI function prototypes are usable. */ -#define PROTOTYPES 1 - -/* Define if we're compiling in support for MD5. */ -#define HAVE_MD5 1 - -/* Define if we're using Solaris libmd5. */ -#undef HAVE_SOLARIS_MD5 - -/* Define if we're using builtin (GNU) md5.c. */ -#define HAVE_BUILTIN_MD5 1 - -/* Work around VC 6 issues */ -#define inline __inline -#define ftruncate chsize - -/* Define if you have the isatty function. */ -#define HAVE_ISATTY 1 - -/* Define if you have the memmove function */ -#define HAVE_MEMMOVE 1 - -/* Define to the length of short. */ -#define SIZEOF_SHORT 2 - -/* Define to the length of int. */ -#define SIZEOF_INT 4 - -/* Define to the length of long. */ -#define SIZEOF_LONG 4 - -/* Defined to int or size_t on systems without socklen_t. */ -#define socklen_t int - -/* Define if you have uint32_t. */ -#undef HAVE_UINT32_T - -#endif /* CONFIG_H */ diff -urN wget-1.10.2/windows/Makefile.src wget-1.10.2_new/windows/Makefile.src --- wget-1.10.2/windows/Makefile.src 2005-06-22 01:27:21.000000000 +0200 +++ wget-1.10.2_new/windows/Makefile.src 2006-06-27 12:20:51.000000000 +0200 @@ -84,7 +84,7 @@ $(LD) @<< $(LDFLAGS) /out:$@ $(OBJ) $(LIBS) << -$(OBJ): config-post.h connect.h convert.h cookies.h ftp.h gen-md5.h \ +$(OBJ): config-post.h config.h connect.h convert.h cookies.h ftp.h gen-md5.h \ getopt.h gnu-md5.h hash.h host.h html-parse.h http-ntlm.h \ init.h log.h mswindows.h netrc.h options.h progress.h \ ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h sysdep.h \ diff -urN wget-1.10.2/windows/Makefile.src.bor wget-1.10.2_new/windows/Makefile.src.bor --- wget-1.10.2/windows/Makefile.src.bor 2005-06-30 14:13:16.000000000 +0200 +++ wget-1.10.2_new/windows/Makefile.src.bor 2006-06-27 12:20:51.000000000 +0200 @@ -60,7 +60,7 @@ | -$(OBJS): config-post.h connect.h convert.h cookies.h ftp.h gen-md5.h \ +$(OBJS): config-post.h config.h connect.h convert.h cookies.h ftp.h gen-md5.h \ getopt.h gnu-md5.h hash.h host.h html-parse.h http-ntlm.h \ init.h log.h mswindows.h netrc.h options.h progress.h \ ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h sysdep.h \ diff -urN wget-1.10.2/windows/Makefile.src.mingw wget-1.10.2_new/windows/Makefile.src.mingw --- wget-1.10.2/windows/Makefile.src.mingw 2005-06-22 01:27:21.000000000 +0200 +++ wget-1.10.2_new/windows/Makefile.src.mingw 2006-06-27 12:20:51.000000000 +0200 @@ -41,7 +41,7 @@ wget.exe: $(OBJS) ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} -$(OBJS): config-post.h connect.h convert.h cookies.h ftp.h gen-md5.h \ +$(OBJS): config-post.h config.h connect.h convert.h cookies.h ftp.h gen-md5.h \ getopt.h gnu-md5.h hash.h host.h html-parse.h http-ntlm.h \ init.h log.h mswindows.h netrc.h options.h progress.h \ ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h sysdep.h \ diff -urN wget-1.10.2/windows/Makefile.watcom wget-1.10.2_new/windows/Makefile.watcom --- wget-1.10.2/windows/Makefile.watcom 2005-04-05 20:46:44.000000000 +0200 +++ wget-1.10.2_new/windows/Makefile.watcom 1970-01-01 01:00:00.000000000 +0100 @@ -1,95 +0,0 @@ -## Compiler, linker, and lib stuff -## Makefile for use with watcom win95/winnt executable. -# -# Copy this file to the ..\src directory (maybe rename to Makefile). -# - -CC=wcc386 /zq -LINK=wlink - -# -# Note: this will wipe anything in the env.var PATH ! -# -.BEFORE - @SET INCLUDE=$(%WATCOM)\h;$(%WATCOM)\h\nt;. - -LFLAGS=op q sys nt op st=32767 op map op de 'GNU Wget' de dw op symf -# -# op q : quiet ! -# sys nt : producing an NT app -# op st(ack)=32768 : stack size -# op vers(ion)=1.7 : "Image version" in the EXE header ( major.minor ) -# op map : produce a map file -# op de : textual description, placed in the executable -# de dw : debug info on Dwarf format -# op symf : place debug info in a separate wget.sym -# - -CFLAGS=/zp4 /w4 /fpd /5s /fp5 /bm /mf /bt=nt /I. /DWINDOWS /DHAVE_CONFIG_H -# ^^^^^^^^ wget will run on NT. We can safely assume a Pentium :-) -# /zp4= pack structure members with this alignment -# /d1 = line number debug info -# /w4 = warning level -# /fpd= Pentium floatingpoint bug workaround -# /5s = Pentium stack-based calling -# /fp5= Pentium floating point -# /bm = build multi-threaded -# /mf = flat memory model -# /bt = "build target" (nt) - -# -# Choose one of the following three: -# /od /d2 for no optimization, full debug info -# /os /d2 to optimize for size, full debug info (or /d1 for line number debug info) -# /othexan for "heavy-duty" optimizations, no debug info -# -#CFLAGS+= /od /d2 -CFLAGS+= /os /d2 -#CFLAGS+= /othexan -# ^^-- mind the gap !! - -#CFLAGS+= /DDEBUG_MALLOC -# ^^-- mind the gap !! - -OBJS = cmpt.obj convert.obj connect.obj cookies.obj ftp.obj ftp-basic.obj & - ftp-ls.obj ftp-opie.obj getopt.obj hash.obj host.obj html-parse.obj html-url.obj & - http.obj init.obj log.obj main.obj gen-md5.obj gnu-md5.obj netrc.obj progress.obj & - recur.obj res.obj retr.obj safe-ctype.obj url.obj utils.obj version.obj & - mswindows.obj xmalloc.obj - -LIBFILES = -# -# Add extra libs like this : -#LIBFILES = LIBF lz32.lib,gdi32.lib - -BINNAME=wget.exe - -all : config.h $(BINNAME) .SYMBOLIC - -# -# We use config.h.ms -# -config.h : ..\windows\config.h.ms - copy $[@ $^@ - -# -# Note: this will pass all the OBJ files to wlink, -# resulting in a very long command line (410 chars, last I counted) -# This might fail on Win9x (works with NT's cmd.exe) -# -$(BINNAME): $(OBJS) Makefile - $(LINK) $(LFLAGS) NAME $(BINNAME) FILE { $(OBJS) } $(LIBPATH) $(LIBFILES) - - -# -# Explicit dependencies not needed because Watcom C stores -# dependency information in the object file. Wmake can read this information -# if prompted by .AUTODEPEND -# - -.c.obj: .AUTODEPEND - $(CC) $(CFLAGS) $[@ - -.c.i: .AUTODEPEND - $(CC) $(CFLAGS) -fo=$@ /Pc $[@ - diff -urN wget-1.10.2/windows/README wget-1.10.2_new/windows/README --- wget-1.10.2/windows/README 2005-04-28 12:11:39.000000000 +0200 +++ wget-1.10.2_new/windows/README 2006-06-27 12:20:51.000000000 +0200 @@ -7,8 +7,10 @@ instructions printed on the screen. The instructions bellow are for building Wget with Microsoft Visual C++ (MSVC); you may need to make appropriate substitutions for your compiler and build environment; -currently wget can be built at least with Visual Studio/.Net, free -Borland or Watcom compilers, and the free cygnus and mingw environments. +currently wget can be built at least with Visual Studio/.Net, the free +Borland compiler, and the free mingw environment. The instructions do +*not* apply to the Cygwin environment, on which Wget is built with the +procedure described in the INSTALL file in the top-level directory. To build Wget with MSVC run configure.bat (in the main Wget directory) with the argument --msvc, and then run nmake. At a certain point in time @@ -54,7 +56,7 @@ port; * Tim Charron -- additional cleanup and - contribution of the Watcom makefile; + contribution of the (now retired) Watcom makefile; * John Burden -- cleanup of the VC++ makefile to get a clean build with VC++ 5.0 on Windows 95; --- wget-1.10.2/src/http.c.rh1 2006-09-25 17:11:55.000000000 +0200 +++ wget-1.10.2/src/http.c 2006-09-25 17:11:59.000000000 +0200 @@ -1762,7 +1762,7 @@ return RETROK; } - else + else if (!ALLOW_CLOBBER) { char *unique = unique_name (hs->local_file, true); if (unique != hs->local_file) @@ -2231,6 +2231,7 @@ { int count; bool got_head = false; /* used for time-stamping */ + bool got_name = false; char *tms; const char *tmrate; uerr_t err, ret = TRYLIMEXC; @@ -2264,7 +2265,10 @@ hstat.referer = referer; if (opt.output_document) + { hstat.local_file = xstrdup (opt.output_document); + got_name = true; + } /* Reset the counter. */ count = 0; @@ -2309,13 +2313,16 @@ /* Default document type is empty. However, if spider mode is on or time-stamping is employed, HEAD_ONLY commands is encoded within *dt. */ - if ((opt.spider && !opt.recursive) || (opt.timestamping && !got_head)) + if ((opt.spider && !opt.recursive) + || (opt.timestamping && !got_head) + || (opt.always_rest && !got_name)) *dt |= HEAD_ONLY; else *dt &= ~HEAD_ONLY; /* Decide whether or not to restart. */ if (opt.always_rest + && got_name && stat (hstat.local_file, &st) == 0 && S_ISREG (st.st_mode)) /* When -c is used, continue from on-disk size. (Can't use @@ -2484,6 +2491,12 @@ continue; } + if (opt.always_rest && !got_name) + { + got_name = true; + continue; + } + if ((tmr != (time_t) (-1)) && (!opt.spider || opt.recursive) && ((hstat.len == hstat.contlen) ||