diff --git a/ChangeLog b/ChangeLog index 4a5b8026..e9d5ad72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2007-07-23 Tatsuhiro Tsujikawa + + Merged Ross's win32 patch(manually) + In the course of merging, following files are added. + * src/strptime.{h,c} + * src/libgen.{h,c} + * src/inet_aton.{h,c} + * src/Platform.{h,cc} + * src/localtime_r.{h,c} + * src/getaddrinfo.{h,c} + I've gethered network related things, and put them to following file: + * src/a2netcompat.h + Also io related things are put to following file: + * src/a2io.h + + Changed %lld to %s because mingw32 doesn't recognize %lld. + * src/message.h + (MSG_ALLOCATION_COMPLETED) + (EX_TOO_LARGE_FILE) + (EX_SIZE_MISMATCH) + (EX_FILE_OFFSET_OUT_OF_RANGE) + (EX_INVALID_CHUNK_CHECKSUM) + (EX_INVALID_RANGE_HEADER) + * src/FileAllocationCommand.cc + * src/HttpResponse.cc + * src/RequestGroup.cc + * src/MultiDiskAdaptor.cc + * src/OptionHandlerImpl.h + * src/HttpResponseCommand.cc + * src/FtpNegotiateCommand.cc + * src/IteratableChecksumValidator.cc + * src/SegmentMan.cc + * src/ChunkChecksumValidator.cc + + Added Randomizer::getRandomNumber(long int) + * src/Randomizer.h (getRandomNumber) + * src/SimpleRandomizer.h (getRandomNumber) + * src/BitfieldMan.cc (getMissingIndexRandomly): Use this new function. + * src/Util.cc (randomAlpha): Use this new function. + 2007-07-21 Tatsuhiro Tsujikawa Converted int's to in32_t. long long int's are also converted to diff --git a/Makefile.in b/Makefile.in index 425bc782..eb3bf4a3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,6 +35,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +target_triplet = @target@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure $(top_srcdir)/intl/Makefile.in \ @@ -127,6 +128,16 @@ GENCAT = @GENCAT@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ +HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@ +HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@ +HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@ +HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@ +HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@ +HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@ +HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@ +HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@ +HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@ +HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -176,6 +187,7 @@ STRIP = @STRIP@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WINSOCK_LIBS = @WINSOCK_LIBS@ XGETTEXT = @XGETTEXT@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ @@ -227,7 +239,11 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ +target = @target@ target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ SUBDIRS = intl m4 po src test doc ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = config.rpath diff --git a/TODO b/TODO index 6fb500a9..2e3f7426 100644 --- a/TODO +++ b/TODO @@ -28,8 +28,22 @@ * Fix log and stdout message in Metalink related class. * Fix Cookie header's value. ';' is not necessary at the end of it. -* It is possible to replace all %lld to %s, using Util::llitos(...) ?. * Time::getTimeInMillis() returns int64_t. * Util::secfmt, What happens if sec is less than 0? * Rewrite ChunkedEncoding -* typedef int32_t CUID in common.h or a2types.h \ No newline at end of file +* typedef int32_t CUID in common.h or a2types.h + +* tempdir in HttpResponseCommand is not patched yet. +* Is localtime.cc not needed? + +* io related headers and compatible macros and definition -> a2io.h +* net related headers and compatible macros and definition -> a2netcompat.h +* used globally -> common.h + +* Following files have copyright issue + libgen.c + libgen.h + inet_aton.c + inet_aton.h + localtime_r.{h,c} + strptime.h diff --git a/config.h.in b/config.h.in index 2a0a073c..ea51194f 100644 --- a/config.h.in +++ b/config.h.in @@ -40,6 +40,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H +/* Define to 1 if you have the `basename' function. */ +#undef HAVE_BASENAME + +/* Define to 1 if you have the `daemon' function. */ +#undef HAVE_DAEMON + /* Define if the GNU dcgettext() function is already present or preinstalled. */ #undef HAVE_DCGETTEXT @@ -59,6 +65,9 @@ /* Define to 1 if you have the `ftruncate' function. */ #undef HAVE_FTRUNCATE +/* Define to 1 if you have the `getaddrinfo' function. */ +#undef HAVE_GETADDRINFO + /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD @@ -89,6 +98,9 @@ /* Define if you have the iconv() function. */ #undef HAVE_ICONV +/* Define to 1 if you have the `inet_aton' function. */ +#undef HAVE_INET_ATON + /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA @@ -99,6 +111,9 @@ declares uintmax_t. */ #undef HAVE_INTTYPES_H_WITH_UINTMAX +/* Define to 1 if you have the header file. */ +#undef HAVE_IO_H + /* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET @@ -117,6 +132,9 @@ /* Define to 1 if you have libgcrypt. */ #undef HAVE_LIBGCRYPT +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBGEN_H + /* Define to 1 if you have libgnutls. */ #undef HAVE_LIBGNUTLS @@ -135,6 +153,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H +/* Define to 1 if you have the `localtime_r' function. */ +#undef HAVE_LOCALTIME_R + /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC @@ -178,6 +199,9 @@ /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV +/* Define to 1 if you have the `random' function. */ +#undef HAVE_RANDOM + /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC @@ -194,9 +218,21 @@ /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE +/* Define to 1 if you have the `setmode' function. */ +#undef HAVE_SETMODE + +/* Define to 1 if you have the `sigaction' function. */ +#undef HAVE_SIGACTION + +/* Define to 1 if you have the `sleep' function. */ +#undef HAVE_SLEEP + /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET +/* Define to 1 if you have the `srandom' function. */ +#undef HAVE_SRANDOM + /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG @@ -244,6 +280,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strptime' function. */ +#undef HAVE_STRPTIME + /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR @@ -271,6 +310,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if you have the `timegm' function. */ +#undef HAVE_TIMEGM + /* Define to 1 if you have the `tsearch' function. */ #undef HAVE_TSEARCH @@ -283,9 +325,18 @@ /* Define if you have the unsigned long long type. */ #undef HAVE_UNSIGNED_LONG_LONG +/* Define to 1 if you have the `usleep' function. */ +#undef HAVE_USLEEP + /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF +/* Define to 1 if you have the header file. */ +#undef HAVE_WINSOCK2_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_WS2TCPIP_H + /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL diff --git a/configure b/configure index d20fe6fb..bb953d7d 100755 --- a/configure +++ b/configure @@ -652,6 +652,18 @@ LIBS build_alias host_alias target_alias +build +build_cpu +build_vendor +build_os +host +host_cpu +host_vendor +host_os +target +target_cpu +target_vendor +target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA @@ -676,6 +688,7 @@ am__untar CPPUNIT_CONFIG CPPUNIT_CFLAGS CPPUNIT_LIBS +WINSOCK_LIBS CXX CXXFLAGS LDFLAGS @@ -734,14 +747,6 @@ MSGFMT GMSGFMT XGETTEXT MSGMERGE -build -build_cpu -build_vendor -build_os -host -host_cpu -host_vendor -host_os GLIBC21 LIBICONV LTLIBICONV @@ -759,6 +764,16 @@ LIBINTL LTLIBINTL POSUB LIBOBJS +HAVE_BASENAME_TRUE +HAVE_BASENAME_FALSE +HAVE_GETADDRINFO_TRUE +HAVE_GETADDRINFO_FALSE +HAVE_INET_ATON_TRUE +HAVE_INET_ATON_FALSE +HAVE_LOCALTIME_R_TRUE +HAVE_LOCALTIME_R_FALSE +HAVE_STRPTIME_TRUE +HAVE_STRPTIME_FALSE LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias @@ -1342,6 +1357,7 @@ Program names: System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi @@ -1835,7 +1851,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -am__api_version="1.9" ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -1867,6 +1882,133 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6; } +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +echo "$as_me: error: invalid value of canonical target" >&2;} + { (exit 1); exit 1; }; };; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- +am__api_version="1.9" # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -2443,6 +2585,13 @@ echo "${ECHO_T}no" >&6; } ac_config_headers="$ac_config_headers config.h" +case "$target" in + *mingw*|*cygwin*) + WINSOCK_LIBS="-lws2_32" + + ;; +esac + # Set localedir localedir=${datadir}/locale @@ -6570,7 +6719,11 @@ fi -for ac_header in argz.h arpa/inet.h fcntl.h inttypes.h langinfo.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h + + + + +for ac_header in winsock2.h ws2tcpip.h argz.h arpa/inet.h fcntl.h inttypes.h io.h langinfo.h libgen.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then @@ -7632,89 +7785,6 @@ echo "${ECHO_T}found xgettext program is not GNU xgettext; ignore it" >&6; } ac_config_commands="$ac_config_commands default-1" -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 -echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} - { (exit 1); exit 1; }; } - -{ echo "$as_me:$LINENO: checking build system type" >&5 -echo $ECHO_N "checking build system type... $ECHO_C" >&6; } -if test "${ac_cv_build+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 -echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} - { (exit 1); exit 1; }; } - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 -echo "$as_me: error: invalid value of canonical build" >&2;} - { (exit 1); exit 1; }; };; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ echo "$as_me:$LINENO: checking host system type" >&5 -echo $ECHO_N "checking host system type... $ECHO_C" >&6; } -if test "${ac_cv_host+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 -echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} - { (exit 1); exit 1; }; } -fi - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -echo "${ECHO_T}$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 -echo "$as_me: error: invalid value of canonical host" >&2;} - { (exit 1); exit 1; }; };; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - { echo "$as_me:$LINENO: checking for strerror in -lcposix" >&5 echo $ECHO_N "checking for strerror in -lcposix... $ECHO_C" >&6; } @@ -12410,7 +12480,15 @@ done -for ac_func in __argz_count __argz_next __argz_stringify ftruncate getcwd getpagesize gettimeofday inet_ntoa memchr mempcpy memset mkdir munmap nl_langinfo rmdir select setlocale socket stpcpy strcasecmp strchr strcspn strdup strerror strstr strtol strtoul + + + + + + + + +for ac_func in __argz_count __argz_next __argz_stringify daemon ftruncate getcwd getpagesize gettimeofday inet_ntoa memchr mempcpy memset mkdir munmap nl_langinfo random rmdir select setlocale setmode sigaction sleep socket srandom stpcpy strcasecmp strchr strcspn strdup strerror strstr strtol strtoul timegm usleep do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -12503,6 +12581,593 @@ _ACEOF fi done + + +for ac_func in basename +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 { as_var=$as_ac_var; eval "test \"\${$as_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 GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + + +if true; then + HAVE_BASENAME_TRUE= + HAVE_BASENAME_FALSE='#' +else + HAVE_BASENAME_TRUE='#' + HAVE_BASENAME_FALSE= +fi + +else + + +if false; then + HAVE_BASENAME_TRUE= + HAVE_BASENAME_FALSE='#' +else + HAVE_BASENAME_TRUE='#' + HAVE_BASENAME_FALSE= +fi + +fi +done + + +for ac_func in getaddrinfo +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 { as_var=$as_ac_var; eval "test \"\${$as_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 GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + + +if true; then + HAVE_GETADDRINFO_TRUE= + HAVE_GETADDRINFO_FALSE='#' +else + HAVE_GETADDRINFO_TRUE='#' + HAVE_GETADDRINFO_FALSE= +fi + +else + + +if false; then + HAVE_GETADDRINFO_TRUE= + HAVE_GETADDRINFO_FALSE='#' +else + HAVE_GETADDRINFO_TRUE='#' + HAVE_GETADDRINFO_FALSE= +fi + +fi +done + + +for ac_func in inet_aton +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 { as_var=$as_ac_var; eval "test \"\${$as_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 GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + + +if true; then + HAVE_INET_ATON_TRUE= + HAVE_INET_ATON_FALSE='#' +else + HAVE_INET_ATON_TRUE='#' + HAVE_INET_ATON_FALSE= +fi + +else + + +if false; then + HAVE_INET_ATON_TRUE= + HAVE_INET_ATON_FALSE='#' +else + HAVE_INET_ATON_TRUE='#' + HAVE_INET_ATON_FALSE= +fi + +fi +done + + +for ac_func in localtime_r +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 { as_var=$as_ac_var; eval "test \"\${$as_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 GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + + +if true; then + HAVE_LOCALTIME_R_TRUE= + HAVE_LOCALTIME_R_FALSE='#' +else + HAVE_LOCALTIME_R_TRUE='#' + HAVE_LOCALTIME_R_FALSE= +fi + +else + + +if false; then + HAVE_LOCALTIME_R_TRUE= + HAVE_LOCALTIME_R_FALSE='#' +else + HAVE_LOCALTIME_R_TRUE='#' + HAVE_LOCALTIME_R_FALSE= +fi + +fi +done + + +for ac_func in strptime +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 { as_var=$as_ac_var; eval "test \"\${$as_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 GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + + +if true; then + HAVE_STRPTIME_TRUE= + HAVE_STRPTIME_FALSE='#' +else + HAVE_STRPTIME_TRUE='#' + HAVE_STRPTIME_FALSE= +fi + +else + + +if false; then + HAVE_STRPTIME_TRUE= + HAVE_STRPTIME_FALSE='#' +else + HAVE_STRPTIME_TRUE='#' + HAVE_STRPTIME_FALSE= +fi + +fi +done + + +case "$target" in + *mingw*) + + +if true; then + HAVE_GETADDRINFO_TRUE= + HAVE_GETADDRINFO_FALSE='#' +else + HAVE_GETADDRINFO_TRUE='#' + HAVE_GETADDRINFO_FALSE= +fi + + ;; +esac + ac_config_files="$ac_config_files Makefile src/Makefile test/Makefile po/Makefile.in m4/Makefile intl/Makefile doc/Makefile" cat >confcache <<\_ACEOF @@ -12678,6 +13343,83 @@ echo "$as_me: error: conditional \"ENABLE_ASYNC_DNS\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${HAVE_BASENAME_TRUE}" && test -z "${HAVE_BASENAME_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_BASENAME\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_BASENAME\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_BASENAME_TRUE}" && test -z "${HAVE_BASENAME_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_BASENAME\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_BASENAME\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_GETADDRINFO_TRUE}" && test -z "${HAVE_GETADDRINFO_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_GETADDRINFO\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_GETADDRINFO\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_GETADDRINFO_TRUE}" && test -z "${HAVE_GETADDRINFO_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_GETADDRINFO\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_GETADDRINFO\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_INET_ATON_TRUE}" && test -z "${HAVE_INET_ATON_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_INET_ATON\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_INET_ATON\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_INET_ATON_TRUE}" && test -z "${HAVE_INET_ATON_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_INET_ATON\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_INET_ATON\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_LOCALTIME_R_TRUE}" && test -z "${HAVE_LOCALTIME_R_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_LOCALTIME_R\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_LOCALTIME_R\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_LOCALTIME_R_TRUE}" && test -z "${HAVE_LOCALTIME_R_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_LOCALTIME_R\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_LOCALTIME_R\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_STRPTIME_TRUE}" && test -z "${HAVE_STRPTIME_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_STRPTIME\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_STRPTIME\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_STRPTIME_TRUE}" && test -z "${HAVE_STRPTIME_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_STRPTIME\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_STRPTIME\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HAVE_GETADDRINFO_TRUE}" && test -z "${HAVE_GETADDRINFO_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_GETADDRINFO\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_GETADDRINFO\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files @@ -13260,6 +14002,18 @@ LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +target!$target$ac_delim +target_cpu!$target_cpu$ac_delim +target_vendor!$target_vendor$ac_delim +target_os!$target_os$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim @@ -13284,6 +14038,7 @@ am__untar!$am__untar$ac_delim CPPUNIT_CONFIG!$CPPUNIT_CONFIG$ac_delim CPPUNIT_CFLAGS!$CPPUNIT_CFLAGS$ac_delim CPPUNIT_LIBS!$CPPUNIT_LIBS$ac_delim +WINSOCK_LIBS!$WINSOCK_LIBS$ac_delim CXX!$CXX$ac_delim CXXFLAGS!$CXXFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim @@ -13307,19 +14062,6 @@ CCDEPMODE!$CCDEPMODE$ac_delim am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim RANLIB!$RANLIB$ac_delim -YACC!$YACC$ac_delim -YFLAGS!$YFLAGS$ac_delim -XML2_CONFIG!$XML2_CONFIG$ac_delim -XML_CPPFLAGS!$XML_CPPFLAGS$ac_delim -XML_LIBS!$XML_LIBS$ac_delim -LIBGNUTLS_CONFIG!$LIBGNUTLS_CONFIG$ac_delim -LIBGNUTLS_CFLAGS!$LIBGNUTLS_CFLAGS$ac_delim -LIBGNUTLS_LIBS!$LIBGNUTLS_LIBS$ac_delim -LIBGCRYPT_CONFIG!$LIBGCRYPT_CONFIG$ac_delim -LIBGCRYPT_CFLAGS!$LIBGCRYPT_CFLAGS$ac_delim -LIBGCRYPT_LIBS!$LIBGCRYPT_LIBS$ac_delim -OPENSSL_LIBS!$OPENSSL_LIBS$ac_delim -OPENSSL_CFLAGS!$OPENSSL_CFLAGS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -13361,6 +14103,19 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +YACC!$YACC$ac_delim +YFLAGS!$YFLAGS$ac_delim +XML2_CONFIG!$XML2_CONFIG$ac_delim +XML_CPPFLAGS!$XML_CPPFLAGS$ac_delim +XML_LIBS!$XML_LIBS$ac_delim +LIBGNUTLS_CONFIG!$LIBGNUTLS_CONFIG$ac_delim +LIBGNUTLS_CFLAGS!$LIBGNUTLS_CFLAGS$ac_delim +LIBGNUTLS_LIBS!$LIBGNUTLS_LIBS$ac_delim +LIBGCRYPT_CONFIG!$LIBGCRYPT_CONFIG$ac_delim +LIBGCRYPT_CFLAGS!$LIBGCRYPT_CFLAGS$ac_delim +LIBGCRYPT_LIBS!$LIBGCRYPT_LIBS$ac_delim +OPENSSL_LIBS!$OPENSSL_LIBS$ac_delim +OPENSSL_CFLAGS!$OPENSSL_CFLAGS$ac_delim LIBCARES_LIBS!$LIBCARES_LIBS$ac_delim LIBCARES_CPPFLAGS!$LIBCARES_CPPFLAGS$ac_delim LIBARES_LIBS!$LIBARES_LIBS$ac_delim @@ -13383,14 +14138,6 @@ MSGFMT!$MSGFMT$ac_delim GMSGFMT!$GMSGFMT$ac_delim XGETTEXT!$XGETTEXT$ac_delim MSGMERGE!$MSGMERGE$ac_delim -build!$build$ac_delim -build_cpu!$build_cpu$ac_delim -build_vendor!$build_vendor$ac_delim -build_os!$build_os$ac_delim -host!$host$ac_delim -host_cpu!$host_cpu$ac_delim -host_vendor!$host_vendor$ac_delim -host_os!$host_os$ac_delim GLIBC21!$GLIBC21$ac_delim LIBICONV!$LIBICONV$ac_delim LTLIBICONV!$LTLIBICONV$ac_delim @@ -13408,10 +14155,20 @@ LIBINTL!$LIBINTL$ac_delim LTLIBINTL!$LTLIBINTL$ac_delim POSUB!$POSUB$ac_delim LIBOBJS!$LIBOBJS$ac_delim +HAVE_BASENAME_TRUE!$HAVE_BASENAME_TRUE$ac_delim +HAVE_BASENAME_FALSE!$HAVE_BASENAME_FALSE$ac_delim +HAVE_GETADDRINFO_TRUE!$HAVE_GETADDRINFO_TRUE$ac_delim +HAVE_GETADDRINFO_FALSE!$HAVE_GETADDRINFO_FALSE$ac_delim +HAVE_INET_ATON_TRUE!$HAVE_INET_ATON_TRUE$ac_delim +HAVE_INET_ATON_FALSE!$HAVE_INET_ATON_FALSE$ac_delim +HAVE_LOCALTIME_R_TRUE!$HAVE_LOCALTIME_R_TRUE$ac_delim +HAVE_LOCALTIME_R_FALSE!$HAVE_LOCALTIME_R_FALSE$ac_delim +HAVE_STRPTIME_TRUE!$HAVE_STRPTIME_TRUE$ac_delim +HAVE_STRPTIME_FALSE!$HAVE_STRPTIME_FALSE$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 48; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 63; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.ac b/configure.ac index c0ab6c9a..fbf9182d 100644 --- a/configure.ac +++ b/configure.ac @@ -3,11 +3,20 @@ # AC_PREREQ(2.59) AC_INIT(aria2c, 0.11.1+1, t-tujikawa@users.sourceforge.net) +AC_CANONICAL_HOST +AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE() AM_PATH_CPPUNIT(1.10.2) AC_CONFIG_SRCDIR([src/Socket.h]) AC_CONFIG_HEADERS([config.h]) +case "$target" in + *mingw*|*cygwin*) + WINSOCK_LIBS="-lws2_32" + AC_SUBST(WINSOCK_LIBS) + ;; +esac + # Set localedir localedir=${datadir}/locale AC_SUBST(localedir) @@ -102,7 +111,7 @@ fi # Checks for header files. AC_FUNC_ALLOCA #AC_HEADER_STDC -AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h inttypes.h langinfo.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h]) +AC_CHECK_HEADERS([winsock2.h ws2tcpip.h argz.h arpa/inet.h fcntl.h inttypes.h io.h langinfo.h libgen.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL @@ -125,7 +134,31 @@ AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_FUNC_STAT AC_FUNC_VPRINTF -AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify ftruncate getcwd getpagesize gettimeofday inet_ntoa memchr mempcpy memset mkdir munmap nl_langinfo rmdir select setlocale socket stpcpy strcasecmp strchr strcspn strdup strerror strstr strtol strtoul]) +AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify daemon ftruncate getcwd getpagesize gettimeofday inet_ntoa memchr mempcpy memset mkdir munmap nl_langinfo random rmdir select setlocale setmode sigaction sleep socket srandom stpcpy strcasecmp strchr strcspn strdup strerror strstr strtol strtoul timegm usleep]) + +AC_CHECK_FUNCS([basename], + [AM_CONDITIONAL([HAVE_BASENAME], true)], + [AM_CONDITIONAL([HAVE_BASENAME], false)]) +AC_CHECK_FUNCS([getaddrinfo], + [AM_CONDITIONAL([HAVE_GETADDRINFO], true)], + [AM_CONDITIONAL([HAVE_GETADDRINFO], false)]) +AC_CHECK_FUNCS([inet_aton], + [AM_CONDITIONAL([HAVE_INET_ATON], true)], + [AM_CONDITIONAL([HAVE_INET_ATON], false)]) +AC_CHECK_FUNCS([localtime_r], + [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)], + [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)]) +AC_CHECK_FUNCS([strptime], + [AM_CONDITIONAL([HAVE_STRPTIME], true)], + [AM_CONDITIONAL([HAVE_STRPTIME], false)]) + +case "$target" in + *mingw*) + dnl true if _WIN32_WINNT >= 0x0501 + AM_CONDITIONAL([HAVE_GETADDRINFO], true) + ;; +esac + AC_CONFIG_FILES([Makefile src/Makefile test/Makefile diff --git a/doc/Makefile.in b/doc/Makefile.in index bdfa9183..3b18d6de 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -35,6 +35,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +target_triplet = @target@ subdir = doc DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -105,6 +106,16 @@ GENCAT = @GENCAT@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ +HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@ +HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@ +HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@ +HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@ +HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@ +HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@ +HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@ +HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@ +HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@ +HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -154,6 +165,7 @@ STRIP = @STRIP@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WINSOCK_LIBS = @WINSOCK_LIBS@ XGETTEXT = @XGETTEXT@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ @@ -205,7 +217,11 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ +target = @target@ target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ man_MANS = aria2c.1 EXTRA_DIST = $(man_MANS) all: all-am diff --git a/m4/Makefile.in b/m4/Makefile.in index a85f8a9c..a40fa005 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -35,6 +35,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +target_triplet = @target@ subdir = m4 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -101,6 +102,16 @@ GENCAT = @GENCAT@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ +HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@ +HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@ +HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@ +HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@ +HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@ +HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@ +HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@ +HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@ +HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@ +HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -150,6 +161,7 @@ STRIP = @STRIP@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WINSOCK_LIBS = @WINSOCK_LIBS@ XGETTEXT = @XGETTEXT@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ @@ -201,7 +213,11 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ +target = @target@ target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 all: all-am diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index 12ba4480..d6fec83d 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -38,6 +38,7 @@ #include "Util.h" #include "message.h" #include "LogFactory.h" +#include "a2io.h" #include #include #include @@ -79,7 +80,7 @@ void AbstractDiskWriter::openExistingFile(const string& filename, int64_t totalL throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), MSG_FILE_NOT_FOUND); } - if((fd = open(filename.c_str(), O_RDWR, OPEN_MODE)) < 0) { + if((fd = open(filename.c_str(), O_RDWR|O_BINARY, OPEN_MODE)) < 0) { throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno)); } if(f.size() < totalLength) { @@ -99,7 +100,7 @@ void AbstractDiskWriter::createFile(const string& filename, int32_t addFlags) { // if(filename.empty()) { // filename = "index.html"; // } - if((fd = open(filename.c_str(), O_CREAT|O_RDWR|O_TRUNC|addFlags, OPEN_MODE)) < 0) { + if((fd = open(filename.c_str(), O_CREAT|O_RDWR|O_TRUNC|O_BINARY|addFlags, OPEN_MODE)) < 0) { throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno)); } } diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc index df6711cc..38e6f036 100644 --- a/src/BitfieldMan.cc +++ b/src/BitfieldMan.cc @@ -135,9 +135,12 @@ int32_t BitfieldMan::getMissingIndexRandomly(const unsigned char* bitfield, int32_t bitfieldLength) const { + /* int32_t byte = (int32_t)(((double)bitfieldLength)* randomizer->getRandomNumber()/ (randomizer->getMaxRandomNumber()+1.0)); + */ + int32_t byte = randomizer->getRandomNumber(bitfieldLength); unsigned char lastMask = 0; // the number of bytes in the last byte of bitfield diff --git a/src/ChunkChecksumValidator.cc b/src/ChunkChecksumValidator.cc index 0d69bc59..ce62c24d 100644 --- a/src/ChunkChecksumValidator.cc +++ b/src/ChunkChecksumValidator.cc @@ -49,7 +49,7 @@ void ChunkChecksumValidator::validateSameLengthChecksum(BitfieldMan* bitfieldMan string actualChecksum = diskWriter->messageDigest(offset, dataLength, algo); if(actualChecksum != expectedChecksum) { logger->info(EX_INVALID_CHUNK_CHECKSUM, - index, offset, + index, Util::llitos(offset, true).c_str(), expectedChecksum.c_str(), actualChecksum.c_str()); bitfieldMan->unsetBit(index); } @@ -71,7 +71,7 @@ void ChunkChecksumValidator::validateDifferentLengthChecksum(BitfieldMan* bitfie if(expectedChecksum != actualChecksum) { // wrong checksum logger->info(EX_INVALID_CHUNK_CHECKSUM, - index, offset, + index, Util::llitos(offset, true).c_str(), expectedChecksum.c_str(), actualChecksum.c_str()); bitfieldMan->unsetBitRange(startIndex, endIndex); } diff --git a/src/CompactPeerListProcessor.cc b/src/CompactPeerListProcessor.cc index 0d597c36..d18e2784 100644 --- a/src/CompactPeerListProcessor.cc +++ b/src/CompactPeerListProcessor.cc @@ -33,7 +33,7 @@ /* copyright --> */ #include "CompactPeerListProcessor.h" #include "Data.h" -#include +#include "a2netcompat.h" bool CompactPeerListProcessor::canHandle(const MetaEntry* peersEntry) const { return dynamic_cast(peersEntry) != 0; diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index d8ff303f..a2da4816 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -40,6 +40,7 @@ #include "message.h" #include "File.h" #include "Util.h" +#include "a2io.h" #include DefaultBtProgressInfoFile::DefaultBtProgressInfoFile(const BtContextHandle& btContext, @@ -59,7 +60,7 @@ DefaultBtProgressInfoFile::~DefaultBtProgressInfoFile() {} void DefaultBtProgressInfoFile::save() { logger->info(MSG_SAVING_SEGMENT_FILE, filename.c_str()); - FILE* file = openFile(filename, "w"); + FILE* file = openFile(filename, "wb"); try { if(fwrite(btContext->getInfoHash(), btContext->getInfoHashLength(), 1, file) < 1) { @@ -93,7 +94,7 @@ void DefaultBtProgressInfoFile::save() { void DefaultBtProgressInfoFile::load() { logger->info(MSG_LOADING_SEGMENT_FILE, filename.c_str()); - FILE* file = openFile(filename, "r+"); + FILE* file = openFile(filename, "r+b"); unsigned char* savedInfoHash = 0; unsigned char* savedBitfield = 0; try { @@ -161,6 +162,9 @@ FILE* DefaultBtProgressInfoFile::openFile(const string& filename, throw new DlAbortEx(EX_SEGMENT_FILE_OPEN, filename.c_str(), strerror(errno)); } +#ifdef HAVE_SETMODE + setmode(fileno(file), O_BINARY); +#endif return file; } diff --git a/src/Directory.cc b/src/Directory.cc index ae05749c..4fade277 100644 --- a/src/Directory.cc +++ b/src/Directory.cc @@ -36,9 +36,11 @@ #include "File.h" #include "DlAbortEx.h" #include "message.h" +#include "a2io.h" #include #include #include +#include Directory::Directory(const string& name):name(name) {} @@ -61,7 +63,7 @@ void Directory::createDir(const string& parentDir, bool recursive) const { throw new DlAbortEx(EX_NOT_DIRECTORY, path.c_str()); } } else { - if(mkdir(path.c_str(), OPEN_MODE) == -1) { + if(a2mkdir(path.c_str(), OPEN_MODE) == -1) { throw new DlAbortEx(EX_MAKE_DIR, path.c_str(), strerror(errno)); } } diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 59b6cff1..bdc514a3 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -44,6 +44,7 @@ # include "ChecksumCommand.h" #endif // ENABLE_MESSAGE_DIGEST #include +#include DownloadCommand::DownloadCommand(int cuid, const RequestHandle req, @@ -71,7 +72,11 @@ bool DownloadCommand::executeInternal() { // TODO we need to specify the sum of all segmentMan's download speed here. if(maxDownloadSpeedLimit > 0 && maxDownloadSpeedLimit < _requestGroup->getSegmentMan()->calculateDownloadSpeed()) { +#ifdef HAVE_USLEEP usleep(1); +#else + _sleep(1); +#endif // HAVE_USLEEP e->commands.push_back(this); return false; } diff --git a/src/File.cc b/src/File.cc index a3d80dd9..342b91ca 100644 --- a/src/File.cc +++ b/src/File.cc @@ -34,9 +34,7 @@ /* copyright --> */ #include "File.h" #include "Util.h" -#include -#include -#include +#include "a2io.h" #include File::File(const string& name):name(name) {} @@ -106,7 +104,7 @@ bool File::mkdirs() { if(File(accDir).isDir()) { continue; } - if(mkdir(accDir.c_str(), DIR_OPEN_MODE) == -1) { + if(a2mkdir(accDir.c_str(), DIR_OPEN_MODE) == -1) { return false; } } @@ -137,3 +135,8 @@ string File::getDirname() const free(s); return dname; } + +bool File::isDir(const string& filename) +{ + return File(filename).isDir(); +} diff --git a/src/File.h b/src/File.h index 8ab22044..27cd386a 100644 --- a/src/File.h +++ b/src/File.h @@ -94,6 +94,8 @@ public: string getBasename() const; string getDirname() const; + + static bool isDir(const string& filename); }; #endif // _D_FILE_H_ diff --git a/src/FileAllocationCommand.cc b/src/FileAllocationCommand.cc index fed1c2a8..554086d8 100644 --- a/src/FileAllocationCommand.cc +++ b/src/FileAllocationCommand.cc @@ -37,6 +37,7 @@ #include "message.h" #include "DownloadCommand.h" #include "prefs.h" +#include "Util.h" bool FileAllocationCommand::executeInternal() { @@ -44,7 +45,8 @@ bool FileAllocationCommand::executeInternal() if(_fileAllocationEntry->finished()) { logger->debug(MSG_ALLOCATION_COMPLETED, - _timer.difference(), _requestGroup->getTotalLength()); + _timer.difference(), + Util::llitos(_requestGroup->getTotalLength(), true).c_str()); _e->_fileAllocationMan->markCurrentFileAllocationEntryDone(); diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index a40c0303..39d8ef82 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -201,7 +201,7 @@ int32_t FtpConnection::receiveSizeResponse(int64_t& size) { pair response; if(bulkReceiveResponse(response)) { if(response.first == 213) { - sscanf(response.second.c_str(), "%*d %Ld", &size); + sscanf(response.second.c_str(), "%*d " LONGLONG_SCANF, &size); } return response.first; } else { diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index b9c03440..bd497228 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -187,7 +187,7 @@ bool FtpNegotiationCommand::recvSize() { throw new DlRetryEx(EX_BAD_STATUS, status); } if(size == INT64_MAX || size < 0) { - throw new DlAbortEx(EX_TOO_LARGE_FILE, size); + throw new DlAbortEx(EX_TOO_LARGE_FILE, Util::llitos(size, true).c_str()); } if(!_requestGroup->getSegmentMan()->downloadStarted) { _requestGroup->getSegmentMan()->downloadStarted = true; @@ -220,23 +220,8 @@ bool FtpNegotiationCommand::recvSize() { sequence = SEQ_FILE_PREPARATION; e->noWait = true; return false; - - /* - _requestGroup->getSegmentMan()->initBitfield(e->option->getAsInt(PREF_SEGMENT_SIZE), - _requestGroup->getSegmentMan()->totalSize); - bool segFileExists = _requestGroup->getSegmentMan()->segmentFileExists(); - if(segFileExists) { - _requestGroup->getSegmentMan()->load(); - _requestGroup->getSegmentMan()->diskWriter->openExistingFile(_requestGroup->getSegmentMan()->getFilePath()); - } else { - _requestGroup->getSegmentMan()->diskWriter->initAndOpenFile(_requestGroup->getSegmentMan()->getFilePath(), size); - } - */ - } else { _requestGroup->validateTotalLength(size); - //if(_requestGroup->getSegmentMan()->totalSize != size) { - //throw new DlAbortEx(EX_SIZE_MISMATCH, _requestGroup->getSegmentMan()->totalSize, size); } if(e->option->get(PREF_FTP_PASV) == V_TRUE) { sequence = SEQ_SEND_PASV; diff --git a/src/HttpConnection.h b/src/HttpConnection.h index 87384b44..f007ccc9 100644 --- a/src/HttpConnection.h +++ b/src/HttpConnection.h @@ -44,8 +44,6 @@ #include "Logger.h" #include "HttpResponse.h" #include "HttpHeaderProcessor.h" -#include -#include class HttpRequestEntry { private: diff --git a/src/HttpRequest.h b/src/HttpRequest.h index 753302b3..b943d2ea 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -40,7 +40,6 @@ #include "Range.h" #include "Request.h" #include "Option.h" -#include class HttpRequest { private: diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index 7e16039e..3a75da50 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -58,12 +58,12 @@ void HttpResponse::validateResponse() const RangeHandle responseRange = httpHeader->getRange(); if(!httpRequest->isRangeSatisfied(responseRange)) { throw new DlRetryEx(EX_INVALID_RANGE_HEADER, - httpRequest->getStartByte(), - httpRequest->getEndByte(), - httpRequest->getEntityLength(), - responseRange->getStartByte(), - responseRange->getEndByte(), - responseRange->getEntityLength()); + Util::llitos(httpRequest->getStartByte(), true).c_str(), + Util::llitos(httpRequest->getEndByte(), true).c_str(), + Util::llitos(httpRequest->getEntityLength(), true).c_str(), + Util::llitos(responseRange->getStartByte(), true).c_str(), + Util::llitos(responseRange->getEndByte(), true).c_str(), + Util::llitos(responseRange->getEntityLength(), true).c_str()); } } } diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index 821406f6..3f5f5bcc 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -121,7 +121,7 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe } int64_t size = httpResponse->getEntityLength(); if(size == INT64_MAX || size < 0) { - throw new DlAbortEx(EX_TOO_LARGE_FILE, size); + throw new DlAbortEx(EX_TOO_LARGE_FILE, Util::llitos(size, true).c_str()); } _requestGroup->getSegmentMan()->isSplittable = !(size == 0); _requestGroup->getSegmentMan()->downloadStarted = true; diff --git a/src/IteratableChunkChecksumValidator.cc b/src/IteratableChunkChecksumValidator.cc index 0fa2fa10..9ad30c46 100644 --- a/src/IteratableChunkChecksumValidator.cc +++ b/src/IteratableChunkChecksumValidator.cc @@ -47,7 +47,7 @@ void IteratableChunkChecksumValidator::validateChunk() // wrong checksum logger->info(EX_INVALID_CHUNK_CHECKSUM, _currentIndex, - offset, + Util::llitos(offset, true).c_str(), _chunkChecksum->getChecksum(_currentIndex).c_str(), actualChecksum.c_str()); int32_t startIndex; diff --git a/src/LogFactory.cc b/src/LogFactory.cc index a0b07293..fbb82c83 100644 --- a/src/LogFactory.cc +++ b/src/LogFactory.cc @@ -34,8 +34,9 @@ /* copyright --> */ #include "LogFactory.h" #include "SimpleLogger.h" +#include "a2io.h" -string LogFactory::filename = "/dev/null"; +string LogFactory::filename = DEV_NULL; Logger* LogFactory::logger = NULL; Logger* LogFactory::getInstance() { diff --git a/src/Makefile.am b/src/Makefile.am index f1a5c3fe..76373ccc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,7 +98,8 @@ SRCS = Socket.h\ CookieParser.cc CookieParser.h\ CookieBoxFactory.cc CookieBoxFactory.h\ HttpHeaderProcessor.cc HttpHeaderProcessor.h\ - FileEntry.cc FileEntry.h + FileEntry.cc FileEntry.h\ + Platform.cc Platform.h # debug_new.cpp if ENABLE_MESSAGE_DIGEST @@ -226,11 +227,31 @@ SRCS += Metalinker.cc Metalinker.h\ MetalinkRequestInfo.cc MetalinkRequestInfo.h endif # ENABLE_METALINK +if !HAVE_BASENAME +SRCS += libgen.c libgen.h +endif # !HAVE_BASENAME + +if !HAVE_GETADDRINFO +SRCS += getaddrinfo.c getaddrinfo.h +endif # !HAVE_GETADDRINFO + +if !HAVE_INET_ATON +SRCS += inet_aton.c inet_aton.h +endif # !HAVE_INET_ATON + +if !HAVE_LOCALTIME_R +SRCS += localtime_r.c localtime_r.h +endif # !HAVE_LOCALTIME_R + +if !HAVE_STRPTIME +SRCS += strptime.c strptime.h +endif # !HAVE_STRPTIME + noinst_LIBRARIES = libaria2c.a libaria2c_a_SOURCES = $(SRCS) aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\ @LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\ - @LIBCARES_LIBS@ # -lprofiler + @LIBCARES_LIBS@ @WINSOCK_LIBS@ # -lprofiler #aria2c_LDFLAGS = #-pg AM_CPPFLAGS = -Wall\ -I../lib -I../intl -I$(top_srcdir)/intl\ diff --git a/src/Makefile.in b/src/Makefile.in index b9190ff3..054700a0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -37,6 +37,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +target_triplet = @target@ bin_PROGRAMS = aria2c$(EXEEXT) # debug_new.cpp @ENABLE_MESSAGE_DIGEST_TRUE@am__append_1 = ChunkChecksumValidator.cc ChunkChecksumValidator.h\ @@ -158,6 +159,11 @@ bin_PROGRAMS = aria2c$(EXEEXT) @ENABLE_METALINK_TRUE@ Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\ @ENABLE_METALINK_TRUE@ MetalinkRequestInfo.cc MetalinkRequestInfo.h +@HAVE_BASENAME_FALSE@am__append_4 = libgen.c libgen.h +@HAVE_GETADDRINFO_FALSE@am__append_5 = getaddrinfo.c getaddrinfo.h +@HAVE_INET_ATON_FALSE@am__append_6 = inet_aton.c inet_aton.h +@HAVE_LOCALTIME_R_FALSE@am__append_7 = localtime_r.c localtime_r.h +@HAVE_STRPTIME_FALSE@am__append_8 = strptime.c strptime.h subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in alloca.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -243,8 +249,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \ RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \ CookieParser.cc CookieParser.h CookieBoxFactory.cc \ CookieBoxFactory.h HttpHeaderProcessor.cc \ - HttpHeaderProcessor.h FileEntry.cc FileEntry.h \ - ChunkChecksumValidator.cc ChunkChecksumValidator.h \ + HttpHeaderProcessor.h FileEntry.cc FileEntry.h Platform.cc \ + Platform.h ChunkChecksumValidator.cc ChunkChecksumValidator.h \ IteratableChunkChecksumValidator.cc \ IteratableChunkChecksumValidator.h \ IteratableChecksumValidator.cc IteratableChecksumValidator.h \ @@ -319,7 +325,9 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \ Metalinker.cc Metalinker.h MetalinkEntry.cc MetalinkEntry.h \ MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \ Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h \ - MetalinkRequestInfo.cc MetalinkRequestInfo.h + MetalinkRequestInfo.cc MetalinkRequestInfo.h libgen.c libgen.h \ + getaddrinfo.c getaddrinfo.h inet_aton.c inet_aton.h \ + localtime_r.c localtime_r.h strptime.c strptime.h @ENABLE_MESSAGE_DIGEST_TRUE@am__objects_1 = \ @ENABLE_MESSAGE_DIGEST_TRUE@ ChunkChecksumValidator.$(OBJEXT) \ @ENABLE_MESSAGE_DIGEST_TRUE@ IteratableChunkChecksumValidator.$(OBJEXT) \ @@ -396,7 +404,12 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \ @ENABLE_METALINK_TRUE@ MetalinkResource.$(OBJEXT) \ @ENABLE_METALINK_TRUE@ Xml2MetalinkProcessor.$(OBJEXT) \ @ENABLE_METALINK_TRUE@ MetalinkRequestInfo.$(OBJEXT) -am__objects_4 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \ +@HAVE_BASENAME_FALSE@am__objects_4 = libgen.$(OBJEXT) +@HAVE_GETADDRINFO_FALSE@am__objects_5 = getaddrinfo.$(OBJEXT) +@HAVE_INET_ATON_FALSE@am__objects_6 = inet_aton.$(OBJEXT) +@HAVE_LOCALTIME_R_FALSE@am__objects_7 = localtime_r.$(OBJEXT) +@HAVE_STRPTIME_FALSE@am__objects_8 = strptime.$(OBJEXT) +am__objects_9 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \ AbstractCommand.$(OBJEXT) \ InitiateConnectionCommandFactory.$(OBJEXT) \ DownloadCommand.$(OBJEXT) \ @@ -436,9 +449,11 @@ am__objects_4 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \ RealtimeCommand.$(OBJEXT) RequestGroupEntry.$(OBJEXT) \ Cookie.$(OBJEXT) CookieParser.$(OBJEXT) \ CookieBoxFactory.$(OBJEXT) HttpHeaderProcessor.$(OBJEXT) \ - FileEntry.$(OBJEXT) $(am__objects_1) $(am__objects_2) \ - $(am__objects_3) -am_libaria2c_a_OBJECTS = $(am__objects_4) + FileEntry.$(OBJEXT) Platform.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) \ + $(am__objects_5) $(am__objects_6) $(am__objects_7) \ + $(am__objects_8) +am_libaria2c_a_OBJECTS = $(am__objects_9) libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) @@ -449,15 +464,15 @@ aria2c_DEPENDENCIES = libaria2c.a @ALLOCA@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libaria2c_a_SOURCES) $(aria2c_SOURCES) DIST_SOURCES = $(am__libaria2c_a_SOURCES_DIST) $(aria2c_SOURCES) ETAGS = etags @@ -506,6 +521,16 @@ GENCAT = @GENCAT@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ +HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@ +HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@ +HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@ +HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@ +HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@ +HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@ +HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@ +HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@ +HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@ +HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -555,6 +580,7 @@ STRIP = @STRIP@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WINSOCK_LIBS = @WINSOCK_LIBS@ XGETTEXT = @XGETTEXT@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ @@ -606,7 +632,11 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ +target = @target@ target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ aria2c_SOURCES = main.cc SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \ AbstractCommand.cc AbstractCommand.h \ @@ -668,13 +698,15 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \ RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \ CookieParser.cc CookieParser.h CookieBoxFactory.cc \ CookieBoxFactory.h HttpHeaderProcessor.cc \ - HttpHeaderProcessor.h FileEntry.cc FileEntry.h $(am__append_1) \ - $(am__append_2) $(am__append_3) + HttpHeaderProcessor.h FileEntry.cc FileEntry.h Platform.cc \ + Platform.h $(am__append_1) $(am__append_2) $(am__append_3) \ + $(am__append_4) $(am__append_5) $(am__append_6) \ + $(am__append_7) $(am__append_8) noinst_LIBRARIES = libaria2c.a libaria2c_a_SOURCES = $(SRCS) aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\ @LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\ - @LIBCARES_LIBS@ # -lprofiler + @LIBCARES_LIBS@ @WINSOCK_LIBS@ # -lprofiler #aria2c_LDFLAGS = #-pg AM_CPPFLAGS = -Wall\ @@ -686,7 +718,7 @@ AM_CPPFLAGS = -Wall\ all: all-am .SUFFIXES: -.SUFFIXES: .cc .o .obj +.SUFFIXES: .c .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -880,6 +912,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerListenCommand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtil.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Piece.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Platform.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RealtimeCommand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactory.Po@am__quote@ @@ -908,7 +941,26 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UriListParser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2MetalinkProcessor.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getaddrinfo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_aton.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localtime_r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strptime.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .cc.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ diff --git a/src/MetaFileUtil.cc b/src/MetaFileUtil.cc index 35c84d38..c687bad5 100644 --- a/src/MetaFileUtil.cc +++ b/src/MetaFileUtil.cc @@ -36,18 +36,21 @@ #include "File.h" #include "DlAbortEx.h" #include "message.h" +#include "a2io.h" #include -#include MetaEntry* MetaFileUtil::parseMetaFile(const string& file) { File f(file); int32_t len = f.size(); char* buf = new char[len]; - FILE* fp = fopen(file.c_str(), "r+"); + FILE* fp = fopen(file.c_str(), "r+b"); try { if(fp == NULL) { throw new DlAbortEx("cannot open metainfo file"); } +#ifdef HAVE_SETMODE + setmode(fileno(fp), O_BINARY); +#endif if(fread(buf, len, 1, fp) != 1) { fclose(fp); throw new DlAbortEx("cannot read metainfo"); diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 7d96d29a..32375528 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -121,7 +121,7 @@ void MultiDiskAdaptor::writeData(const unsigned char* data, int32_t len, } } if(!writing) { - throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset); + throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, Util::llitos(offset, true).c_str()); } } @@ -164,7 +164,7 @@ int32_t MultiDiskAdaptor::readData(unsigned char* data, int32_t len, int64_t off } } if(!reading) { - throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset); + throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, Util::llitos(offset, true).c_str()); } return totalReadLength; } @@ -212,7 +212,7 @@ string MultiDiskAdaptor::messageDigest(int64_t offset, int64_t length, } } if(!reading) { - throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset); + throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, Util::llitos(offset, true).c_str()); } unsigned char hashValue[20]; ctx.digestFinal(hashValue); diff --git a/src/NameResolver.h b/src/NameResolver.h index e4da707c..858227c1 100644 --- a/src/NameResolver.h +++ b/src/NameResolver.h @@ -36,10 +36,7 @@ #define _D_NAME_RESOLVER_H_ #include "common.h" -#include -#include -#include -#include +#include "a2netcompat.h" #ifdef ENABLE_ASYNC_DNS diff --git a/src/OptionHandlerImpl.h b/src/OptionHandlerImpl.h index 5065fe82..71b2cc55 100644 --- a/src/OptionHandlerImpl.h +++ b/src/OptionHandlerImpl.h @@ -40,7 +40,6 @@ #include "Util.h" #include "FatalException.h" #include "prefs.h" -#include class NullOptionHandler : public OptionHandler { public: @@ -91,14 +90,14 @@ public: } else { string msg = _optName+" "; if(_min == -1 && _max != -1) { - msg += _("must be smaller than or equal to %lld."); - throw new FatalException(msg.c_str(), _max); + msg += _("must be smaller than or equal to %s."); + throw new FatalException(msg.c_str(), Util::llitos(_max).c_str()); } else if(_min != -1 && _max != -1) { - msg += _("must be between %lld and %lld."); - throw new FatalException(msg.c_str(), _min, _max); + msg += _("must be between %s and %s."); + throw new FatalException(msg.c_str(), Util::llitos(_min).c_str(), Util::llitos(_max).c_str()); } else if(_min != -1 && _max == -1) { - msg += _("must be greater than or equal to %lld."); - throw new FatalException(msg.c_str(), _min); + msg += _("must be greater than or equal to %s."); + throw new FatalException(msg.c_str(), Util::llitos(_min).c_str()); } else { msg += _("must be a number."); throw new FatalException(msg.c_str()); @@ -218,9 +217,9 @@ public: virtual void parseArg(Option* option, const string& optarg) { pair proxy = Util::split(optarg, ":"); - in_port_t port = strtol(proxy.second.c_str(), 0, 10); + int32_t port = strtol(proxy.second.c_str(), 0, 10); if(proxy.first.empty() || proxy.second.empty() || - port <= 0) { + port <= 0 || 65535 < port) { throw new FatalException(_("unrecognized proxy format")); } option->put(PREF_HTTP_PROXY, optarg); diff --git a/src/PeerConnection.cc b/src/PeerConnection.cc index 137bf383..bee3fd48 100644 --- a/src/PeerConnection.cc +++ b/src/PeerConnection.cc @@ -39,7 +39,7 @@ #include "Util.h" #include "LogFactory.h" #include "BtHandshakeMessage.h" -#include +#include "a2netcompat.h" PeerConnection::PeerConnection(int32_t cuid, const SocketHandle& socket, diff --git a/src/PeerMessageUtil.cc b/src/PeerMessageUtil.cc index 6be0564e..c342aec3 100644 --- a/src/PeerMessageUtil.cc +++ b/src/PeerMessageUtil.cc @@ -35,7 +35,7 @@ #include "PeerMessageUtil.h" #include "DlAbortEx.h" #include "Util.h" -#include +#include "a2netcompat.h" int8_t PeerMessageUtil::getId(const unsigned char* msg) { return msg[0]; diff --git a/src/Platform.cc b/src/Platform.cc new file mode 100644 index 00000000..4db776f2 --- /dev/null +++ b/src/Platform.cc @@ -0,0 +1,63 @@ +/* */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H + +#ifdef HAVE_WINSOCK2_H +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x501 +# endif // _WIN32_WINNT +# include +#endif // HAVE_WINSOCK2_H + +#include "Platform.h" +#include "DlAbortEx.h" + +Platform::Platform() { +#ifdef HAVE_WINSOCK2_H + WSADATA wsaData; + memset((char*)&wsaData, 0, sizeof(wsaData)); + if (WSAStartup(MAKEWORD(1, 1), &wsaData)) { + throw new DlAbortEx(_("Windows socket library initialization failed")); + } +#endif // HAVE_WINSOCK2_H +} + +Platform::~Platform() { +#ifdef HAVE_WINSOCK2_H + WSACleanup(); +#endif // HAVE_WINSOCK2_H +} diff --git a/src/Platform.h b/src/Platform.h new file mode 100644 index 00000000..daab06f3 --- /dev/null +++ b/src/Platform.h @@ -0,0 +1,45 @@ +/* */ +#ifndef _D_PLATFORM_H_ +#define _D_PLATFORM_H_ + +class Platform { +public: + Platform(); + + ~Platform(); +}; + +#endif // _D_PLATFORM_H_ diff --git a/src/Randomizer.h b/src/Randomizer.h index aa4be677..f4c37f42 100644 --- a/src/Randomizer.h +++ b/src/Randomizer.h @@ -44,6 +44,11 @@ public: virtual long int getRandomNumber() = 0; virtual long int getMaxRandomNumber() = 0; + + /** + * Returns random number in [0, to). + */ + virtual long int getRandomNumber(long int to) = 0; }; typedef SharedHandle RandomizerHandle; diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 0e886d73..ca4e850c 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -269,8 +269,8 @@ void RequestGroup::validateTotalLength(int64_t expectedTotalLength, } if(expectedTotalLength != actualTotalLength) { throw new DlAbortEx(EX_SIZE_MISMATCH, - expectedTotalLength, - actualTotalLength); + Util::llitos(expectedTotalLength, true).c_str(), + Util::llitos(actualTotalLength, true).c_str()); } } diff --git a/src/SegmentMan.cc b/src/SegmentMan.cc index 60547d8b..8c0f23a5 100644 --- a/src/SegmentMan.cc +++ b/src/SegmentMan.cc @@ -43,9 +43,7 @@ #ifdef ENABLE_MESSAGE_DIGEST #include "ChunkChecksumValidator.h" #endif // ENABLE_MESSAGE_DIGEST -#include -#include -#include +#include "a2io.h" #include SegmentMan::SegmentMan():logger(LogFactory::getInstance()), @@ -88,7 +86,7 @@ void SegmentMan::load() { } string segFilename = getSegmentFilePath(); logger->info(MSG_LOADING_SEGMENT_FILE, segFilename.c_str()); - FILE* segFile = openSegFile(segFilename, "r+"); + FILE* segFile = openSegFile(segFilename, "r+b"); try { read(segFile); fclose(segFile); @@ -106,7 +104,7 @@ void SegmentMan::save() const { } string segFilename = getSegmentFilePath(); logger->info(MSG_SAVING_SEGMENT_FILE, segFilename.c_str()); - FILE* segFile = openSegFile(segFilename, "w"); + FILE* segFile = openSegFile(segFilename, "wb"); try { if(fwrite(&totalSize, sizeof(totalSize), 1, segFile) < 1) { throw string("writeError"); @@ -155,6 +153,9 @@ FILE* SegmentMan::openSegFile(const string& segFilename, const string& mode) con throw new DlAbortEx(EX_SEGMENT_FILE_OPEN, segFilename.c_str(), strerror(errno)); } +#ifdef HAVE_SETMODE + setmode(fileno(segFile), O_BINARY); +#endif return segFile; } @@ -537,7 +538,7 @@ void SegmentMan::tryChunkChecksumValidation(const SegmentHandle& segment) logger->info(MSG_GOOD_CHUNK_CHECKSUM); } else { logger->info(EX_INVALID_CHUNK_CHECKSUM, - index, offset, + index, Util::llitos(offset, true).c_str(), expectedChecksum.c_str(), actualChecksum.c_str()); logger->debug("Unset bit from %d to %d(inclusive)", startIndex, endIndex); bitfield->unsetBitRange(startIndex, endIndex); diff --git a/src/SimpleLogger.cc b/src/SimpleLogger.cc index 68c56e5c..7e7f192f 100644 --- a/src/SimpleLogger.cc +++ b/src/SimpleLogger.cc @@ -36,11 +36,15 @@ #include "Util.h" #include "DlAbortEx.h" #include "message.h" +#include "a2io.h" #include #include -#include #include +#ifndef HAVE_LOCALTIME_R +# include "localtime_r.h" +#endif // HAVE_LOCALTIME_R + #define WRITE_LOG(LEVEL, MSG) \ va_list ap;\ va_start(ap, MSG);\ @@ -60,10 +64,13 @@ SimpleLogger::~SimpleLogger() { } void SimpleLogger::openFile(const string& filename) { - file = fopen(filename.c_str(), "a"); + file = fopen(filename.c_str(), "ab"); if(file == NULL) { throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno)); } +#ifdef HAVE_SETMODE + setmode(fileno(file), O_BINARY); +#endif } void SimpleLogger::closeFile() { diff --git a/src/SimpleRandomizer.h b/src/SimpleRandomizer.h index bdbcfc57..007daf54 100644 --- a/src/SimpleRandomizer.h +++ b/src/SimpleRandomizer.h @@ -54,18 +54,31 @@ public: } static void init() { +#ifdef HAVE_SRANDOM srandom(time(0)); +#else + srand(time(0)); +#endif } virtual ~SimpleRandomizer() {} virtual long int getRandomNumber() { +#ifdef HAVE_RANDOM return random(); +#else + return rand(); +#endif } virtual long int getMaxRandomNumber() { return RAND_MAX; } + + virtual long int getRandomNumber(long int to) + { + return(int32_t)(((double)to)*getRandomNumber()/(getMaxRandomNumber()+1.0)); + } }; #endif // _D_SIMPLE_RANDOMIZER_H_ diff --git a/src/SocketCore.cc b/src/SocketCore.cc index 8422ed74..4cbfef21 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -36,17 +36,38 @@ #include "DlRetryEx.h" #include "DlAbortEx.h" #include "message.h" +#include "a2io.h" +#include "a2netcompat.h" #include #include -#include -#include -#include -#include -#include #include -#include #include +#ifdef __MINGW32__ + +static char *mingw_strerror(int err) { + err = WSAGetLastError(); + static char buf[2048]; + if (FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &buf, + sizeof(buf), + NULL + ) == 0) { + snprintf(buf, sizeof(buf), _("Unknown socket error %d"), err); + } + return buf; +} + +#define strerror mingw_strerror +#define gai_strerror mingw_strerror + +#endif // __MINGW32__ + SocketCore::SocketCore():sockfd(-1) { init(); } @@ -86,7 +107,7 @@ void SocketCore::beginListen(int32_t port) { if(sockfd == -1) { throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno)); } - socklen_t sockopt = 1; + SOCKOPT_T sockopt = 1; if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) { close(sockfd); sockfd = -1; @@ -151,7 +172,7 @@ void SocketCore::establishConnection(const string& host, int32_t port) { if(sockfd == -1) { throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno)); } - socklen_t sockopt = 1; + SOCKOPT_T sockopt = 1; if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) { close(sockfd); sockfd = -1; @@ -188,15 +209,25 @@ void SocketCore::establishConnection(const string& host, int32_t port) { } void SocketCore::setNonBlockingMode() const { +#ifdef __MINGW32__ + u_long flag = 0; + ::ioctlsocket(sockfd, FIONBIO, &flag); +#else int32_t flags = fcntl(sockfd, F_GETFL, 0); // TODO add error handling fcntl(sockfd, F_SETFL, flags|O_NONBLOCK); +#endif // __MINGW32__ } void SocketCore::setBlockingMode() const { +#ifdef __MINGW32__ + u_long flag = 1; + ::ioctlsocket(sockfd, FIONBIO, &flag); +#else int32_t flags = fcntl(sockfd, F_GETFL, 0); // TODO add error handling fcntl(sockfd, F_SETFL, flags&(~O_NONBLOCK)); +#endif // __MINGW32__ } void SocketCore::closeConnection() { diff --git a/src/TorrentRequestInfo.cc b/src/TorrentRequestInfo.cc index 0d71d625..c95661d5 100644 --- a/src/TorrentRequestInfo.cc +++ b/src/TorrentRequestInfo.cc @@ -44,6 +44,10 @@ #include "DNSCache.h" #include +#ifndef SA_RESETHAND +# define SA_RESETHAND 0x80000000 +#endif // SA_RESETHAND + extern volatile sig_atomic_t btHaltRequested; void torrentHandler(int signal) { diff --git a/src/Util.cc b/src/Util.cc index 9607a9e0..7ce63548 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -36,19 +36,19 @@ #include "DlAbortEx.h" #include "File.h" #include "message.h" +#include "SimpleRandomizer.h" +#include "a2io.h" +#include "a2netcompat.h" #include #include -#include -#include #include -#include -#include -#include -#include #include #include #include +#ifndef HAVE_STRPTIME +# include "strptime.h" +#endif // HAVE_STRPTIME template string uint2str(T value, bool comma) { @@ -311,6 +311,9 @@ string Util::toHex(const unsigned char* src, int32_t len) { FILE* Util::openFile(const string& filename, const string& mode) { FILE* file = fopen(filename.c_str(), mode.c_str()); +#ifdef HAVE_SETMODE + setmode(fileno(file), O_BINARY); +#endif return file; } @@ -325,10 +328,10 @@ void Util::rangedFileCopy(const string& dest, const string& src, int64_t srcOffs int32_t destFd = -1; int32_t srcFd = -1; try { - if((destFd = open(dest.c_str(), O_CREAT|O_WRONLY|O_TRUNC, OPEN_MODE)) == -1) { + if((destFd = open(dest.c_str(), O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, OPEN_MODE)) == -1) { throw new DlAbortEx(EX_FILE_OPEN, dest.c_str(), strerror(errno)); } - if((srcFd = open(src.c_str(), O_RDONLY, OPEN_MODE)) == -1) { + if((srcFd = open(src.c_str(), O_RDONLY|O_BINARY, OPEN_MODE)) == -1) { throw new DlAbortEx(EX_FILE_OPEN, src.c_str(), strerror(errno)); } if(lseek(srcFd, srcOffset, SEEK_SET) != srcOffset) { @@ -508,7 +511,7 @@ void Util::fileChecksum(const string& filename, unsigned char* digest, char buf[BUFLEN]; int32_t fd; - if((fd = open(filename.c_str(), O_RDWR, OPEN_MODE)) < 0) { + if((fd = open(filename.c_str(), O_RDWR|O_BINARY, OPEN_MODE)) < 0) { throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno)); } while(1) { @@ -597,16 +600,11 @@ int32_t Util::countBit(uint32_t n) { } string Util::randomAlpha(int32_t length) { + static char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; string str; for(int32_t i = 0; i < length; i++) { - int32_t index = (int32_t)(((double)52)*random()/(RAND_MAX+1.0)); - char ch; - if(index < 26) { - ch = (char)('A'+index); - } else { - ch = (char)('a'+index-26); - } - str += ch; + int32_t index = SimpleRandomizer::getInstance()->getRandomNumber(strlen(random_chars)); + str += random_chars[index]; } return str; } @@ -647,11 +645,15 @@ bool Util::isNumbersAndDotsNotation(const string& name) { } void Util::setGlobalSignalHandler(int32_t signal, void (*handler)(int32_t), int32_t flags) { +#ifdef HAVE_SIGACTION struct sigaction sigact; sigact.sa_handler = handler; sigact.sa_flags = flags; sigemptyset(&sigact.sa_mask); sigaction(signal, &sigact, NULL); +#else + signal(sig, handler); +#endif // HAVE_SIGACTION } void Util::indexRange(int32_t& startIndex, int32_t& endIndex, @@ -715,8 +717,23 @@ time_t Util::httpGMT(const string& httpStdTime) struct tm tm; memset(&tm, 0, sizeof(tm)); strptime(httpStdTime.c_str(), "%a, %Y-%m-%d %H:%M:%S GMT", &tm); +#ifdef HAVE_TIMEGM time_t thetime = timegm(&tm); return thetime; +#else + char *tz; + tz = getenv("TZ"); + putenv("TZ="); + tzset(); + time_t thetime = mktime(&tm); + if (tz) { + char s[256]; + sprintf("TZ=%s", tz); + putenv(s); + } + tzset(); + return thetime; +#endif // HAVE_TIMEGM } void Util::toStream(ostream& os, const FileEntries& fileEntries) diff --git a/src/a2io.h b/src/a2io.h new file mode 100644 index 00000000..50dde46d --- /dev/null +++ b/src/a2io.h @@ -0,0 +1,119 @@ +/* */ +#ifndef _D_A2IO_H_ +#define _D_A2IO_H_ +#include "common.h" +#include +#include +#include +#include + +#ifdef HAVE_IO_H +# include +#endif // HAVE_IO_H + +// in some platforms following definitions are missing: +#ifndef EINPROGRESS +# define EINPROGRESS (WSAEINPROGRESS) +#endif // EINPROGRESS + +#ifndef O_NONBLOCK +# define O_NONBLOCK (O_NDELAY) +#endif // O_NONBLOCK + +#ifndef O_BINARY +# define O_BINARY (0) +#endif // O_BINARY + +// st_mode flags +#ifndef S_IRUSR +# define S_IRUSR 0000400 /* read permission, owner */ +#endif /* S_IRUSR */ +#ifndef S_IWUSR +# define S_IWUSR 0000200 /* write permission, owner */ +#endif /* S_IWUSR */ +#ifndef S_IXUSR +# define S_IXUSR 0000100/* execute/search permission, owner */ +#endif /* S_IXUSR */ +#ifndef S_IRWXU +# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +#endif /* S_IRWXU */ +#ifndef S_IRGRP +# define S_IRGRP 0000040 /* read permission, group */ +#endif /* S_IRGRP */ +#ifndef S_IWGRP +# define S_IWGRP 0000020 /* write permission, grougroup */ +#endif /* S_IWGRP */ +#ifndef S_IXGRP +# define S_IXGRP 0000010/* execute/search permission, group */ +#endif /* S_IXGRP */ +#ifndef S_IRWXG +# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +#endif /* S_IRWXG */ +#ifndef S_IROTH +# define S_IROTH 0000004 /* read permission, other */ +#endif /* S_IROTH */ +#ifndef S_IWOTH +# define S_IWOTH 0000002 /* write permission, other */ +#endif /* S_IWOTH */ +#ifndef S_IXOTH +# define S_IXOTH 0000001/* execute/search permission, other */ +#endif /* S_IXOTH */ +#ifndef S_IRWXO +# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +#endif /* S_IRWXO */ + +// Use 'null' instead of /dev/null in win32. +#ifdef HAVE_WINSOCK2_H +# define DEV_NULL "nul" +#else +# define DEV_NULL "/dev/null" +#endif // HAVE_WINSOCK2_H + +// Use 'con' instead of '/dev/stdout' in win32. +#ifdef HAVE_WINSOCK2_H +# define DEV_STDOUT "con" +#else +# define DEV_STDOUT "/dev/stdout" +#endif // HAVE_WINSOCK2_H + + +#ifdef __MINGW32__ +# define a2mkdir(path, openMode) mkdir(path) +#else +# define a2mkdir(path, openMode) mkdir(path, openMode) +#endif // __MINGW32__ + +#endif // _D_A2IO_H_ diff --git a/src/a2netcompat.h b/src/a2netcompat.h new file mode 100644 index 00000000..80da911f --- /dev/null +++ b/src/a2netcompat.h @@ -0,0 +1,75 @@ +/* + * aria2 - The high speed download utility + * + * Copyright (C) 2006 Tatsuhiro Tsujikawa + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations + * including the two. + * You must obey the GNU General Public License in all respects + * for all of the code used other than OpenSSL. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you + * do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source + * files in the program, then also delete it here. + */ +/* copyright --> */ +#ifndef _D_A2NETCOMPAT_H_ +#define _D_A2NETCOMPAT_H_ + +#ifdef HAVE_NETDB_H +# include +#endif // HAVE_NETDB_H + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif // HAVE_SYS_SOCKET_H + +#ifdef HAVE_NETINET_IN_H +# include +#endif // HAVE_NETINET_IN_H + +#ifdef HAVE_ARPA_INET_H +# include +#endif // HAVE_ARPA_INET_H + +#ifdef HAVE_NETINET_IN_H +# include +#endif // HAVE_NETINET_IN_H + +#ifndef HAVE_INET_ATON +# include "inet_aton.h" +#endif // HAVE_INET_ATON + +#ifdef __MINGW32__ +# include +# undef ERROR +# include +# define SOCKOPT_T const char +# define HAVE_GETADDRINFO +#else +# define SOCKOPT_T socklen_t +#endif // __MINGW32__ + +#ifndef HAVE_GETADDRINFO +# include "getaddrinfo.h" +#endif // HAVE_GETADDRINFO + +#endif // _D_A2NETCOMPAT_H_ diff --git a/src/common.h b/src/common.h index 2c61b472..8679224f 100644 --- a/src/common.h +++ b/src/common.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -81,4 +82,22 @@ typedef deque Integers; #define OPEN_MODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH #define DIR_OPEN_MODE S_IRWXU|S_IRWXG|S_IRWXO +#ifdef __MINGW32__ +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x501 +# endif // _WIN32_WINNT +#endif // __MINGW32__ + +#ifdef __MINGW32__ +# define LONGLONG_PRINTF "%I64d" +# define ULONGLONG_PRINTF "%I64u" +# define LONGLONG_SCANF "%I64d" +# define ULONGLONG_SCANF "%I64u" +#else +# define LONGLONG_PRINTF "%lld" +# define ULONGLONG_PRINTF "%llu" +# define LONGLONG_SCANF "%Ld" +# define ULONGLONG_SCANF "%Lu" +#endif // __MINGW32__ + #endif // _D_COMMON_H_ diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c new file mode 100644 index 00000000..ba9297d9 --- /dev/null +++ b/src/getaddrinfo.c @@ -0,0 +1,608 @@ +/* + * Copyright (c) 2001, 02 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This program provides getaddrinfo() and getnameinfo() described in + * RFC2133, 2553 and 3493. These functions are mainly used for IPv6 + * application to resolve hostname or address. + * + * This program is designed to be working on traditional IPv4 systems + * which don't have those functions. Therefore, this implementation + * supports IPv4 only. + * + * This program is useful for application which should support both IPv6 + * and traditional IPv4 systems. Use genuine getaddrinfo() and getnameinfo() + * provided by system if the system supports IPv6. Otherwise, use this + * implementation. + * + * This program is intended to be used in combination with GNU Autoconf. + * + * This program also provides freeaddrinfo() and gai_strerror(). + * + * To use this program in your application, insert the following lines to + * C source files after including `sys/types.h', `sys/socket.h' and + * `netdb.h'. `getaddrinfo.h' defines `struct addrinfo' and AI_, NI_, + * EAI_ macros. + * + * #ifndef HAVE_GETADDRINFO + * #include "getaddrinfo.h" + * #endif + * + * Restriction: + * getaddrinfo() and getnameinfo() of this program are NOT thread + * safe, unless the cpp macro ENABLE_PTHREAD is defined. + */ + +/* + * Add the following code to your configure.ac (or configure.in). + * AC_C_CONST + * AC_HEADER_STDC + * AC_CHECK_HEADERS(string.h memory.h stdlib.h) + * AC_CHECK_FUNCS(memcpy) + * AC_REPLACE_FUNCS(memset) + * AC_TYPE_SOCKLEN_T + * AC_TYPE_IN_PORT_T + * AC_DECL_H_ERRNO + * + * AC_CHECK_FUNCS(getaddrinfo getnameinfo) + * if test "$ac_cv_func_getaddrinfo$ac_cv_func_getnameinfo" != yesyes ; then + * LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext" + * fi + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef __MINGW32__ +# include +# undef ERROR +# include +#endif + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif + +#include +#include + +#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) +#include +#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +#include +#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ +#else /* not STDC_HEADERS and not HAVE_STRING_H */ +#include +#endif /* not STDC_HEADERS and not HAVE_STRING_H */ + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef ENABLE_PTHREAD +#include +#endif + +#ifdef ENABLE_NLS +#include +#endif + +#ifndef HAVE_MEMCPY +#define memcpy(d, s, n) bcopy((s), (d), (n)) +#ifdef __STDC__ +void *memchr(const void *, int, size_t); +int memcmp(const void *, const void *, size_t); +void *memmove(void *, const void *, size_t); +void *memset(void *, int, size_t); +#else /* not __STDC__ */ +char *memchr(); +int memcmp(); +char *memmove(); +char *memset(); +#endif /* not __STDC__ */ +#endif /* not HAVE_MEMCPY */ + +#ifndef H_ERRNO_DECLARED +extern int h_errno; +#endif + +#include "getaddrinfo.h" + +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define gettext(string) (string) +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Error messages for gai_strerror(). + */ +static char *eai_errlist[] = { + N_("Success"), + + /* EAI_ADDRFAMILY */ + N_("Address family for hostname not supported"), + + /* EAI_AGAIN */ + N_("Temporary failure in name resolution"), + + /* EAI_BADFLAGS */ + N_("Invalid value for ai_flags"), + + /* EAI_FAIL */ + N_("Non-recoverable failure in name resolution"), + + /* EAI_FAMILY */ + N_("ai_family not supported"), + + /* EAI_MEMORY */ + N_("Memory allocation failure"), + + /* EAI_NONAME */ + N_("hostname nor servname provided, or not known"), + + /* EAI_OVERFLOW */ + N_("An argument buffer overflowed"), + + /* EAI_SERVICE */ + N_("servname not supported for ai_socktype"), + + /* EAI_SOCKTYPE */ + N_("ai_socktype not supported"), + + /* EAI_SYSTEM */ + N_("System error returned in errno") +}; + +/* + * Default hints for getaddrinfo(). + */ +static struct addrinfo default_hints = { + 0, PF_UNSPEC, 0, 0, 0, NULL, NULL, NULL +}; + +/* + * Mutex. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t gai_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Declaration of static functions. + */ +#ifdef __STDC__ +static int is_integer(const char *); +static int is_address(const char *); +static int itoa_length(int); +#else +static int is_integer(); +static int is_address(); +static int itoa_length(); +#endif + +/* + * gai_strerror(). + */ +const char * +gai_strerror(ecode) + int ecode; +{ + if (ecode < 0 || ecode > EAI_SYSTEM) + return _("Unknown error"); + + return gettext(eai_errlist[ecode]); +} + +/* + * freeaddrinfo(). + */ +void +freeaddrinfo(ai) + struct addrinfo *ai; +{ + struct addrinfo *next_ai; + + while (ai != NULL) { + if (ai->ai_canonname != NULL) + free(ai->ai_canonname); + if (ai->ai_addr != NULL) + free(ai->ai_addr); + next_ai = ai->ai_next; + free(ai); + ai = next_ai; + } +} + +/* + * Return 1 if the string `s' represents an integer. + */ +static int +is_integer(s) + const char *s; +{ + if (*s == '-' || *s == '+') + s++; + if (*s < '0' || '9' < *s) + return 0; + + s++; + while ('0' <= *s && *s <= '9') + s++; + + return (*s == '\0'); +} + +/* + * Return 1 if the string `s' represents an IPv4 address. + * Unlike inet_addr(), it doesn't permit malformed nortation such + * as "192.168". + */ +static int +is_address(s) + const char *s; +{ + const static char delimiters[] = {'.', '.', '.', '\0'}; + int i, j; + int octet; + + for (i = 0; i < 4; i++) { + if (*s == '0' && *(s + 1) != delimiters[i]) + return 0; + for (j = 0, octet = 0; '0' <= *s && *s <= '9' && j < 3; s++, j++) + octet = octet * 10 + (*s - '0'); + if (j == 0 || octet > 255 || *s != delimiters[i]) + return 0; + s++; + } + + return 1; +} + +/* + * Calcurate length of the string `s', where `s' is set by + * sprintf(s, "%d", n). + */ +static int +itoa_length(n) + int n; +{ + int result = 1; + + if (n < 0) { + n = -n; + result++; + } + + while (n >= 10) { + result++; + n /= 10; + } + + return result; +} + +/* + * getaddrinfo(). + */ +int +getaddrinfo(nodename, servname, hints, res) + const char *nodename; + const char *servname; + const struct addrinfo *hints; + struct addrinfo **res; +{ + struct addrinfo *head_res = NULL; + struct addrinfo *tail_res = NULL; + struct addrinfo *new_res; + struct sockaddr_in *sa_in; + struct in_addr **addr_list; + struct in_addr *addr_list_buf[2]; + struct in_addr addr_buf; + struct in_addr **ap; + struct servent *servent; + struct hostent *hostent; + const char *canonname = NULL; + in_port_t port; + int saved_h_errno; + int result = 0; + +#ifdef ENABLE_PTHREAD + pthread_mutex_lock(&gai_mutex); +#endif + + saved_h_errno = h_errno; + + if (nodename == NULL && servname == NULL) { + result = EAI_NONAME; + goto end; + } + + if (hints != NULL) { + if (hints->ai_family != PF_INET && hints->ai_family != PF_UNSPEC) { + result = EAI_FAMILY; + goto end; + } + if (hints->ai_socktype != SOCK_DGRAM + && hints->ai_socktype != SOCK_STREAM + && hints->ai_socktype != 0) { + result = EAI_SOCKTYPE; + goto end; + } + } else { + hints = &default_hints; + } + + if (servname != NULL) { + if (is_integer(servname)) + port = htons(atoi(servname)); + else { + if (hints->ai_flags & AI_NUMERICSERV) { + result = EAI_NONAME; + goto end; + } + + if (hints->ai_socktype == SOCK_DGRAM) + servent = getservbyname(servname, "udp"); + else if (hints->ai_socktype == SOCK_STREAM) + servent = getservbyname(servname, "tcp"); + else if (hints->ai_socktype == 0) + servent = getservbyname(servname, "tcp"); + else { + result = EAI_SOCKTYPE; + goto end; + } + + if (servent == NULL) { + result = EAI_SERVICE; + goto end; + } + port = servent->s_port; + } + } else { + port = htons(0); + } + + if (nodename != NULL) { + if (is_address(nodename)) { + addr_buf.s_addr = inet_addr(nodename); + addr_list_buf[0] = &addr_buf; + addr_list_buf[1] = NULL; + addr_list = addr_list_buf; + + if (hints->ai_flags & AI_CANONNAME + && !(hints->ai_flags & AI_NUMERICHOST)) { + hostent = gethostbyaddr((char *)&addr_buf, + sizeof(struct in_addr), AF_INET); + if (hostent != NULL) + canonname = hostent->h_name; + else + canonname = nodename; + } + } else { + if (hints->ai_flags & AI_NUMERICHOST) { + result = EAI_NONAME; + goto end; + } + + hostent = gethostbyname(nodename); + if (hostent == NULL) { + switch (h_errno) { + case HOST_NOT_FOUND: + case NO_DATA: + result = EAI_NONAME; + goto end; + case TRY_AGAIN: + result = EAI_AGAIN; + goto end; + default: + result = EAI_FAIL; + goto end; + } + } + addr_list = (struct in_addr **)hostent->h_addr_list; + + if (hints->ai_flags & AI_CANONNAME) + canonname = hostent->h_name; + } + } else { + if (hints->ai_flags & AI_PASSIVE) + addr_buf.s_addr = htonl(INADDR_ANY); + else + addr_buf.s_addr = htonl(0x7F000001); + addr_list_buf[0] = &addr_buf; + addr_list_buf[1] = NULL; + addr_list = addr_list_buf; + } + + for (ap = addr_list; *ap != NULL; ap++) { + new_res = (struct addrinfo *)malloc(sizeof(struct addrinfo)); + if (new_res == NULL) { + if (head_res != NULL) + freeaddrinfo(head_res); + result = EAI_MEMORY; + goto end; + } + + new_res->ai_family = PF_INET; + new_res->ai_socktype = hints->ai_socktype; + new_res->ai_protocol = hints->ai_protocol; + new_res->ai_addr = NULL; + new_res->ai_addrlen = sizeof(struct sockaddr_in); + new_res->ai_canonname = NULL; + new_res->ai_next = NULL; + + new_res->ai_addr = (struct sockaddr *) + malloc(sizeof(struct sockaddr_in)); + if (new_res->ai_addr == NULL) { + free(new_res); + if (head_res != NULL) + freeaddrinfo(head_res); + result = EAI_MEMORY; + goto end; + } + + sa_in = (struct sockaddr_in *)new_res->ai_addr; + memset(sa_in, 0, sizeof(struct sockaddr_in)); + sa_in->sin_family = PF_INET; + sa_in->sin_port = port; + memcpy(&sa_in->sin_addr, *ap, sizeof(struct in_addr)); + + if (head_res == NULL) + head_res = new_res; + else + tail_res->ai_next = new_res; + tail_res = new_res; + } + + if (canonname != NULL && head_res != NULL) { + head_res->ai_canonname = (char *)malloc(strlen(canonname) + 1); + if (head_res->ai_canonname != NULL) + strcpy(head_res->ai_canonname, canonname); + } + + *res = head_res; + + end: + h_errno = saved_h_errno; +#ifdef ENABLE_PTHREAD + pthread_mutex_unlock(&gai_mutex); +#endif + return result; +} + +/* + * getnameinfo(). + */ +int +getnameinfo(sa, salen, node, nodelen, serv, servlen, flags) + const struct sockaddr *sa; + socklen_t salen; + char *node; + socklen_t nodelen; + char *serv; + socklen_t servlen; + int flags; +{ + const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa; + struct hostent *hostent; + struct servent *servent; + char *ntoa_address; + int saved_h_errno; + int result = 0; + +#ifdef ENABLE_PTHREAD + pthread_mutex_lock(&gai_mutex); +#endif + + saved_h_errno = h_errno; + + if (sa_in->sin_family != PF_INET) { + result = EAI_FAMILY; + goto end; + } else if (node == NULL && serv == NULL) { + result = EAI_NONAME; + goto end; + } + + if (serv != NULL && servlen > 0) { + if (flags & NI_NUMERICSERV) + servent = NULL; + else if (flags & NI_DGRAM) + servent = getservbyport(sa_in->sin_port, "udp"); + else + servent = getservbyport(sa_in->sin_port, "tcp"); + + if (servent != NULL) { + if (servlen <= strlen(servent->s_name)) { + result = EAI_OVERFLOW; + goto end; + } + strcpy(serv, servent->s_name); + } else { + if (servlen <= itoa_length(ntohs(sa_in->sin_port))) { + result = EAI_OVERFLOW; + goto end; + } + sprintf(serv, "%d", ntohs(sa_in->sin_port)); + } + } + + if (node != NULL && nodelen > 0) { + if (flags & NI_NUMERICHOST) + hostent = NULL; + else { + hostent = gethostbyaddr((char *)&sa_in->sin_addr, + sizeof(struct in_addr), AF_INET); + } + if (hostent != NULL) { + if (nodelen <= strlen(hostent->h_name)) { + result = EAI_OVERFLOW; + goto end; + } + strcpy(node, hostent->h_name); + } else { + if (flags & NI_NAMEREQD) { + result = EAI_NONAME; + goto end; + } + ntoa_address = inet_ntoa(sa_in->sin_addr); + if (nodelen <= strlen(ntoa_address)) { + result = EAI_OVERFLOW; + goto end; + } + strcpy(node, ntoa_address); + } + + } + + end: + h_errno = saved_h_errno; +#ifdef ENABLE_PTHREAD + pthread_mutex_unlock(&gai_mutex); +#endif + return result; +} + diff --git a/src/getaddrinfo.h b/src/getaddrinfo.h new file mode 100644 index 00000000..7f1750a4 --- /dev/null +++ b/src/getaddrinfo.h @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2001, 02 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _D_GETADDRINFO_H +#define _D_GETADDRINFO_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H + +#ifdef __MINGW32__ +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x501 +# endif // _WIN32_WINNT +# include +# undef ERROR +# include +#endif // __MINGW32__ + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif // HAVE_SYS_SOCKET_H +#ifdef HAVE_NETDB_H +# include +#endif // HAVE_NETDB_H + +#include + +/********************************************************************/ +/* + * Undefine all the macros. + * might defines some of them. + */ +#ifdef EAI_ADDRFAMILY +#undef EAI_ADDRFAMILY +#endif +#ifdef EAI_AGAIN +#undef EAI_AGAIN +#endif +#ifdef EAI_BADFLAGS +#undef EAI_BADFLAGS +#endif +#ifdef EAI_FAIL +#undef EAI_FAIL +#endif +#ifdef EAI_FAMILY +#undef EAI_FAMILY +#endif +#ifdef EAI_MEMORY +#undef EAI_MEMORY +#endif +#ifdef EAI_NONAME +#undef EAI_NONAME +#endif +#ifdef EAI_OVERFLOW +#undef EAI_OVERFLOW +#endif +#ifdef EAI_SERVICE +#undef EAI_SERVICE +#endif +#ifdef EAI_SOCKTYPE +#undef EAI_SOCKTYPE +#endif +#ifdef EAI_SYSTEM +#undef EAI_SYSTEM +#endif + +#ifdef AI_PASSIVE +#undef AI_PASSIVE +#endif +#ifdef AI_CANONNAME +#undef AI_CANONNAME +#endif +#ifdef AI_NUMERICHOST +#undef AI_NUMERICHOST +#endif +#ifdef AI_NUMERICSERV +#undef AI_NUMERICSERV +#endif +#ifdef AI_V4MAPPED +#undef AI_V4MAPPED +#endif +#ifdef AI_ALL +#undef AI_ALL +#endif +#ifdef AI_ADDRCONFIG +#undef AI_ADDRCONFIG +#endif +#ifdef AI_DEFAULT +#undef AI_DEFAULT +#endif + +#ifdef NI_NOFQDN +#undef NI_NOFQDN +#endif +#ifdef NI_NUMERICHOST +#undef NI_NUMERICHOST +#endif +#ifdef NI_NAMEREQD +#undef NI_NAMEREQD +#endif +#ifdef NI_NUMERICSERV +#undef NI_NUMERICSERV +#endif +#ifdef NI_NUMERICSCOPE +#undef NI_NUMERICSCOPE +#endif + +#ifdef NI_DGRAM +#undef NI_DGRAM +#endif +#ifdef NI_MAXHOST +#undef NI_MAXHOST +#endif +#ifdef NI_MAXSERV +#undef NI_MAXSERV +#endif + +/* + * Fake struct and function names. + * might declares all or some of them. + */ +#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO) +#define addrinfo my_addrinfo +#define gai_strerror my_gai_strerror +#define freeaddrinfo my_freeaddrinfo +#define getaddrinfo my_getaddrinfo +#define getnameinfo my_getnameinfo +#endif + +/********************************************************************/ +/* + * Error codes. + */ +#define EAI_ADDRFAMILY 1 +#define EAI_AGAIN 2 +#define EAI_BADFLAGS 3 +#define EAI_FAIL 4 +#define EAI_FAMILY 5 +#define EAI_MEMORY 6 +#define EAI_NONAME 7 +#define EAI_OVERFLOW 8 +#define EAI_SERVICE 9 +#define EAI_SOCKTYPE 10 +#define EAI_SYSTEM 11 + +/* + * Flags for getaddrinfo(). + */ +#define AI_ADDRCONFIG 0x0001 +#define AI_ALL 0x0002 +#define AI_CANONNAME 0x0004 +#define AI_NUMERICHOST 0x0008 +#define AI_NUMERICSERV 0x0010 +#define AI_PASSIVE 0x0020 +#define AI_V4MAPPED 0x0040 +#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) + +/* + * Flags for getnameinfo(). + */ +#define NI_DGRAM 0x0001 +#define NI_NAMEREQD 0x0002 +#define NI_NOFQDN 0x0004 +#define NI_NUMERICHOST 0x0008 +#define NI_NUMERICSCOPE 0x0010 +#define NI_NUMERICSERV 0x0020 + +/* + * Maximum length of FQDN and servie name for getnameinfo(). + */ +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +/* + * Address families and Protocol families. + */ +#ifndef AF_UNSPEC +#define AF_UNSPEC AF_INET +#endif +#ifndef PF_UNSPEC +#define PF_UNSPEC PF_INET +#endif + +/* + * struct addrinfo. + */ +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + char *ai_canonname; + struct sockaddr *ai_addr; + struct addrinfo *ai_next; +}; + +/* + * Functions. + */ +#ifdef __STDC__ +const char *gai_strerror(int); +void freeaddrinfo(struct addrinfo *); +int getaddrinfo(const char *, const char *, const struct addrinfo *, + struct addrinfo **); +int getnameinfo(const struct sockaddr *, socklen_t, char *, + socklen_t, char *, socklen_t, int); +#else +const char *gai_strerror(); +void freeaddrinfo(); +int getaddrinfo(); +int getnameinfo(); +#endif + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* not _D_GETADDRINFO_H */ diff --git a/src/inet_aton.c b/src/inet_aton.c new file mode 100644 index 00000000..3d121469 --- /dev/null +++ b/src/inet_aton.c @@ -0,0 +1,69 @@ +/* */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H + +#ifdef __MINGW32__ +# define _WIN32_WINNT 0x501 +# include +# undef ERROR +# include +#endif // __MINGW32__ + +#ifdef HAVE_NETDB_H +# include +#endif // HAVE_NETDB_H +#ifdef HAVE_SYS_SOCKET_H +# include +#endif // HAVE_SYS_SOCKET_H +#ifdef HAVE_NETINET_IN_H +# include +#endif // HAVE_NETINET_IN_H +#ifdef HAVE_ARPA_INET_H +# include +#endif // HAVE_ARPA_INET_H + +#include + +int inet_aton(const char *cp, struct in_addr *inp) { + unsigned long res = inet_addr(cp); + if (res == INADDR_NONE && strcmp(cp, "255.255.255.255")) + return 0; + if (inp) + inp->s_addr = res; + return 1; +} diff --git a/src/inet_aton.h b/src/inet_aton.h new file mode 100644 index 00000000..5a22e815 --- /dev/null +++ b/src/inet_aton.h @@ -0,0 +1,75 @@ +/* */ + +#ifndef _D_INET_ATON_H +#define _D_INET_ATON_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H + +#ifdef __MINGW32__ +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x501 +# endif // _WIN32_WINNT +# include +# undef ERROR +# include +#endif // __MINGW32__ + +#ifdef HAVE_NETDB_H +# include +#endif // HAVE_NETDB_H +#ifdef HAVE_SYS_SOCKET_H +# include +#endif // HAVE_SYS_SOCKET_H +#ifdef HAVE_NETINET_IN_H +# include +#endif // HAVE_NETINET_IN_H +#ifdef HAVE_ARPA_INET_H +# include +#endif // HAVE_ARPA_INET_H + +int inet_aton(const char *cp, struct in_addr *inp); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* not _D_INET_ATON_H */ diff --git a/src/libgen.c b/src/libgen.c new file mode 100644 index 00000000..110cfde6 --- /dev/null +++ b/src/libgen.c @@ -0,0 +1,89 @@ +/* */ + +#include +#include +#include + +#if defined(__CYGWIN__) || defined(__DJGPP__) || defined(__MINGW32__) +# define IS_PATH_SEPARATOR(c) (((c) == '/') || ((c) == '\\')) +#else +# define IS_PATH_SEPARATOR(c) ((c) == '/') +#endif + +/* per http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+basename */ +char* basename(char* s) { + char* rv; + + if (!s || !*s) + return "."; + + rv = s + strlen(s) - 1; + + do { + if (IS_PATH_SEPARATOR(*rv)) + return rv + 1; + --rv; + } while (rv >= s); + + return s; +} + +/* per http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+dirname */ +char* dirname(char* path) { + char *p; + + if (path == NULL || *path == '\0') + return "."; + p = path + strlen(path) - 1; + while (IS_PATH_SEPARATOR(*p)) { + if (p == path) + return path; + *p-- = '\0'; + } + + while (p >= path && !IS_PATH_SEPARATOR(*p)) + p--; + + if (p < path) + return "."; + + if (p == path) + return "/"; + + *p = '\0'; + + return path; +} diff --git a/src/libgen.h b/src/libgen.h new file mode 100644 index 00000000..7e3cd347 --- /dev/null +++ b/src/libgen.h @@ -0,0 +1,60 @@ +/* */ + +#ifndef _D_LIBGEN_H +#define _D_LIBGEN_H 1 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef __MINGW32__ + +char *basename (char *path); +char *dirname (char *path); + +#else + +char *basename (const char *path); +char *dirname (const char *path); + +#endif // __MINGW32__ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* not _D_LIBGEN_H */ + diff --git a/src/localtime_r.c b/src/localtime_r.c new file mode 100644 index 00000000..18ae695d --- /dev/null +++ b/src/localtime_r.c @@ -0,0 +1,61 @@ +/* */ + +#include +#ifdef __MINGW32__ +#include +#endif // __MINGW32__ + +#include "localtime_r.h" + +struct tm * localtime_r(const time_t *clock, struct tm *result) +{ + static struct tm *local_tm; +#ifdef __MINGW32__ + static CRITICAL_SECTION cs; + static int initialized = 0; + + if (!initialized) { + ++initialized; + InitializeCriticalSection(&cs); + } + + EnterCriticalSection(&cs); + local_tm = localtime(clock); + memcpy(result, local_tm, sizeof(struct tm)); + LeaveCriticalSection(&cs); +#endif // __MINGW32__ + return result; +}; diff --git a/src/localtime_r.h b/src/localtime_r.h new file mode 100644 index 00000000..8b209732 --- /dev/null +++ b/src/localtime_r.h @@ -0,0 +1,51 @@ +/* */ + +#ifndef _D_LOCALTIME_R_H +#define _D_LOCALTIME_R_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +struct tm * localtime_r(const time_t *clock, struct tm *result); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* not _D_LOCALTIME_R_H */ diff --git a/src/main.cc b/src/main.cc index cd5a5221..5a2b4e33 100644 --- a/src/main.cc +++ b/src/main.cc @@ -54,6 +54,8 @@ #include "CookieBoxFactory.h" #include "a2algo.h" #include "message.h" +#include "a2io.h" +#include "Platform.h" #include #include #include @@ -124,7 +126,9 @@ void showUsage() { cout << _(" -o, --out=FILE The file name for downloaded file.") << endl; cout << _(" -l, --log=LOG The file path to store log. If '-' is specified,\n" " log is written to stdout.") << endl; +#ifdef HAVE_DAEMON cout << _(" -D, --daemon Run as daemon.") << endl; +#endif // HAVE_DAEMON cout << _(" -s, --split=N Download a file using N connections. N must be\n" " between 1 and 5. This option affects all URLs.\n" " Thus, aria2 connects to each URL with\n" @@ -323,6 +327,10 @@ void showUsage() { } int main(int argc, char* argv[]) { +#ifdef HAVE_WINSOCK2_H + Platform platform; +#endif // HAVE_WINSOCK2_H + #ifdef ENABLE_NLS setlocale (LC_CTYPE, ""); setlocale (LC_MESSAGES, ""); @@ -388,7 +396,9 @@ int main(int argc, char* argv[]) { int32_t optIndex = 0; int32_t lopt; static struct option longOpts[] = { +#ifdef HAVE_DAEMON { "daemon", no_argument, NULL, 'D' }, +#endif // HAVE_DAEMON { "dir", required_argument, NULL, 'd' }, { "out", required_argument, NULL, 'o' }, { "log", required_argument, NULL, 'l' }, @@ -565,9 +575,11 @@ int main(int argc, char* argv[]) { } break; } +#ifdef HAVE_DAEMON case 'D': cmdstream << PREF_DAEMON << "=" << V_TRUE << "\n"; break; +#endif // HAVE_DAEMON case 'd': cmdstream << PREF_DIR << "=" << optarg << "\n"; break; @@ -670,12 +682,14 @@ int main(int argc, char* argv[]) { exit(EXIT_FAILURE); } } +#ifdef HAVE_DAEMON if(op->getAsBool(PREF_DAEMON)) { if(daemon(1, 1) < 0) { perror(MSG_DAEMON_FAILED); exit(EXIT_FAILURE); } } +#endif // HAVE_DAEMON Strings args(argv+optind, argv+argc); #ifdef HAVE_LIBSSL @@ -693,11 +707,11 @@ int main(int argc, char* argv[]) { BitfieldManFactory::setDefaultRandomizer(SimpleRandomizer::getInstance()); FileAllocationMonitorFactory::setFactory(new ConsoleFileAllocationMonitorFactory()); if(op->getAsBool(PREF_STDOUT_LOG)) { - LogFactory::setLogFile("/dev/stdout"); + LogFactory::setLogFile(DEV_STDOUT); } else if(op->get(PREF_LOG).size()) { LogFactory::setLogFile(op->get(PREF_LOG)); } else { - LogFactory::setLogFile("/dev/null"); + LogFactory::setLogFile(DEV_NULL); } int32_t exitStatus = EXIT_SUCCESS; try { @@ -736,8 +750,9 @@ int main(int argc, char* argv[]) { RequestFactorySingletonHolder::instance(requestFactory); CUIDCounterHandle cuidCounter = new CUIDCounter(); CUIDCounterSingletonHolder::instance(cuidCounter); - +#ifdef SIGPIPE Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0); +#endif RequestInfo* firstReqInfo; #ifdef ENABLE_BITTORRENT diff --git a/src/message.h b/src/message.h index 23aeacc2..636c55f4 100644 --- a/src/message.h +++ b/src/message.h @@ -111,7 +111,7 @@ #define MSG_DOWNLOAD_COMPLETED _("The download was complete.") #define MSG_REMOVED_HAVE_ENTRY _("Removed %d have entries.") #define MSG_VALIDATING_FILE _("Validating file %s") -#define MSG_ALLOCATION_COMPLETED _("%d seconds to allocate %lld byte(s)") +#define MSG_ALLOCATION_COMPLETED _("%d seconds to allocate %s byte(s)") #define MSG_FILE_ALLOCATION_DISPATCH _("Dispatching FileAllocationCommand for CUID#%d.") #define MSG_METALINK_QUEUEING _("Metalink: Queueing %s for download.") #define MSG_FILE_DOWNLOAD_COMPLETED _("Download complete: %s") @@ -136,10 +136,10 @@ #define EX_CONNECTION_FAILED _("Connection failed.") #define EX_FILENAME_MISMATCH _("The requested filename and the previously registered one are not same. Expected:%s Actual:%s") #define EX_BAD_STATUS _("The response status is not successful. status=%d") -#define EX_TOO_LARGE_FILE _("Too large file size. size=%lld") +#define EX_TOO_LARGE_FILE _("Too large file size. size=%s") #define EX_TRANSFER_ENCODING_NOT_SUPPORTED _("Transfer encoding %s is not supported.") #define EX_SSL_INIT_FAILURE _("SSL initialization failed.") -#define EX_SIZE_MISMATCH _("Size mismatch Expected:%lld Actual:%lld") +#define EX_SIZE_MISMATCH _("Size mismatch Expected:%s Actual:%s") #define EX_AUTH_FAILED _("Authorization failed.") #define EX_GOT_EOF _("Got EOF from the server.") #define EX_EOF_FROM_PEER _("Got EOF from peer.") @@ -151,7 +151,7 @@ #define EX_DATA_READ _("Failed to read data from disk.") #define EX_FILE_SHA1SUM _("Failed to calculate SHA1 digest of or a part of the file %s, cause: %s") #define EX_FILE_SEEK _("Failed to seek the file %s, cause: %s") -#define EX_FILE_OFFSET_OUT_OF_RANGE _("The offset is out of range, offset=%lld") +#define EX_FILE_OFFSET_OUT_OF_RANGE _("The offset is out of range, offset=%s") #define EX_NOT_DIRECTORY _("%s is not a directory.") #define EX_MAKE_DIR _("Failed to make the directory %s, cause: %s") #define EX_SEGMENT_FILE_OPEN _("Failed to open the segment file %s, cause: %s") @@ -175,7 +175,7 @@ #define EX_FILE_ALREADY_EXISTS _("File %s exists, but %s does not exist.") #define EX_INVALID_PAYLOAD_SIZE _("Invalid payload size for %s, size=%d. It should be %d.") #define EX_INVALID_BT_MESSAGE_ID _("Invalid ID=%d for %s. It should be %d.") -#define EX_INVALID_CHUNK_CHECKSUM _("Chunk checksum validation failed. checksumIndex=%d, offset=%lld, expectedHash=%s, actualHash=%s") +#define EX_INVALID_CHUNK_CHECKSUM _("Chunk checksum validation failed. checksumIndex=%d, offset=%s, expectedHash=%s, actualHash=%s") #define EX_DOWNLOAD_ABORTED _("Download aborted.") #define EX_DUPLICATE_FILE_DOWNLOAD _("File %s is being downloaded by other command.") #define EX_INSUFFICIENT_CHECKSUM _("Insufficient checksums.") @@ -187,7 +187,7 @@ #define EX_TOO_SLOW_DOWNLOAD_SPEED _("Too slow Downloading speed: %d <= %d(B/s), host:%s") #define EX_NO_HTTP_REQUEST_ENTRY_FOUND _("No HttpRequestEntry found.") #define EX_LOCATION_HEADER_REQUIRED _("Got %d status, but no location header provided.") -#define EX_INVALID_RANGE_HEADER _("Invalid range header. Request: %lld-%lld/%lld, Response: %lld-%lld/%lld") +#define EX_INVALID_RANGE_HEADER _("Invalid range header. Request: %s-%s/%s, Response: %s-%s/%s") #define EX_NO_RESULT_WITH_YOUR_PREFS _("No file matched with your preference.") #define EX_EXCEPTION_CAUGHT _("Exception caught") #define EX_TOO_LONG_PAYLOAD _("Max payload length exceeded or invalid. length = %d") diff --git a/src/prefs.h b/src/prefs.h index 870cad13..4f688c20 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -40,8 +40,11 @@ /** * Constants */ +#undef V_TRUE #define V_TRUE "true" +#undef V_FALSE #define V_FALSE "false" +#undef V_NONE #define V_NONE "none" /** diff --git a/src/strptime.c b/src/strptime.c new file mode 100644 index 00000000..5581fd46 --- /dev/null +++ b/src/strptime.c @@ -0,0 +1,443 @@ +/* + * Copyright (c) 1999 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of KTH nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include +#include +#include +#include +#include +#include + +#include "strptime.h" + +static const char *abb_weekdays[] = { + "Sun", + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat", + NULL +}; + +static const char *full_weekdays[] = { + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + NULL +}; + +static const char *abb_month[] = { + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", + NULL +}; + +static const char *full_month[] = { + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + NULL, +}; + +static const char *ampm[] = { + "am", + "pm", + NULL +}; + +/* + * tm_year is relative this year + */ +const int tm_year_base = 1900; + +/* + * Return TRUE iff `year' was a leap year. + * Needed for strptime. + */ +static int +is_leap_year (int year) +{ + return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0); +} + +/* Needed for strptime. */ +static int +match_string (const char **buf, const char **strs) +{ + int i = 0; + + for (i = 0; strs[i] != NULL; ++i) { + int len = strlen (strs[i]); + + if (strncasecmp (*buf, strs[i], len) == 0) { + *buf += len; + return i; + } + } + return -1; +} + +/* Needed for strptime. */ +static int +first_day (int year) +{ + int ret = 4; + + for (; year > 1970; --year) + ret = (ret + 365 + is_leap_year (year) ? 1 : 0) % 7; + return ret; +} + +/* + * Set `timeptr' given `wnum' (week number [0, 53]) + * Needed for strptime + */ + +static void +set_week_number_sun (struct tm *timeptr, int wnum) +{ + int fday = first_day (timeptr->tm_year + tm_year_base); + + timeptr->tm_yday = wnum * 7 + timeptr->tm_wday - fday; + if (timeptr->tm_yday < 0) { + timeptr->tm_wday = fday; + timeptr->tm_yday = 0; + } +} + +/* + * Set `timeptr' given `wnum' (week number [0, 53]) + * Needed for strptime + */ + +static void +set_week_number_mon (struct tm *timeptr, int wnum) +{ + int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7; + + timeptr->tm_yday = wnum * 7 + (timeptr->tm_wday + 6) % 7 - fday; + if (timeptr->tm_yday < 0) { + timeptr->tm_wday = (fday + 1) % 7; + timeptr->tm_yday = 0; + } +} + +/* + * Set `timeptr' given `wnum' (week number [0, 53]) + * Needed for strptime + */ +static void +set_week_number_mon4 (struct tm *timeptr, int wnum) +{ + int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7; + int offset = 0; + + if (fday < 4) + offset += 7; + + timeptr->tm_yday = offset + (wnum - 1) * 7 + timeptr->tm_wday - fday; + if (timeptr->tm_yday < 0) { + timeptr->tm_wday = fday; + timeptr->tm_yday = 0; + } +} + +/* strptime: roken */ +//extern "C" +char * +strptime (const char *buf, const char *format, struct tm *timeptr) +{ + char c; + + for (; (c = *format) != '\0'; ++format) { + char *s; + int ret; + + if (isspace (c)) { + while (isspace (*buf)) + ++buf; + } else if (c == '%' && format[1] != '\0') { + c = *++format; + if (c == 'E' || c == 'O') + c = *++format; + switch (c) { + case 'A' : + ret = match_string (&buf, full_weekdays); + if (ret < 0) + return NULL; + timeptr->tm_wday = ret; + break; + case 'a' : + ret = match_string (&buf, abb_weekdays); + if (ret < 0) + return NULL; + timeptr->tm_wday = ret; + break; + case 'B' : + ret = match_string (&buf, full_month); + if (ret < 0) + return NULL; + timeptr->tm_mon = ret; + break; + case 'b' : + case 'h' : + ret = match_string (&buf, abb_month); + if (ret < 0) + return NULL; + timeptr->tm_mon = ret; + break; + case 'C' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_year = (ret * 100) - tm_year_base; + buf = s; + break; + case 'c' : /* %a %b %e %H:%M:%S %Y */ + s = strptime (buf, "%a %b %e %H:%M:%S %Y", timeptr); + if (s == NULL) + return NULL; + buf = s; + break; + case 'D' : /* %m/%d/%y */ + s = strptime (buf, "%m/%d/%y", timeptr); + if (s == NULL) + return NULL; + buf = s; + break; + case 'd' : + case 'e' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_mday = ret; + buf = s; + break; + case 'H' : + case 'k' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_hour = ret; + buf = s; + break; + case 'I' : + case 'l' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + if (ret == 12) + timeptr->tm_hour = 0; + else + timeptr->tm_hour = ret; + buf = s; + break; + case 'j' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_yday = ret - 1; + buf = s; + break; + case 'm' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_mon = ret - 1; + buf = s; + break; + case 'M' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_min = ret; + buf = s; + break; + case 'n' : + if (*buf == '\n') + ++buf; + else + return NULL; + break; + case 'p' : + ret = match_string (&buf, ampm); + if (ret < 0) + return NULL; + if (timeptr->tm_hour == 0) { + if (ret == 1) + timeptr->tm_hour = 12; + } else + timeptr->tm_hour += 12; + break; + case 'r' : /* %I:%M:%S %p */ + s = strptime (buf, "%I:%M:%S %p", timeptr); + if (s == NULL) + return NULL; + buf = s; + break; + case 'R' : /* %H:%M */ + s = strptime (buf, "%H:%M", timeptr); + if (s == NULL) + return NULL; + buf = s; + break; + case 'S' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_sec = ret; + buf = s; + break; + case 't' : + if (*buf == '\t') + ++buf; + else + return NULL; + break; + case 'T' : /* %H:%M:%S */ + case 'X' : + s = strptime (buf, "%H:%M:%S", timeptr); + if (s == NULL) + return NULL; + buf = s; + break; + case 'u' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_wday = ret - 1; + buf = s; + break; + case 'w' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_wday = ret; + buf = s; + break; + case 'U' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + set_week_number_sun (timeptr, ret); + buf = s; + break; + case 'V' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + set_week_number_mon4 (timeptr, ret); + buf = s; + break; + case 'W' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + set_week_number_mon (timeptr, ret); + buf = s; + break; + case 'x' : + s = strptime (buf, "%Y:%m:%d", timeptr); + if (s == NULL) + return NULL; + buf = s; + break; + case 'y' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + if (ret < 70) + timeptr->tm_year = 100 + ret; + else + timeptr->tm_year = ret; + buf = s; + break; + case 'Y' : + ret = strtol (buf, &s, 10); + if (s == buf) + return NULL; + timeptr->tm_year = ret - tm_year_base; + buf = s; + break; + case 'Z' : + /* Unsupported. Just ignore. */ + break; + case '\0' : + --format; + /* FALLTHROUGH */ + case '%' : + if (*buf == '%') + ++buf; + else + return NULL; + break; + default : + if (*buf == '%' || *++buf == c) + ++buf; + else + return NULL; + break; + } + } else { + if (*buf == c) + ++buf; + else + return NULL; + } + } + return (char *)buf; +} diff --git a/src/strptime.h b/src/strptime.h new file mode 100644 index 00000000..a169a6e2 --- /dev/null +++ b/src/strptime.h @@ -0,0 +1,51 @@ +/* */ + +#ifndef _D_STRPTIME_H +#define _D_STRPTIME_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +char * strptime (const char *buf, const char *format, struct tm *timeptr); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* not _D_STRPTIME_H */ diff --git a/test/FixedNumberRandomizer.h b/test/FixedNumberRandomizer.h index 5d96ae00..b03ee1a7 100644 --- a/test/FixedNumberRandomizer.h +++ b/test/FixedNumberRandomizer.h @@ -19,6 +19,11 @@ public: return RAND_MAX; } + virtual long int getRandomNumber(long int to) + { + return getRandomNumber(); + } + void setFixedNumber(int32_t num) { this->fixedNumber = num; } diff --git a/test/Makefile.in b/test/Makefile.in index 599ab279..34364ede 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -35,6 +35,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +target_triplet = @target@ check_PROGRAMS = $(am__EXEEXT_1) subdir = test DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in @@ -168,6 +169,16 @@ GENCAT = @GENCAT@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ +HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@ +HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@ +HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@ +HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@ +HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@ +HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@ +HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@ +HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@ +HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@ +HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -217,6 +228,7 @@ STRIP = @STRIP@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WINSOCK_LIBS = @WINSOCK_LIBS@ XGETTEXT = @XGETTEXT@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ @@ -268,7 +280,11 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ +target = @target@ target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ TESTS = aria2c aria2c_SOURCES = AllTest.cc\ FileUriListParserTest.cc\