libtorrent-0.13.2/000755 000765 000024 00000000000 11744204512 014721 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/aclocal.m4000644 000765 000024 00000126720 11744204214 016570 0ustar00rakshasastaff000000 000000 # generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, # Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) dnl dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) dnl AC_DEFUN([AM_PATH_CPPUNIT], [ AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)], cppunit_config_prefix="$withval", cppunit_config_prefix="") AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)], cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="") if test x$cppunit_config_exec_prefix != x ; then cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix" if test x${CPPUNIT_CONFIG+set} != xset ; then CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config fi fi if test x$cppunit_config_prefix != x ; then cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix" if test x${CPPUNIT_CONFIG+set} != xset ; then CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config fi fi AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no) cppunit_version_min=$1 AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min) no_cppunit="" if test "$CPPUNIT_CONFIG" = "no" ; then AC_MSG_RESULT(no) no_cppunit=yes else CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags` CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs` cppunit_version=`$CPPUNIT_CONFIG --version` cppunit_major_version=`echo $cppunit_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` cppunit_minor_version=`echo $cppunit_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` cppunit_micro_version=`echo $cppunit_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` cppunit_major_min=`echo $cppunit_version_min | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` if test "x${cppunit_major_min}" = "x" ; then cppunit_major_min=0 fi cppunit_minor_min=`echo $cppunit_version_min | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` if test "x${cppunit_minor_min}" = "x" ; then cppunit_minor_min=0 fi cppunit_micro_min=`echo $cppunit_version_min | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x${cppunit_micro_min}" = "x" ; then cppunit_micro_min=0 fi cppunit_version_proper=`expr \ $cppunit_major_version \> $cppunit_major_min \| \ $cppunit_major_version \= $cppunit_major_min \& \ $cppunit_minor_version \> $cppunit_minor_min \| \ $cppunit_major_version \= $cppunit_major_min \& \ $cppunit_minor_version \= $cppunit_minor_min \& \ $cppunit_micro_version \>= $cppunit_micro_min ` if test "$cppunit_version_proper" = "1" ; then AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version]) else AC_MSG_RESULT(no) no_cppunit=yes fi fi if test "x$no_cppunit" = x ; then ifelse([$2], , :, [$2]) else CPPUNIT_CFLAGS="" CPPUNIT_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(CPPUNIT_CFLAGS) AC_SUBST(CPPUNIT_LIBS) ]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([scripts/attributes.m4]) m4_include([scripts/ax_pthread.m4]) m4_include([scripts/checks.m4]) m4_include([scripts/common.m4]) m4_include([scripts/libtool.m4]) m4_include([scripts/ltoptions.m4]) m4_include([scripts/ltsugar.m4]) m4_include([scripts/ltversion.m4]) m4_include([scripts/lt~obsolete.m4]) libtorrent-0.13.2/AUTHORS000644 000765 000024 00000000040 11705767056 016001 0ustar00rakshasastaff000000 000000 Jari Sundell libtorrent-0.13.2/autogen.sh000755 000765 000024 00000002013 11716350717 016726 0ustar00rakshasastaff000000 000000 #! /bin/sh echo aclocal... (aclocal --version) < /dev/null > /dev/null 2>&1 || { echo aclocal not found exit 1 } aclocal -I ./scripts -I . ${ACLOCAL_FLAGS} || exit 1 echo autoheader... (autoheader --version) < /dev/null > /dev/null 2>&1 || { echo autoheader not found exit 1 } autoheader || exit 1 echo -n "libtoolize... " if ( (glibtoolize --version) < /dev/null > /dev/null 2>&1 ); then echo "using glibtoolize" glibtoolize --automake --copy --force || exit 1 elif ( (libtoolize --version) < /dev/null > /dev/null 2>&1 ) ; then echo "using libtoolize" libtoolize --automake --copy --force || exit 1 else echo "libtoolize nor glibtoolize not found" exit 1 fi echo automake... (automake --version) < /dev/null > /dev/null 2>&1 || { echo automake not found exit 1 } automake --add-missing --copy --gnu || exit 1 echo autoconf... (autoconf --version) < /dev/null > /dev/null 2>&1 || { echo autoconf not found exit 1 } autoconf || exit 1 echo ready to configure exit 0 libtorrent-0.13.2/ChangeLog000644 000765 000024 00000000000 11705767056 016477 0ustar00rakshasastaff000000 000000 libtorrent-0.13.2/config.guess000755 000765 000024 00000127045 11706024320 017245 0ustar00rakshasastaff000000 000000 #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011 Free Software Foundation, Inc. timestamp='2011-11-11' # This file 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. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo hexagon-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libtorrent-0.13.2/config.h.in000644 000765 000024 00000012275 11744204434 016756 0ustar00rakshasastaff000000 000000 /* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Default address space size. */ #undef DEFAULT_ADDRESS_SPACE_SIZE /* Determine the block size */ #undef FS_STAT_BLOCK_SIZE /* Type of block count member in stat struct */ #undef FS_STAT_COUNT_TYPE /* Function to determine filesystem stats from fd */ #undef FS_STAT_FD /* Function to determine filesystem stats from filename */ #undef FS_STAT_FN /* Type of block size member in stat struct */ #undef FS_STAT_SIZE_TYPE /* Type of second argument to statfs function */ #undef FS_STAT_STRUCT /* true if config.h was included */ #undef HAVE_CONFIG_H /* Define to 1 if your C++ compiler has support for C++11. */ #undef HAVE_CXX11 /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Linux's fallocate supported. */ #undef HAVE_FALLOCATE /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `posix_memalign' function. */ #undef HAVE_POSIX_MEMALIGN /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Have PTHREAD_PRIO_INHERIT. */ #undef HAVE_PTHREAD_PRIO_INHERIT /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MOUNT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STATFS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STATVFS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_VFS_H /* Define to 1 if your C++ library supports the extensions from Technical Report 1 */ #undef HAVE_TR1 /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Big endian */ #undef IS_BIG_ENDIAN /* Little endian */ #undef IS_LITTLE_ENDIAN /* kqueue only supports sockets. */ #undef KQUEUE_SOCKET_ONLY /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Largest L1 cache size we know of should work on all archs. */ #undef LT_SMP_CACHE_BYTES /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Identifier that is part of the default peer id */ #undef PEER_NAME /* 4 byte client and version identifier for DHT */ #undef PEER_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* enable ipv6 stuff */ #undef RAK_USE_INET6 /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define this if the compiler supports the unused attribute */ #undef SUPPORT_ATTRIBUTE_UNUSED /* Define this if the compiler supports the visibility attributes. */ #undef SUPPORT_ATTRIBUTE_VISIBILITY /* Require byte alignment */ #undef USE_ALIGNED /* Use __builtin_popcount. */ #undef USE_BUILTIN_POPCOUNT /* Using Cyrus RC4 implementation. */ #undef USE_CYRUS_RC4 /* Use epoll. */ #undef USE_EPOLL /* Enable extra debugging checks. */ #undef USE_EXTRA_DEBUG /* Use kqueue. */ #undef USE_KQUEUE /* Use madvise */ #undef USE_MADVISE /* Use mincore */ #undef USE_MINCORE /* use char* in mincore */ #undef USE_MINCORE_UNSIGNED /* Using Mozilla's SHA1 implementation. */ #undef USE_NSS_SHA /* Using OpenSSL. */ #undef USE_OPENSSL /* Using OpenSSL's SHA1 implementation. */ #undef USE_OPENSSL_SHA /* posix_fallocate supported. */ #undef USE_POSIX_FALLOCATE /* Version number of package */ #undef VERSION /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Null-wrapper if unused attribute is unsupported */ #undef __UNUSED /* LibTorrent defined cacheline aligned. */ #undef lt_cacheline_aligned libtorrent-0.13.2/config.sub000755 000765 000024 00000105162 11706024320 016704 0ustar00rakshasastaff000000 000000 #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011 Free Software Foundation, Inc. timestamp='2011-11-11' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libtorrent-0.13.2/configure000755 000765 000024 00002332453 11744204216 016645 0ustar00rakshasastaff000000 000000 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for libtorrent 0.13.2. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and jaris@ifi.uio.no $0: about your system, including any error possibly output $0: before this message. Then install a modern shell, or $0: manually run the script under such a shell if you do $0: have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libtorrent' PACKAGE_TARNAME='libtorrent' PACKAGE_VERSION='0.13.2' PACKAGE_STRING='libtorrent 0.13.2' PACKAGE_BUGREPORT='jaris@ifi.uio.no' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS LIBTORRENT_CFLAGS LIBTORRENT_LIBS STUFF_LIBS STUFF_CFLAGS OPENSSL_LIBS OPENSSL_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CC ax_pthread_config CXXCPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL CPPUNIT_LIBS CPPUNIT_CFLAGS CPPUNIT_CONFIG am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM LIBTORRENT_INTERFACE_VERSION_NO LIBTORRENT_INTERFACE_VERSION_INFO LIBTORRENT_CURRENT target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_cppunit_prefix with_cppunit_exec_prefix enable_static enable_shared with_pic enable_fast_install enable_dependency_tracking with_gnu_ld with_sysroot enable_libtool_lock enable_aligned enable_debug enable_extra_debug enable_werror enable_std_tr1 enable_std_c__11 enable_ipv6 enable_largefile enable_arch with_kqueue with_epoll with_posix_fallocate with_address_space with_statvfs with_statfs enable_openssl enable_cyrus_rc4 enable_mincore ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC CXXCPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR OPENSSL_CFLAGS OPENSSL_LIBS STUFF_CFLAGS STUFF_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures libtorrent 0.13.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/libtorrent] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of libtorrent 0.13.2:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-static[=PKGS] build static libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-libtool-lock avoid locking (might break parallel builds) --enable-aligned enable alignment safe code [default=check] --enable-debug enable debug information [default=yes] --enable-extra-debug enable extra debugging checks. [default=no] --enable-werror enable the -Werror and -Wall flag [default=no] --disable-std_tr1 disable check for support for TR1 [default=enable] --disable-std_c++11 disable check for support for C++11 [default=enable] --enable-ipv6 disable ipv6 [default=no] --disable-largefile omit support for large files --enable-arch=ARCH comma seprated list of architectures to compile for. --disable-openssl Don't use OpenSSL's SHA1 implementation. --enable-cyrus-rc4=PFX Use Cyrus RC4 implementation. --disable-mincore disable mincore check [default=enable] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional) --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-sysroot=PATH compile and link with a specific sysroot. --without-kqueue Do not check for kqueue support. --without-epoll Do not check for epoll support. --with-posix-fallocate Check for and use posix_fallocate to allocate files. --with-address-space=MB Change the default address space size, default 1024 MB. --without-statvfs Don't try to use statvfs to find free diskspace. --without-statfs Don't try to use statfs to find free diskspace. Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path OPENSSL_CFLAGS C compiler flags for OPENSSL, overriding pkg-config OPENSSL_LIBS linker flags for OPENSSL, overriding pkg-config STUFF_CFLAGS C compiler flags for STUFF, overriding pkg-config STUFF_LIBS linker flags for STUFF, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF libtorrent configure 0.13.2 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 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 ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* 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 $2 (); /* 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_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 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 ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 &5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------- ## ## Report this to jaris@ifi.uio.no ## ## ------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by libtorrent $as_me 0.13.2, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu $as_echo "#define PEER_NAME \"-lt0D20-\"" >>confdefs.h $as_echo "#define PEER_VERSION \"lt\\x0D\\x20\"" >>confdefs.h LIBTORRENT_CURRENT=14 LIBTORRENT_REVISION=4 LIBTORRENT_AGE=0 LIBTORRENT_INTERFACE_VERSION_INFO=$LIBTORRENT_CURRENT:$LIBTORRENT_REVISION:$LIBTORRENT_AGE LIBTORRENT_INTERFACE_VERSION_NO=$LIBTORRENT_CURRENT.$LIBTORRENT_AGE.$LIBTORRENT_REVISION am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. 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. # 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: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='libtorrent' VERSION='0.13.2' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' ac_config_headers="$ac_config_headers config.h" # Check whether --with-cppunit-prefix was given. if test "${with_cppunit_prefix+set}" = set; then : withval=$with_cppunit_prefix; cppunit_config_prefix="$withval" else cppunit_config_prefix="" fi # Check whether --with-cppunit-exec-prefix was given. if test "${with_cppunit_exec_prefix+set}" = set; then : withval=$with_cppunit_exec_prefix; cppunit_config_exec_prefix="$withval" else cppunit_config_exec_prefix="" fi if test x$cppunit_config_exec_prefix != x ; then cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix" if test x${CPPUNIT_CONFIG+set} != xset ; then CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config fi fi if test x$cppunit_config_prefix != x ; then cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix" if test x${CPPUNIT_CONFIG+set} != xset ; then CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config fi fi # Extract the first word of "cppunit-config", so it can be a program name with args. set dummy cppunit-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_CPPUNIT_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $CPPUNIT_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_CPPUNIT_CONFIG="$CPPUNIT_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CPPUNIT_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_CPPUNIT_CONFIG" && ac_cv_path_CPPUNIT_CONFIG="no" ;; esac fi CPPUNIT_CONFIG=$ac_cv_path_CPPUNIT_CONFIG if test -n "$CPPUNIT_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPPUNIT_CONFIG" >&5 $as_echo "$CPPUNIT_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi cppunit_version_min=1.9.6 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Cppunit - version >= $cppunit_version_min" >&5 $as_echo_n "checking for Cppunit - version >= $cppunit_version_min... " >&6; } no_cppunit="" if test "$CPPUNIT_CONFIG" = "no" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } no_cppunit=yes else CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags` CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs` cppunit_version=`$CPPUNIT_CONFIG --version` cppunit_major_version=`echo $cppunit_version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` cppunit_minor_version=`echo $cppunit_version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` cppunit_micro_version=`echo $cppunit_version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` cppunit_major_min=`echo $cppunit_version_min | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` if test "x${cppunit_major_min}" = "x" ; then cppunit_major_min=0 fi cppunit_minor_min=`echo $cppunit_version_min | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` if test "x${cppunit_minor_min}" = "x" ; then cppunit_minor_min=0 fi cppunit_micro_min=`echo $cppunit_version_min | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` if test "x${cppunit_micro_min}" = "x" ; then cppunit_micro_min=0 fi cppunit_version_proper=`expr \ $cppunit_major_version \> $cppunit_major_min \| \ $cppunit_major_version \= $cppunit_major_min \& \ $cppunit_minor_version \> $cppunit_minor_min \| \ $cppunit_major_version \= $cppunit_major_min \& \ $cppunit_minor_version \= $cppunit_minor_min \& \ $cppunit_micro_version \>= $cppunit_micro_min ` if test "$cppunit_version_proper" = "1" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version" >&5 $as_echo "$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } no_cppunit=yes fi fi if test "x$no_cppunit" = x ; then : else CPPUNIT_CFLAGS="" CPPUNIT_LIBS="" : fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=no fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=no fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&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 && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&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` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; 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 # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds reload_flag_CXX=$reload_flag reload_cmds_CXX=$reload_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC compiler_CXX=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec_CXX='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty # executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' ${wl}-bernotok' allow_undefined_flag_CXX=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' fi archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared # libraries. archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_CXX=' ' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=yes file_list_spec_CXX='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' enable_shared_with_static_runtimes_CXX=yes # Don't use ranlib old_postinstall_cmds_CXX='chmod 644 $oldlib' postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' export_dynamic_flag_spec_CXX='${wl}--export-all-symbols' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec_CXX='' fi link_all_deplibs_CXX=yes allow_undefined_flag_CXX="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" if test "$lt_cv_apple_cc_single_mod" != "yes"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi else ld_shlibs_CXX=no fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; gnu*) ;; haiku*) archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs_CXX=yes ;; hpux9*) hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='${wl}-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5].* | *pgcpp\ [1-5].*) prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) ld_shlibs_CXX=yes ;; openbsd2*) # C++ shared libraries are fairly broken ld_shlibs_CXX=no ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='${wl}-E' whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else ld_shlibs_CXX=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then no_undefined_flag_CXX=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='${wl}-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_CXX='${wl}-z,text' allow_undefined_flag_CXX='${wl}-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ '"$old_archive_cmds_CXX" reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ '"$reload_cmds_CXX" ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no GCC_CXX="$GXX" LD_CXX="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX="${prev}${p}" else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX="${prev}${p}" else postdeps_CXX="${postdeps_CXX} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$predep_objects_CXX"; then predep_objects_CXX="$p" else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX="$p" else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken case $host_os in interix[3-9]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static_CXX= ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix[4-9]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) # IBM XL 8.0, 9.0 on PPC and BlueGene lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works_CXX=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then : else lt_prog_compiler_static_CXX= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' ;; esac ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc_CXX=no else lt_cv_archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 $as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test "X$hardcode_automatic_CXX" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct_CXX" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && test "$hardcode_minus_L_CXX" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } if test "$hardcode_action_CXX" = relink || test "$inherit_rpath_CXX" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define IS_BIG_ENDIAN 1" >>confdefs.h ;; #( no) $as_echo "#define IS_LITTLE_ENDIAN 1" >>confdefs.h ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "Could not determine endianness" "$LINENO" 5 ;; esac # Check whether --enable-aligned was given. if test "${enable_aligned+set}" = set; then : enableval=$enable_aligned; if test "$enableval" = "yes"; then $as_echo "#define USE_ALIGNED 1" >>confdefs.h fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking the byte alignment" >&5 $as_echo_n "checking the byte alignment... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main() { char buf8 = { 0, 0, 0, 0, 1, 0, 0, 0 }; int i; for (i = 1; i < 4; ++i) if (*(uint32_t*)(buf + i) == 0) return -1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } else $as_echo "#define USE_ALIGNED 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: required" >&5 $as_echo "required" >&6; } fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for user-defined CXXFLAGS" >&5 $as_echo_n "checking for user-defined CXXFLAGS... " >&6; } if test -n "$CXXFLAGS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: user-defined \"$CXXFLAGS\"" >&5 $as_echo "user-defined \"$CXXFLAGS\"" >&6; } else CXXFLAGS="-O2 -Wall" { $as_echo "$as_me:${as_lineno-$LINENO}: result: default \"$CXXFLAGS\"" >&5 $as_echo "default \"$CXXFLAGS\"" >&6; } fi # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; if test "$enableval" = "yes"; then CXXFLAGS="$CXXFLAGS -g -DDEBUG" else CXXFLAGS="$CXXFLAGS -DNDEBUG" fi else CXXFLAGS="$CXXFLAGS -g -DDEBUG" fi # Check whether --enable-extra-debug was given. if test "${enable_extra_debug+set}" = set; then : enableval=$enable_extra_debug; if test "$enableval" = "yes"; then $as_echo "#define USE_EXTRA_DEBUG 1" >>confdefs.h fi fi # Check whether --enable-werror was given. if test "${enable_werror+set}" = set; then : enableval=$enable_werror; if test "$enableval" = "yes"; then CXXFLAGS="$CXXFLAGS -Werror -Wall" fi fi # Check whether --enable-std_tr1 was given. if test "${enable_std_tr1+set}" = set; then : enableval=$enable_std_tr1; if test "$enableval" = "yes"; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TR1 support" >&5 $as_echo_n "checking for TR1 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include class Foo; typedef std::tr1::unordered_map Bar; _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_TR1 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TR1 support" >&5 $as_echo_n "checking for TR1 support... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TR1 support" >&5 $as_echo_n "checking for TR1 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include class Foo; typedef std::tr1::unordered_map Bar; _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_TR1 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi # Check whether --enable-std_c++11 was given. if test "${enable_std_c__11+set}" = set; then : enableval=$enable_std_c__11; if test "$enableval" = "yes"; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 support" >&5 $as_echo_n "checking for C++11 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include class Foo; typedef std::unordered_map Bar; union test { Bar b1; }; _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_CXX11 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 support" >&5 $as_echo_n "checking for C++11 support... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 support" >&5 $as_echo_n "checking for C++11 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include class Foo; typedef std::unordered_map Bar; union test { Bar b1; }; _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_CXX11 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi # Check whether --enable-ipv6 was given. if test "${enable_ipv6+set}" = set; then : enableval=$enable_ipv6; if test "$enableval" = "yes"; then $as_echo "#define RAK_USE_INET6 1" >>confdefs.h fi fi # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi fi # Check whether --enable-arch was given. if test "${enable_arch+set}" = set; then : enableval=$enable_arch; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for target architectures" >&5 $as_echo_n "checking for target architectures... " >&6; } if test "$enableval" = "yes"; then as_fn_error $? "no arch supplied" "$LINENO" 5 elif test "$enableval" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: using default" >&5 $as_echo "using default" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5 $as_echo "$enableval" >&6; } for i in `IFS=,; echo $enableval`; do CFLAGS="$CFLAGS -march=$i" CXXFLAGS="$CXXFLAGS -march=$i" LDFLAGS="$LDFLAGS -march=$i" done fi fi # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } if test "$withval" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } elif test "$withval" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not a path" >&5 $as_echo "not a path" >&6; } as_fn_error like f.ex "/Developer/SDKs/MacOSX10.4u.sdk". "The sysroot option must point to a directory" "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $withval" >&5 $as_echo "$withval" >&6; } CXXFLAGS="$CXXFLAGS -isysroot $withval" LDFLAGS="$LDFLAGS -Wl,-syslibroot,$withval" fi fi # Check whether --with-kqueue was given. if test "${with_kqueue+set}" = set; then : withval=$with_kqueue; if test "$withval" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kqueue support" >&5 $as_echo_n "checking for kqueue support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Because OpenBSD's sys/event.h fails to compile otherwise. Yeah... */ #include int main() { int fd = kqueue(); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define USE_KQUEUE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether kqueue supports pipes and ptys" >&5 $as_echo_n "checking whether kqueue supports pipes and ptys... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include int main() { struct kevent ev2, ev_out2; struct timespec ts = { 0, 0 }; int pfd2, pty2, kfd, n; char buffer9001; if (pipe(pfd) == -1) return 1; if (fcntl(pfd1, F_SETFL, O_NONBLOCK) == -1) return 2; while ((n = write(pfd1, buffer, sizeof(buffer))) == sizeof(buffer)); if ((pty0=posix_openpt(O_RDWR | O_NOCTTY)) == -1) return 3; if ((pty1=grantpt(pty0)) == -1) return 4; EV_SET(ev+0, pfd1, EVFILT_WRITE, EV_ADD | EV_ENABLE, 0, 0, NULL); EV_SET(ev+1, pty1, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL); if ((kfd = kqueue()) == -1) return 5; if ((n = kevent(kfd, ev, 2, NULL, 0, NULL)) == -1) return 6; if (ev_out0.flags & EV_ERROR) return 7; if (ev_out1.flags & EV_ERROR) return 8; read(pfd0, buffer, sizeof(buffer)); if ((n = kevent(kfd, NULL, 0, ev_out, 2, &ts)) < 1) return 9; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else $as_echo "#define KQUEUE_SOCKET_ONLY 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kqueue support" >&5 $as_echo_n "checking for kqueue support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Because OpenBSD's sys/event.h fails to compile otherwise. Yeah... */ #include int main() { int fd = kqueue(); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define USE_KQUEUE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether kqueue supports pipes and ptys" >&5 $as_echo_n "checking whether kqueue supports pipes and ptys... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include int main() { struct kevent ev2, ev_out2; struct timespec ts = { 0, 0 }; int pfd2, pty2, kfd, n; char buffer9001; if (pipe(pfd) == -1) return 1; if (fcntl(pfd1, F_SETFL, O_NONBLOCK) == -1) return 2; while ((n = write(pfd1, buffer, sizeof(buffer))) == sizeof(buffer)); if ((pty0=posix_openpt(O_RDWR | O_NOCTTY)) == -1) return 3; if ((pty1=grantpt(pty0)) == -1) return 4; EV_SET(ev+0, pfd1, EVFILT_WRITE, EV_ADD | EV_ENABLE, 0, 0, NULL); EV_SET(ev+1, pty1, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL); if ((kfd = kqueue()) == -1) return 5; if ((n = kevent(kfd, ev, 2, NULL, 0, NULL)) == -1) return 6; if (ev_out0.flags & EV_ERROR) return 7; if (ev_out1.flags & EV_ERROR) return 8; read(pfd0, buffer, sizeof(buffer)); if ((n = kevent(kfd, NULL, 0, ev_out, 2, &ts)) < 1) return 9; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else $as_echo "#define KQUEUE_SOCKET_ONLY 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi # Check whether --with-epoll was given. if test "${with_epoll+set}" = set; then : withval=$with_epoll; if test "$withval" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for epoll support" >&5 $as_echo_n "checking for epoll support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main() { int fd = epoll_create(100); return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define USE_EPOLL 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for epoll support" >&5 $as_echo_n "checking for epoll support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main() { int fd = epoll_create(100); return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define USE_EPOLL 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fallocate" >&5 $as_echo_n "checking for fallocate... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 0); return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_FALLOCATE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # Check whether --with-posix-fallocate was given. if test "${with_posix_fallocate+set}" = set; then : withval=$with_posix_fallocate; if test "$withval" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for posix_fallocate" >&5 $as_echo_n "checking for posix_fallocate... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { posix_fallocate(0, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define USE_POSIX_FALLOCATE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi fi # Check whether --with-address-space was given. if test "${with_address_space+set}" = set; then : withval=$with_address_space; if test ! -z $withval -a "$withval" != "yes" -a "$withval" != "no"; then cat >>confdefs.h <<_ACEOF #define DEFAULT_ADDRESS_SPACE_SIZE $withval _ACEOF else as_fn_error $? "--with-address-space requires a parameter." "$LINENO" 5 fi else # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } if ${ac_cv_sizeof_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 $as_echo "$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF if test $ac_cv_sizeof_long = 8; then $as_echo "#define DEFAULT_ADDRESS_SPACE_SIZE 4096" >>confdefs.h else $as_echo "#define DEFAULT_ADDRESS_SPACE_SIZE 1024" >>confdefs.h fi fi # Check whether --with-statvfs was given. if test "${with_statvfs+set}" = set; then : withval=$with_statvfs; if test "$withval" = "yes"; then for ac_header in sys/vfs.h sys/statvfs.h sys/statfs.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for statvfs" >&5 $as_echo_n "checking for statvfs... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_VFS_H #include #endif #if HAVE_SYS_STATVFS_H #include #endif #if HAVE_SYS_STATFS_H #include #endif int main () { struct statvfs s; fsblkcnt_t c; statvfs("", &s); fstatvfs(0, &s); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define FS_STAT_FD fstatvfs(fd, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_FN statvfs(fn, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_STRUCT struct statvfs" >>confdefs.h $as_echo "#define FS_STAT_SIZE_TYPE unsigned long" >>confdefs.h $as_echo "#define FS_STAT_COUNT_TYPE fsblkcnt_t" >>confdefs.h $as_echo "#define FS_STAT_BLOCK_SIZE (m_stat.f_frsize)" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } have_stat_vfs=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_stat_vfs=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext else have_stat_vfs=no fi else for ac_header in sys/vfs.h sys/statvfs.h sys/statfs.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for statvfs" >&5 $as_echo_n "checking for statvfs... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_VFS_H #include #endif #if HAVE_SYS_STATVFS_H #include #endif #if HAVE_SYS_STATFS_H #include #endif int main () { struct statvfs s; fsblkcnt_t c; statvfs("", &s); fstatvfs(0, &s); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define FS_STAT_FD fstatvfs(fd, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_FN statvfs(fn, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_STRUCT struct statvfs" >>confdefs.h $as_echo "#define FS_STAT_SIZE_TYPE unsigned long" >>confdefs.h $as_echo "#define FS_STAT_COUNT_TYPE fsblkcnt_t" >>confdefs.h $as_echo "#define FS_STAT_BLOCK_SIZE (m_stat.f_frsize)" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } have_stat_vfs=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_stat_vfs=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # Check whether --with-statfs was given. if test "${with_statfs+set}" = set; then : withval=$with_statfs; if test "$have_stat_vfs" = "no"; then if test "$withval" = "yes"; then for ac_header in sys/statfs.h sys/param.h sys/mount.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for statfs" >&5 $as_echo_n "checking for statfs... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_STATFS_H #include #endif #if HAVE_SYS_PARAM_H #include #endif #if HAVE_SYS_MOUNT_H #include #endif int main () { struct statfs s; statfs("", &s); fstatfs(0, &s); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define FS_STAT_FD fstatfs(fd, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_FN statfs(fn, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_STRUCT struct statfs" >>confdefs.h $as_echo "#define FS_STAT_SIZE_TYPE long" >>confdefs.h $as_echo "#define FS_STAT_COUNT_TYPE long" >>confdefs.h $as_echo "#define FS_STAT_BLOCK_SIZE (m_stat.f_bsize)" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } have_stat_vfs=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_stat_vfs=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext else $as_echo "#define FS_STAT_FD (errno = ENOSYS) == 0" >>confdefs.h $as_echo "#define FS_STAT_FN (errno = ENOSYS) == 0" >>confdefs.h $as_echo "#define FS_STAT_STRUCT struct {blocksize_type f_bsize; blockcount_type f_bavail;}" >>confdefs.h $as_echo "#define FS_STAT_SIZE_TYPE int" >>confdefs.h $as_echo "#define FS_STAT_COUNT_TYPE int" >>confdefs.h $as_echo "#define FS_STAT_BLOCK_SIZE (4096)" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: No filesystem stats available" >&5 $as_echo "No filesystem stats available" >&6; } fi fi else if test "$have_stat_vfs" = "no"; then for ac_header in sys/statfs.h sys/param.h sys/mount.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for statfs" >&5 $as_echo_n "checking for statfs... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_STATFS_H #include #endif #if HAVE_SYS_PARAM_H #include #endif #if HAVE_SYS_MOUNT_H #include #endif int main () { struct statfs s; statfs("", &s); fstatfs(0, &s); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define FS_STAT_FD fstatfs(fd, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_FN statfs(fn, &m_stat) == 0" >>confdefs.h $as_echo "#define FS_STAT_STRUCT struct statfs" >>confdefs.h $as_echo "#define FS_STAT_SIZE_TYPE long" >>confdefs.h $as_echo "#define FS_STAT_COUNT_TYPE long" >>confdefs.h $as_echo "#define FS_STAT_BLOCK_SIZE (m_stat.f_bsize)" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } have_stat_vfs=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_stat_vfs=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$have_stat_vfs" = "no"; then $as_echo "#define FS_STAT_FD (errno = ENOSYS) == 0" >>confdefs.h $as_echo "#define FS_STAT_FN (errno = ENOSYS) == 0" >>confdefs.h $as_echo "#define FS_STAT_STRUCT struct {blocksize_type f_bsize; blockcount_type f_bavail;}" >>confdefs.h $as_echo "#define FS_STAT_SIZE_TYPE int" >>confdefs.h $as_echo "#define FS_STAT_COUNT_TYPE int" >>confdefs.h $as_echo "#define FS_STAT_BLOCK_SIZE (4096)" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: No filesystem stats available" >&5 $as_echo "No filesystem stats available" >&6; } fi fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu tmp_CXXFLAGS=$CXXFLAGS CXXFLAGS="$CXXFLAGS -fvisibility=hidden" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports __attribute__((visibility(\"default\")))" >&5 $as_echo_n "checking if compiler supports __attribute__((visibility(\"default\")))... " >&6; } if ${cc_cv_attribute_visibility+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ void __attribute__((visibility("default"))) visibility_function() { } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : cc_cv_attribute_visibility=yes else cc_cv_attribute_visibility=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cc_cv_attribute_visibility" >&5 $as_echo "$cc_cv_attribute_visibility" >&6; } CXXFLAGS=$tmp_CXXFLAGS ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "x$cc_cv_attribute_visibility" = "xyes"; then $as_echo "#define SUPPORT_ATTRIBUTE_VISIBILITY 1" >>confdefs.h CXXFLAGS="$CXXFLAGS -fvisibility=hidden" else true fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* 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 pthread_join (); int main () { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } if test x"$ax_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ;; *-darwin*) ax_pthread_flags="-pthread $ax_pthread_flags" ;; esac if test x"$ax_pthread_ok" = xno; then for flag in $ax_pthread_flags; do case $flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 $as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ax_pthread_config+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ax_pthread_config"; then ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ax_pthread_config="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no" fi fi ax_pthread_config=$ac_cv_prog_ax_pthread_config if test -n "$ax_pthread_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5 $as_echo "$ax_pthread_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x"$ax_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 $as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; } int main () { pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } if test "x$ax_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int attr = $attr; return attr /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : attr_name=$attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 $as_echo "$attr_name" >&6; } if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then cat >>confdefs.h <<_ACEOF #define PTHREAD_CREATE_JOINABLE $attr_name _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *-osf* | *-hpux*) flag="-D_REENTRANT";; *solaris*) if test "$GCC" = "yes"; then flag="-D_REENTRANT" else flag="-mt -D_REENTRANT" fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 $as_echo "${flag}" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5 $as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; } if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int i = PTHREAD_PRIO_INHERIT; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_cv_PTHREAD_PRIO_INHERIT=yes else ax_cv_PTHREAD_PRIO_INHERIT=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5 $as_echo "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; } if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"; then : $as_echo "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then for ac_prog in xlc_r cc_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PTHREAD_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PTHREAD_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}" else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$ax_pthread_ok" = xyes; then $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h : else ax_pthread_ok=no as_fn_error $? "requires pthread" "$LINENO" 5 fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi # Check whether --enable-openssl was given. if test "${enable_openssl+set}" = set; then : enableval=$enable_openssl; if test "$enableval" = "yes"; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5 $as_echo_n "checking for OPENSSL... " >&6; } if test -n "$OPENSSL_CFLAGS"; then pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcrypto\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcrypto") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "libcrypto" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$OPENSSL_LIBS"; then pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcrypto\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcrypto") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "libcrypto" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libcrypto" 2>&1` else OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libcrypto" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$OPENSSL_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (libcrypto) were not met: $OPENSSL_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables OPENSSL_CFLAGS and OPENSSL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables OPENSSL_CFLAGS and OPENSSL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS"; LIBS="$LIBS $OPENSSL_LIBS" fi $as_echo "#define USE_OPENSSL 1" >>confdefs.h $as_echo "#define USE_OPENSSL_SHA 1" >>confdefs.h else $as_echo "#define USE_NSS_SHA 1" >>confdefs.h fi else pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5 $as_echo_n "checking for OPENSSL... " >&6; } if test -n "$OPENSSL_CFLAGS"; then pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcrypto\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcrypto") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "libcrypto" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$OPENSSL_LIBS"; then pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcrypto\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcrypto") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "libcrypto" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libcrypto" 2>&1` else OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libcrypto" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$OPENSSL_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (libcrypto) were not met: $OPENSSL_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables OPENSSL_CFLAGS and OPENSSL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables OPENSSL_CFLAGS and OPENSSL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS"; LIBS="$LIBS $OPENSSL_LIBS" fi $as_echo "#define USE_OPENSSL 1" >>confdefs.h $as_echo "#define USE_OPENSSL_SHA 1" >>confdefs.h fi # Check whether --enable-cyrus-rc4 was given. if test "${enable_cyrus_rc4+set}" = set; then : enableval=$enable_cyrus_rc4; CXXFLAGS="$CXXFLAGS -I${enableval}/include"; LIBS="$LIBS -lrc4 -L${enableval}/lib" $as_echo "#define USE_CYRUS_RC4 1" >>confdefs.h fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for STUFF" >&5 $as_echo_n "checking for STUFF... " >&6; } if test -n "$STUFF_CFLAGS"; then pkg_cv_STUFF_CFLAGS="$STUFF_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sigc++-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "sigc++-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_STUFF_CFLAGS=`$PKG_CONFIG --cflags "sigc++-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$STUFF_LIBS"; then pkg_cv_STUFF_LIBS="$STUFF_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sigc++-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "sigc++-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_STUFF_LIBS=`$PKG_CONFIG --libs "sigc++-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then STUFF_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sigc++-2.0" 2>&1` else STUFF_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sigc++-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$STUFF_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (sigc++-2.0) were not met: $STUFF_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables STUFF_CFLAGS and STUFF_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables STUFF_CFLAGS and STUFF_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else STUFF_CFLAGS=$pkg_cv_STUFF_CFLAGS STUFF_LIBS=$pkg_cv_STUFF_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS"; LIBS="$LIBS $STUFF_LIBS" fi for ac_func in posix_memalign do : ac_fn_c_check_func "$LINENO" "posix_memalign" "ac_cv_func_posix_memalign" if test "x$ac_cv_func_posix_memalign" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_POSIX_MEMALIGN 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for madvise" >&5 $as_echo_n "checking for madvise... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include void f() { static char test1024; madvise((void *)test, sizeof(test), MADV_NORMAL); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define USE_MADVISE 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cacheline" >&5 $as_echo_n "checking for cacheline... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include void* vptr __cacheline_aligned; void f() { posix_memalign(&vptr, SMP_CACHE_BYTES, 42); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: found builtin" >&5 $as_echo "found builtin" >&6; } $as_echo "#define LT_SMP_CACHE_BYTES 128" >>confdefs.h $as_echo "#define lt_cacheline_aligned __attribute__((__aligned__(LT_SMP_CACHE_BYTES)))" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: using default 128 bytes" >&5 $as_echo "using default 128 bytes" >&6; } $as_echo "#define LT_SMP_CACHE_BYTES 128" >>confdefs.h $as_echo "#define lt_cacheline_aligned __attribute__((__aligned__(LT_SMP_CACHE_BYTES)))" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_popcount" >&5 $as_echo_n "checking for __builtin_popcount... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int f() { return __builtin_popcount(0); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define USE_BUILTIN_POPCOUNT 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Check whether --enable-mincore was given. if test "${enable_mincore+set}" = set; then : enableval=$enable_mincore; if test "$enableval" = "yes"; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking signedness of mincore parameter" >&5 $as_echo_n "checking signedness of mincore parameter... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include void f() { mincore((char*)0, 0, (unsigned char*)0); } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define USE_MINCORE 1" >>confdefs.h $as_echo "#define USE_MINCORE_UNSIGNED 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsigned" >&5 $as_echo "unsigned" >&6; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include void f() { mincore((char*)0, 0, (char*)0); } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define USE_MINCORE 1" >>confdefs.h $as_echo "#define USE_MINCORE_UNSIGNED 0" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: signed" >&5 $as_echo "signed" >&6; } else as_fn_error $? "failed, do *not* attempt fix this with --disable-mincore unless you are running Win32." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mincore" >&5 $as_echo_n "checking for mincore... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking signedness of mincore parameter" >&5 $as_echo_n "checking signedness of mincore parameter... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include void f() { mincore((char*)0, 0, (unsigned char*)0); } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define USE_MINCORE 1" >>confdefs.h $as_echo "#define USE_MINCORE_UNSIGNED 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsigned" >&5 $as_echo "unsigned" >&6; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include void f() { mincore((char*)0, 0, (char*)0); } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define USE_MINCORE 1" >>confdefs.h $as_echo "#define USE_MINCORE_UNSIGNED 0" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: signed" >&5 $as_echo "signed" >&6; } else as_fn_error $? "failed, do *not* attempt fix this with --disable-mincore unless you are running Win32." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for proper overloaded template function disambiguation" >&5 $as_echo_n "checking for proper overloaded template function disambiguation... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ template void f(T&) {} template void f(T*) {} int main() { int *i = 0; f(*i); f(i); } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "your compiler does not properly handle overloaded template function disambiguation" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu LIBTORRENT_LIBS="-ltorrent" LIBTORRENT_CFLAGS="" $as_echo "#define HAVE_CONFIG_H 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports __attribute__((unused))" >&5 $as_echo_n "checking if compiler supports __attribute__((unused))... " >&6; } if ${cc_cv_attribute_unused+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ void some_function(void *foo, __attribute__((unused)) void *bar); _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cc_cv_attribute_unused=yes else cc_cv_attribute_unused=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cc_cv_attribute_unused" >&5 $as_echo "$cc_cv_attribute_unused" >&6; } if test "x$cc_cv_attribute_unused" = "xyes"; then $as_echo "#define SUPPORT_ATTRIBUTE_UNUSED 1" >>confdefs.h $as_echo "#define __UNUSED __attribute__((unused))" >>confdefs.h else true $as_echo "#define __UNUSED /**/" >>confdefs.h fi ac_config_files="$ac_config_files libtorrent.pc Makefile src/Makefile src/torrent/Makefile src/torrent/peer/Makefile src/torrent/data/Makefile src/torrent/download/Makefile src/torrent/utils/Makefile src/data/Makefile src/dht/Makefile src/download/Makefile src/net/Makefile src/protocol/Makefile src/tracker/Makefile src/utils/Makefile test/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by libtorrent $as_me 0.13.2, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ libtorrent config.status 0.13.2 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ reload_flag_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_separator_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec \ reload_cmds_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX \ postlink_cmds_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "libtorrent.pc") CONFIG_FILES="$CONFIG_FILES libtorrent.pc" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/torrent/Makefile") CONFIG_FILES="$CONFIG_FILES src/torrent/Makefile" ;; "src/torrent/peer/Makefile") CONFIG_FILES="$CONFIG_FILES src/torrent/peer/Makefile" ;; "src/torrent/data/Makefile") CONFIG_FILES="$CONFIG_FILES src/torrent/data/Makefile" ;; "src/torrent/download/Makefile") CONFIG_FILES="$CONFIG_FILES src/torrent/download/Makefile" ;; "src/torrent/utils/Makefile") CONFIG_FILES="$CONFIG_FILES src/torrent/utils/Makefile" ;; "src/data/Makefile") CONFIG_FILES="$CONFIG_FILES src/data/Makefile" ;; "src/dht/Makefile") CONFIG_FILES="$CONFIG_FILES src/dht/Makefile" ;; "src/download/Makefile") CONFIG_FILES="$CONFIG_FILES src/download/Makefile" ;; "src/net/Makefile") CONFIG_FILES="$CONFIG_FILES src/net/Makefile" ;; "src/protocol/Makefile") CONFIG_FILES="$CONFIG_FILES src/protocol/Makefile" ;; "src/tracker/Makefile") CONFIG_FILES="$CONFIG_FILES src/tracker/Makefile" ;; "src/utils/Makefile") CONFIG_FILES="$CONFIG_FILES src/utils/Makefile" ;; "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="CXX " # ### BEGIN LIBTOOL CONFIG # Whether or not to build static libraries. build_old_libs=$enable_static # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # How to create reloadable object files. reload_flag=$lt_reload_flag_CXX reload_cmds=$lt_reload_cmds_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi libtorrent-0.13.2/configure.ac000644 000765 000024 00000006574 11744204116 017223 0ustar00rakshasastaff000000 000000 AC_INIT(libtorrent, 0.13.2, jaris@ifi.uio.no) dnl Find a better way to do this AC_DEFINE(PEER_NAME, "-lt0D20-", Identifier that is part of the default peer id) AC_DEFINE(PEER_VERSION, "lt\x0D\x20", 4 byte client and version identifier for DHT) LIBTORRENT_CURRENT=14 LIBTORRENT_REVISION=4 LIBTORRENT_AGE=0 LIBTORRENT_INTERFACE_VERSION_INFO=$LIBTORRENT_CURRENT:$LIBTORRENT_REVISION:$LIBTORRENT_AGE LIBTORRENT_INTERFACE_VERSION_NO=$LIBTORRENT_CURRENT.$LIBTORRENT_AGE.$LIBTORRENT_REVISION AC_SUBST(LIBTORRENT_CURRENT) AC_SUBST(LIBTORRENT_INTERFACE_VERSION_INFO) AC_SUBST(LIBTORRENT_INTERFACE_VERSION_NO) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) AM_PATH_CPPUNIT(1.9.6) AC_DISABLE_STATIC AM_DISABLE_STATIC AM_PROG_LIBTOOL AC_PROG_CXX AC_C_BIGENDIAN( AC_DEFINE(IS_BIG_ENDIAN, 1, Big endian), AC_DEFINE(IS_LITTLE_ENDIAN, 1, Little endian), AC_MSG_ERROR([Could not determine endianness]) ) TORRENT_ENABLE_ALIGNED TORRENT_CHECK_CXXFLAGS TORRENT_ENABLE_DEBUG TORRENT_ENABLE_EXTRA_DEBUG TORRENT_ENABLE_WERROR TORRENT_ENABLE_TR1 TORRENT_ENABLE_CXX11 TORRENT_DISABLE_IPV6 AC_SYS_LARGEFILE TORRENT_ENABLE_ARCH TORRENT_WITH_SYSROOT dnl TORRENT_WITH_XFS TORRENT_WITHOUT_KQUEUE TORRENT_WITHOUT_EPOLL TORRENT_CHECK_FALLOCATE TORRENT_WITH_POSIX_FALLOCATE TORRENT_WITH_ADDRESS_SPACE TORRENT_WITHOUT_STATVFS TORRENT_WITHOUT_STATFS CC_ATTRIBUTE_VISIBILITY AX_PTHREAD([], AC_MSG_ERROR([requires pthread])) CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" AC_ARG_ENABLE(openssl, [ --disable-openssl Don't use OpenSSL's SHA1 implementation.], [ if test "$enableval" = "yes"; then PKG_CHECK_MODULES(OPENSSL, libcrypto, CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS"; LIBS="$LIBS $OPENSSL_LIBS") AC_DEFINE(USE_OPENSSL, 1, Using OpenSSL.) AC_DEFINE(USE_OPENSSL_SHA, 1, Using OpenSSL's SHA1 implementation.) else AC_DEFINE(USE_NSS_SHA, 1, Using Mozilla's SHA1 implementation.) fi ],[ PKG_CHECK_MODULES(OPENSSL, libcrypto, CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS"; LIBS="$LIBS $OPENSSL_LIBS") AC_DEFINE(USE_OPENSSL, 1, Using OpenSSL.) AC_DEFINE(USE_OPENSSL_SHA, 1, Using OpenSSL's SHA1 implementation.) ] ) AC_ARG_ENABLE(cyrus-rc4, [ --enable-cyrus-rc4=PFX Use Cyrus RC4 implementation.], [ CXXFLAGS="$CXXFLAGS -I${enableval}/include"; LIBS="$LIBS -lrc4 -L${enableval}/lib" AC_DEFINE(USE_CYRUS_RC4, 1, Using Cyrus RC4 implementation.) ] ) PKG_CHECK_MODULES(STUFF, sigc++-2.0, CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS"; LIBS="$LIBS $STUFF_LIBS") AC_CHECK_FUNCS(posix_memalign) TORRENT_CHECK_MADVISE() TORRENT_CHECK_CACHELINE() TORRENT_CHECK_POPCOUNT() TORRENT_MINCORE() TORRENT_OTFD() LIBTORRENT_LIBS="-ltorrent" AC_SUBST(LIBTORRENT_LIBS) LIBTORRENT_CFLAGS="" AC_SUBST(LIBTORRENT_CFLAGS) AC_DEFINE(HAVE_CONFIG_H, 1, true if config.h was included) CC_ATTRIBUTE_UNUSED( AC_DEFINE([__UNUSED], [__attribute__((unused))], [Wrapper around unused attribute]), AC_DEFINE([__UNUSED], [], [Null-wrapper if unused attribute is unsupported]) ) AC_OUTPUT([ libtorrent.pc Makefile src/Makefile src/torrent/Makefile src/torrent/peer/Makefile src/torrent/data/Makefile src/torrent/download/Makefile src/torrent/utils/Makefile src/data/Makefile src/dht/Makefile src/download/Makefile src/net/Makefile src/protocol/Makefile src/tracker/Makefile src/utils/Makefile test/Makefile ]) libtorrent-0.13.2/COPYING000644 000765 000024 00000043131 11705767056 015774 0ustar00rakshasastaff000000 000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. libtorrent-0.13.2/depcomp000755 000765 000024 00000047556 11706024320 016312 0ustar00rakshasastaff000000 000000 #! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2011-12-04.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/ \1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/ / G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libtorrent-0.13.2/doc/000755 000765 000024 00000000000 11744204512 015466 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/INSTALL000644 000765 000024 00000022030 11705767056 015765 0ustar00rakshasastaff000000 000000 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. (Caching is disabled by default to prevent problems with accidental use of stale cache files.) If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not support the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the `--target=TYPE' option to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc will cause the specified gcc to be used as the C compiler (unless it is overridden in the site shell script). `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. libtorrent-0.13.2/install-sh000755 000765 000024 00000033256 11706024320 016731 0ustar00rakshasastaff000000 000000 #!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libtorrent-0.13.2/libtorrent.pc.in000644 000765 000024 00000000315 11705767056 020053 0ustar00rakshasastaff000000 000000 prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libtorrent Description: A BitTorrent library Version: @VERSION@ Libs: -L${libdir} -ltorrent Cflags: -I${includedir} libtorrent-0.13.2/ltmain.sh000644 000765 000024 00001051522 11744204175 016554 0ustar00rakshasastaff000000 000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION=2.4.2 TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 libtorrent-0.13.2/Makefile.am000644 000765 000024 00000001141 11716350717 016762 0ustar00rakshasastaff000000 000000 SUBDIRS = src test pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libtorrent.pc EXTRA_DIST= \ autogen.sh \ scripts/checks.m4 \ scripts/common.m4 \ scripts/attributes.m4 \ doc/main.xml \ doc/http.xml \ doc/torrent.xml \ rak/address_info.h \ rak/algorithm.h \ rak/allocators.h \ rak/error_number.h \ rak/file_stat.h \ rak/fs_stat.h \ rak/functional.h \ rak/path.h \ rak/partial_queue.h \ rak/priority_queue.h \ rak/priority_queue_default.h \ rak/regex.h \ rak/socket_address.h \ rak/string_manip.h \ rak/timer.h \ rak/unordered_vector.h ACLOCAL_AMFLAGS = -I scripts libtorrent-0.13.2/Makefile.in000644 000765 000024 00000065240 11744204217 016777 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/libtorrent.pc.in $(top_srcdir)/configure AUTHORS \ COPYING ChangeLog INSTALL NEWS config.guess config.sub depcomp \ install-sh ltmain.sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = libtorrent.pc CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgconfigdir)" DATA = $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src test pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libtorrent.pc EXTRA_DIST = \ autogen.sh \ scripts/checks.m4 \ scripts/common.m4 \ scripts/attributes.m4 \ doc/main.xml \ doc/http.xml \ doc/torrent.xml \ rak/address_info.h \ rak/algorithm.h \ rak/allocators.h \ rak/error_number.h \ rak/file_stat.h \ rak/fs_stat.h \ rak/functional.h \ rak/path.h \ rak/partial_queue.h \ rak/priority_queue.h \ rak/priority_queue_default.h \ rak/regex.h \ rak/socket_address.h \ rak/string_manip.h \ rak/timer.h \ rak/unordered_vector.h ACLOCAL_AMFLAGS = -I scripts all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 libtorrent.pc: $(top_builddir)/config.status $(srcdir)/libtorrent.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(DATA) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-pkgconfigDATA install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-pkgconfigDATA .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-generic distclean-hdr \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-pkgconfigDATA install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am uninstall-pkgconfigDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/missing000755 000765 000024 00000026233 11706024320 016321 0ustar00rakshasastaff000000 000000 #! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # 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, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libtorrent-0.13.2/NEWS000644 000765 000024 00000000052 11705767056 015433 0ustar00rakshasastaff000000 000000 If you want news, watch CNN or something. libtorrent-0.13.2/rak/000755 000765 000024 00000000000 11744204512 015476 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/README000644 000765 000024 00000002273 11744202527 015611 0ustar00rakshasastaff000000 000000 LibTorrent LICENSE GNU GPL, see COPYING. "libtorrent/src/utils/sha_fast.{cc,h}" is originally from the Mozilla NSS and is under a triple license; MPL, LGPL and GPL. An exception to non-NSS code has been added for linking to OpenSSL as requested by Debian, though the author considers that library to be part of the Operative System and thus linking is allowed according to the GPL. Use whatever fits your purpose, the code required to compile with Mozilla's NSS implementation of SHA1 has been retained and can be compiled if the user wishes to avoid using OpenSSL. CONTACT Send bug reports, suggestions and patches to or to the mailinglist. LIBRARY DEPENDENCIES libsigc++ 2.0 (deb: libsigc++-2.0-dev) g++ >= 3.3 SIGC++ The API will use sigc++ signals to give the client a simple, yet powerful way of reacting to events from the library. The client can hook multiple slots on each signal and modify the parameters to suit the functions. This avoids lots of unnecessary code in the client. POLLING "libtorrent/src/torrent/poll.h" provides an abstract class for implementing any kind of polling the client wishes to use. Currently epoll and select based polling is included.libtorrent-0.13.2/scripts/000755 000765 000024 00000000000 11744204512 016410 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/000755 000765 000024 00000000000 11744204512 015510 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/test/000755 000765 000024 00000000000 11744204514 015702 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/test/data/000755 000765 000024 00000000000 11744204514 016613 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/test/main.cc000644 000765 000024 00000001375 11705767057 017160 0ustar00rakshasastaff000000 000000 #include #include #include int main(int argc, char* argv[]) { // Get the top level suite from the registry CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); // Adds the test to the list of test to run CppUnit::TextUi::TestRunner runner; runner.addTest( suite ); // Change the default outputter to a compiler error format outputter runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); // Run the tests. bool wasSucessful = runner.run(); // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; } libtorrent-0.13.2/test/Makefile.am000644 000765 000024 00000004252 11741025651 017741 0ustar00rakshasastaff000000 000000 TESTS = LibTorrentTest check_PROGRAMS = $(TESTS) LibTorrentTest_LDADD = \ ../src/libtorrent.la \ ../src/torrent/libsub_torrent.la \ ../src/torrent/data/libsub_torrentdata.la \ ../src/torrent/download/libsub_torrentdownload.la \ ../src/torrent/peer/libsub_torrentpeer.la \ ../src/data/libsub_data.la \ ../src/dht/libsub_dht.la \ ../src/download/libsub_download.la \ ../src/net/libsub_net.la \ ../src/protocol/libsub_protocol.la \ ../src/tracker/libsub_tracker.la \ ../src/utils/libsub_utils.la \ ../src/torrent/utils/libsub_torrentutils.la LibTorrentTest_SOURCES = \ ../src/thread_disk.cc \ ../src/thread_disk.h \ \ rak/allocators_test.cc \ rak/allocators_test.h \ rak/ranges_test.cc \ rak/ranges_test.h \ data/chunk_list_test.cc \ data/chunk_list_test.h \ data/hash_check_queue_test.cc \ data/hash_check_queue_test.h \ data/hash_queue_test.cc \ data/hash_queue_test.h \ torrent/http_test.cc \ torrent/http_test.h \ torrent/object_test.cc \ torrent/object_test.h \ torrent/object_test_utils.cc \ torrent/object_test_utils.h \ torrent/object_static_map_test.cc \ torrent/object_static_map_test.h \ torrent/object_stream_test.cc \ torrent/object_stream_test.h \ torrent/tracker_controller_test.cc \ torrent/tracker_controller_test.h \ torrent/tracker_controller_features.cc \ torrent/tracker_controller_features.h \ torrent/tracker_list_test.cc \ torrent/tracker_list_test.h \ torrent/tracker_list_features_test.cc \ torrent/tracker_list_features_test.h \ torrent/tracker_timeout_test.cc \ torrent/tracker_timeout_test.h \ torrent/utils/extents_test.cc \ torrent/utils/extents_test.h \ torrent/utils/log_test.cc \ torrent/utils/log_test.h \ torrent/utils/log_buffer_test.cc \ torrent/utils/log_buffer_test.h \ torrent/utils/option_strings_test.cc \ torrent/utils/option_strings_test.h \ torrent/utils/signal_bitfield_test.cc \ torrent/utils/signal_bitfield_test.h \ torrent/utils/thread_base_test.cc \ torrent/utils/thread_base_test.h \ tracker/tracker_http_test.cc \ tracker/tracker_http_test.h \ main.cc LibTorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS) LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS) -ldl INCLUDES = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src libtorrent-0.13.2/test/Makefile.in000644 000765 000024 00000232074 11744204217 017757 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ TESTS = LibTorrentTest$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) subdir = test DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__EXEEXT_1 = LibTorrentTest$(EXEEXT) am_LibTorrentTest_OBJECTS = LibTorrentTest-thread_disk.$(OBJEXT) \ LibTorrentTest-allocators_test.$(OBJEXT) \ LibTorrentTest-ranges_test.$(OBJEXT) \ LibTorrentTest-chunk_list_test.$(OBJEXT) \ LibTorrentTest-hash_check_queue_test.$(OBJEXT) \ LibTorrentTest-hash_queue_test.$(OBJEXT) \ LibTorrentTest-http_test.$(OBJEXT) \ LibTorrentTest-object_test.$(OBJEXT) \ LibTorrentTest-object_test_utils.$(OBJEXT) \ LibTorrentTest-object_static_map_test.$(OBJEXT) \ LibTorrentTest-object_stream_test.$(OBJEXT) \ LibTorrentTest-tracker_controller_test.$(OBJEXT) \ LibTorrentTest-tracker_controller_features.$(OBJEXT) \ LibTorrentTest-tracker_list_test.$(OBJEXT) \ LibTorrentTest-tracker_list_features_test.$(OBJEXT) \ LibTorrentTest-tracker_timeout_test.$(OBJEXT) \ LibTorrentTest-extents_test.$(OBJEXT) \ LibTorrentTest-log_test.$(OBJEXT) \ LibTorrentTest-log_buffer_test.$(OBJEXT) \ LibTorrentTest-option_strings_test.$(OBJEXT) \ LibTorrentTest-signal_bitfield_test.$(OBJEXT) \ LibTorrentTest-thread_base_test.$(OBJEXT) \ LibTorrentTest-tracker_http_test.$(OBJEXT) \ LibTorrentTest-main.$(OBJEXT) LibTorrentTest_OBJECTS = $(am_LibTorrentTest_OBJECTS) LibTorrentTest_DEPENDENCIES = ../src/libtorrent.la \ ../src/torrent/libsub_torrent.la \ ../src/torrent/data/libsub_torrentdata.la \ ../src/torrent/download/libsub_torrentdownload.la \ ../src/torrent/peer/libsub_torrentpeer.la \ ../src/data/libsub_data.la ../src/dht/libsub_dht.la \ ../src/download/libsub_download.la ../src/net/libsub_net.la \ ../src/protocol/libsub_protocol.la \ ../src/tracker/libsub_tracker.la ../src/utils/libsub_utils.la \ ../src/torrent/utils/libsub_torrentutils.la LibTorrentTest_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) \ $(LibTorrentTest_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(LibTorrentTest_SOURCES) DIST_SOURCES = $(LibTorrentTest_SOURCES) ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ LibTorrentTest_LDADD = \ ../src/libtorrent.la \ ../src/torrent/libsub_torrent.la \ ../src/torrent/data/libsub_torrentdata.la \ ../src/torrent/download/libsub_torrentdownload.la \ ../src/torrent/peer/libsub_torrentpeer.la \ ../src/data/libsub_data.la \ ../src/dht/libsub_dht.la \ ../src/download/libsub_download.la \ ../src/net/libsub_net.la \ ../src/protocol/libsub_protocol.la \ ../src/tracker/libsub_tracker.la \ ../src/utils/libsub_utils.la \ ../src/torrent/utils/libsub_torrentutils.la LibTorrentTest_SOURCES = \ ../src/thread_disk.cc \ ../src/thread_disk.h \ \ rak/allocators_test.cc \ rak/allocators_test.h \ rak/ranges_test.cc \ rak/ranges_test.h \ data/chunk_list_test.cc \ data/chunk_list_test.h \ data/hash_check_queue_test.cc \ data/hash_check_queue_test.h \ data/hash_queue_test.cc \ data/hash_queue_test.h \ torrent/http_test.cc \ torrent/http_test.h \ torrent/object_test.cc \ torrent/object_test.h \ torrent/object_test_utils.cc \ torrent/object_test_utils.h \ torrent/object_static_map_test.cc \ torrent/object_static_map_test.h \ torrent/object_stream_test.cc \ torrent/object_stream_test.h \ torrent/tracker_controller_test.cc \ torrent/tracker_controller_test.h \ torrent/tracker_controller_features.cc \ torrent/tracker_controller_features.h \ torrent/tracker_list_test.cc \ torrent/tracker_list_test.h \ torrent/tracker_list_features_test.cc \ torrent/tracker_list_features_test.h \ torrent/tracker_timeout_test.cc \ torrent/tracker_timeout_test.h \ torrent/utils/extents_test.cc \ torrent/utils/extents_test.h \ torrent/utils/log_test.cc \ torrent/utils/log_test.h \ torrent/utils/log_buffer_test.cc \ torrent/utils/log_buffer_test.h \ torrent/utils/option_strings_test.cc \ torrent/utils/option_strings_test.h \ torrent/utils/signal_bitfield_test.cc \ torrent/utils/signal_bitfield_test.h \ torrent/utils/thread_base_test.cc \ torrent/utils/thread_base_test.h \ tracker/tracker_http_test.cc \ tracker/tracker_http_test.h \ main.cc LibTorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS) LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS) -ldl INCLUDES = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu test/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list LibTorrentTest$(EXEEXT): $(LibTorrentTest_OBJECTS) $(LibTorrentTest_DEPENDENCIES) $(EXTRA_LibTorrentTest_DEPENDENCIES) @rm -f LibTorrentTest$(EXEEXT) $(LibTorrentTest_LINK) $(LibTorrentTest_OBJECTS) $(LibTorrentTest_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-allocators_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-chunk_list_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-extents_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-hash_check_queue_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-hash_queue_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-http_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-log_buffer_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-log_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-object_static_map_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-object_stream_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-object_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-object_test_utils.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-option_strings_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-ranges_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-signal_bitfield_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-thread_base_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-thread_disk.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-tracker_controller_features.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-tracker_controller_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-tracker_http_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-tracker_list_features_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-tracker_list_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibTorrentTest-tracker_timeout_test.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< LibTorrentTest-thread_disk.o: ../src/thread_disk.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-thread_disk.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-thread_disk.Tpo -c -o LibTorrentTest-thread_disk.o `test -f '../src/thread_disk.cc' || echo '$(srcdir)/'`../src/thread_disk.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-thread_disk.Tpo $(DEPDIR)/LibTorrentTest-thread_disk.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../src/thread_disk.cc' object='LibTorrentTest-thread_disk.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-thread_disk.o `test -f '../src/thread_disk.cc' || echo '$(srcdir)/'`../src/thread_disk.cc LibTorrentTest-thread_disk.obj: ../src/thread_disk.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-thread_disk.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-thread_disk.Tpo -c -o LibTorrentTest-thread_disk.obj `if test -f '../src/thread_disk.cc'; then $(CYGPATH_W) '../src/thread_disk.cc'; else $(CYGPATH_W) '$(srcdir)/../src/thread_disk.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-thread_disk.Tpo $(DEPDIR)/LibTorrentTest-thread_disk.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../src/thread_disk.cc' object='LibTorrentTest-thread_disk.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-thread_disk.obj `if test -f '../src/thread_disk.cc'; then $(CYGPATH_W) '../src/thread_disk.cc'; else $(CYGPATH_W) '$(srcdir)/../src/thread_disk.cc'; fi` LibTorrentTest-allocators_test.o: rak/allocators_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-allocators_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-allocators_test.Tpo -c -o LibTorrentTest-allocators_test.o `test -f 'rak/allocators_test.cc' || echo '$(srcdir)/'`rak/allocators_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-allocators_test.Tpo $(DEPDIR)/LibTorrentTest-allocators_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rak/allocators_test.cc' object='LibTorrentTest-allocators_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-allocators_test.o `test -f 'rak/allocators_test.cc' || echo '$(srcdir)/'`rak/allocators_test.cc LibTorrentTest-allocators_test.obj: rak/allocators_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-allocators_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-allocators_test.Tpo -c -o LibTorrentTest-allocators_test.obj `if test -f 'rak/allocators_test.cc'; then $(CYGPATH_W) 'rak/allocators_test.cc'; else $(CYGPATH_W) '$(srcdir)/rak/allocators_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-allocators_test.Tpo $(DEPDIR)/LibTorrentTest-allocators_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rak/allocators_test.cc' object='LibTorrentTest-allocators_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-allocators_test.obj `if test -f 'rak/allocators_test.cc'; then $(CYGPATH_W) 'rak/allocators_test.cc'; else $(CYGPATH_W) '$(srcdir)/rak/allocators_test.cc'; fi` LibTorrentTest-ranges_test.o: rak/ranges_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-ranges_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-ranges_test.Tpo -c -o LibTorrentTest-ranges_test.o `test -f 'rak/ranges_test.cc' || echo '$(srcdir)/'`rak/ranges_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-ranges_test.Tpo $(DEPDIR)/LibTorrentTest-ranges_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rak/ranges_test.cc' object='LibTorrentTest-ranges_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-ranges_test.o `test -f 'rak/ranges_test.cc' || echo '$(srcdir)/'`rak/ranges_test.cc LibTorrentTest-ranges_test.obj: rak/ranges_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-ranges_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-ranges_test.Tpo -c -o LibTorrentTest-ranges_test.obj `if test -f 'rak/ranges_test.cc'; then $(CYGPATH_W) 'rak/ranges_test.cc'; else $(CYGPATH_W) '$(srcdir)/rak/ranges_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-ranges_test.Tpo $(DEPDIR)/LibTorrentTest-ranges_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rak/ranges_test.cc' object='LibTorrentTest-ranges_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-ranges_test.obj `if test -f 'rak/ranges_test.cc'; then $(CYGPATH_W) 'rak/ranges_test.cc'; else $(CYGPATH_W) '$(srcdir)/rak/ranges_test.cc'; fi` LibTorrentTest-chunk_list_test.o: data/chunk_list_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-chunk_list_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-chunk_list_test.Tpo -c -o LibTorrentTest-chunk_list_test.o `test -f 'data/chunk_list_test.cc' || echo '$(srcdir)/'`data/chunk_list_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-chunk_list_test.Tpo $(DEPDIR)/LibTorrentTest-chunk_list_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='data/chunk_list_test.cc' object='LibTorrentTest-chunk_list_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-chunk_list_test.o `test -f 'data/chunk_list_test.cc' || echo '$(srcdir)/'`data/chunk_list_test.cc LibTorrentTest-chunk_list_test.obj: data/chunk_list_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-chunk_list_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-chunk_list_test.Tpo -c -o LibTorrentTest-chunk_list_test.obj `if test -f 'data/chunk_list_test.cc'; then $(CYGPATH_W) 'data/chunk_list_test.cc'; else $(CYGPATH_W) '$(srcdir)/data/chunk_list_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-chunk_list_test.Tpo $(DEPDIR)/LibTorrentTest-chunk_list_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='data/chunk_list_test.cc' object='LibTorrentTest-chunk_list_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-chunk_list_test.obj `if test -f 'data/chunk_list_test.cc'; then $(CYGPATH_W) 'data/chunk_list_test.cc'; else $(CYGPATH_W) '$(srcdir)/data/chunk_list_test.cc'; fi` LibTorrentTest-hash_check_queue_test.o: data/hash_check_queue_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-hash_check_queue_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-hash_check_queue_test.Tpo -c -o LibTorrentTest-hash_check_queue_test.o `test -f 'data/hash_check_queue_test.cc' || echo '$(srcdir)/'`data/hash_check_queue_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-hash_check_queue_test.Tpo $(DEPDIR)/LibTorrentTest-hash_check_queue_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='data/hash_check_queue_test.cc' object='LibTorrentTest-hash_check_queue_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-hash_check_queue_test.o `test -f 'data/hash_check_queue_test.cc' || echo '$(srcdir)/'`data/hash_check_queue_test.cc LibTorrentTest-hash_check_queue_test.obj: data/hash_check_queue_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-hash_check_queue_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-hash_check_queue_test.Tpo -c -o LibTorrentTest-hash_check_queue_test.obj `if test -f 'data/hash_check_queue_test.cc'; then $(CYGPATH_W) 'data/hash_check_queue_test.cc'; else $(CYGPATH_W) '$(srcdir)/data/hash_check_queue_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-hash_check_queue_test.Tpo $(DEPDIR)/LibTorrentTest-hash_check_queue_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='data/hash_check_queue_test.cc' object='LibTorrentTest-hash_check_queue_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-hash_check_queue_test.obj `if test -f 'data/hash_check_queue_test.cc'; then $(CYGPATH_W) 'data/hash_check_queue_test.cc'; else $(CYGPATH_W) '$(srcdir)/data/hash_check_queue_test.cc'; fi` LibTorrentTest-hash_queue_test.o: data/hash_queue_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-hash_queue_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-hash_queue_test.Tpo -c -o LibTorrentTest-hash_queue_test.o `test -f 'data/hash_queue_test.cc' || echo '$(srcdir)/'`data/hash_queue_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-hash_queue_test.Tpo $(DEPDIR)/LibTorrentTest-hash_queue_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='data/hash_queue_test.cc' object='LibTorrentTest-hash_queue_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-hash_queue_test.o `test -f 'data/hash_queue_test.cc' || echo '$(srcdir)/'`data/hash_queue_test.cc LibTorrentTest-hash_queue_test.obj: data/hash_queue_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-hash_queue_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-hash_queue_test.Tpo -c -o LibTorrentTest-hash_queue_test.obj `if test -f 'data/hash_queue_test.cc'; then $(CYGPATH_W) 'data/hash_queue_test.cc'; else $(CYGPATH_W) '$(srcdir)/data/hash_queue_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-hash_queue_test.Tpo $(DEPDIR)/LibTorrentTest-hash_queue_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='data/hash_queue_test.cc' object='LibTorrentTest-hash_queue_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-hash_queue_test.obj `if test -f 'data/hash_queue_test.cc'; then $(CYGPATH_W) 'data/hash_queue_test.cc'; else $(CYGPATH_W) '$(srcdir)/data/hash_queue_test.cc'; fi` LibTorrentTest-http_test.o: torrent/http_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-http_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-http_test.Tpo -c -o LibTorrentTest-http_test.o `test -f 'torrent/http_test.cc' || echo '$(srcdir)/'`torrent/http_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-http_test.Tpo $(DEPDIR)/LibTorrentTest-http_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/http_test.cc' object='LibTorrentTest-http_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-http_test.o `test -f 'torrent/http_test.cc' || echo '$(srcdir)/'`torrent/http_test.cc LibTorrentTest-http_test.obj: torrent/http_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-http_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-http_test.Tpo -c -o LibTorrentTest-http_test.obj `if test -f 'torrent/http_test.cc'; then $(CYGPATH_W) 'torrent/http_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/http_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-http_test.Tpo $(DEPDIR)/LibTorrentTest-http_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/http_test.cc' object='LibTorrentTest-http_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-http_test.obj `if test -f 'torrent/http_test.cc'; then $(CYGPATH_W) 'torrent/http_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/http_test.cc'; fi` LibTorrentTest-object_test.o: torrent/object_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_test.Tpo -c -o LibTorrentTest-object_test.o `test -f 'torrent/object_test.cc' || echo '$(srcdir)/'`torrent/object_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_test.Tpo $(DEPDIR)/LibTorrentTest-object_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_test.cc' object='LibTorrentTest-object_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_test.o `test -f 'torrent/object_test.cc' || echo '$(srcdir)/'`torrent/object_test.cc LibTorrentTest-object_test.obj: torrent/object_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_test.Tpo -c -o LibTorrentTest-object_test.obj `if test -f 'torrent/object_test.cc'; then $(CYGPATH_W) 'torrent/object_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_test.Tpo $(DEPDIR)/LibTorrentTest-object_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_test.cc' object='LibTorrentTest-object_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_test.obj `if test -f 'torrent/object_test.cc'; then $(CYGPATH_W) 'torrent/object_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_test.cc'; fi` LibTorrentTest-object_test_utils.o: torrent/object_test_utils.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_test_utils.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_test_utils.Tpo -c -o LibTorrentTest-object_test_utils.o `test -f 'torrent/object_test_utils.cc' || echo '$(srcdir)/'`torrent/object_test_utils.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_test_utils.Tpo $(DEPDIR)/LibTorrentTest-object_test_utils.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_test_utils.cc' object='LibTorrentTest-object_test_utils.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_test_utils.o `test -f 'torrent/object_test_utils.cc' || echo '$(srcdir)/'`torrent/object_test_utils.cc LibTorrentTest-object_test_utils.obj: torrent/object_test_utils.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_test_utils.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_test_utils.Tpo -c -o LibTorrentTest-object_test_utils.obj `if test -f 'torrent/object_test_utils.cc'; then $(CYGPATH_W) 'torrent/object_test_utils.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_test_utils.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_test_utils.Tpo $(DEPDIR)/LibTorrentTest-object_test_utils.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_test_utils.cc' object='LibTorrentTest-object_test_utils.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_test_utils.obj `if test -f 'torrent/object_test_utils.cc'; then $(CYGPATH_W) 'torrent/object_test_utils.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_test_utils.cc'; fi` LibTorrentTest-object_static_map_test.o: torrent/object_static_map_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_static_map_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_static_map_test.Tpo -c -o LibTorrentTest-object_static_map_test.o `test -f 'torrent/object_static_map_test.cc' || echo '$(srcdir)/'`torrent/object_static_map_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_static_map_test.Tpo $(DEPDIR)/LibTorrentTest-object_static_map_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_static_map_test.cc' object='LibTorrentTest-object_static_map_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_static_map_test.o `test -f 'torrent/object_static_map_test.cc' || echo '$(srcdir)/'`torrent/object_static_map_test.cc LibTorrentTest-object_static_map_test.obj: torrent/object_static_map_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_static_map_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_static_map_test.Tpo -c -o LibTorrentTest-object_static_map_test.obj `if test -f 'torrent/object_static_map_test.cc'; then $(CYGPATH_W) 'torrent/object_static_map_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_static_map_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_static_map_test.Tpo $(DEPDIR)/LibTorrentTest-object_static_map_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_static_map_test.cc' object='LibTorrentTest-object_static_map_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_static_map_test.obj `if test -f 'torrent/object_static_map_test.cc'; then $(CYGPATH_W) 'torrent/object_static_map_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_static_map_test.cc'; fi` LibTorrentTest-object_stream_test.o: torrent/object_stream_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_stream_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_stream_test.Tpo -c -o LibTorrentTest-object_stream_test.o `test -f 'torrent/object_stream_test.cc' || echo '$(srcdir)/'`torrent/object_stream_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_stream_test.Tpo $(DEPDIR)/LibTorrentTest-object_stream_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_stream_test.cc' object='LibTorrentTest-object_stream_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_stream_test.o `test -f 'torrent/object_stream_test.cc' || echo '$(srcdir)/'`torrent/object_stream_test.cc LibTorrentTest-object_stream_test.obj: torrent/object_stream_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-object_stream_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-object_stream_test.Tpo -c -o LibTorrentTest-object_stream_test.obj `if test -f 'torrent/object_stream_test.cc'; then $(CYGPATH_W) 'torrent/object_stream_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_stream_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-object_stream_test.Tpo $(DEPDIR)/LibTorrentTest-object_stream_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/object_stream_test.cc' object='LibTorrentTest-object_stream_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-object_stream_test.obj `if test -f 'torrent/object_stream_test.cc'; then $(CYGPATH_W) 'torrent/object_stream_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/object_stream_test.cc'; fi` LibTorrentTest-tracker_controller_test.o: torrent/tracker_controller_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_controller_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_controller_test.Tpo -c -o LibTorrentTest-tracker_controller_test.o `test -f 'torrent/tracker_controller_test.cc' || echo '$(srcdir)/'`torrent/tracker_controller_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_controller_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_controller_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_controller_test.cc' object='LibTorrentTest-tracker_controller_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_controller_test.o `test -f 'torrent/tracker_controller_test.cc' || echo '$(srcdir)/'`torrent/tracker_controller_test.cc LibTorrentTest-tracker_controller_test.obj: torrent/tracker_controller_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_controller_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_controller_test.Tpo -c -o LibTorrentTest-tracker_controller_test.obj `if test -f 'torrent/tracker_controller_test.cc'; then $(CYGPATH_W) 'torrent/tracker_controller_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_controller_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_controller_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_controller_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_controller_test.cc' object='LibTorrentTest-tracker_controller_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_controller_test.obj `if test -f 'torrent/tracker_controller_test.cc'; then $(CYGPATH_W) 'torrent/tracker_controller_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_controller_test.cc'; fi` LibTorrentTest-tracker_controller_features.o: torrent/tracker_controller_features.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_controller_features.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_controller_features.Tpo -c -o LibTorrentTest-tracker_controller_features.o `test -f 'torrent/tracker_controller_features.cc' || echo '$(srcdir)/'`torrent/tracker_controller_features.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_controller_features.Tpo $(DEPDIR)/LibTorrentTest-tracker_controller_features.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_controller_features.cc' object='LibTorrentTest-tracker_controller_features.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_controller_features.o `test -f 'torrent/tracker_controller_features.cc' || echo '$(srcdir)/'`torrent/tracker_controller_features.cc LibTorrentTest-tracker_controller_features.obj: torrent/tracker_controller_features.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_controller_features.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_controller_features.Tpo -c -o LibTorrentTest-tracker_controller_features.obj `if test -f 'torrent/tracker_controller_features.cc'; then $(CYGPATH_W) 'torrent/tracker_controller_features.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_controller_features.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_controller_features.Tpo $(DEPDIR)/LibTorrentTest-tracker_controller_features.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_controller_features.cc' object='LibTorrentTest-tracker_controller_features.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_controller_features.obj `if test -f 'torrent/tracker_controller_features.cc'; then $(CYGPATH_W) 'torrent/tracker_controller_features.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_controller_features.cc'; fi` LibTorrentTest-tracker_list_test.o: torrent/tracker_list_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_list_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_list_test.Tpo -c -o LibTorrentTest-tracker_list_test.o `test -f 'torrent/tracker_list_test.cc' || echo '$(srcdir)/'`torrent/tracker_list_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_list_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_list_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_list_test.cc' object='LibTorrentTest-tracker_list_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_list_test.o `test -f 'torrent/tracker_list_test.cc' || echo '$(srcdir)/'`torrent/tracker_list_test.cc LibTorrentTest-tracker_list_test.obj: torrent/tracker_list_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_list_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_list_test.Tpo -c -o LibTorrentTest-tracker_list_test.obj `if test -f 'torrent/tracker_list_test.cc'; then $(CYGPATH_W) 'torrent/tracker_list_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_list_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_list_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_list_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_list_test.cc' object='LibTorrentTest-tracker_list_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_list_test.obj `if test -f 'torrent/tracker_list_test.cc'; then $(CYGPATH_W) 'torrent/tracker_list_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_list_test.cc'; fi` LibTorrentTest-tracker_list_features_test.o: torrent/tracker_list_features_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_list_features_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_list_features_test.Tpo -c -o LibTorrentTest-tracker_list_features_test.o `test -f 'torrent/tracker_list_features_test.cc' || echo '$(srcdir)/'`torrent/tracker_list_features_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_list_features_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_list_features_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_list_features_test.cc' object='LibTorrentTest-tracker_list_features_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_list_features_test.o `test -f 'torrent/tracker_list_features_test.cc' || echo '$(srcdir)/'`torrent/tracker_list_features_test.cc LibTorrentTest-tracker_list_features_test.obj: torrent/tracker_list_features_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_list_features_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_list_features_test.Tpo -c -o LibTorrentTest-tracker_list_features_test.obj `if test -f 'torrent/tracker_list_features_test.cc'; then $(CYGPATH_W) 'torrent/tracker_list_features_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_list_features_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_list_features_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_list_features_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_list_features_test.cc' object='LibTorrentTest-tracker_list_features_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_list_features_test.obj `if test -f 'torrent/tracker_list_features_test.cc'; then $(CYGPATH_W) 'torrent/tracker_list_features_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_list_features_test.cc'; fi` LibTorrentTest-tracker_timeout_test.o: torrent/tracker_timeout_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_timeout_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_timeout_test.Tpo -c -o LibTorrentTest-tracker_timeout_test.o `test -f 'torrent/tracker_timeout_test.cc' || echo '$(srcdir)/'`torrent/tracker_timeout_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_timeout_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_timeout_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_timeout_test.cc' object='LibTorrentTest-tracker_timeout_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_timeout_test.o `test -f 'torrent/tracker_timeout_test.cc' || echo '$(srcdir)/'`torrent/tracker_timeout_test.cc LibTorrentTest-tracker_timeout_test.obj: torrent/tracker_timeout_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_timeout_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_timeout_test.Tpo -c -o LibTorrentTest-tracker_timeout_test.obj `if test -f 'torrent/tracker_timeout_test.cc'; then $(CYGPATH_W) 'torrent/tracker_timeout_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_timeout_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_timeout_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_timeout_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/tracker_timeout_test.cc' object='LibTorrentTest-tracker_timeout_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_timeout_test.obj `if test -f 'torrent/tracker_timeout_test.cc'; then $(CYGPATH_W) 'torrent/tracker_timeout_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/tracker_timeout_test.cc'; fi` LibTorrentTest-extents_test.o: torrent/utils/extents_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-extents_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-extents_test.Tpo -c -o LibTorrentTest-extents_test.o `test -f 'torrent/utils/extents_test.cc' || echo '$(srcdir)/'`torrent/utils/extents_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-extents_test.Tpo $(DEPDIR)/LibTorrentTest-extents_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/extents_test.cc' object='LibTorrentTest-extents_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-extents_test.o `test -f 'torrent/utils/extents_test.cc' || echo '$(srcdir)/'`torrent/utils/extents_test.cc LibTorrentTest-extents_test.obj: torrent/utils/extents_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-extents_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-extents_test.Tpo -c -o LibTorrentTest-extents_test.obj `if test -f 'torrent/utils/extents_test.cc'; then $(CYGPATH_W) 'torrent/utils/extents_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/extents_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-extents_test.Tpo $(DEPDIR)/LibTorrentTest-extents_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/extents_test.cc' object='LibTorrentTest-extents_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-extents_test.obj `if test -f 'torrent/utils/extents_test.cc'; then $(CYGPATH_W) 'torrent/utils/extents_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/extents_test.cc'; fi` LibTorrentTest-log_test.o: torrent/utils/log_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-log_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-log_test.Tpo -c -o LibTorrentTest-log_test.o `test -f 'torrent/utils/log_test.cc' || echo '$(srcdir)/'`torrent/utils/log_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-log_test.Tpo $(DEPDIR)/LibTorrentTest-log_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/log_test.cc' object='LibTorrentTest-log_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-log_test.o `test -f 'torrent/utils/log_test.cc' || echo '$(srcdir)/'`torrent/utils/log_test.cc LibTorrentTest-log_test.obj: torrent/utils/log_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-log_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-log_test.Tpo -c -o LibTorrentTest-log_test.obj `if test -f 'torrent/utils/log_test.cc'; then $(CYGPATH_W) 'torrent/utils/log_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/log_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-log_test.Tpo $(DEPDIR)/LibTorrentTest-log_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/log_test.cc' object='LibTorrentTest-log_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-log_test.obj `if test -f 'torrent/utils/log_test.cc'; then $(CYGPATH_W) 'torrent/utils/log_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/log_test.cc'; fi` LibTorrentTest-log_buffer_test.o: torrent/utils/log_buffer_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-log_buffer_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-log_buffer_test.Tpo -c -o LibTorrentTest-log_buffer_test.o `test -f 'torrent/utils/log_buffer_test.cc' || echo '$(srcdir)/'`torrent/utils/log_buffer_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-log_buffer_test.Tpo $(DEPDIR)/LibTorrentTest-log_buffer_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/log_buffer_test.cc' object='LibTorrentTest-log_buffer_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-log_buffer_test.o `test -f 'torrent/utils/log_buffer_test.cc' || echo '$(srcdir)/'`torrent/utils/log_buffer_test.cc LibTorrentTest-log_buffer_test.obj: torrent/utils/log_buffer_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-log_buffer_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-log_buffer_test.Tpo -c -o LibTorrentTest-log_buffer_test.obj `if test -f 'torrent/utils/log_buffer_test.cc'; then $(CYGPATH_W) 'torrent/utils/log_buffer_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/log_buffer_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-log_buffer_test.Tpo $(DEPDIR)/LibTorrentTest-log_buffer_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/log_buffer_test.cc' object='LibTorrentTest-log_buffer_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-log_buffer_test.obj `if test -f 'torrent/utils/log_buffer_test.cc'; then $(CYGPATH_W) 'torrent/utils/log_buffer_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/log_buffer_test.cc'; fi` LibTorrentTest-option_strings_test.o: torrent/utils/option_strings_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-option_strings_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-option_strings_test.Tpo -c -o LibTorrentTest-option_strings_test.o `test -f 'torrent/utils/option_strings_test.cc' || echo '$(srcdir)/'`torrent/utils/option_strings_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-option_strings_test.Tpo $(DEPDIR)/LibTorrentTest-option_strings_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/option_strings_test.cc' object='LibTorrentTest-option_strings_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-option_strings_test.o `test -f 'torrent/utils/option_strings_test.cc' || echo '$(srcdir)/'`torrent/utils/option_strings_test.cc LibTorrentTest-option_strings_test.obj: torrent/utils/option_strings_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-option_strings_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-option_strings_test.Tpo -c -o LibTorrentTest-option_strings_test.obj `if test -f 'torrent/utils/option_strings_test.cc'; then $(CYGPATH_W) 'torrent/utils/option_strings_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/option_strings_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-option_strings_test.Tpo $(DEPDIR)/LibTorrentTest-option_strings_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/option_strings_test.cc' object='LibTorrentTest-option_strings_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-option_strings_test.obj `if test -f 'torrent/utils/option_strings_test.cc'; then $(CYGPATH_W) 'torrent/utils/option_strings_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/option_strings_test.cc'; fi` LibTorrentTest-signal_bitfield_test.o: torrent/utils/signal_bitfield_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-signal_bitfield_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-signal_bitfield_test.Tpo -c -o LibTorrentTest-signal_bitfield_test.o `test -f 'torrent/utils/signal_bitfield_test.cc' || echo '$(srcdir)/'`torrent/utils/signal_bitfield_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-signal_bitfield_test.Tpo $(DEPDIR)/LibTorrentTest-signal_bitfield_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/signal_bitfield_test.cc' object='LibTorrentTest-signal_bitfield_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-signal_bitfield_test.o `test -f 'torrent/utils/signal_bitfield_test.cc' || echo '$(srcdir)/'`torrent/utils/signal_bitfield_test.cc LibTorrentTest-signal_bitfield_test.obj: torrent/utils/signal_bitfield_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-signal_bitfield_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-signal_bitfield_test.Tpo -c -o LibTorrentTest-signal_bitfield_test.obj `if test -f 'torrent/utils/signal_bitfield_test.cc'; then $(CYGPATH_W) 'torrent/utils/signal_bitfield_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/signal_bitfield_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-signal_bitfield_test.Tpo $(DEPDIR)/LibTorrentTest-signal_bitfield_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/signal_bitfield_test.cc' object='LibTorrentTest-signal_bitfield_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-signal_bitfield_test.obj `if test -f 'torrent/utils/signal_bitfield_test.cc'; then $(CYGPATH_W) 'torrent/utils/signal_bitfield_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/signal_bitfield_test.cc'; fi` LibTorrentTest-thread_base_test.o: torrent/utils/thread_base_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-thread_base_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-thread_base_test.Tpo -c -o LibTorrentTest-thread_base_test.o `test -f 'torrent/utils/thread_base_test.cc' || echo '$(srcdir)/'`torrent/utils/thread_base_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-thread_base_test.Tpo $(DEPDIR)/LibTorrentTest-thread_base_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/thread_base_test.cc' object='LibTorrentTest-thread_base_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-thread_base_test.o `test -f 'torrent/utils/thread_base_test.cc' || echo '$(srcdir)/'`torrent/utils/thread_base_test.cc LibTorrentTest-thread_base_test.obj: torrent/utils/thread_base_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-thread_base_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-thread_base_test.Tpo -c -o LibTorrentTest-thread_base_test.obj `if test -f 'torrent/utils/thread_base_test.cc'; then $(CYGPATH_W) 'torrent/utils/thread_base_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/thread_base_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-thread_base_test.Tpo $(DEPDIR)/LibTorrentTest-thread_base_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='torrent/utils/thread_base_test.cc' object='LibTorrentTest-thread_base_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-thread_base_test.obj `if test -f 'torrent/utils/thread_base_test.cc'; then $(CYGPATH_W) 'torrent/utils/thread_base_test.cc'; else $(CYGPATH_W) '$(srcdir)/torrent/utils/thread_base_test.cc'; fi` LibTorrentTest-tracker_http_test.o: tracker/tracker_http_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_http_test.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_http_test.Tpo -c -o LibTorrentTest-tracker_http_test.o `test -f 'tracker/tracker_http_test.cc' || echo '$(srcdir)/'`tracker/tracker_http_test.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_http_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_http_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='tracker/tracker_http_test.cc' object='LibTorrentTest-tracker_http_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_http_test.o `test -f 'tracker/tracker_http_test.cc' || echo '$(srcdir)/'`tracker/tracker_http_test.cc LibTorrentTest-tracker_http_test.obj: tracker/tracker_http_test.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-tracker_http_test.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-tracker_http_test.Tpo -c -o LibTorrentTest-tracker_http_test.obj `if test -f 'tracker/tracker_http_test.cc'; then $(CYGPATH_W) 'tracker/tracker_http_test.cc'; else $(CYGPATH_W) '$(srcdir)/tracker/tracker_http_test.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-tracker_http_test.Tpo $(DEPDIR)/LibTorrentTest-tracker_http_test.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='tracker/tracker_http_test.cc' object='LibTorrentTest-tracker_http_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-tracker_http_test.obj `if test -f 'tracker/tracker_http_test.cc'; then $(CYGPATH_W) 'tracker/tracker_http_test.cc'; else $(CYGPATH_W) '$(srcdir)/tracker/tracker_http_test.cc'; fi` LibTorrentTest-main.o: main.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-main.o -MD -MP -MF $(DEPDIR)/LibTorrentTest-main.Tpo -c -o LibTorrentTest-main.o `test -f 'main.cc' || echo '$(srcdir)/'`main.cc @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-main.Tpo $(DEPDIR)/LibTorrentTest-main.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='main.cc' object='LibTorrentTest-main.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-main.o `test -f 'main.cc' || echo '$(srcdir)/'`main.cc LibTorrentTest-main.obj: main.cc @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -MT LibTorrentTest-main.obj -MD -MP -MF $(DEPDIR)/LibTorrentTest-main.Tpo -c -o LibTorrentTest-main.obj `if test -f 'main.cc'; then $(CYGPATH_W) 'main.cc'; else $(CYGPATH_W) '$(srcdir)/main.cc'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/LibTorrentTest-main.Tpo $(DEPDIR)/LibTorrentTest-main.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='main.cc' object='LibTorrentTest-main.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(LibTorrentTest_CXXFLAGS) $(CXXFLAGS) -c -o LibTorrentTest-main.obj `if test -f 'main.cc'; then $(CYGPATH_W) 'main.cc'; else $(CYGPATH_W) '$(srcdir)/main.cc'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ col="$$grn"; \ else \ col="$$red"; \ fi; \ echo "$${col}$$dashes$${std}"; \ echo "$${col}$$banner$${std}"; \ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ test -z "$$report" || echo "$${col}$$report$${std}"; \ echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool ctags \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/test/rak/000755 000765 000024 00000000000 11744204514 016457 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/test/torrent/000755 000765 000024 00000000000 11744204514 017377 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/test/tracker/000755 000765 000024 00000000000 11744204514 017335 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/test/tracker/tracker_http_test.cc000644 000765 000024 00000000316 11705767057 023412 0ustar00rakshasastaff000000 000000 #include "config.h" #include "tracker_http_test.h" #include "tracker/tracker_http.h" void tracker_http_test::setUp() { } void tracker_http_test::tearDown() { } void tracker_http_test::test_basic() { } libtorrent-0.13.2/test/tracker/tracker_http_test.h000644 000765 000024 00000000543 11705767057 023256 0ustar00rakshasastaff000000 000000 #include #include "tracker/tracker_http.h" class tracker_http_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(tracker_http_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_scrape); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_scrape(); }; libtorrent-0.13.2/test/torrent/http_test.cc000644 000765 000024 00000011067 11716350717 021737 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include "http_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(HttpTest); #define HTTP_SETUP() \ bool http_destroyed = false; \ bool stream_destroyed = false; \ \ TestHttp* test_http = new TestHttp(&http_destroyed); \ torrent::Http* http = test_http; \ std::stringstream* http_stream = new StringStream(&stream_destroyed); \ \ int done_counter = 0; \ int failed_counter = 0; \ \ http->set_stream(http_stream); \ http->signal_done().push_back(std::tr1::bind(&increment_value, &done_counter)); \ http->signal_failed().push_back(std::tr1::bind(&increment_value, &failed_counter)); class StringStream : public std::stringstream { public: StringStream(bool *destroyed) : m_destroyed(destroyed) {} ~StringStream() { *m_destroyed = true; } private: bool* m_destroyed; }; class TestHttp : public torrent::Http { public: static const int flag_active = 0x1; TestHttp(bool *destroyed = NULL) : m_flags(0), m_destroyed(destroyed) {} virtual ~TestHttp() { if (m_destroyed) *m_destroyed = true; } virtual void start() { m_flags |= flag_active; } virtual void close() { m_flags &= ~flag_active; } bool trigger_signal_done(); bool trigger_signal_failed(); private: int m_flags; bool* m_destroyed; }; bool TestHttp::trigger_signal_done() { if (!(m_flags & flag_active)) return false; m_flags &= ~flag_active; trigger_done(); return true; } bool TestHttp::trigger_signal_failed() { if (!(m_flags & flag_active)) return false; m_flags &= ~flag_active; trigger_failed("We Fail."); return true; } TestHttp* create_test_http() { return new TestHttp; } static void increment_value(int* value) { (*value)++; } void HttpTest::test_basic() { torrent::Http::slot_factory() = std::tr1::bind(&create_test_http); torrent::Http* http = torrent::Http::slot_factory()(); std::stringstream* http_stream = new std::stringstream; http->set_url("http://example.com"); CPPUNIT_ASSERT(http->url() == "http://example.com"); CPPUNIT_ASSERT(http->stream() == NULL); http->set_stream(http_stream); CPPUNIT_ASSERT(http->stream() == http_stream); CPPUNIT_ASSERT(http->timeout() == 0); http->set_timeout(666); CPPUNIT_ASSERT(http->timeout() == 666); delete http; delete http_stream; } void HttpTest::test_done() { HTTP_SETUP(); http->start(); CPPUNIT_ASSERT(test_http->trigger_signal_done()); // Check that we didn't delete... CPPUNIT_ASSERT(done_counter == 1 && failed_counter == 0); } void HttpTest::test_failure() { HTTP_SETUP(); http->start(); CPPUNIT_ASSERT(test_http->trigger_signal_failed()); // Check that we didn't delete... CPPUNIT_ASSERT(done_counter == 0 && failed_counter == 1); } void HttpTest::test_delete_on_done() { HTTP_SETUP(); http->start(); http->set_delete_stream(); CPPUNIT_ASSERT(!stream_destroyed); CPPUNIT_ASSERT(!http_destroyed); CPPUNIT_ASSERT(test_http->trigger_signal_done()); CPPUNIT_ASSERT(stream_destroyed); CPPUNIT_ASSERT(!http_destroyed); CPPUNIT_ASSERT(http->stream() == NULL); stream_destroyed = false; http_stream = new StringStream(&stream_destroyed); http->set_stream(http_stream); http->start(); http->set_delete_self(); CPPUNIT_ASSERT(!stream_destroyed); CPPUNIT_ASSERT(!http_destroyed); CPPUNIT_ASSERT(test_http->trigger_signal_done()); CPPUNIT_ASSERT(stream_destroyed); CPPUNIT_ASSERT(http_destroyed); } void HttpTest::test_delete_on_failure() { HTTP_SETUP(); http->start(); http->set_delete_stream(); CPPUNIT_ASSERT(!stream_destroyed); CPPUNIT_ASSERT(!http_destroyed); CPPUNIT_ASSERT(test_http->trigger_signal_failed()); CPPUNIT_ASSERT(stream_destroyed); CPPUNIT_ASSERT(!http_destroyed); CPPUNIT_ASSERT(http->stream() == NULL); stream_destroyed = false; http_stream = new StringStream(&stream_destroyed); http->set_stream(http_stream); http->start(); http->set_delete_self(); CPPUNIT_ASSERT(!stream_destroyed); CPPUNIT_ASSERT(!http_destroyed); CPPUNIT_ASSERT(test_http->trigger_signal_failed()); CPPUNIT_ASSERT(stream_destroyed); CPPUNIT_ASSERT(http_destroyed); } libtorrent-0.13.2/test/torrent/http_test.h000644 000765 000024 00000001014 11705767057 021577 0ustar00rakshasastaff000000 000000 #include #include "torrent/http.h" class HttpTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(HttpTest); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_done); CPPUNIT_TEST(test_failure); CPPUNIT_TEST(test_delete_on_done); CPPUNIT_TEST(test_delete_on_failure); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void test_basic(); void test_done(); void test_failure(); void test_delete_on_done(); void test_delete_on_failure(); }; libtorrent-0.13.2/test/torrent/object_static_map_test.cc000644 000765 000024 00000033015 11716350717 024427 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "torrent/object_static_map.h" #include "protocol/extensions.h" #include "object_test_utils.h" #include "object_static_map_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(ObjectStaticMapTest); // Possible bencode keys in a DHT message. enum keys { key_d_a, key_d_d_a, key_d_b, key_e_0, key_e_1, key_e_2, key_s_a, key_s_b, key_v_a, key_v_b, key_LAST, }; enum keys_2 { key_2_d_x_y, key_2_d_x_z, key_2_l_x_1, key_2_l_x_2, key_2_s_a, key_2_v_a, key_2_LAST }; typedef torrent::static_map_type test_map_type; typedef torrent::static_map_type test_map_2_type; // List of all possible keys we need/support in a DHT message. // Unsupported keys we receive are dropped (ignored) while decoding. // See torrent/object_static_map.h for how this works. template <> const test_map_type::key_list_type test_map_type::keys = { { key_d_a, "d_a::b" }, { key_d_d_a, "d_a::c::a" }, { key_d_b, "d_a::d" }, { key_e_0, "e[]" }, { key_e_1, "e[]" }, { key_e_2, "e[]" }, { key_s_a, "s_a" }, { key_s_b, "s_b" }, { key_v_a, "v_a" }, { key_v_b, "v_b" }, }; template <> const test_map_2_type::key_list_type test_map_2_type::keys = { { key_2_d_x_y, "d_x::f" }, { key_2_d_x_z, "d_x::g" }, { key_2_l_x_1, "l_x[]" }, { key_2_l_x_2, "l_x[]" }, { key_2_s_a, "s_a" }, { key_2_v_a, "v_a" }, }; void ObjectStaticMapTest::test_basics() { test_map_type test_map; test_map[key_v_a] = int64_t(1); test_map[key_v_b] = int64_t(2); test_map[key_s_a] = std::string("a"); test_map[key_s_b] = std::string("b"); CPPUNIT_ASSERT(test_map[key_v_a].as_value() == 1); CPPUNIT_ASSERT(test_map[key_v_b].as_value() == 2); CPPUNIT_ASSERT(test_map[key_s_a].as_string() == "a"); CPPUNIT_ASSERT(test_map[key_s_b].as_string() == "b"); } void ObjectStaticMapTest::test_write() { test_map_type test_map; test_map[key_v_a] = int64_t(1); test_map[key_v_b] = int64_t(2); test_map[key_s_a] = std::string("a"); // test_map[key_s_b] = std::string("b"); test_map[key_d_a] = std::string("xx"); test_map[key_d_d_a] = std::string("a"); test_map[key_d_b] = std::string("yy"); test_map[key_e_0] = std::string("f"); test_map[key_e_1] = torrent::object_create_raw_bencode_c_str("1:g"); test_map[key_e_2] = std::string("h"); char buffer[1024]; torrent::object_buffer_t result = torrent::static_map_write_bencode_c(torrent::object_write_to_buffer, NULL, std::make_pair(buffer, buffer + sizeof(buffer)), test_map); // std::cout << "static map write: '" << std::string(buffer, std::distance(buffer, result.first)) << "'" << std::endl; CPPUNIT_ASSERT(validate_bencode(buffer, result.first)); } static const char* test_read_bencode = "d3:d_xd1:fi3e1:gli4ei5eee3:l_xli1ei2ei3ee3:s_a1:a3:v_ai2ee"; static const char* test_read_skip_bencode = "d3:d_xd1:fi3e1:gli4ei5eee1:fi1e3:l_xli1ei2ei3ee3:s_a1:a3:v_ai2ee"; template bool static_map_read_bencode(map_type& map, const char* str) { try { return torrent::static_map_read_bencode(str, str + strlen(str), map) == str + strlen(str); } catch (torrent::bencode_error&) { return false; } } template bool static_map_read_bencode_exception(map_type& map, const char* str) { try { torrent::static_map_read_bencode(str, str + strlen(str), map); return false; } catch (torrent::bencode_error&) { return true; } } void ObjectStaticMapTest::test_read() { test_map_2_type test_map; CPPUNIT_ASSERT(static_map_read_bencode(test_map, test_read_bencode)); CPPUNIT_ASSERT(test_map[key_2_d_x_y].as_value() == 3); CPPUNIT_ASSERT(test_map[key_2_d_x_z].as_list().size() == 2); CPPUNIT_ASSERT(test_map[key_2_l_x_1].as_value() == 1); CPPUNIT_ASSERT(test_map[key_2_l_x_2].as_value() == 2); CPPUNIT_ASSERT(test_map[key_2_s_a].as_string() == "a"); CPPUNIT_ASSERT(test_map[key_2_v_a].as_value() == 2); test_map_2_type test_skip_map; CPPUNIT_ASSERT(static_map_read_bencode(test_skip_map, test_read_skip_bencode)); } enum ext_test_keys { key_e, // key_m_utMetadata, key_m_utPex, // key_metadataSize, key_p, key_reqq, key_v, key_test_LAST }; typedef torrent::static_map_type ext_test_message; template <> const ext_test_message::key_list_type ext_test_message::keys = { { key_e, "e" }, { key_m_utPex, "m::ut_pex" }, { key_p, "p" }, { key_reqq, "reqq" }, { key_v, "v" }, }; void ObjectStaticMapTest::test_read_extensions() { ext_test_message test_ext; CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:ai1ee")); CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:mi1ee")); CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:mdee")); CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d6:ut_pexi0ee")); CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:md6:ut_pexi0eee")); } template bool static_map_write_bencode(map_type map, const char* original) { try { char buffer[1023]; char* last = torrent::static_map_write_bencode_c(&torrent::object_write_to_buffer, NULL, torrent::object_buffer_t(buffer, buffer + 1024), map).first; return std::strncmp(buffer, original, std::distance(buffer, last)) == 0; } catch (torrent::bencode_error& e) { return false; } } // // Proper unit tests: // enum keys_empty { key_empty_LAST }; enum keys_single { key_single_a, key_single_LAST }; enum keys_raw { key_raw_a, key_raw_LAST }; enum keys_raw_types { key_raw_types_empty, key_raw_types_list, key_raw_types_map, key_raw_types_str, key_raw_types_LAST}; enum keys_multiple { key_multiple_a, key_multiple_b, key_multiple_c, key_multiple_LAST }; enum keys_dict { key_dict_a_b, key_dict_LAST }; typedef torrent::static_map_type test_empty_type; typedef torrent::static_map_type test_single_type; typedef torrent::static_map_type test_raw_type; typedef torrent::static_map_type test_raw_types_type; typedef torrent::static_map_type test_multiple_type; typedef torrent::static_map_type test_dict_type; template <> const test_empty_type::key_list_type test_empty_type::keys = { }; template <> const test_single_type::key_list_type test_single_type::keys = { { key_single_a, "b" } }; template <> const test_raw_type::key_list_type test_raw_type::keys = { { key_raw_a, "b*" } }; template <> const test_raw_types_type::key_list_type test_raw_types_type::keys = { { key_raw_types_empty, "e*"}, { key_raw_types_list, "l*L"}, { key_raw_types_map, "m*M"}, { key_raw_types_str, "s*S"} }; template <> const test_multiple_type::key_list_type test_multiple_type::keys = { { key_multiple_a, "a" }, { key_multiple_b, "b*" }, { key_multiple_c, "c" } }; template <> const test_dict_type::key_list_type test_dict_type::keys = { { key_dict_a_b, "a::b" } }; void ObjectStaticMapTest::test_read_empty() { test_empty_type map_normal; test_empty_type map_skip; test_empty_type map_incomplete; CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "de")); CPPUNIT_ASSERT(static_map_read_bencode(map_skip, "d1:ai1ee")); CPPUNIT_ASSERT(static_map_read_bencode_exception(map_incomplete, "")); CPPUNIT_ASSERT(static_map_read_bencode_exception(map_incomplete, "d")); } void ObjectStaticMapTest::test_read_single() { test_single_type map_normal; test_single_type map_skip; test_single_type map_incomplete; CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:bi1ee")); CPPUNIT_ASSERT(map_normal[key_single_a].as_value() == 1); CPPUNIT_ASSERT(static_map_read_bencode(map_skip, "d1:ai0e1:bi1e1:ci2ee")); CPPUNIT_ASSERT(map_skip[key_single_a].as_value() == 1); CPPUNIT_ASSERT(static_map_read_bencode_exception(map_incomplete, "d")); CPPUNIT_ASSERT(static_map_read_bencode_exception(map_incomplete, "d1:b")); CPPUNIT_ASSERT(static_map_read_bencode_exception(map_incomplete, "d1:bi1")); CPPUNIT_ASSERT(static_map_read_bencode_exception(map_incomplete, "d1:bi1e")); } void ObjectStaticMapTest::test_read_single_raw() { test_raw_type map_raw; CPPUNIT_ASSERT(static_map_read_bencode(map_raw, "d1:bi1ee")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode(), "i1e")); CPPUNIT_ASSERT(static_map_read_bencode(map_raw, "d1:b2:abe")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode(), "2:ab")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode().as_raw_string(), "ab")); CPPUNIT_ASSERT(static_map_read_bencode(map_raw, "d1:bli1ei2eee")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode(), "li1ei2ee")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode().as_raw_list(), "i1ei2e")); CPPUNIT_ASSERT(static_map_read_bencode(map_raw, "d1:bd1:ai1e1:bi2eee")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode(), "d1:ai1e1:bi2ee")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode().as_raw_map(), "1:ai1e1:bi2e")); } void ObjectStaticMapTest::test_read_raw_types() { test_raw_types_type map_raw; CPPUNIT_ASSERT(static_map_read_bencode(map_raw, "d" "1:ei1e" "1:lli1ei2ee" "1:md1:ai1e1:bi2ee" "1:s2:ab" "e")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_types_empty].as_raw_bencode(), "i1e")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_types_str].as_raw_string(), "ab")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_types_list].as_raw_list(), "i1ei2e")); CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_types_map].as_raw_map(), "1:ai1e1:bi2e")); } void ObjectStaticMapTest::test_read_multiple() { test_multiple_type map_normal; CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ai1ee")); CPPUNIT_ASSERT(map_normal[key_multiple_a].as_value() == 1); CPPUNIT_ASSERT(map_normal[key_multiple_b].is_empty()); CPPUNIT_ASSERT(map_normal[key_multiple_c].is_empty()); map_normal = test_multiple_type(); CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ci3ee")); CPPUNIT_ASSERT(map_normal[key_multiple_a].is_empty()); CPPUNIT_ASSERT(map_normal[key_multiple_b].is_empty()); CPPUNIT_ASSERT(map_normal[key_multiple_c].as_value() == 3); map_normal = test_multiple_type(); CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ai1e1:ci3ee")); CPPUNIT_ASSERT(map_normal[key_multiple_a].as_value() == 1); CPPUNIT_ASSERT(map_normal[key_multiple_b].is_empty()); CPPUNIT_ASSERT(map_normal[key_multiple_c].as_value() == 3); map_normal = test_multiple_type(); CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ai1e1:bi2e1:ci3ee")); CPPUNIT_ASSERT(map_normal[key_multiple_a].as_value() == 1); // CPPUNIT_ASSERT(map_normal[key_multiple_b].as_raw_bencode().as_raw_value().size() == 1); // CPPUNIT_ASSERT(map_normal[key_multiple_b].as_raw_bencode().as_raw_value().data()[0] == '2'); CPPUNIT_ASSERT(map_normal[key_multiple_c].as_value() == 3); } void ObjectStaticMapTest::test_read_dict() { test_dict_type map_normal; CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ai1ee")); CPPUNIT_ASSERT(map_normal[key_dict_a_b].is_empty()); CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:adee")); CPPUNIT_ASSERT(map_normal[key_dict_a_b].is_empty()); CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ad1:bi1eee")); CPPUNIT_ASSERT(map_normal[key_dict_a_b].as_value() == 1); } void ObjectStaticMapTest::test_write_empty() { test_empty_type map_normal; CPPUNIT_ASSERT(static_map_write_bencode(map_normal, "de")); } void ObjectStaticMapTest::test_write_single() { test_single_type map_value; CPPUNIT_ASSERT(static_map_write_bencode(map_value, "de")); map_value[key_single_a] = (int64_t)1; CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bi1ee")); map_value[key_single_a] = "test"; CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:b4:teste")); map_value[key_single_a] = torrent::Object::create_list(); map_value[key_single_a].as_list().push_back("test"); CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bl4:testee")); map_value[key_single_a] = torrent::raw_bencode("i1e", 3); CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bi1ee")); // map_value[key_single_a] = torrent::raw_value("1", 1); // CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bi1ee")); map_value[key_single_a] = torrent::raw_string("test", 4); CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:b4:teste")); map_value[key_single_a] = torrent::raw_list("1:a2:bb", strlen("1:a2:bb")); CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bl1:a2:bbee")); map_value[key_single_a] = torrent::raw_map("1:a2:bb", strlen("1:a2:bb")); CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bd1:a2:bbee")); } void ObjectStaticMapTest::test_write_multiple() { // test_multiple_type map_value; // CPPUNIT_ASSERT(static_map_write_bencode(map_value, "de")); } libtorrent-0.13.2/test/torrent/object_static_map_test.h000644 000765 000024 00000002060 11705767057 024274 0ustar00rakshasastaff000000 000000 #include #include "torrent/object.h" class ObjectStaticMapTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ObjectStaticMapTest); CPPUNIT_TEST(test_basics); CPPUNIT_TEST(test_write); CPPUNIT_TEST(test_read); CPPUNIT_TEST(test_read_extensions); CPPUNIT_TEST(test_read_empty); CPPUNIT_TEST(test_read_single); CPPUNIT_TEST(test_read_single_raw); CPPUNIT_TEST(test_read_raw_types); CPPUNIT_TEST(test_read_multiple); CPPUNIT_TEST(test_read_dict); CPPUNIT_TEST(test_write_empty); CPPUNIT_TEST(test_write_single); CPPUNIT_TEST(test_write_multiple); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void test_basics(); void test_write(); void test_read(); void test_read_extensions(); // Proper unit tests: void test_read_empty(); void test_read_single(); void test_read_single_raw(); void test_read_raw_types(); void test_read_multiple(); void test_read_dict(); void test_write_empty(); void test_write_single(); void test_write_multiple(); }; libtorrent-0.13.2/test/torrent/object_stream_test.cc000644 000765 000024 00000016060 11736251430 023571 0ustar00rakshasastaff000000 000000 #include "config.h" #define __STDC_CONSTANT_MACROS #include #include #include #include #include "object_stream_test.h" #include "object_test_utils.h" CPPUNIT_TEST_SUITE_REGISTRATION(ObjectStreamTest); static const char* ordered_bencode = "d1:ei0e4:ipv44:XXXX4:ipv616:XXXXXXXXXXXXXXXX1:md11:upload_onlyi3e12:ut_holepunchi4e11:ut_metadatai2e6:ut_pexi1ee13:metadata_sizei15408e1:pi16033e4:reqqi255e1:v15:uuTorrent 1.8.46:yourip4:XXXXe"; static const char* unordered_bencode = "d1:ei0e1:md11:upload_onlyi3e12:ut_holepunchi4e11:ut_metadatai2e6:ut_pexi1ee4:ipv44:XXXX4:ipv616:XXXXXXXXXXXXXXXX13:metadata_sizei15408e1:pi16033e4:reqqi255e1:v15:uuTorrent 1.8.46:yourip4:XXXXe"; static const char* string_bencode = "32:aaaaaaaabbbbbbbbccccccccdddddddd"; void ObjectStreamTest::testInputOrdered() { torrent::Object orderedObj = create_bencode(ordered_bencode); torrent::Object unorderedObj = create_bencode(unordered_bencode); CPPUNIT_ASSERT(!(orderedObj.flags() & torrent::Object::flag_unordered)); CPPUNIT_ASSERT(unorderedObj.flags() & torrent::Object::flag_unordered); } void ObjectStreamTest::testInputNullKey() { torrent::Object obj = create_bencode("d0:i1e5:filesi2ee"); CPPUNIT_ASSERT(!(obj.flags() & torrent::Object::flag_unordered)); } void ObjectStreamTest::testOutputMask() { torrent::Object normalObj = create_bencode("d1:ai1e1:bi2e1:ci3ee"); CPPUNIT_ASSERT(compare_bencode(normalObj, "d1:ai1e1:bi2e1:ci3ee")); normalObj.get_key("b").set_flags(torrent::Object::flag_session_data); normalObj.get_key("c").set_flags(torrent::Object::flag_static_data); CPPUNIT_ASSERT(compare_bencode(normalObj, "d1:ai1e1:ci3ee", torrent::Object::flag_session_data)); } // // Testing for bugs in bencode write. // // Dummy function that invalidates the buffer once called. torrent::object_buffer_t object_write_to_invalidate(void* data, torrent::object_buffer_t buffer) { return torrent::object_buffer_t(buffer.second, buffer.second); } void ObjectStreamTest::testBuffer() { char raw_buffer[16]; torrent::object_buffer_t buffer(raw_buffer, raw_buffer + 16); torrent::Object obj = create_bencode(string_bencode); object_write_bencode_c(&object_write_to_invalidate, NULL, buffer, &obj); } static const char* single_level_bencode = "d1:ai1e1:bi2e1:cl1:ai1e1:bi2eee"; void ObjectStreamTest::testReadBencodeC() { torrent::Object orderedObj = create_bencode_c(ordered_bencode); torrent::Object unorderedObj = create_bencode_c(unordered_bencode); CPPUNIT_ASSERT(!(orderedObj.flags() & torrent::Object::flag_unordered)); CPPUNIT_ASSERT(unorderedObj.flags() & torrent::Object::flag_unordered); CPPUNIT_ASSERT(compare_bencode(orderedObj, ordered_bencode)); // torrent::Object single_level = create_bencode_c(single_level_bencode); torrent::Object single_level = create_bencode_c(single_level_bencode); CPPUNIT_ASSERT(compare_bencode(single_level, single_level_bencode)); } bool object_write_bencode(const torrent::Object& obj, const char* original) { try { char buffer[1025]; char* last = torrent::object_write_bencode(buffer, buffer + 1024, &obj).first; return std::strncmp(buffer, original, std::distance(buffer, last)) == 0; } catch (torrent::bencode_error& e) { return false; } } bool object_stream_read_skip(const char* input) { try { torrent::Object tmp; return torrent::object_read_bencode_c(input, input + strlen(input), &tmp) == input + strlen(input) && torrent::object_read_bencode_skip_c(input, input + strlen(input)) == input + strlen(input); } catch (torrent::bencode_error& e) { return false; } } bool object_stream_read_skip_catch(const char* input) { try { torrent::Object tmp; torrent::object_read_bencode_c(input, input + strlen(input), &tmp); std::cout << "(N)"; return false; } catch (torrent::bencode_error& e) { } try { torrent::object_read_bencode_skip_c(input, input + strlen(input)); std::cout << "(S)"; return false; } catch (torrent::bencode_error& e) { return true; } } void ObjectStreamTest::test_read_skip() { CPPUNIT_ASSERT(object_stream_read_skip("i0e")); CPPUNIT_ASSERT(object_stream_read_skip("i9999e")); CPPUNIT_ASSERT(object_stream_read_skip("i-1e")); CPPUNIT_ASSERT(object_stream_read_skip("i-9999e")); CPPUNIT_ASSERT(object_stream_read_skip("0:")); CPPUNIT_ASSERT(object_stream_read_skip("4:test")); CPPUNIT_ASSERT(object_stream_read_skip("le")); CPPUNIT_ASSERT(object_stream_read_skip("li1ee")); CPPUNIT_ASSERT(object_stream_read_skip("llee")); CPPUNIT_ASSERT(object_stream_read_skip("ll1:a1:bel1:c1:dee")); CPPUNIT_ASSERT(object_stream_read_skip("de")); CPPUNIT_ASSERT(object_stream_read_skip("d1:ai1e1:b1:xe")); CPPUNIT_ASSERT(object_stream_read_skip("d1:ali1eee")); CPPUNIT_ASSERT(object_stream_read_skip("d1:ad1:bi1eee")); CPPUNIT_ASSERT(object_stream_read_skip("d1:md6:ut_pexi0eee")); } void ObjectStreamTest::test_read_skip_invalid() { CPPUNIT_ASSERT(object_stream_read_skip_catch("")); CPPUNIT_ASSERT(object_stream_read_skip_catch("i")); CPPUNIT_ASSERT(object_stream_read_skip_catch("1")); CPPUNIT_ASSERT(object_stream_read_skip_catch("d")); CPPUNIT_ASSERT(object_stream_read_skip_catch("i-0e")); CPPUNIT_ASSERT(object_stream_read_skip_catch("i--1e")); CPPUNIT_ASSERT(object_stream_read_skip_catch("-1")); CPPUNIT_ASSERT(object_stream_read_skip_catch("-1a")); CPPUNIT_ASSERT(object_stream_read_skip_catch("llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll" "llllllll")); } void ObjectStreamTest::test_write() { torrent::Object obj; CPPUNIT_ASSERT(object_write_bencode(torrent::Object(), "")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object((int64_t)0), "i0e")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object((int64_t)1), "i1e")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object((int64_t)-1), "i-1e")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object(INT64_C(123456789012345)), "i123456789012345e")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object(INT64_C(-123456789012345)), "i-123456789012345e")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object("test"), "4:test")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object::create_list(), "le")); CPPUNIT_ASSERT(object_write_bencode(torrent::Object::create_map(), "de")); obj = torrent::Object::create_map(); obj.as_map()["a"] = (int64_t)1; CPPUNIT_ASSERT(object_write_bencode(obj, "d1:ai1ee")); obj.as_map()["b"] = "test"; CPPUNIT_ASSERT(object_write_bencode(obj, "d1:ai1e1:b4:teste")); obj.as_map()["c"] = torrent::Object::create_list(); obj.as_map()["c"].as_list().push_back("foo"); CPPUNIT_ASSERT(object_write_bencode(obj, "d1:ai1e1:b4:test1:cl3:fooee")); obj.as_map()["c"].as_list().push_back(torrent::Object()); obj.as_map()["d"] = torrent::Object(); CPPUNIT_ASSERT(object_write_bencode(obj, "d1:ai1e1:b4:test1:cl3:fooee")); } libtorrent-0.13.2/test/torrent/object_stream_test.h000644 000765 000024 00000001332 11705767057 023444 0ustar00rakshasastaff000000 000000 #include #include "torrent/object_stream.h" class ObjectStreamTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ObjectStreamTest); CPPUNIT_TEST(testInputOrdered); CPPUNIT_TEST(testInputNullKey); CPPUNIT_TEST(testOutputMask); CPPUNIT_TEST(testBuffer); CPPUNIT_TEST(testReadBencodeC); CPPUNIT_TEST(test_read_skip); CPPUNIT_TEST(test_read_skip_invalid); CPPUNIT_TEST(test_write); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void testInputOrdered(); void testInputNullKey(); void testOutputMask(); void testBuffer(); void testReadBencodeC(); void test_read_skip(); void test_read_skip_invalid(); void test_write(); }; libtorrent-0.13.2/test/torrent/object_test.cc000644 000765 000024 00000011623 11716350717 022224 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "object_test.h" #include "object_test_utils.h" CPPUNIT_TEST_SUITE_REGISTRATION(ObjectTest); void object_test_return_void() { } // template // struct object_void_wrapper { // typedef // object_void_wrapper(Slot s) : m_slot(s) {} // torrent::Object operator () () { m_slot( // Slot m_slot; // } void ObjectTest::test_basic() { // std::cout << "sizeof(torrent::Object) = " << sizeof(torrent::Object) << std::endl; // std::cout << "sizeof(torrent::Object::list_type) = " << sizeof(torrent::Object::list_type) << std::endl; // std::cout << "sizeof(torrent::Object::map_type) = " << sizeof(torrent::Object::map_type) << std::endl; // torrent::Object obj_void(object_test_return_void()); } void ObjectTest::test_flags() { torrent::Object objectFlagsValue = torrent::Object(int64_t()); torrent::Object objectNoFlagsEmpty = torrent::Object(); torrent::Object objectNoFlagsValue = torrent::Object(int64_t()); objectFlagsValue.set_flags(torrent::Object::flag_static_data | torrent::Object::flag_session_data); CPPUNIT_ASSERT(objectNoFlagsEmpty.flags() == 0); CPPUNIT_ASSERT(objectNoFlagsValue.flags() == 0); CPPUNIT_ASSERT(objectFlagsValue.flags() & torrent::Object::flag_session_data && objectFlagsValue.flags() & torrent::Object::flag_static_data); objectFlagsValue.unset_flags(torrent::Object::flag_session_data); CPPUNIT_ASSERT(!(objectFlagsValue.flags() & torrent::Object::flag_session_data) && objectFlagsValue.flags() & torrent::Object::flag_static_data); } void ObjectTest::test_merge() { } #define TEST_VALUE_A "i10e" #define TEST_VALUE_B "i20e" #define TEST_STRING_A "1:g" #define TEST_STRING_B "1:h" #define TEST_MAP_A "d1:ai1e1:bi2ee" #define TEST_MAP_B "d1:ci4e1:di5ee" #define TEST_LIST_A "l1:e1:fe" #define TEST_LIST_B "li1ei2ee" static bool swap_compare(const char* left, const char* right) { torrent::Object obj_left = create_bencode(left); torrent::Object obj_right = create_bencode(right); obj_left.swap(obj_right); if (!compare_bencode(obj_left, right) || !compare_bencode(obj_right, left)) return false; obj_left.swap(obj_right); if (!compare_bencode(obj_left, left) || !compare_bencode(obj_right, right)) return false; return true; } static bool swap_compare_dict_key(const char* left_key, const char* left_obj, const char* right_key, const char* right_obj) { torrent::Object obj_left = torrent::Object::create_dict_key(); torrent::Object obj_right = torrent::Object::create_dict_key(); obj_left.as_dict_key() = left_key; obj_left.as_dict_obj() = create_bencode(left_obj); obj_right.as_dict_key() = right_key; obj_right.as_dict_obj() = create_bencode(right_obj); obj_left.swap(obj_right); if (obj_left.as_dict_key() != right_key || !compare_bencode(obj_left.as_dict_obj(), right_obj) || obj_right.as_dict_key() != left_key || !compare_bencode(obj_right.as_dict_obj(), left_obj)) return false; obj_left.swap(obj_right); if (obj_left.as_dict_key() != left_key || !compare_bencode(obj_left.as_dict_obj(), left_obj) || obj_right.as_dict_key() != right_key || !compare_bencode(obj_right.as_dict_obj(), right_obj)) return false; return true; } void ObjectTest::test_swap_and_move() { CPPUNIT_ASSERT(swap_compare(TEST_VALUE_A, TEST_VALUE_B)); CPPUNIT_ASSERT(swap_compare(TEST_STRING_A, TEST_STRING_B)); CPPUNIT_ASSERT(swap_compare(TEST_MAP_A, TEST_MAP_B)); CPPUNIT_ASSERT(swap_compare(TEST_LIST_A, TEST_LIST_B)); CPPUNIT_ASSERT(swap_compare(TEST_VALUE_A, TEST_STRING_B)); CPPUNIT_ASSERT(swap_compare(TEST_STRING_A, TEST_MAP_B)); CPPUNIT_ASSERT(swap_compare(TEST_MAP_A, TEST_LIST_B)); CPPUNIT_ASSERT(swap_compare(TEST_LIST_A, TEST_VALUE_B)); CPPUNIT_ASSERT(swap_compare("i1e", TEST_VALUE_A)); CPPUNIT_ASSERT(swap_compare("i1e", TEST_MAP_A)); CPPUNIT_ASSERT(swap_compare("i1e", TEST_LIST_A)); CPPUNIT_ASSERT(swap_compare_dict_key("a", TEST_VALUE_A, "b", TEST_STRING_B)); CPPUNIT_ASSERT(swap_compare_dict_key("a", TEST_STRING_A, "b", TEST_STRING_B)); } void ObjectTest::test_create_normal() { torrent::Object obj; CPPUNIT_ASSERT(torrent::object_create_normal(create_bencode_raw_bencode_c("i45e")).as_value() == 45); CPPUNIT_ASSERT(torrent::object_create_normal(create_bencode_raw_bencode_c("4:test")).as_string() == "test"); CPPUNIT_ASSERT(torrent::object_create_normal(create_bencode_raw_bencode_c("li5ee")).as_list().front().as_value() == 5); CPPUNIT_ASSERT(torrent::object_create_normal(create_bencode_raw_bencode_c("d1:ai6ee")).as_map()["a"].as_value() == 6); CPPUNIT_ASSERT(torrent::object_create_normal(create_bencode_raw_string_c("test")).as_string() == "test"); CPPUNIT_ASSERT(torrent::object_create_normal(create_bencode_raw_list_c("i5ei6e")).as_list().back().as_value() == 6); CPPUNIT_ASSERT(torrent::object_create_normal(create_bencode_raw_map_c("1:ai2e1:bi3e")).as_map()["b"].as_value() == 3); } libtorrent-0.13.2/test/torrent/object_test.h000644 000765 000024 00000000753 11705767057 022077 0ustar00rakshasastaff000000 000000 #include #include "torrent/object.h" class ObjectTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ObjectTest); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_flags); CPPUNIT_TEST(test_swap_and_move); CPPUNIT_TEST(test_create_normal); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void test_basic(); void test_flags(); void test_merge(); void test_swap_and_move(); void test_create_normal(); }; libtorrent-0.13.2/test/torrent/object_test_utils.cc000644 000765 000024 00000002706 11716350717 023446 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "torrent/object_stream.h" #include "object_test_utils.h" torrent::Object create_bencode(const char* str) { torrent::Object obj; std::stringstream stream(str); stream >> obj; CPPUNIT_ASSERT(!stream.fail()); return obj; } torrent::Object create_bencode_c(const char* str) { torrent::Object obj; const char* last = str + strlen(str); CPPUNIT_ASSERT(object_read_bencode_c(str, last, &obj) == last); return obj; } // torrent::Object // create_bencode_raw_bencode_c(const char* str) { // torrent::Object obj; // const char* last = str + strlen(str); // CPPUNIT_ASSERT(object_read_bencode_skip_c(str, last) == last); // return torrent::raw_bencode(str, std::distance(str, last)); // } // torrent::Object // create_bencode_raw_list_c(const char* str) { // torrent::Object obj; // const char* last = str + strlen(str); // CPPUNIT_ASSERT(object_read_bencode_skip_c(str, last) == last); // return torrent::raw_bencode(str, std::distance(str, last)); // } bool validate_bencode(const char* first, const char* last) { torrent::Object obj; return object_read_bencode_c(first, last, &obj) == last; } bool compare_bencode(const torrent::Object& obj, const char* str, uint32_t skip_mask) { char buffer[256]; std::memset(buffer, 0, 256); torrent::object_write_bencode(buffer, buffer + 256, &obj, skip_mask); return strcmp(buffer, str) == 0; } libtorrent-0.13.2/test/torrent/object_test_utils.h000644 000765 000024 00000001422 11705767057 023311 0ustar00rakshasastaff000000 000000 #include #include "torrent/object.h" torrent::Object create_bencode(const char* str); torrent::Object create_bencode_c(const char* str); inline torrent::Object create_bencode_raw_bencode_c(const char* str) { return torrent::raw_bencode(str, std::strlen(str)); } inline torrent::Object create_bencode_raw_string_c(const char* str) { return torrent::raw_string(str, std::strlen(str)); } inline torrent::Object create_bencode_raw_list_c(const char* str) { return torrent::raw_list(str, std::strlen(str)); } inline torrent::Object create_bencode_raw_map_c(const char* str) { return torrent::raw_map(str, std::strlen(str)); } bool validate_bencode(const char* first, const char* last); bool compare_bencode(const torrent::Object& obj, const char* str, uint32_t skip_mask = 0); libtorrent-0.13.2/test/torrent/tracker_controller_features.cc000644 000765 000024 00000023740 11741025651 025510 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "rak/priority_queue_default.h" #include "globals.h" #include "tracker_list_test.h" #include "tracker_controller_features.h" namespace tr1 { using namespace std::tr1; } CPPUNIT_TEST_SUITE_REGISTRATION(tracker_controller_features); void tracker_controller_features::setUp() { CPPUNIT_ASSERT(torrent::taskScheduler.empty()); torrent::cachedTime = rak::timer::current(); } void tracker_controller_features::tearDown() { torrent::taskScheduler.clear(); } void tracker_controller_features::test_requesting_basic() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_0_0->trigger_success(8, 9)); tracker_controller.start_requesting(); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("00111", "00111"); // CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(tracker_1_0->trigger_success()); CPPUNIT_ASSERT(tracker_2_0->trigger_success()); CPPUNIT_ASSERT(tracker_3_0->trigger_success()); // TODO: Change this so that requesting state results in tracker // requests from many peers. Also, add a limit so we don't keep // requesting from spent trackers. // Next timeout should be soon... CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 30)); TEST_MULTI3_IS_BUSY("10111", "10111"); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); tracker_controller.stop_requesting(); TEST_MULTIPLE_END(5, 0); } void tracker_controller_features::test_requesting_timeout() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); tracker_controller.start_requesting(); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("10111", "10111"); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() == 5); // CPPUNIT_ASSERT(tracker_0_1->trigger_failure()); CPPUNIT_ASSERT(tracker_1_0->trigger_failure()); CPPUNIT_ASSERT(tracker_2_0->trigger_failure()); CPPUNIT_ASSERT(tracker_3_0->trigger_failure()); // CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("01000", "01000"); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 5)); TEST_MULTI3_IS_BUSY("01111", "01111"); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() == 30); TEST_MULTIPLE_END(1, 4); } void tracker_controller_features::test_promiscious_timeout() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(start); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 3)); TEST_MULTI3_IS_BUSY("10111", "10111"); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(!(tracker_controller.flags() & torrent::TrackerController::flag_promiscuous_mode)); // CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT(tracker_1_0->trigger_success()); CPPUNIT_ASSERT(tracker_2_0->trigger_success()); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_3_0->trigger_success()); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, tracker_0_0->normal_interval())); TEST_MULTIPLE_END(4, 0); } // Fix failure event handler so that it properly handles multi-request // situations. This includes fixing old tests. void tracker_controller_features::test_promiscious_failed() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(start); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::flag_promiscuous_mode)); TEST_MULTI3_IS_BUSY("01111", "01111"); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_3_0->trigger_failure()); torrent::cachedTime += rak::timer::from_seconds(2); CPPUNIT_ASSERT(tracker_2_0->trigger_failure()); TEST_MULTI3_IS_BUSY("01100", "01100"); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 3)); TEST_MULTI3_IS_BUSY("01101", "01101"); CPPUNIT_ASSERT(tracker_0_1->trigger_failure()); CPPUNIT_ASSERT(tracker_1_0->trigger_failure()); CPPUNIT_ASSERT(tracker_3_0->trigger_failure()); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); CPPUNIT_ASSERT(!tracker_list.has_active()); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); TEST_MULTIPLE_END(0, 7); } void tracker_controller_features::test_scrape_basic() { TEST_MULTI3_BEGIN(); tracker_controller.disable(); CPPUNIT_ASSERT(!tracker_controller.task_scrape()->is_queued()); tracker_0_1->set_can_scrape(); tracker_1_0->set_can_scrape(); tracker_controller.scrape_request(0); TEST_MULTI3_IS_BUSY("00000", "00000"); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_controller.task_scrape()->is_queued()); CPPUNIT_ASSERT(tracker_0_1->latest_event() == torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_1_0->latest_event() == torrent::Tracker::EVENT_NONE); TEST_GOTO_NEXT_SCRAPE(0); TEST_MULTI3_IS_BUSY("01100", "01100"); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(!tracker_controller.task_scrape()->is_queued()); CPPUNIT_ASSERT(tracker_0_1->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(tracker_1_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(tracker_0_1->trigger_scrape()); CPPUNIT_ASSERT(tracker_1_0->trigger_scrape()); TEST_MULTI3_IS_BUSY("00000", "00000"); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(!tracker_controller.task_scrape()->is_queued()); CPPUNIT_ASSERT(tracker_0_1->scrape_time_last() != 0); CPPUNIT_ASSERT(tracker_1_0->scrape_time_last() != 0); TEST_SINGLE_END(0, 0); } void tracker_controller_features::test_scrape_priority() { TEST_SINGLE_BEGIN(); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); tracker_0_0->trigger_success(); tracker_0_0->set_can_scrape(); tracker_controller.scrape_request(0); TEST_GOTO_NEXT_SCRAPE(0); CPPUNIT_ASSERT(tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_0_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); // Check the other event types too? tracker_controller.send_update_event(); CPPUNIT_ASSERT(tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_0_0->latest_event() == torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(!tracker_controller.task_scrape()->is_queued()); tracker_0_0->trigger_success(); CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() > 1); torrent::cachedTime += rak::timer::from_seconds(tracker_controller.seconds_to_next_timeout() - 1); rak::priority_queue_perform(&torrent::taskScheduler, torrent::cachedTime); tracker_controller.scrape_request(0); TEST_GOTO_NEXT_SCRAPE(0); CPPUNIT_ASSERT(tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_0_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 1)); CPPUNIT_ASSERT(tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_0_0->latest_event() == torrent::Tracker::EVENT_NONE); TEST_SINGLE_END(2, 0); } void tracker_controller_features::test_groups_requesting() { TEST_GROUP_BEGIN(); TEST_SEND_SINGLE_BEGIN(start); // CPPUNIT_ASSERT(tracker_0_0->trigger_success(10, 20)); tracker_controller.start_requesting(); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_GROUP_IS_BUSY("100101", "100101"); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(tracker_1_0->trigger_success()); CPPUNIT_ASSERT(tracker_2_0->trigger_success()); // TODO: Change this so that requesting state results in tracker // requests from many peers. Also, add a limit so we don't keep // requesting from spent trackers. // Next timeout should be soon... CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 30)); TEST_GROUP_IS_BUSY("100101", "100101"); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(tracker_1_0->trigger_success()); CPPUNIT_ASSERT(tracker_2_0->trigger_success()); // Once we've requested twice, it should stop requesting from that tier. CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 30)); TEST_GROUP_IS_BUSY("000000", "000000"); tracker_controller.stop_requesting(); TEST_MULTIPLE_END(6, 0); } void tracker_controller_features::test_groups_scrape() { TEST_GROUP_BEGIN(); tracker_controller.disable(); tracker_0_0->set_can_scrape(); tracker_0_1->set_can_scrape(); tracker_0_2->set_can_scrape(); tracker_1_0->set_can_scrape(); tracker_1_1->set_can_scrape(); tracker_2_0->set_can_scrape(); CPPUNIT_ASSERT(!tracker_controller.task_scrape()->is_queued()); tracker_controller.scrape_request(0); TEST_GROUP_IS_BUSY("000000", "000000"); TEST_GOTO_NEXT_SCRAPE(0); CPPUNIT_ASSERT(tracker_0_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(tracker_0_1->latest_event() == torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_0_2->latest_event() == torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_1_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(tracker_1_1->latest_event() == torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_2_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); TEST_GROUP_IS_BUSY("100101", "100101"); CPPUNIT_ASSERT(tracker_0_0->trigger_scrape()); CPPUNIT_ASSERT(tracker_1_0->trigger_scrape()); CPPUNIT_ASSERT(tracker_2_0->trigger_scrape()); // Test with a non-can_scrape !busy tracker? // TEST_GROUP_IS_BUSY("100101", "100101"); // CPPUNIT_ASSERT(tracker_0_0->trigger_scrape()); // CPPUNIT_ASSERT(tracker_0_1->trigger_scrape()); // CPPUNIT_ASSERT(tracker_0_2->trigger_scrape()); // CPPUNIT_ASSERT(tracker_1_0->trigger_scrape()); // CPPUNIT_ASSERT(tracker_1_1->trigger_scrape()); // CPPUNIT_ASSERT(tracker_2_0->trigger_scrape()); TEST_GROUP_IS_BUSY("000000", "000000"); TEST_MULTIPLE_END(0, 0); } libtorrent-0.13.2/test/torrent/tracker_controller_features.h000644 000765 000024 00000001523 11741025651 025345 0ustar00rakshasastaff000000 000000 #include #include "tracker_controller_test.h" class tracker_controller_features : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(tracker_controller_features); CPPUNIT_TEST(test_requesting_basic); CPPUNIT_TEST(test_requesting_timeout); CPPUNIT_TEST(test_promiscious_timeout); CPPUNIT_TEST(test_promiscious_failed); CPPUNIT_TEST(test_scrape_basic); CPPUNIT_TEST(test_scrape_priority); CPPUNIT_TEST(test_groups_requesting); CPPUNIT_TEST(test_groups_scrape); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_requesting_basic(); void test_requesting_timeout(); void test_promiscious_timeout(); void test_promiscious_failed(); void test_scrape_basic(); void test_scrape_priority(); void test_groups_requesting(); void test_groups_scrape(); }; libtorrent-0.13.2/test/torrent/tracker_controller_test.cc000644 000765 000024 00000042307 11741025651 024651 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "rak/priority_queue_default.h" #include "globals.h" #include "tracker_list_test.h" #include "tracker_controller_test.h" namespace tr1 { using namespace std::tr1; } CPPUNIT_TEST_SUITE_REGISTRATION(tracker_controller_test); bool test_goto_next_timeout(torrent::TrackerController* tracker_controller, uint32_t assumed_timeout) { if (!tracker_controller->task_timeout()->is_queued()) { std::cout << "(nq)"; return false; } if (assumed_timeout != tracker_controller->seconds_to_next_timeout()) { std::cout << '(' << assumed_timeout << "!=" << tracker_controller->seconds_to_next_timeout() << ')'; return false; } torrent::cachedTime += rak::timer::from_seconds(tracker_controller->seconds_to_next_timeout()); rak::priority_queue_perform(&torrent::taskScheduler, torrent::cachedTime); return true; } void tracker_controller_test::setUp() { CPPUNIT_ASSERT(torrent::taskScheduler.empty()); torrent::cachedTime = rak::timer::current(); } void tracker_controller_test::tearDown() { torrent::taskScheduler.clear(); } void tracker_controller_test::test_basic() { torrent::TrackerController tracker_controller(NULL); CPPUNIT_ASSERT(tracker_controller.flags() == 0); CPPUNIT_ASSERT(!tracker_controller.is_active()); CPPUNIT_ASSERT(!tracker_controller.is_requesting()); } void tracker_controller_test::test_enable() { torrent::TrackerList tracker_list; torrent::TrackerController tracker_controller(&tracker_list); tracker_controller.enable(); CPPUNIT_ASSERT(tracker_controller.is_active()); CPPUNIT_ASSERT(!tracker_controller.is_requesting()); } void tracker_controller_test::test_requesting() { torrent::TrackerList tracker_list; torrent::TrackerController tracker_controller(&tracker_list); tracker_controller.enable(); tracker_controller.start_requesting(); CPPUNIT_ASSERT(tracker_controller.is_active()); CPPUNIT_ASSERT(tracker_controller.is_requesting()); tracker_controller.stop_requesting(); CPPUNIT_ASSERT(tracker_controller.is_active()); CPPUNIT_ASSERT(!tracker_controller.is_requesting()); } void tracker_controller_test::test_timeout() { TRACKER_CONTROLLER_SETUP(); TRACKER_INSERT(0, tracker_0_0); CPPUNIT_ASSERT(enabled_counter == 1); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); tracker_controller.enable(); rak::priority_queue_perform(&torrent::taskScheduler, torrent::cachedTime); CPPUNIT_ASSERT(timeout_counter == 1); TEST_SINGLE_END(0, 0); } void tracker_controller_test::test_single_success() { TEST_SINGLE_BEGIN(); tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(success_counter == 1 && failure_counter == 0); tracker_list.send_state_idx(0, 2); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); TEST_SINGLE_END(1, 1); } #define TEST_SINGLE_FAILURE_TIMEOUT(test_interval) \ rak::priority_queue_perform(&torrent::taskScheduler, torrent::cachedTime); \ CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); \ CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() == test_interval); \ torrent::cachedTime += rak::timer::from_seconds(test_interval); void tracker_controller_test::test_single_failure() { torrent::cachedTime = rak::timer::from_seconds(1 << 20); TEST_SINGLE_BEGIN(); TEST_SINGLE_FAILURE_TIMEOUT(5); TEST_SINGLE_FAILURE_TIMEOUT(10); TEST_SINGLE_FAILURE_TIMEOUT(20); TEST_SINGLE_FAILURE_TIMEOUT(40); TEST_SINGLE_FAILURE_TIMEOUT(80); TEST_SINGLE_FAILURE_TIMEOUT(160); TEST_SINGLE_FAILURE_TIMEOUT(320); TEST_SINGLE_FAILURE_TIMEOUT(320); // TODO: Test with cachedTime not rounded to second. // Test also with a low timer value... // torrent::cachedTime = rak::timer::from_seconds(1000); TEST_SINGLE_END(0, 4); } void tracker_controller_test::test_single_disable() { TEST_SINGLE_BEGIN(); tracker_list.send_state_idx(0, 0); TEST_SINGLE_END(0, 0); } void tracker_controller_test::test_send_start() { TEST_SINGLE_BEGIN(); TEST_SEND_SINGLE_BEGIN(start); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_0_0->requesting_state() == torrent::Tracker::EVENT_STARTED); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(!(tracker_controller.flags() & torrent::TrackerController::mask_send)); CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() != 0); tracker_controller.send_start_event(); tracker_controller.disable(); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); TEST_SEND_SINGLE_END(1, 0); } void tracker_controller_test::test_send_stop_normal() { TEST_SINGLE_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); tracker_controller.send_stop_event(); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == torrent::TrackerController::flag_send_stop); CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() == 0); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == 0); tracker_controller.send_stop_event(); tracker_controller.disable(); CPPUNIT_ASSERT(tracker_0_0->is_busy()); tracker_0_0->trigger_success(); TEST_SEND_SINGLE_END(3, 0); } // send_stop during request and right after start, send stop failed. void tracker_controller_test::test_send_completed_normal() { TEST_SINGLE_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); tracker_controller.send_completed_event(); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == torrent::TrackerController::flag_send_completed); CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() == 0); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == 0); tracker_controller.send_completed_event(); tracker_controller.disable(); CPPUNIT_ASSERT(tracker_0_0->is_busy()); tracker_0_0->trigger_success(); TEST_SEND_SINGLE_END(3, 0); } void tracker_controller_test::test_send_update_normal() { TEST_SINGLE_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == torrent::TrackerController::flag_send_update); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_0_0->latest_event() == torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); TEST_SEND_SINGLE_END(1, 0); } void tracker_controller_test::test_send_task_timeout() { TEST_SINGLE_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); TEST_SEND_SINGLE_END(0, 0); } void tracker_controller_test::test_send_close_on_enable() { TRACKER_CONTROLLER_SETUP(); TRACKER_INSERT(0, tracker_0); TRACKER_INSERT(0, tracker_1); TRACKER_INSERT(0, tracker_2); TRACKER_INSERT(0, tracker_3); tracker_list.send_state_idx(0, torrent::Tracker::EVENT_NONE); tracker_list.send_state_idx(1, torrent::Tracker::EVENT_STARTED); tracker_list.send_state_idx(2, torrent::Tracker::EVENT_STOPPED); tracker_list.send_state_idx(3, torrent::Tracker::EVENT_COMPLETED); tracker_controller.enable(); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_1->is_busy()); CPPUNIT_ASSERT(!tracker_2->is_busy()); CPPUNIT_ASSERT(tracker_3->is_busy()); } void tracker_controller_test::test_multiple_success() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, tracker_0_0->normal_interval())); TEST_MULTI3_IS_BUSY("10000", "10000"); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, tracker_0_0->normal_interval())); TEST_MULTI3_IS_BUSY("10000", "10000"); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(!tracker_list.has_active()); CPPUNIT_ASSERT(tracker_0_0->success_counter() == 3); TEST_MULTIPLE_END(3, 0); } void tracker_controller_test::test_multiple_failure() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); CPPUNIT_ASSERT(!tracker_controller.is_failure_mode()); TEST_MULTI3_IS_BUSY("01000", "01000"); CPPUNIT_ASSERT(tracker_0_1->trigger_failure()); TEST_MULTI3_IS_BUSY("00100", "00100"); CPPUNIT_ASSERT(tracker_1_0->trigger_success()); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, tracker_0_0->normal_interval())); TEST_MULTI3_IS_BUSY("10000", "10000"); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); TEST_MULTI3_IS_BUSY("01000", "01000"); CPPUNIT_ASSERT(tracker_0_1->trigger_failure()); CPPUNIT_ASSERT(!tracker_controller.is_failure_mode()); TEST_MULTI3_IS_BUSY("00100", "00100"); CPPUNIT_ASSERT(tracker_1_0->trigger_failure()); CPPUNIT_ASSERT(tracker_controller.is_failure_mode()); TEST_MULTI3_IS_BUSY("00010", "00010"); CPPUNIT_ASSERT(tracker_2_0->trigger_failure()); TEST_MULTI3_IS_BUSY("00001", "00001"); CPPUNIT_ASSERT(tracker_3_0->trigger_failure()); // Properly tests that we're going into timeouts... Disable remaining trackers. // for (int i = 0; i < 5; i++) // std::cout << std::endl << i << ": " // << tracker_list[i]->activity_time_last() << ' ' // << tracker_list[i]->success_time_last() << ' ' // << tracker_list[i]->failed_time_last() << std::endl; // Try inserting some delays in order to test the timers. CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 5)); TEST_MULTI3_IS_BUSY("00100", "00100"); CPPUNIT_ASSERT(tracker_1_0->trigger_success()); CPPUNIT_ASSERT(!tracker_controller.is_failure_mode()); // CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, tracker_list[0]->normal_interval())); // TEST_MULTI3_IS_BUSY("01000", "10000"); // CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT(tracker_list.count_active() == 0); TEST_MULTIPLE_END(2, 7); } void tracker_controller_test::test_multiple_cycle() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT(tracker_list.front() == tracker_0_1); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, tracker_0_1->normal_interval())); TEST_MULTI3_IS_BUSY("01000", "10000"); CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT(tracker_list.count_active() == 0); TEST_MULTIPLE_END(2, 1); } void tracker_controller_test::test_multiple_cycle_second_group() { TEST_MULTI3_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_0_0->trigger_failure()); CPPUNIT_ASSERT(tracker_0_1->trigger_failure()); CPPUNIT_ASSERT(tracker_1_0->trigger_success()); CPPUNIT_ASSERT(tracker_list[0] == tracker_0_0); CPPUNIT_ASSERT(tracker_list[1] == tracker_0_1); CPPUNIT_ASSERT(tracker_list[2] == tracker_1_0); CPPUNIT_ASSERT(tracker_list[3] == tracker_2_0); CPPUNIT_ASSERT(tracker_list[4] == tracker_3_0); TEST_MULTIPLE_END(1, 2); } void tracker_controller_test::test_multiple_send_stop() { TEST_MULTI3_BEGIN(); tracker_list.send_state_idx(1, torrent::Tracker::EVENT_NONE); tracker_list.send_state_idx(3, torrent::Tracker::EVENT_NONE); tracker_list.send_state_idx(4, torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT(tracker_2_0->trigger_success()); CPPUNIT_ASSERT(tracker_3_0->trigger_success()); CPPUNIT_ASSERT(tracker_list.count_active() == 0); tracker_controller.send_stop_event(); CPPUNIT_ASSERT(tracker_list.count_active() == 3); TEST_MULTI3_IS_BUSY("01011", "10011"); CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) != torrent::TrackerController::flag_send_stop); CPPUNIT_ASSERT(tracker_2_0->trigger_success()); CPPUNIT_ASSERT(tracker_3_0->trigger_success()); CPPUNIT_ASSERT(tracker_list.count_active() == 0); tracker_controller.send_stop_event(); tracker_controller.disable(); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == torrent::TrackerController::flag_send_stop); TEST_MULTI3_IS_BUSY("01011", "10011"); tracker_controller.enable(torrent::TrackerController::enable_dont_reset_stats); TEST_MULTI3_IS_BUSY("00000", "00000"); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == 0); tracker_controller.send_stop_event(); TEST_MULTI3_IS_BUSY("01011", "10011"); tracker_controller.disable(); tracker_controller.enable(); TEST_MULTI3_IS_BUSY("00000", "00000"); CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == 0); tracker_controller.send_stop_event(); TEST_MULTI3_IS_BUSY("00000", "00000"); // Test also that after closing the tracker controller, and // reopening it a 'send stop' event causes no tracker to be busy. TEST_MULTIPLE_END(6, 0); } void tracker_controller_test::test_multiple_send_update() { TEST_MULTI3_BEGIN(); tracker_controller.send_update_event(); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("10000", "10000"); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); tracker_0_0->set_failed(1, torrent::cachedTime.seconds()); tracker_controller.send_update_event(); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("01000", "01000"); CPPUNIT_ASSERT(tracker_0_1->trigger_failure()); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("00100", "00100"); TEST_MULTIPLE_END(2, 0); } // Test timeout called, no usable trackers at all which leads to // disabling the timeout. // // The enable/disable tracker functions will poke the tracker // controller, ensuring the tast timeout gets re-started. void tracker_controller_test::test_timeout_lacking_usable() { TEST_MULTI3_BEGIN(); std::for_each(tracker_list.begin(), tracker_list.end(), std::mem_fun(&torrent::Tracker::disable)); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("00000", "00000"); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); tracker_1_0->enable(); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() == 0); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); TEST_MULTI3_IS_BUSY("00100", "00100"); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); tracker_3_0->enable(); CPPUNIT_ASSERT(!tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(enabled_counter == 5 + 2 && disabled_counter == 5); TEST_MULTIPLE_END(0, 0); } void tracker_controller_test::test_disable_tracker() { TEST_SINGLE_BEGIN(); TEST_SEND_SINGLE_BEGIN(update); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); CPPUNIT_ASSERT(tracker_0_0->is_busy()); tracker_0_0->disable(); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_controller.task_timeout()->is_queued()); TEST_SINGLE_END(0, 0); } void tracker_controller_test::test_new_peers() { TRACKER_CONTROLLER_SETUP(); TRACKER_INSERT(0, tracker_0); tracker_list.send_state_idx(0, torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_0->trigger_success(10)); CPPUNIT_ASSERT(tracker_0->latest_new_peers() == 10); tracker_controller.enable(); CPPUNIT_ASSERT(test_goto_next_timeout(&tracker_controller, 0)); CPPUNIT_ASSERT(tracker_0->trigger_success(20)); CPPUNIT_ASSERT(tracker_0->latest_new_peers() == 20); } // Add new function for finding the first tracker that will time out, // e.g. both with failure mode and normal rerequesting. // Make sure that adding a new tracker to a tracker list with no // usable tracker restarts the tracker requests. // Test timeout called, usable trackers exist but could not be called // at this moment, thus leading to no active trackers. (Rather, clean // up the 'is_usable()' functions, and make it a new function that is // independent of enabled, or is itself manipulating/dependent on // enabled) // Add checks to ensure we don't prematurely do timeout on a tracker // after disabling the lead one. // Make sure that we always remain with timeout, even if we send a // request that somehow doesn't actually activate any // trackers. e.g. check all send_tracker_itr uses. // Add test for promiscious mode while with a single tracker? // Test send_* with controller not enabled. // Test cleanup after disable. // Test cleanup of timers at disable (and empty timers at enable). // Test trying to send_start twice, etc. // Test send_start promiscious... // - Make sure we check that no timer is inserted while still having active trackers. // - Calculate the next timeout according to a list of in-use trackers, with the first timeout as the interval. // Test clearing of recv/failed counter on trackers. libtorrent-0.13.2/test/torrent/tracker_controller_test.h000644 000765 000024 00000017103 11741025651 024507 0ustar00rakshasastaff000000 000000 #include #include "torrent/tracker_controller.h" class tracker_controller_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(tracker_controller_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_enable); CPPUNIT_TEST(test_requesting); CPPUNIT_TEST(test_timeout); CPPUNIT_TEST(test_single_success); CPPUNIT_TEST(test_single_failure); CPPUNIT_TEST(test_single_disable); CPPUNIT_TEST(test_send_start); CPPUNIT_TEST(test_send_stop_normal); CPPUNIT_TEST(test_send_completed_normal); CPPUNIT_TEST(test_send_update_normal); CPPUNIT_TEST(test_send_task_timeout); CPPUNIT_TEST(test_send_close_on_enable); CPPUNIT_TEST(test_multiple_success); CPPUNIT_TEST(test_multiple_failure); CPPUNIT_TEST(test_multiple_cycle); CPPUNIT_TEST(test_multiple_cycle_second_group); CPPUNIT_TEST(test_multiple_send_stop); CPPUNIT_TEST(test_timeout_lacking_usable); CPPUNIT_TEST(test_disable_tracker); CPPUNIT_TEST(test_new_peers); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_enable(); void test_disable(); void test_requesting(); void test_timeout(); void test_single_success(); void test_single_failure(); void test_single_disable(); void test_send_start(); void test_send_stop_normal(); void test_send_completed_normal(); void test_send_update_normal(); void test_send_task_timeout(); void test_send_close_on_enable(); void test_multiple_success(); void test_multiple_failure(); void test_multiple_cycle(); void test_multiple_cycle_second_group(); void test_multiple_send_stop(); void test_multiple_send_update(); void test_timeout_lacking_usable(); void test_disable_tracker(); void test_new_peers(); }; #define TRACKER_CONTROLLER_SETUP() \ torrent::TrackerList tracker_list; \ torrent::TrackerController tracker_controller(&tracker_list); \ \ int success_counter = 0; \ int failure_counter = 0; \ int timeout_counter = 0; \ int enabled_counter = 0; \ int disabled_counter = 0; \ \ tracker_controller.slot_success() = tr1::bind(&increment_value, &success_counter); \ tracker_controller.slot_failure() = tr1::bind(&increment_value, &failure_counter); \ tracker_controller.slot_timeout() = tr1::bind(&increment_value, &timeout_counter); \ tracker_controller.slot_tracker_enabled() = tr1::bind(&increment_value, &enabled_counter); \ tracker_controller.slot_tracker_disabled() = tr1::bind(&increment_value, &disabled_counter); \ \ tracker_list.slot_success() = tr1::bind(&torrent::TrackerController::receive_success, &tracker_controller, tr1::placeholders::_1, tr1::placeholders::_2); \ tracker_list.slot_failure() = tr1::bind(&torrent::TrackerController::receive_failure, &tracker_controller, tr1::placeholders::_1, tr1::placeholders::_2); \ tracker_list.slot_tracker_enabled() = tr1::bind(&torrent::TrackerController::receive_tracker_enabled, &tracker_controller, tr1::placeholders::_1); \ tracker_list.slot_tracker_disabled() = tr1::bind(&torrent::TrackerController::receive_tracker_disabled, &tracker_controller, tr1::placeholders::_1); #define TEST_SINGLE_BEGIN() \ TRACKER_CONTROLLER_SETUP(); \ TRACKER_INSERT(0, tracker_0_0); \ \ tracker_controller.enable(); \ CPPUNIT_ASSERT(!(tracker_controller.flags() & torrent::TrackerController::mask_send)); \ #define TEST_SINGLE_END(succeeded, failed) \ tracker_controller.disable(); \ CPPUNIT_ASSERT(!tracker_list.has_active()); \ CPPUNIT_ASSERT(success_counter == succeeded && \ failure_counter == failure_counter); #define TEST_SEND_SINGLE_BEGIN(event_name) \ tracker_controller.send_##event_name##_event(); \ CPPUNIT_ASSERT((tracker_controller.flags() & torrent::TrackerController::mask_send) == \ torrent::TrackerController::flag_send_##event_name); \ \ CPPUNIT_ASSERT(tracker_controller.is_active()); \ CPPUNIT_ASSERT(tracker_controller.tracker_list()->count_active() == 1); #define TEST_SEND_SINGLE_END(succeeded, failed) \ TEST_SINGLE_END(succeeded, failed) \ CPPUNIT_ASSERT(tracker_controller.seconds_to_next_timeout() == 0); \ //CPPUNIT_ASSERT(tracker_controller.seconds_to_promicious_mode() != 0); #define TEST_MULTI3_BEGIN() \ TRACKER_CONTROLLER_SETUP(); \ TRACKER_INSERT(0, tracker_0_0); \ TRACKER_INSERT(0, tracker_0_1); \ TRACKER_INSERT(1, tracker_1_0); \ TRACKER_INSERT(2, tracker_2_0); \ TRACKER_INSERT(3, tracker_3_0); \ \ tracker_controller.enable(); \ CPPUNIT_ASSERT(!(tracker_controller.flags() & torrent::TrackerController::mask_send)); \ #define TEST_GROUP_BEGIN() \ TRACKER_CONTROLLER_SETUP(); \ TRACKER_INSERT(0, tracker_0_0); \ TRACKER_INSERT(0, tracker_0_1); \ TRACKER_INSERT(0, tracker_0_2); \ TRACKER_INSERT(1, tracker_1_0); \ TRACKER_INSERT(1, tracker_1_1); \ TRACKER_INSERT(2, tracker_2_0); \ \ tracker_controller.enable(); \ CPPUNIT_ASSERT(!(tracker_controller.flags() & torrent::TrackerController::mask_send)); \ #define TEST_MULTIPLE_END(succeeded, failed) \ tracker_controller.disable(); \ CPPUNIT_ASSERT(!tracker_list.has_active()); \ CPPUNIT_ASSERT(success_counter == succeeded && \ failure_counter == failed); #define TEST_GOTO_NEXT_SCRAPE(assumed_scrape) \ CPPUNIT_ASSERT(tracker_controller.task_scrape()->is_queued()); \ CPPUNIT_ASSERT(assumed_scrape == tracker_controller.seconds_to_next_scrape()); \ torrent::cachedTime += rak::timer::from_seconds(tracker_controller.seconds_to_next_scrape()); \ rak::priority_queue_perform(&torrent::taskScheduler, torrent::cachedTime); bool test_goto_next_timeout(torrent::TrackerController* tracker_controller, uint32_t assumed_timeout); libtorrent-0.13.2/test/torrent/tracker_list_features_test.cc000644 000765 000024 00000017365 11716350717 025353 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include "torrent/http.h" #include "net/address_list.h" #include "globals.h" #include "tracker_list_test.h" #include "tracker_list_features_test.h" namespace tr1 { using namespace std::tr1; } CPPUNIT_TEST_SUITE_REGISTRATION(tracker_list_features_test); void tracker_list_features_test::setUp() { CPPUNIT_ASSERT(torrent::taskScheduler.empty()); torrent::cachedTime = rak::timer::current(); } void tracker_list_features_test::tearDown() { } void tracker_list_features_test::test_new_peers() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); CPPUNIT_ASSERT(tracker_0->latest_new_peers() == 0); CPPUNIT_ASSERT(tracker_0->latest_sum_peers() == 0); tracker_list.send_state_idx(0, torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_0->trigger_success(10, 20)); CPPUNIT_ASSERT(tracker_0->latest_new_peers() == 10); CPPUNIT_ASSERT(tracker_0->latest_sum_peers() == 20); tracker_list.send_state_idx(0, torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(tracker_0->trigger_failure()); CPPUNIT_ASSERT(tracker_0->latest_new_peers() == 10); CPPUNIT_ASSERT(tracker_0->latest_sum_peers() == 20); tracker_list.clear_stats(); CPPUNIT_ASSERT(tracker_0->latest_new_peers() == 0); CPPUNIT_ASSERT(tracker_0->latest_sum_peers() == 0); } // test last_connect timer. // test has_active, and then clean up TrackerManager. void tracker_list_features_test::test_has_active() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0_0); TRACKER_INSERT(0, tracker_0_1); TRACKER_INSERT(1, tracker_1_0); CPPUNIT_ASSERT(!tracker_list.has_active()); CPPUNIT_ASSERT(!tracker_list.has_active_not_scrape()); tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_list.has_active()); CPPUNIT_ASSERT(tracker_list.has_active_not_scrape()); tracker_0_0->trigger_success(); CPPUNIT_ASSERT(!tracker_list.has_active()); CPPUNIT_ASSERT(!tracker_list.has_active_not_scrape()); tracker_list.send_state_idx(2, 1); CPPUNIT_ASSERT(tracker_list.has_active()); tracker_1_0->trigger_success(); CPPUNIT_ASSERT(!tracker_list.has_active()); // Test multiple active trackers. tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_list.has_active()); tracker_list.send_state_idx(1, 1); tracker_0_0->trigger_success(); CPPUNIT_ASSERT(tracker_list.has_active()); tracker_0_1->trigger_success(); CPPUNIT_ASSERT(!tracker_list.has_active()); tracker_1_0->set_can_scrape(); tracker_list.send_scrape(tracker_1_0); CPPUNIT_ASSERT(tracker_list.has_active()); CPPUNIT_ASSERT(!tracker_list.has_active_not_scrape()); } void tracker_list_features_test::test_find_next_to_request() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); TRACKER_INSERT(0, tracker_1); TRACKER_INSERT(0, tracker_2); TRACKER_INSERT(0, tracker_3); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin()); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin() + 1) == tracker_list.begin() + 1); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.end()) == tracker_list.end()); tracker_0->disable(); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin() + 1); tracker_0->enable(); tracker_0->set_failed(1, torrent::cachedTime.seconds() - 0); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin() + 1); tracker_1->set_failed(1, torrent::cachedTime.seconds() - 0); tracker_2->set_failed(1, torrent::cachedTime.seconds() - 0); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin() + 3); tracker_3->set_failed(1, torrent::cachedTime.seconds() - 0); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin() + 0); tracker_0->set_failed(1, torrent::cachedTime.seconds() - 3); tracker_1->set_failed(1, torrent::cachedTime.seconds() - 2); tracker_2->set_failed(1, torrent::cachedTime.seconds() - 4); tracker_3->set_failed(1, torrent::cachedTime.seconds() - 2); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin() + 2); tracker_1->set_failed(0, torrent::cachedTime.seconds() - 1); tracker_1->set_success(1, torrent::cachedTime.seconds() - 1); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin() + 0); tracker_1->set_success(1, torrent::cachedTime.seconds() - (tracker_1->normal_interval() - 1)); CPPUNIT_ASSERT(tracker_list.find_next_to_request(tracker_list.begin()) == tracker_list.begin() + 1); } void tracker_list_features_test::test_count_active() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0_0); TRACKER_INSERT(0, tracker_0_1); TRACKER_INSERT(1, tracker_1_0); TRACKER_INSERT(2, tracker_2_0); CPPUNIT_ASSERT(tracker_list.count_active() == 0); tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_list.count_active() == 1); tracker_list.send_state_idx(3, 1); CPPUNIT_ASSERT(tracker_list.count_active() == 2); tracker_list.send_state_idx(1, 1); tracker_list.send_state_idx(2, 1); CPPUNIT_ASSERT(tracker_list.count_active() == 4); tracker_0_0->trigger_success(); CPPUNIT_ASSERT(tracker_list.count_active() == 3); tracker_0_1->trigger_success(); tracker_2_0->trigger_success(); CPPUNIT_ASSERT(tracker_list.count_active() == 1); tracker_1_0->trigger_success(); CPPUNIT_ASSERT(tracker_list.count_active() == 0); } // Add separate functions for sending state to multiple trackers... bool verify_did_internal_error(tr1::function func, bool should_throw) { bool did_throw = false; try { func(); } catch (torrent::internal_error& e) { did_throw = true; } return should_throw == did_throw; } void tracker_list_features_test::test_request_safeguard() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_1); TRACKER_INSERT(0, tracker_2); TRACKER_INSERT(0, tracker_3); TRACKER_INSERT(0, tracker_foo); for (unsigned int i = 0; i < 9; i++) { CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::TrackerList::send_state, &tracker_list, tracker_1, 1), false)); CPPUNIT_ASSERT(tracker_1->trigger_success()); CPPUNIT_ASSERT(tracker_1->success_counter() == (i + 1)); } CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::TrackerList::send_state, &tracker_list, tracker_1, 1), true)); CPPUNIT_ASSERT(tracker_1->trigger_success()); torrent::cachedTime += rak::timer::from_seconds(1000); for (unsigned int i = 0; i < 9; i++) { CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::TrackerList::send_state, &tracker_list, tracker_foo, 1), false)); CPPUNIT_ASSERT(tracker_foo->trigger_success()); CPPUNIT_ASSERT(tracker_foo->success_counter() == (i + 1)); CPPUNIT_ASSERT(tracker_foo->is_usable()); } CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::TrackerList::send_state, &tracker_list, tracker_foo, 1), true)); CPPUNIT_ASSERT(tracker_foo->trigger_success()); for (unsigned int i = 0; i < 40; i++) { CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::TrackerList::send_state, &tracker_list, tracker_2, 1), false)); CPPUNIT_ASSERT(tracker_2->trigger_success()); CPPUNIT_ASSERT(tracker_2->success_counter() == (i + 1)); torrent::cachedTime += rak::timer::from_seconds(1); } for (unsigned int i = 0; i < 17; i++) { CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::TrackerList::send_state, &tracker_list, tracker_3, 1), false)); CPPUNIT_ASSERT(tracker_3->trigger_success()); CPPUNIT_ASSERT(tracker_3->success_counter() == (i + 1)); if (i % 2) torrent::cachedTime += rak::timer::from_seconds(1); } CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::TrackerList::send_state, &tracker_list, tracker_3, 1), true)); CPPUNIT_ASSERT(tracker_3->trigger_success()); } libtorrent-0.13.2/test/torrent/tracker_list_features_test.h000644 000765 000024 00000001072 11716350717 025201 0ustar00rakshasastaff000000 000000 #include class tracker_list_features_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(tracker_list_features_test); CPPUNIT_TEST(test_new_peers); CPPUNIT_TEST(test_has_active); CPPUNIT_TEST(test_find_next_to_request); CPPUNIT_TEST(test_count_active); CPPUNIT_TEST(test_request_safeguard); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_new_peers(); void test_has_active(); void test_find_next_to_request(); void test_count_active(); void test_request_safeguard(); }; libtorrent-0.13.2/test/torrent/tracker_list_test.cc000644 000765 000024 00000042602 11740502002 023424 0ustar00rakshasastaff000000 000000 #include "config.h" #include "torrent/http.h" #include "net/address_list.h" #include "globals.h" #include "tracker_list_test.h" namespace tr1 { using namespace std::tr1; } CPPUNIT_TEST_SUITE_REGISTRATION(tracker_list_test); uint32_t return_new_peers = 0xdeadbeef; class http_get : public torrent::Http { public: ~http_get() { } // Start must never throw on bad input. Calling start/stop on an // object in the wrong state should throw a torrent::internal_error. void start() { } void close() { } }; torrent::Http* http_factory() { return new http_get; } bool TrackerTest::trigger_success(uint32_t new_peers, uint32_t sum_peers) { torrent::TrackerList::address_list address_list; for (unsigned int i = 0; i != sum_peers; i++) { rak::socket_address sa; sa.sa_inet()->clear(); sa.sa_inet()->set_port(0x100 + i); address_list.push_back(sa); } return trigger_success(&address_list, new_peers); } bool TrackerTest::trigger_success(torrent::TrackerList::address_list* address_list, uint32_t new_peers) { if (parent() == NULL || !is_busy() || !is_open()) return false; m_busy = false; m_open = !(m_flags & flag_close_on_done); return_new_peers = new_peers; if (m_latest_event == EVENT_SCRAPE) parent()->receive_scrape_success(this); else parent()->receive_success(this, address_list); m_requesting_state = -1; return true; } bool TrackerTest::trigger_failure() { if (parent() == NULL || !is_busy() || !is_open()) return false; m_busy = false; m_open = !(m_flags & flag_close_on_done); return_new_peers = 0; if (m_latest_event == EVENT_SCRAPE) parent()->receive_scrape_failed(this, "failed"); else parent()->receive_failed(this, "failed"); m_requesting_state = -1; return true; } bool TrackerTest::trigger_scrape() { if (parent() == NULL || !is_busy() || !is_open()) return false; if (m_latest_event != EVENT_SCRAPE) return false; return trigger_success(); } void tracker_list_test::test_basic() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); CPPUNIT_ASSERT(tracker_0 == tracker_list[0]); CPPUNIT_ASSERT(tracker_list[0]->parent() == &tracker_list); CPPUNIT_ASSERT(std::distance(tracker_list.begin_group(0), tracker_list.end_group(0)) == 1); CPPUNIT_ASSERT(tracker_list.find_usable(tracker_list.begin()) != tracker_list.end()); } void tracker_list_test::test_enable() { TRACKER_SETUP(); int enabled_counter = 0; int disabled_counter = 0; tracker_list.slot_tracker_enabled() = tr1::bind(&increment_value, &enabled_counter); tracker_list.slot_tracker_disabled() = tr1::bind(&increment_value, &disabled_counter); TRACKER_INSERT(0, tracker_0); TRACKER_INSERT(1, tracker_1); CPPUNIT_ASSERT(enabled_counter == 2 && disabled_counter == 0); tracker_0->enable(); tracker_1->enable(); CPPUNIT_ASSERT(enabled_counter == 2 && disabled_counter == 0); tracker_0->disable(); tracker_1->enable(); CPPUNIT_ASSERT(enabled_counter == 2 && disabled_counter == 1); tracker_1->disable(); tracker_0->disable(); CPPUNIT_ASSERT(enabled_counter == 2 && disabled_counter == 2); tracker_0->enable(); tracker_1->enable(); tracker_0->enable(); tracker_1->enable(); CPPUNIT_ASSERT(enabled_counter == 4 && disabled_counter == 2); } void tracker_list_test::test_close() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); TRACKER_INSERT(0, tracker_1); TRACKER_INSERT(0, tracker_2); TRACKER_INSERT(0, tracker_3); tracker_list.send_state_idx(0, torrent::Tracker::EVENT_NONE); tracker_list.send_state_idx(1, torrent::Tracker::EVENT_STARTED); tracker_list.send_state_idx(2, torrent::Tracker::EVENT_STOPPED); tracker_list.send_state_idx(3, torrent::Tracker::EVENT_COMPLETED); CPPUNIT_ASSERT(tracker_0->is_busy()); CPPUNIT_ASSERT(tracker_1->is_busy()); CPPUNIT_ASSERT(tracker_2->is_busy()); CPPUNIT_ASSERT(tracker_3->is_busy()); tracker_list.close_all_excluding((1 << torrent::Tracker::EVENT_STARTED) | (1 << torrent::Tracker::EVENT_STOPPED)); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(tracker_1->is_busy()); CPPUNIT_ASSERT(tracker_2->is_busy()); CPPUNIT_ASSERT(!tracker_3->is_busy()); tracker_list.close_all(); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_1->is_busy()); CPPUNIT_ASSERT(!tracker_2->is_busy()); CPPUNIT_ASSERT(!tracker_3->is_busy()); tracker_list.send_state_idx(0, torrent::Tracker::EVENT_NONE); tracker_list.send_state_idx(1, torrent::Tracker::EVENT_STARTED); tracker_list.send_state_idx(2, torrent::Tracker::EVENT_STOPPED); tracker_list.send_state_idx(3, torrent::Tracker::EVENT_COMPLETED); tracker_list.close_all_excluding((1 << torrent::Tracker::EVENT_NONE) | (1 << torrent::Tracker::EVENT_COMPLETED)); CPPUNIT_ASSERT(tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_1->is_busy()); CPPUNIT_ASSERT(!tracker_2->is_busy()); CPPUNIT_ASSERT(tracker_3->is_busy()); } // Test clear. void tracker_list_test::test_tracker_flags() { TRACKER_SETUP(); tracker_list.insert(0, new TrackerTest(&tracker_list, "")); tracker_list.insert(0, new TrackerTest(&tracker_list, "", 0)); tracker_list.insert(0, new TrackerTest(&tracker_list, "", torrent::Tracker::flag_enabled)); tracker_list.insert(0, new TrackerTest(&tracker_list, "", torrent::Tracker::flag_extra_tracker)); tracker_list.insert(0, new TrackerTest(&tracker_list, "", torrent::Tracker::flag_enabled | torrent::Tracker::flag_extra_tracker)); CPPUNIT_ASSERT((tracker_list[0]->flags() & torrent::Tracker::mask_base_flags) == torrent::Tracker::flag_enabled); CPPUNIT_ASSERT((tracker_list[1]->flags() & torrent::Tracker::mask_base_flags) == 0); CPPUNIT_ASSERT((tracker_list[2]->flags() & torrent::Tracker::mask_base_flags) == torrent::Tracker::flag_enabled); CPPUNIT_ASSERT((tracker_list[3]->flags() & torrent::Tracker::mask_base_flags) == torrent::Tracker::flag_extra_tracker); CPPUNIT_ASSERT((tracker_list[4]->flags() & torrent::Tracker::mask_base_flags) == (torrent::Tracker::flag_enabled | torrent::Tracker::flag_extra_tracker)); } void tracker_list_test::test_find_url() { TRACKER_SETUP(); tracker_list.insert(0, new TrackerTest(&tracker_list, "http://1")); tracker_list.insert(0, new TrackerTest(&tracker_list, "http://2")); tracker_list.insert(1, new TrackerTest(&tracker_list, "http://3")); CPPUNIT_ASSERT(tracker_list.find_url("http://") == tracker_list.end()); CPPUNIT_ASSERT(tracker_list.find_url("http://1") != tracker_list.end()); CPPUNIT_ASSERT(*tracker_list.find_url("http://1") == tracker_list[0]); CPPUNIT_ASSERT(tracker_list.find_url("http://2") != tracker_list.end()); CPPUNIT_ASSERT(*tracker_list.find_url("http://2") == tracker_list[1]); CPPUNIT_ASSERT(tracker_list.find_url("http://3") != tracker_list.end()); CPPUNIT_ASSERT(*tracker_list.find_url("http://3") == tracker_list[2]); } void tracker_list_test::test_can_scrape() { TRACKER_SETUP(); torrent::Http::slot_factory() = std::tr1::bind(&http_factory); tracker_list.insert_url(0, "http://example.com/announce"); CPPUNIT_ASSERT((tracker_list.back()->flags() & torrent::Tracker::flag_can_scrape)); CPPUNIT_ASSERT(torrent::Tracker::scrape_url_from(tracker_list.back()->url()) == "http://example.com/scrape"); tracker_list.insert_url(0, "http://example.com/x/announce"); CPPUNIT_ASSERT((tracker_list.back()->flags() & torrent::Tracker::flag_can_scrape)); CPPUNIT_ASSERT(torrent::Tracker::scrape_url_from(tracker_list.back()->url()) == "http://example.com/x/scrape"); tracker_list.insert_url(0, "http://example.com/announce.php"); CPPUNIT_ASSERT((tracker_list.back()->flags() & torrent::Tracker::flag_can_scrape)); CPPUNIT_ASSERT(torrent::Tracker::scrape_url_from(tracker_list.back()->url()) == "http://example.com/scrape.php"); tracker_list.insert_url(0, "http://example.com/a"); CPPUNIT_ASSERT(!(tracker_list.back()->flags() & torrent::Tracker::flag_can_scrape)); tracker_list.insert_url(0, "http://example.com/announce?x2%0644"); CPPUNIT_ASSERT((tracker_list.back()->flags() & torrent::Tracker::flag_can_scrape)); CPPUNIT_ASSERT(torrent::Tracker::scrape_url_from(tracker_list.back()->url()) == "http://example.com/scrape?x2%0644"); tracker_list.insert_url(0, "http://example.com/announce?x=2/4"); CPPUNIT_ASSERT(!(tracker_list.back()->flags() & torrent::Tracker::flag_can_scrape)); tracker_list.insert_url(0, "http://example.com/x%064announce"); CPPUNIT_ASSERT(!(tracker_list.back()->flags() & torrent::Tracker::flag_can_scrape)); } void tracker_list_test::test_single_success() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_0->is_busy_not_scrape()); CPPUNIT_ASSERT(!tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->requesting_state() == -1); CPPUNIT_ASSERT(tracker_0->latest_event() == torrent::Tracker::EVENT_NONE); tracker_list.send_state_idx(0, torrent::Tracker::EVENT_STARTED); CPPUNIT_ASSERT(tracker_0->is_busy()); CPPUNIT_ASSERT(tracker_0->is_busy_not_scrape()); CPPUNIT_ASSERT(tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->requesting_state() == torrent::Tracker::EVENT_STARTED); CPPUNIT_ASSERT(tracker_0->latest_event() == torrent::Tracker::EVENT_STARTED); CPPUNIT_ASSERT(tracker_0->trigger_success()); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_0->is_busy_not_scrape()); CPPUNIT_ASSERT(!tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->requesting_state() == -1); CPPUNIT_ASSERT(tracker_0->latest_event() == torrent::Tracker::EVENT_STARTED); CPPUNIT_ASSERT(success_counter == 1 && failure_counter == 0); CPPUNIT_ASSERT(tracker_0->success_counter() == 1); CPPUNIT_ASSERT(tracker_0->failed_counter() == 0); } void tracker_list_test::test_single_failure() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_0->trigger_failure()); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->requesting_state() == -1); CPPUNIT_ASSERT(success_counter == 0 && failure_counter == 1); CPPUNIT_ASSERT(tracker_0->success_counter() == 0); CPPUNIT_ASSERT(tracker_0->failed_counter() == 1); tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_0->trigger_success()); CPPUNIT_ASSERT(success_counter == 1 && failure_counter == 1); CPPUNIT_ASSERT(tracker_0->success_counter() == 1); CPPUNIT_ASSERT(tracker_0->failed_counter() == 0); } void tracker_list_test::test_single_closing() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); CPPUNIT_ASSERT(!tracker_0->is_open()); tracker_0->set_close_on_done(false); tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->trigger_success()); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(tracker_0->is_open()); tracker_list.close_all(); tracker_list.clear_stats(); CPPUNIT_ASSERT(!tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->success_counter() == 0); CPPUNIT_ASSERT(tracker_0->failed_counter() == 0); } void tracker_list_test::test_multiple_success() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0_0); TRACKER_INSERT(0, tracker_0_1); TRACKER_INSERT(1, tracker_1_0); TRACKER_INSERT(1, tracker_1_1); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); CPPUNIT_ASSERT(!tracker_0_1->is_busy()); CPPUNIT_ASSERT(!tracker_1_0->is_busy()); CPPUNIT_ASSERT(!tracker_1_1->is_busy()); tracker_list.send_state_idx(0, 1); CPPUNIT_ASSERT(tracker_0_0->is_busy()); CPPUNIT_ASSERT(!tracker_0_1->is_busy()); CPPUNIT_ASSERT(!tracker_1_0->is_busy()); CPPUNIT_ASSERT(!tracker_1_1->is_busy()); CPPUNIT_ASSERT(tracker_0_0->trigger_success()); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); CPPUNIT_ASSERT(!tracker_0_1->is_busy()); CPPUNIT_ASSERT(!tracker_1_0->is_busy()); CPPUNIT_ASSERT(!tracker_1_1->is_busy()); tracker_list.send_state_idx(1, 1); tracker_list.send_state_idx(3, 1); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_0_1->is_busy()); CPPUNIT_ASSERT(!tracker_1_0->is_busy()); CPPUNIT_ASSERT(tracker_1_1->is_busy()); CPPUNIT_ASSERT(tracker_1_1->trigger_success()); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); CPPUNIT_ASSERT(tracker_0_1->is_busy()); CPPUNIT_ASSERT(!tracker_1_0->is_busy()); CPPUNIT_ASSERT(!tracker_1_1->is_busy()); CPPUNIT_ASSERT(tracker_0_1->trigger_success()); CPPUNIT_ASSERT(!tracker_0_0->is_busy()); CPPUNIT_ASSERT(!tracker_0_1->is_busy()); CPPUNIT_ASSERT(!tracker_1_0->is_busy()); CPPUNIT_ASSERT(!tracker_1_1->is_busy()); CPPUNIT_ASSERT(success_counter == 3 && failure_counter == 0); } void tracker_list_test::test_scrape_success() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); tracker_0->set_can_scrape(); tracker_list.send_scrape(tracker_0); CPPUNIT_ASSERT(tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_0->is_busy_not_scrape()); CPPUNIT_ASSERT(tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->requesting_state() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(tracker_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(tracker_0->trigger_scrape()); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_0->is_busy_not_scrape()); CPPUNIT_ASSERT(!tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->requesting_state() == -1); CPPUNIT_ASSERT(tracker_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(success_counter == 0 && failure_counter == 0); CPPUNIT_ASSERT(scrape_success_counter == 1 && scrape_failure_counter == 0); CPPUNIT_ASSERT(tracker_0->success_counter() == 0); CPPUNIT_ASSERT(tracker_0->failed_counter() == 0); CPPUNIT_ASSERT(tracker_0->scrape_counter() == 1); } void tracker_list_test::test_scrape_failure() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); tracker_0->set_can_scrape(); tracker_list.send_scrape(tracker_0); CPPUNIT_ASSERT(tracker_0->trigger_failure()); CPPUNIT_ASSERT(!tracker_0->is_busy()); CPPUNIT_ASSERT(!tracker_0->is_open()); CPPUNIT_ASSERT(tracker_0->requesting_state() == -1); CPPUNIT_ASSERT(tracker_0->latest_event() == torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(success_counter == 0 && failure_counter == 0); CPPUNIT_ASSERT(scrape_success_counter == 0 && scrape_failure_counter == 1); CPPUNIT_ASSERT(tracker_0->success_counter() == 0); CPPUNIT_ASSERT(tracker_0->failed_counter() == 0); CPPUNIT_ASSERT(tracker_0->scrape_counter() == 0); } bool check_has_active_in_group(const torrent::TrackerList* tracker_list, const char* states, bool scrape) { int group = 0; while (*states != '\0') { bool result = scrape ? tracker_list->has_active_in_group(group++) : tracker_list->has_active_not_scrape_in_group(group++); if ((*states == '1' && !result) || (*states == '0' && result)) return false; states++; } return true; } void tracker_list_test::test_has_active() { TRACKER_SETUP(); TRACKER_INSERT(0, tracker_0); TRACKER_INSERT(0, tracker_1); TRACKER_INSERT(1, tracker_2); TRACKER_INSERT(3, tracker_3); TRACKER_INSERT(4, tracker_4); // TODO: Test scrape... TEST_TRACKERS_IS_BUSY_5("00000", "00000"); CPPUNIT_ASSERT(!tracker_list.has_active()); CPPUNIT_ASSERT(!tracker_list.has_active_not_scrape()); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "000000", false)); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "000000", true)); tracker_list.send_state_idx(0, 1); TEST_TRACKERS_IS_BUSY_5("10000", "10000"); CPPUNIT_ASSERT( tracker_list.has_active()); CPPUNIT_ASSERT( tracker_list.has_active_not_scrape()); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "100000", false)); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "100000", true)); CPPUNIT_ASSERT(tracker_0->trigger_success()); TEST_TRACKERS_IS_BUSY_5("00000", "00000"); CPPUNIT_ASSERT(!tracker_list.has_active()); CPPUNIT_ASSERT(!tracker_list.has_active_not_scrape()); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "000000", false)); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "000000", true)); tracker_list.send_state_idx(1, 1); tracker_list.send_state_idx(3, 1); TEST_TRACKERS_IS_BUSY_5("01010", "01010"); CPPUNIT_ASSERT( tracker_list.has_active()); CPPUNIT_ASSERT( tracker_list.has_active_not_scrape()); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "100100", false)); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "100100", true)); tracker_2->set_can_scrape(); tracker_list.send_scrape(tracker_2); tracker_list.send_state_idx(1, 1); tracker_list.send_state_idx(3, 1); TEST_TRACKERS_IS_BUSY_5("01110", "01110"); CPPUNIT_ASSERT( tracker_list.has_active()); CPPUNIT_ASSERT( tracker_list.has_active_not_scrape()); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "100100", false)); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "110100", true)); CPPUNIT_ASSERT(tracker_1->trigger_success()); TEST_TRACKERS_IS_BUSY_5("00110", "00110"); CPPUNIT_ASSERT( tracker_list.has_active()); CPPUNIT_ASSERT( tracker_list.has_active_not_scrape()); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "000100", false)); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "010100", true)); CPPUNIT_ASSERT(tracker_2->trigger_scrape()); CPPUNIT_ASSERT(tracker_3->trigger_success()); TEST_TRACKERS_IS_BUSY_5("00000", "00000"); CPPUNIT_ASSERT(!tracker_list.has_active()); CPPUNIT_ASSERT(!tracker_list.has_active_not_scrape()); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "000000", false)); CPPUNIT_ASSERT(check_has_active_in_group(&tracker_list, "000000", true)); } libtorrent-0.13.2/test/torrent/tracker_list_test.h000644 000765 000024 00000016035 11740502002 023267 0ustar00rakshasastaff000000 000000 #include #include #include #include class tracker_list_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(tracker_list_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_enable); CPPUNIT_TEST(test_close); CPPUNIT_TEST(test_tracker_flags); CPPUNIT_TEST(test_find_url); CPPUNIT_TEST(test_can_scrape); CPPUNIT_TEST(test_single_success); CPPUNIT_TEST(test_single_failure); CPPUNIT_TEST(test_single_closing); CPPUNIT_TEST(test_multiple_success); CPPUNIT_TEST(test_scrape_success); CPPUNIT_TEST(test_scrape_failure); CPPUNIT_TEST(test_has_active); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void test_basic(); void test_enable(); void test_close(); void test_tracker_flags(); void test_find_url(); void test_can_scrape(); void test_single_success(); void test_single_failure(); void test_single_closing(); void test_multiple_success(); void test_scrape_success(); void test_scrape_failure(); void test_has_active(); }; class TrackerTest : public torrent::Tracker { public: static const int flag_close_on_done = max_flag_size << 0; static const int flag_scrape_on_success = max_flag_size << 1; // TODO: Clean up tracker related enums. TrackerTest(torrent::TrackerList* parent, const std::string& url, int flags = torrent::Tracker::flag_enabled) : torrent::Tracker(parent, url, flags), m_busy(false), m_open(false), m_requesting_state(-1) { m_flags |= flag_close_on_done; } virtual bool is_busy() const { return m_busy; } bool is_open() const { return m_open; } virtual Type type() const { return (Type)(TRACKER_DHT + 1); } int requesting_state() const { return m_requesting_state; } bool trigger_success(uint32_t new_peers = 0, uint32_t sum_peers = 0); bool trigger_success(torrent::TrackerList::address_list* address_list, uint32_t new_peers = 0); bool trigger_failure(); bool trigger_scrape(); void set_close_on_done(bool state) { if (state) m_flags |= flag_close_on_done; else m_flags &= ~flag_close_on_done; } void set_scrape_on_success(bool state) { if (state) m_flags |= flag_scrape_on_success; else m_flags &= ~flag_scrape_on_success; } void set_can_scrape() { m_flags |= flag_can_scrape; } void set_success(uint32_t counter, uint32_t time_last) { m_success_counter = counter; m_success_time_last = time_last; } void set_failed(uint32_t counter, uint32_t time_last) { m_failed_counter = counter; m_failed_time_last = time_last; } void set_latest_new_peers(uint32_t peers) { m_latest_new_peers = peers; } void set_latest_sum_peers(uint32_t peers) { m_latest_sum_peers = peers; } virtual void send_state(int state) { m_busy = true; m_open = true; m_requesting_state = m_latest_event = state; } virtual void send_scrape() { m_busy = true; m_open = true; m_requesting_state = m_latest_event = torrent::Tracker::EVENT_SCRAPE; } virtual void close() { m_busy = false; m_open = false; m_requesting_state = -1; } virtual void disown() { m_busy = false; m_open = false; m_requesting_state = -1; } private: bool m_busy; bool m_open; int m_requesting_state; }; extern uint32_t return_new_peers; inline uint32_t increment_value(int* value) { (*value)++; return return_new_peers; } bool check_has_active_in_group(const torrent::TrackerList* tracker_list, const char* states, bool scrape); #define TRACKER_SETUP() \ torrent::TrackerList tracker_list; \ int success_counter = 0; \ int failure_counter = 0; \ int scrape_success_counter = 0; \ int scrape_failure_counter = 0; \ tracker_list.slot_success() = tr1::bind(&increment_value, &success_counter); \ tracker_list.slot_failure() = tr1::bind(&increment_value, &failure_counter); \ tracker_list.slot_scrape_success() = tr1::bind(&increment_value, &scrape_success_counter); \ tracker_list.slot_scrape_failure() = tr1::bind(&increment_value, &scrape_failure_counter); #define TRACKER_INSERT(group, name) \ TrackerTest* name = new TrackerTest(&tracker_list, ""); \ tracker_list.insert(group, name); #define TEST_TRACKER_IS_BUSY(tracker, state) \ CPPUNIT_ASSERT(state == '0' || tracker->is_busy()); \ CPPUNIT_ASSERT(state == '1' || !tracker->is_busy()); #define TEST_MULTI3_IS_BUSY(original, rearranged) \ TEST_TRACKER_IS_BUSY(tracker_0_0, original[0]); \ TEST_TRACKER_IS_BUSY(tracker_0_1, original[1]); \ TEST_TRACKER_IS_BUSY(tracker_1_0, original[2]); \ TEST_TRACKER_IS_BUSY(tracker_2_0, original[3]); \ TEST_TRACKER_IS_BUSY(tracker_3_0, original[4]); \ TEST_TRACKER_IS_BUSY(tracker_list[0], rearranged[0]); \ TEST_TRACKER_IS_BUSY(tracker_list[1], rearranged[1]); \ TEST_TRACKER_IS_BUSY(tracker_list[2], rearranged[2]); \ TEST_TRACKER_IS_BUSY(tracker_list[3], rearranged[3]); \ TEST_TRACKER_IS_BUSY(tracker_list[4], rearranged[4]); #define TEST_GROUP_IS_BUSY(original, rearranged) \ TEST_TRACKER_IS_BUSY(tracker_0_0, original[0]); \ TEST_TRACKER_IS_BUSY(tracker_0_1, original[1]); \ TEST_TRACKER_IS_BUSY(tracker_0_2, original[2]); \ TEST_TRACKER_IS_BUSY(tracker_1_0, original[3]); \ TEST_TRACKER_IS_BUSY(tracker_1_1, original[4]); \ TEST_TRACKER_IS_BUSY(tracker_2_0, original[5]); \ TEST_TRACKER_IS_BUSY(tracker_list[0], rearranged[0]); \ TEST_TRACKER_IS_BUSY(tracker_list[1], rearranged[1]); \ TEST_TRACKER_IS_BUSY(tracker_list[2], rearranged[2]); \ TEST_TRACKER_IS_BUSY(tracker_list[3], rearranged[3]); \ TEST_TRACKER_IS_BUSY(tracker_list[4], rearranged[4]); \ TEST_TRACKER_IS_BUSY(tracker_list[5], rearranged[5]); #define TEST_TRACKERS_IS_BUSY_5(original, rearranged) \ TEST_TRACKER_IS_BUSY(tracker_0, original[0]); \ TEST_TRACKER_IS_BUSY(tracker_1, original[1]); \ TEST_TRACKER_IS_BUSY(tracker_2, original[2]); \ TEST_TRACKER_IS_BUSY(tracker_3, original[3]); \ TEST_TRACKER_IS_BUSY(tracker_4, original[4]); \ TEST_TRACKER_IS_BUSY(tracker_list[0], rearranged[0]); \ TEST_TRACKER_IS_BUSY(tracker_list[1], rearranged[1]); \ TEST_TRACKER_IS_BUSY(tracker_list[2], rearranged[2]); \ TEST_TRACKER_IS_BUSY(tracker_list[3], rearranged[3]); \ TEST_TRACKER_IS_BUSY(tracker_list[4], rearranged[4]); libtorrent-0.13.2/test/torrent/tracker_timeout_test.cc000644 000765 000024 00000012616 11741025651 024154 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "rak/priority_queue_default.h" #include "globals.h" #include "tracker_list_test.h" #include "tracker_timeout_test.h" namespace tr1 { using namespace std::tr1; } CPPUNIT_TEST_SUITE_REGISTRATION(tracker_timeout_test); void tracker_timeout_test::setUp() { torrent::cachedTime = rak::timer::current(); // torrent::cachedTime = rak::timer::current().round_seconds(); } void tracker_timeout_test::tearDown() { } void tracker_timeout_test::test_timeout_tracker() { TrackerTest tracker(NULL, ""); int flags = 0; CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); torrent::cachedTime += rak::timer::from_seconds(3); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); flags = torrent::TrackerController::flag_active; CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.send_state(torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == ~uint32_t()); tracker.send_state(torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.close(); tracker.set_success(1, torrent::cachedTime.seconds()); // Check also failed... CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 1800); tracker.send_state(torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == ~uint32_t()); tracker.send_state(torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 1800); tracker.close(); tracker.set_success(1, torrent::cachedTime.seconds() - 3); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 1800 - 3); tracker.set_success(1, torrent::cachedTime.seconds() + 3); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 1800 + 3); tracker.close(); flags = torrent::TrackerController::flag_active | torrent::TrackerController::flag_promiscuous_mode; CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.send_state(torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == ~uint32_t()); tracker.send_state(torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); } void tracker_timeout_test::test_timeout_update() { TrackerTest tracker(NULL, ""); int flags = 0; flags = torrent::TrackerController::flag_active | torrent::TrackerController::flag_send_update; CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.send_state(torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.send_state(torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == ~uint32_t()); tracker.close(); tracker.set_failed(1, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.set_failed(0, torrent::cachedTime.seconds()); tracker.set_success(0, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); } void tracker_timeout_test::test_timeout_requesting() { TrackerTest tracker(NULL, ""); int flags = 0; flags = torrent::TrackerController::flag_active | torrent::TrackerController::flag_requesting; CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.send_state(torrent::Tracker::EVENT_SCRAPE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 0); tracker.send_state(torrent::Tracker::EVENT_NONE); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == ~uint32_t()); // tracker.set_latest_new_peers(10 - 1); tracker.close(); tracker.set_failed(1, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 5); tracker.set_failed(2, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 10); tracker.set_failed(6 + 1, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 320); tracker.set_failed(7 + 1, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 320); //std::cout << "timeout:" << torrent::tracker_next_timeout(&tracker, flags) << std::endl; tracker.set_failed(0, torrent::cachedTime.seconds()); tracker.set_success(0, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 10); tracker.set_success(1, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 20); tracker.set_success(2, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 600); tracker.set_success(6, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 600); tracker.set_success(1, torrent::cachedTime.seconds()); tracker.set_latest_sum_peers(9); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 20); tracker.set_latest_sum_peers(10); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 600); tracker.set_latest_sum_peers(10); tracker.set_latest_new_peers(10); tracker.set_success(1, torrent::cachedTime.seconds()); CPPUNIT_ASSERT(torrent::tracker_next_timeout(&tracker, flags) == 600); } libtorrent-0.13.2/test/torrent/tracker_timeout_test.h000644 000765 000024 00000000735 11705767057 024032 0ustar00rakshasastaff000000 000000 #include #include "torrent/tracker_controller.h" class tracker_timeout_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(tracker_timeout_test); CPPUNIT_TEST(test_timeout_tracker); CPPUNIT_TEST(test_timeout_update); CPPUNIT_TEST(test_timeout_requesting); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_timeout_tracker(); void test_timeout_update(); void test_timeout_requesting(); }; libtorrent-0.13.2/test/torrent/utils/000755 000765 000024 00000000000 11744204514 020537 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/test/torrent/utils/extents_test.cc000644 000765 000024 00000003272 11721626402 023602 0ustar00rakshasastaff000000 000000 #include "config.h" #include "extents_test.h" #include #include #include CPPUNIT_TEST_SUITE_REGISTRATION(ExtentsTest); void ExtentsTest::setUp() { } void ExtentsTest::tearDown() { } typedef torrent::extents extent_type_1; // typedef torrent::extents extent_type_3; template bool verify_extent_data(Extent& extent, const uint32_t* idx, const int* val) { while (*idx != *(idx + 1)) { if (!extent.is_equal_range(*idx, *(idx + 1) - 1, *val)) { // std::cout << *idx << ' ' << *(idx + 1) << ' ' << *val << std::endl; // std::cout << extent.at(*idx) << std::endl; // std::cout << extent.at(*(idx + 1)) << std::endl; return false; } idx++; val++; } return true; } static const uint32_t idx_empty[] = {0, 256, 256}; static const int val_empty[] = {0, 1}; static const uint32_t idx_basic_1[] = {0, 1, 255, 256, 256}; static const int val_basic_1[] = {1, 0, 1}; static const uint32_t idx_basic_2[] = {0, 1, 16, 255, 256, 256}; static const int val_basic_2[] = {1, 0, 2, 1}; void ExtentsTest::test_basic() { extent_type_1 extent_1; // Test empty. CPPUNIT_ASSERT(verify_extent_data(extent_1, idx_empty, val_empty)); CPPUNIT_ASSERT(extent_1.at(0) == int()); CPPUNIT_ASSERT(extent_1.at(255) == int()); extent_1.insert(0, 0, 1); extent_1.insert(255, 0, 1); CPPUNIT_ASSERT(extent_1.at(0) == 1); CPPUNIT_ASSERT(extent_1.at(255) == 1); CPPUNIT_ASSERT(verify_extent_data(extent_1, idx_basic_1, val_basic_1)); // extent_1.insert(38, 3, 2); // CPPUNIT_ASSERT(verify_extent_data(extent_1, idx_basic_2, val_basic_2)); } libtorrent-0.13.2/test/torrent/utils/extents_test.h000644 000765 000024 00000000400 11721626402 023432 0ustar00rakshasastaff000000 000000 #include class ExtentsTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ExtentsTest); CPPUNIT_TEST(test_basic); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); }; libtorrent-0.13.2/test/torrent/utils/log_buffer_test.cc000644 000765 000024 00000003466 11727634354 024242 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include "globals.h" #include "log_buffer_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(utils_log_buffer_test); namespace tr1 { using namespace std::tr1; } void utils_log_buffer_test::setUp() { torrent::cachedTime = rak::timer::from_seconds(1000); } void utils_log_buffer_test::tearDown() { } void utils_log_buffer_test::test_basic() { torrent::log_buffer log; log.lock(); CPPUNIT_ASSERT(log.empty()); CPPUNIT_ASSERT(log.find_older(0) == log.end()); log.unlock(); log.lock_and_push_log("foobar", 6, -1); CPPUNIT_ASSERT(log.empty()); log.lock_and_push_log("foobar", 6, 0); CPPUNIT_ASSERT(log.size() == 1); CPPUNIT_ASSERT(log.back().timestamp == 1000); CPPUNIT_ASSERT(log.back().group == 0); CPPUNIT_ASSERT(log.back().message == "foobar"); torrent::cachedTime += rak::timer::from_milliseconds(1000); log.lock_and_push_log("barbaz", 6, 0); CPPUNIT_ASSERT(log.size() == 2); CPPUNIT_ASSERT(log.back().timestamp == 1001); CPPUNIT_ASSERT(log.back().group == 0); CPPUNIT_ASSERT(log.back().message == "barbaz"); } void utils_log_buffer_test::test_timestamps() { torrent::log_buffer log; log.lock_and_push_log("foobar", 6, 0); CPPUNIT_ASSERT(log.back().timestamp == 1000); CPPUNIT_ASSERT(log.find_older(1000 - 1) == log.begin()); CPPUNIT_ASSERT(log.find_older(1000) == log.end()); CPPUNIT_ASSERT(log.find_older(1000 + 1) == log.end()); torrent::cachedTime += rak::timer::from_milliseconds(10 * 1000); log.lock_and_push_log("foobar", 6, 0); CPPUNIT_ASSERT(log.back().timestamp == 1010); CPPUNIT_ASSERT(log.find_older(1010 - 10) == log.begin()); CPPUNIT_ASSERT(log.find_older(1010 - 1) == log.begin() + 1); CPPUNIT_ASSERT(log.find_older(1010) == log.end()); CPPUNIT_ASSERT(log.find_older(1010 + 1) == log.end()); } libtorrent-0.13.2/test/torrent/utils/log_buffer_test.h000644 000765 000024 00000000566 11727634354 024102 0ustar00rakshasastaff000000 000000 #include #include "torrent/utils/log_buffer.h" class utils_log_buffer_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(utils_log_buffer_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_timestamps); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_timestamps(); }; libtorrent-0.13.2/test/torrent/utils/log_test.cc000644 000765 000024 00000011013 11717116032 022657 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include #include #include #include #include #include "log_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(utils_log_test); namespace tr1 { using namespace std::tr1; } const char* expected_output = NULL; unsigned int output_mask; static void test_output(const char* output, unsigned int length, unsigned int mask) { CPPUNIT_ASSERT_MESSAGE("'" + std::string(output) + "' != '" + std::string(expected_output) + "'", std::strcmp(output, expected_output) == 0); CPPUNIT_ASSERT_MESSAGE("'" + std::string(output) + "'", std::strlen(output) == length); output_mask |= mask; } #define LTUNIT_ASSERT_OUTPUT(group, mask, expected, ...) \ output_mask = 0; expected_output = expected; \ lt_log_print(group, __VA_ARGS__); \ CPPUNIT_ASSERT(output_mask == (mask)); void utils_log_test::setUp() { // Don't initialize since this creates the group->child connections. // torrent::log_initialize(); } void utils_log_test::tearDown() { torrent::log_cleanup(); } void utils_log_test::test_basic() { CPPUNIT_ASSERT(!torrent::log_groups.empty()); CPPUNIT_ASSERT(torrent::log_groups.size() == torrent::LOG_GROUP_MAX_SIZE); CPPUNIT_ASSERT(std::find_if(torrent::log_groups.begin(), torrent::log_groups.end(), tr1::bind(&torrent::log_group::valid, tr1::placeholders::_1)) == torrent::log_groups.end()); } inline void open_output(const char* name, int mask = 0) { torrent::log_open_output(name, tr1::bind(&::test_output, tr1::placeholders::_1, tr1::placeholders::_2, mask)); } void utils_log_test::test_output_open() { CPPUNIT_ASSERT(torrent::log_groups[0].size_outputs() == 0); // Add test for unknown output names. open_output("test_output_1", 0x0); torrent::log_add_group_output(0, "test_output_1"); CPPUNIT_ASSERT(torrent::log_outputs.size() == 1); CPPUNIT_ASSERT(torrent::log_outputs[0].first == "test_output_1"); CPPUNIT_ASSERT(torrent::log_groups[0].outputs() == 0x1); CPPUNIT_ASSERT(torrent::log_groups[0].size_outputs() == 1); // Test inserting duplicate names, should catch. // CPPUNIT_ASSERT_THROW(torrent::log_open_output("test_output_1", torrent::log_slot());, torrent::input_error); try { torrent::log_open_output("test_output_1", torrent::log_slot()); } catch (torrent::input_error& e) { return; } CPPUNIT_ASSERT(false); // Test more than 64 entries. } // Test to make sure we don't call functions when using lt_log_print // on unused log items. void utils_log_test::test_print() { open_output("test_print_1", 0x1); open_output("test_print_2", 0x2); torrent::log_add_group_output(0, "test_print_1"); LTUNIT_ASSERT_OUTPUT(0, 0x1, "foo_bar", "foo_bar"); LTUNIT_ASSERT_OUTPUT(0, 0x1, "foo 123 bar", "foo %i %s", 123, "bar"); torrent::log_add_group_output(0, "test_print_2"); LTUNIT_ASSERT_OUTPUT(0, 0x1|0x2, "test_multiple", "test_multiple"); } enum { GROUP_PARENT_1, GROUP_PARENT_2, GROUP_CHILD_1, GROUP_CHILD_1_1 }; void utils_log_test::test_children() { open_output("test_children_1", 0x1); open_output("test_children_2", 0x2); torrent::log_add_group_output(GROUP_PARENT_1, "test_children_1"); torrent::log_add_group_output(GROUP_PARENT_2, "test_children_2"); torrent::log_add_child(GROUP_PARENT_1, GROUP_CHILD_1); torrent::log_add_child(GROUP_CHILD_1, GROUP_CHILD_1_1); // std::cout << "cached_output(" << torrent::log_groups[GROUP_PARENT_1].cached_outputs() << ')'; LTUNIT_ASSERT_OUTPUT(GROUP_PARENT_1, 0x1, "parent_1", "parent_1"); LTUNIT_ASSERT_OUTPUT(GROUP_CHILD_1, 0x1, "child_1", "child_1"); LTUNIT_ASSERT_OUTPUT(GROUP_CHILD_1_1, 0x1, "child_1", "child_1"); torrent::log_add_child(GROUP_PARENT_2, GROUP_CHILD_1); LTUNIT_ASSERT_OUTPUT(GROUP_PARENT_2, 0x2, "parent_2", "parent_2"); LTUNIT_ASSERT_OUTPUT(GROUP_CHILD_1, 0x3, "child_1", "child_1"); LTUNIT_ASSERT_OUTPUT(GROUP_CHILD_1_1, 0x3, "child_1", "child_1"); } void utils_log_test::test_file_output() { char* filename = tmpnam(NULL); torrent::log_open_file_output("test_file", filename); torrent::log_add_group_output(GROUP_PARENT_1, "test_file"); lt_log_print(GROUP_PARENT_1, "test_file"); torrent::log_cleanup(); // To ensure we flush the buffers. std::ifstream temp_file(filename); CPPUNIT_ASSERT(temp_file.good()); char buffer[256]; temp_file.getline(buffer, 256); CPPUNIT_ASSERT_MESSAGE(buffer, std::string(buffer).find("test_file") != std::string::npos); } libtorrent-0.13.2/test/torrent/utils/log_test.h000644 000765 000024 00000001012 11705767057 022537 0ustar00rakshasastaff000000 000000 #include #include "torrent/utils/log.h" class utils_log_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(utils_log_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_output_open); CPPUNIT_TEST(test_print); CPPUNIT_TEST(test_children); CPPUNIT_TEST(test_file_output); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_output_open(); void test_print(); void test_children(); void test_file_output(); }; libtorrent-0.13.2/test/torrent/utils/option_strings_test.cc000644 000765 000024 00000002720 11716350717 025175 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include "option_strings_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(option_strings_test); namespace tr1 { using namespace std::tr1; } void option_strings_test::test_basic() { } #define TEST_ENTRY(group, name, value) \ { std::string result(torrent::option_as_string(torrent::group, value)); \ CPPUNIT_ASSERT_MESSAGE("Not found '" + result + "'", result == name); \ CPPUNIT_ASSERT(torrent::option_find_string(torrent::group, name) == value); } void option_strings_test::test_entries() { TEST_ENTRY(OPTION_CONNECTION_TYPE, "leech", torrent::Download::CONNECTION_LEECH); TEST_ENTRY(OPTION_CONNECTION_TYPE, "seed", torrent::Download::CONNECTION_SEED); TEST_ENTRY(OPTION_CONNECTION_TYPE, "initial_seed", torrent::Download::CONNECTION_INITIAL_SEED); TEST_ENTRY(OPTION_CONNECTION_TYPE, "metadata", torrent::Download::CONNECTION_METADATA); TEST_ENTRY(OPTION_LOG_GROUP, "critical", torrent::LOG_CRITICAL); TEST_ENTRY(OPTION_LOG_GROUP, "storage_notice", torrent::LOG_STORAGE_NOTICE); TEST_ENTRY(OPTION_LOG_GROUP, "torrent_debug", torrent::LOG_TORRENT_DEBUG); } libtorrent-0.13.2/test/torrent/utils/option_strings_test.h000644 000765 000024 00000000564 11705767057 025052 0ustar00rakshasastaff000000 000000 #include #include "torrent/utils/option_strings.h" class option_strings_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(option_strings_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_entries); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void test_basic(); void test_entries(); }; libtorrent-0.13.2/test/torrent/utils/signal_bitfield_test.cc000644 000765 000024 00000010025 11721117103 025212 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include #include "signal_bitfield_test.h" #include "thread_base_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(utils_signal_bitfield_test); namespace tr1 { using namespace std::tr1; } static void mark_index(uint32_t* bitfield, unsigned int index) { __sync_fetch_and_or(bitfield, 1 << index); } static bool check_index(uint32_t* bitfield, unsigned int index) { return *bitfield & (1 << index); } void utils_signal_bitfield_test::setUp() { } void utils_signal_bitfield_test::tearDown() { CPPUNIT_ASSERT(torrent::thread_base::trylock_global_lock()); torrent::thread_base::release_global_lock(); } static bool verify_did_internal_error(tr1::function func, bool should_throw) { bool did_throw = false; try { func(); } catch (torrent::internal_error& e) { did_throw = true; } return should_throw == did_throw; } #define SETUP_SIGNAL_BITFIELD() \ uint32_t marked_bitfield = 0; \ torrent::signal_bitfield signal_bitfield; #define SIGNAL_BITFIELD_DID_INTERNAL_ERROR(verify_slot, did_throw) \ CPPUNIT_ASSERT(verify_did_internal_error(tr1::bind(&torrent::signal_bitfield::add_signal, \ &signal_bitfield, \ torrent::signal_bitfield::slot_type(verify_slot)), \ did_throw)); void utils_signal_bitfield_test::test_basic() { SETUP_SIGNAL_BITFIELD(); CPPUNIT_ASSERT(torrent::signal_bitfield::max_size == sizeof(torrent::signal_bitfield::bitfield_type) * 8); SIGNAL_BITFIELD_DID_INTERNAL_ERROR(torrent::signal_bitfield::slot_type(), true); for (unsigned int i = 0; i < torrent::signal_bitfield::max_size; i++) CPPUNIT_ASSERT(signal_bitfield.add_signal(tr1::bind(&mark_index, &marked_bitfield, i)) == i); SIGNAL_BITFIELD_DID_INTERNAL_ERROR(tr1::bind(&mark_index, &marked_bitfield, torrent::signal_bitfield::max_size), true); } void utils_signal_bitfield_test::test_single() { SETUP_SIGNAL_BITFIELD(); CPPUNIT_ASSERT(signal_bitfield.add_signal(tr1::bind(&mark_index, &marked_bitfield, 0)) == 0); signal_bitfield.signal(0); CPPUNIT_ASSERT(marked_bitfield == 0x0); signal_bitfield.work(); CPPUNIT_ASSERT(marked_bitfield == 0x1); marked_bitfield = 0; signal_bitfield.work(); CPPUNIT_ASSERT(marked_bitfield == 0x0); } void utils_signal_bitfield_test::test_multiple() { SETUP_SIGNAL_BITFIELD(); for (unsigned int i = 0; i < torrent::signal_bitfield::max_size; i++) CPPUNIT_ASSERT(signal_bitfield.add_signal(tr1::bind(&mark_index, &marked_bitfield, i)) == i); signal_bitfield.signal(2); signal_bitfield.signal(31); CPPUNIT_ASSERT(marked_bitfield == 0x0); signal_bitfield.work(); CPPUNIT_ASSERT(marked_bitfield == (((unsigned int)1 << 2) | ((unsigned int)1 << 31))); marked_bitfield = 0; signal_bitfield.work(); CPPUNIT_ASSERT(marked_bitfield == 0x0); } void utils_signal_bitfield_test::test_thread() { uint32_t marked_bitfield = 0; thread_test* thread = new thread_test; // thread->set_test_flag(thread_test::test_flag_long_timeout); for (unsigned int i = 0; i < torrent::signal_bitfield::max_size; i++) CPPUNIT_ASSERT(thread->signal_bitfield()->add_signal(tr1::bind(&mark_index, &marked_bitfield, i)) == i); thread->init_thread(); thread->start_thread(); // Vary the various timeouts. for (int i = 0; i < 100; i++) { // thread->interrupt(); // usleep(0); thread->signal_bitfield()->signal(i % 20); // thread->interrupt(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&check_index, &marked_bitfield, i % 20))); __sync_fetch_and_and(&marked_bitfield, ~uint32_t()); } thread->stop_thread(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_state, thread, thread_test::STATE_INACTIVE))); delete thread; } // Test invalid signal added. // Test overflow signals added. // Test multiple signals triggered. // Stresstest with real thread/polling. libtorrent-0.13.2/test/torrent/utils/signal_bitfield_test.h000644 000765 000024 00000000751 11716350717 025077 0ustar00rakshasastaff000000 000000 #include #include "torrent/utils/signal_bitfield.h" class utils_signal_bitfield_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(utils_signal_bitfield_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_single); CPPUNIT_TEST(test_multiple); CPPUNIT_TEST(test_thread); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_single(); void test_multiple(); void test_thread(); }; libtorrent-0.13.2/test/torrent/utils/thread_base_test.cc000644 000765 000024 00000013710 11721117103 024340 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include #include #include #include "thread_base_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(utils_thread_base_test); namespace tr1 { using namespace std::tr1; } void throw_shutdown_exception() { throw torrent::shutdown_exception(); } thread_test::thread_test() : m_test_state(TEST_NONE), m_test_flags(0) { } void thread_test::init_thread() { m_state = STATE_INITIALIZED; m_test_state = TEST_PRE_START; m_poll = torrent::PollSelect::create(256); } void thread_test::call_events() { if ((m_test_flags & test_flag_pre_stop) && m_test_state == TEST_PRE_START && m_state == STATE_ACTIVE) __sync_lock_test_and_set(&m_test_state, TEST_PRE_STOP); if ((m_test_flags & test_flag_acquire_global)) { acquire_global_lock(); __sync_and_and_fetch(&m_test_flags, ~test_flag_acquire_global); __sync_or_and_fetch(&m_test_flags, test_flag_has_global); } if ((m_flags & flag_do_shutdown)) { if ((m_flags & flag_did_shutdown)) throw torrent::internal_error("Already trigged shutdown."); __sync_or_and_fetch(&m_flags, flag_did_shutdown); throw torrent::shutdown_exception(); } if ((m_test_flags & test_flag_pre_poke)) { } if ((m_test_flags & test_flag_do_work)) { usleep(10 * 1000); // TODO: Don't just sleep, as that give up core. __sync_and_and_fetch(&m_test_flags, ~test_flag_do_work); } if ((m_test_flags & test_flag_post_poke)) { } } bool wait_for_true(std::tr1::function test_function) { int i = 100; do { if (test_function()) return true; usleep(10 * 1000); } while (--i); return false; } void utils_thread_base_test::setUp() { } void utils_thread_base_test::tearDown() { CPPUNIT_ASSERT(torrent::thread_base::trylock_global_lock()); torrent::thread_base::release_global_lock(); } void utils_thread_base_test::test_basic() { thread_test* thread = new thread_test; CPPUNIT_ASSERT(thread->flags() == 0); CPPUNIT_ASSERT(!thread->is_main_polling()); CPPUNIT_ASSERT(!thread->is_active()); CPPUNIT_ASSERT(thread->global_queue_size() == 0); CPPUNIT_ASSERT(thread->poll() == NULL); // Check active... } void utils_thread_base_test::test_lifecycle() { thread_test* thread = new thread_test; CPPUNIT_ASSERT(thread->state() == torrent::thread_base::STATE_UNKNOWN); CPPUNIT_ASSERT(thread->test_state() == thread_test::TEST_NONE); thread->init_thread(); CPPUNIT_ASSERT(thread->state() == torrent::thread_base::STATE_INITIALIZED); CPPUNIT_ASSERT(thread->is_initialized()); CPPUNIT_ASSERT(thread->test_state() == thread_test::TEST_PRE_START); thread->set_pre_stop(); CPPUNIT_ASSERT(!wait_for_true(tr1::bind(&thread_test::is_test_state, thread, thread_test::TEST_PRE_STOP))); thread->start_thread(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_state, thread, thread_test::STATE_ACTIVE))); CPPUNIT_ASSERT(thread->is_active()); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_test_state, thread, thread_test::TEST_PRE_STOP))); thread->stop_thread(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_state, thread, thread_test::STATE_INACTIVE))); CPPUNIT_ASSERT(thread->is_inactive()); delete thread; } void utils_thread_base_test::test_global_lock_basic() { thread_test* thread = new thread_test; thread->init_thread(); thread->start_thread(); CPPUNIT_ASSERT(torrent::thread_base::global_queue_size() == 0); // Acquire main thread... CPPUNIT_ASSERT(torrent::thread_base::trylock_global_lock()); CPPUNIT_ASSERT(!torrent::thread_base::trylock_global_lock()); torrent::thread_base::release_global_lock(); CPPUNIT_ASSERT(torrent::thread_base::trylock_global_lock()); CPPUNIT_ASSERT(!torrent::thread_base::trylock_global_lock()); torrent::thread_base::release_global_lock(); torrent::thread_base::acquire_global_lock(); CPPUNIT_ASSERT(!torrent::thread_base::trylock_global_lock()); thread->set_acquire_global(); CPPUNIT_ASSERT(!wait_for_true(tr1::bind(&thread_test::is_test_flags, thread, thread_test::test_flag_has_global))); torrent::thread_base::release_global_lock(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_test_flags, thread, thread_test::test_flag_has_global))); CPPUNIT_ASSERT(!torrent::thread_base::trylock_global_lock()); torrent::thread_base::release_global_lock(); CPPUNIT_ASSERT(torrent::thread_base::trylock_global_lock()); // Test waive (loop). CPPUNIT_ASSERT(torrent::thread_base::global_queue_size() == 0); torrent::thread_base::release_global_lock(); thread->stop_thread(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_state, thread, thread_test::STATE_INACTIVE))); delete thread; } void utils_thread_base_test::test_interrupt() { thread_test* thread = new thread_test; thread->set_test_flag(thread_test::test_flag_long_timeout); thread->init_thread(); thread->start_thread(); // Vary the various timeouts. for (int i = 0; i < 100; i++) { thread->interrupt(); usleep(0); thread->set_test_flag(thread_test::test_flag_do_work); thread->interrupt(); // Wait for flag to clear. CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_not_test_flags, thread, thread_test::test_flag_do_work))); } thread->stop_thread(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&thread_test::is_state, thread, thread_test::STATE_INACTIVE))); delete thread; } void utils_thread_base_test::test_stop() { CPPUNIT_ASSERT(torrent::thread_base::trylock_global_lock()); // torrent::thread_base::acquire_global_lock(); for (int i = 0; i < 20; i++) { CPPUNIT_ASSERT(!torrent::thread_base::trylock_global_lock()); thread_test* thread = new thread_test; thread->set_test_flag(thread_test::test_flag_do_work); thread->init_thread(); thread->start_thread(); thread->stop_thread_wait(); CPPUNIT_ASSERT(thread->is_inactive()); delete thread; } torrent::thread_base::release_global_lock(); } libtorrent-0.13.2/test/torrent/utils/thread_base_test.h000644 000765 000024 00000005531 11716350717 024222 0ustar00rakshasastaff000000 000000 #include #include "torrent/utils/thread_base.h" class utils_thread_base_test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(utils_thread_base_test); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_lifecycle); CPPUNIT_TEST(test_global_lock_basic); CPPUNIT_TEST(test_interrupt); CPPUNIT_TEST(test_stop); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_lifecycle(); void test_global_lock_basic(); void test_interrupt(); void test_stop(); }; struct thread_management_type { thread_management_type() { CPPUNIT_ASSERT(torrent::thread_base::trylock_global_lock()); } ~thread_management_type() { torrent::thread_base::release_global_lock(); } }; #define SETUP_THREAD() \ thread_management_type thread_management; \ torrent::thread_disk* thread_disk = new torrent::thread_disk(); \ thread_disk->init_thread(); #define CLEANUP_THREAD() \ CPPUNIT_ASSERT(wait_for_true(tr1::bind(&torrent::thread_base::is_inactive, thread_disk))); \ delete thread_disk; bool wait_for_true(std::tr1::function test_function); class thread_test : public torrent::thread_base { public: enum test_state { TEST_NONE, TEST_PRE_START, TEST_PRE_STOP, TEST_STOP }; static const int test_flag_pre_stop = 0x1; static const int test_flag_long_timeout = 0x2; static const int test_flag_acquire_global = 0x10; static const int test_flag_has_global = 0x20; static const int test_flag_do_work = 0x100; static const int test_flag_pre_poke = 0x200; static const int test_flag_post_poke = 0x400; thread_test(); int test_state() const { return m_test_state; } bool is_state(int state) const { return m_state == state; } bool is_test_state(int state) const { return m_test_state == state; } bool is_test_flags(int flags) const { return (m_test_flags & flags) == flags; } bool is_not_test_flags(int flags) const { return !(m_test_flags & flags); } const char* name() const { return "test_thread"; } void init_thread(); void set_pre_stop() { __sync_or_and_fetch(&m_test_flags, test_flag_pre_stop); } void set_acquire_global() { __sync_or_and_fetch(&m_test_flags, test_flag_acquire_global); } void set_test_flag(int flags) { __sync_or_and_fetch(&m_test_flags, flags); } private: void call_events(); int64_t next_timeout_usec() { return (m_test_flags & test_flag_long_timeout) ? (10000 * 1000) : (100 * 1000); } int m_test_state lt_cacheline_aligned; int m_test_flags lt_cacheline_aligned; }; libtorrent-0.13.2/test/rak/allocators_test.cc000644 000765 000024 00000001230 11705767057 022201 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include "allocators_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(AllocatorsTest); template bool is_aligned(const T& t) { return t.empty() || (reinterpret_cast(&t[0]) & (LT_SMP_CACHE_BYTES - 1)) == 0x0; } void AllocatorsTest::testAlignment() { aligned_vector_type v1; aligned_vector_type v2(1, 'a'); aligned_vector_type v3(16, 'a'); aligned_vector_type v4(LT_SMP_CACHE_BYTES, 'b'); aligned_vector_type v5(1, 'a'); CPPUNIT_ASSERT(is_aligned(v1)); CPPUNIT_ASSERT(is_aligned(v2)); CPPUNIT_ASSERT(is_aligned(v3)); CPPUNIT_ASSERT(is_aligned(v4)); CPPUNIT_ASSERT(is_aligned(v5)); } libtorrent-0.13.2/test/rak/allocators_test.h000644 000765 000024 00000000623 11705767057 022050 0ustar00rakshasastaff000000 000000 #include #include #include "rak/allocators.h" class AllocatorsTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(AllocatorsTest); CPPUNIT_TEST(testAlignment); CPPUNIT_TEST_SUITE_END(); public: typedef std::vector > aligned_vector_type; void setUp() {} void tearDown() {} void testAlignment(); }; libtorrent-0.13.2/test/rak/ranges_test.cc000644 000765 000024 00000007764 11716350717 021330 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include "ranges_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(RangesTest); template bool verify_ranges(const torrent::ranges& ranges) { typename torrent::ranges::const_iterator first = ranges.begin(); typename torrent::ranges::const_iterator last = ranges.begin(); if (first == last) return true; if (first->second <= first->first) return false; Type boundary = first++->second; do { if (first->first <= boundary) return false; if (first->second <= first->first) return false; } while (++first != last); return true; } void RangesTest::test_basic() { } void RangesTest::test_intersect() { torrent::ranges range; CPPUNIT_ASSERT(verify_ranges(range)); CPPUNIT_ASSERT(range.intersect_distance(0, 0) == 0); CPPUNIT_ASSERT(range.intersect_distance(0, 10) == 0); range.insert(0, 5); CPPUNIT_ASSERT(verify_ranges(range)); CPPUNIT_ASSERT(range.intersect_distance(0, 5) == 5); CPPUNIT_ASSERT(range.intersect_distance(0, 10) == 5); CPPUNIT_ASSERT(range.intersect_distance(-5, 5) == 5); CPPUNIT_ASSERT(range.intersect_distance(-5, 10) == 5); CPPUNIT_ASSERT(range.intersect_distance(2, 2) == 0); CPPUNIT_ASSERT(range.intersect_distance(1, 4) == 3); CPPUNIT_ASSERT(range.intersect_distance(1, 10) == 4); CPPUNIT_ASSERT(range.intersect_distance(-5, 4) == 4); range.insert(10, 15); CPPUNIT_ASSERT(verify_ranges(range)); CPPUNIT_ASSERT(range.intersect_distance(0, 15) == 10); CPPUNIT_ASSERT(range.intersect_distance(0, 20) == 10); CPPUNIT_ASSERT(range.intersect_distance(-5, 15) == 10); CPPUNIT_ASSERT(range.intersect_distance(-5, 20) == 10); CPPUNIT_ASSERT(range.intersect_distance(2, 12) == 5); CPPUNIT_ASSERT(range.intersect_distance(1, 14) == 8); CPPUNIT_ASSERT(range.intersect_distance(1, 20) == 9); CPPUNIT_ASSERT(range.intersect_distance(-5, 14) == 9); } void RangesTest::test_create_union() { torrent::ranges range_1l; torrent::ranges range_1r; torrent::ranges range_1u; // Empty: range_1u = torrent::ranges::create_union(range_1l, range_1r); CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 20) == 0); range_1l.insert(0, 5); // Left one entry: range_1u = torrent::ranges::create_union(range_1l, range_1r); CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 20) == 5); // Right one entry: range_1u = torrent::ranges::create_union(range_1r, range_1l); CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 20) == 5); range_1r.insert(10, 15); // Both one entry: range_1u = torrent::ranges::create_union(range_1l, range_1r); // std::cout << "range_1u.intersect_distance(-5, 20) = " << range_1u.intersect_distance(-5, 20) << std::endl; CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 20) == 10); range_1r.insert(4, 6); // Overlap: range_1u = torrent::ranges::create_union(range_1l, range_1r); // std::cout << "range_1u.intersect_distance(-5, 20) = " << range_1u.intersect_distance(-5, 20) << std::endl; CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 20) == 11); range_1r.insert(9, 10); // Boundary: range_1u = torrent::ranges::create_union(range_1l, range_1r); CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 20) == 12); // Trailing ranges left. range_1l.insert(25, 30); range_1l.insert(35, 40); range_1u = torrent::ranges::create_union(range_1l, range_1r); CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 50) == 22); // Trailing ranges right. range_1r.insert(37, 45); range_1r.insert(50, 55); range_1u = torrent::ranges::create_union(range_1l, range_1r); CPPUNIT_ASSERT(verify_ranges(range_1u)); CPPUNIT_ASSERT(range_1u.intersect_distance(-5, 60) == 32); } libtorrent-0.13.2/test/rak/ranges_test.h000644 000765 000024 00000000661 11705767057 021166 0ustar00rakshasastaff000000 000000 #include #include #include "torrent/utils/ranges.h" class RangesTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(RangesTest); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_intersect); CPPUNIT_TEST(test_create_union); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void test_basic(); void test_intersect(); void test_create_union(); }; libtorrent-0.13.2/test/data/chunk_list_test.cc000644 000765 000024 00000010274 11716350717 022336 0ustar00rakshasastaff000000 000000 #include "config.h" #include "chunk_list_test.h" #include "torrent/chunk_manager.h" #include "torrent/exceptions.h" CPPUNIT_TEST_SUITE_REGISTRATION(ChunkListTest); namespace tr1 { using namespace std::tr1; } torrent::Chunk* func_create_chunk(uint32_t index, int prot_flags) { // Do proper handling of prot_flags... char* memory_part1 = (char*)mmap(NULL, 10, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (memory_part1 == MAP_FAILED) throw torrent::internal_error("func_create_chunk() failed: " + std::string(strerror(errno))); std::memset(memory_part1, index, 10); torrent::Chunk* chunk = new torrent::Chunk(); chunk->push_back(torrent::ChunkPart::MAPPED_MMAP, torrent::MemoryChunk(memory_part1, memory_part1, memory_part1 + 10, torrent::MemoryChunk::prot_read, 0)); if (chunk == NULL) throw torrent::internal_error("func_create_chunk() failed: chunk == NULL."); return chunk; } uint64_t func_free_diskspace(torrent::ChunkList* chunk_list) { return 0; } void func_storage_error(torrent::ChunkList* chunk_list, const std::string& message) { } void ChunkListTest::test_basic() { torrent::ChunkManager chunk_manager; torrent::ChunkList chunk_list; CPPUNIT_ASSERT(chunk_list.flags() == 0); CPPUNIT_ASSERT(chunk_list.chunk_size() == 0); chunk_list.set_chunk_size(1 << 16); chunk_list.set_manager(&chunk_manager); chunk_list.resize(32); CPPUNIT_ASSERT(chunk_list.size() == 32); CPPUNIT_ASSERT(chunk_list.chunk_size() == (1 << 16)); for (unsigned int i = 0; i < 32; i++) CPPUNIT_ASSERT(chunk_list[i].index() == i); } void ChunkListTest::test_get_release() { SETUP_CHUNK_LIST(); CPPUNIT_ASSERT(!(*chunk_list)[0].is_valid()); torrent::ChunkHandle handle_0 = chunk_list->get(0); CPPUNIT_ASSERT(handle_0.object() != NULL); CPPUNIT_ASSERT(handle_0.object()->index() == 0); CPPUNIT_ASSERT(handle_0.index() == 0); CPPUNIT_ASSERT(!handle_0.is_writable()); CPPUNIT_ASSERT(!handle_0.is_blocking()); CPPUNIT_ASSERT((*chunk_list)[0].is_valid()); CPPUNIT_ASSERT((*chunk_list)[0].references() == 1); CPPUNIT_ASSERT((*chunk_list)[0].writable() == 0); CPPUNIT_ASSERT((*chunk_list)[0].blocking() == 0); chunk_list->release(&handle_0); torrent::ChunkHandle handle_1 = chunk_list->get(1, torrent::ChunkList::get_writable); CPPUNIT_ASSERT(handle_1.object() != NULL); CPPUNIT_ASSERT(handle_1.object()->index() == 1); CPPUNIT_ASSERT(handle_1.index() == 1); CPPUNIT_ASSERT(handle_1.is_writable()); CPPUNIT_ASSERT(!handle_1.is_blocking()); CPPUNIT_ASSERT((*chunk_list)[1].is_valid()); CPPUNIT_ASSERT((*chunk_list)[1].references() == 1); CPPUNIT_ASSERT((*chunk_list)[1].writable() == 1); CPPUNIT_ASSERT((*chunk_list)[1].blocking() == 0); chunk_list->release(&handle_1); torrent::ChunkHandle handle_2 = chunk_list->get(2, torrent::ChunkList::get_blocking); CPPUNIT_ASSERT(handle_2.object() != NULL); CPPUNIT_ASSERT(handle_2.object()->index() == 2); CPPUNIT_ASSERT(handle_2.index() == 2); CPPUNIT_ASSERT(!handle_2.is_writable()); CPPUNIT_ASSERT(handle_2.is_blocking()); CPPUNIT_ASSERT((*chunk_list)[2].is_valid()); CPPUNIT_ASSERT((*chunk_list)[2].references() == 1); CPPUNIT_ASSERT((*chunk_list)[2].writable() == 0); CPPUNIT_ASSERT((*chunk_list)[2].blocking() == 1); chunk_list->release(&handle_2); // Test ro->wr, etc. CLEANUP_CHUNK_LIST(); } // Make sure we can't go into writable when blocking, etc. void ChunkListTest::test_blocking() { SETUP_CHUNK_LIST(); torrent::ChunkHandle handle_0_ro = chunk_list->get(0, torrent::ChunkList::get_blocking); CPPUNIT_ASSERT(handle_0_ro.is_valid()); // Test writable, etc, on blocking without get_nonblock using a // timer on other thread. // torrent::ChunkHandle handle_1 = chunk_list->get(0, torrent::ChunkList::get_writable); torrent::ChunkHandle handle_0_rw = chunk_list->get(0, torrent::ChunkList::get_writable | torrent::ChunkList::get_nonblock); CPPUNIT_ASSERT(!handle_0_rw.is_valid()); CPPUNIT_ASSERT(handle_0_rw.error_number() == rak::error_number::e_again); chunk_list->release(&handle_0_ro); handle_0_rw = chunk_list->get(0, torrent::ChunkList::get_writable); CPPUNIT_ASSERT(handle_0_rw.is_valid()); chunk_list->release(&handle_0_rw); CLEANUP_CHUNK_LIST(); } libtorrent-0.13.2/test/data/chunk_list_test.h000644 000765 000024 00000002677 11716350717 022210 0ustar00rakshasastaff000000 000000 #include #include "data/chunk_list.h" class ChunkListTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ChunkListTest); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_get_release); CPPUNIT_TEST(test_blocking); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void test_basic(); void test_get_release(); void test_blocking(); }; torrent::Chunk* func_create_chunk(uint32_t index, int prot_flags); uint64_t func_free_diskspace(torrent::ChunkList* chunk_list); void func_storage_error(torrent::ChunkList* chunk_list, const std::string& message); #define SETUP_CHUNK_LIST() \ torrent::ChunkManager* chunk_manager = new torrent::ChunkManager; \ torrent::ChunkList* chunk_list = new torrent::ChunkList; \ chunk_list->set_manager(chunk_manager); \ chunk_list->slot_create_chunk() = tr1::bind(&func_create_chunk, tr1::placeholders::_1, tr1::placeholders::_2); \ chunk_list->slot_free_diskspace() = tr1::bind(&func_free_diskspace, chunk_list); \ chunk_list->slot_storage_error() = tr1::bind(&func_storage_error, chunk_list, tr1::placeholders::_1); \ chunk_list->set_chunk_size(1 << 16); \ chunk_list->resize(32); #define CLEANUP_CHUNK_LIST() \ delete chunk_list; \ delete chunk_manager; libtorrent-0.13.2/test/data/hash_check_queue_test.cc000644 000765 000024 00000013364 11717365231 023460 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "data/hash_queue_node.h" #include "utils/sha1.h" #include "torrent/chunk_manager.h" #include "torrent/exceptions.h" #include "torrent/poll_select.h" #include "torrent/utils/thread_base_test.h" #include "thread_disk.h" #include "chunk_list_test.h" #include "hash_check_queue_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(HashCheckQueueTest); namespace tr1 { using namespace std::tr1; } pthread_mutex_t done_chunks_lock = PTHREAD_MUTEX_INITIALIZER; static void chunk_done(done_chunks_type* done_chunks, torrent::HashChunk* hash_chunk, const torrent::HashString& hash_value) { pthread_mutex_lock(&done_chunks_lock); (*done_chunks)[hash_chunk->handle().index()] = hash_value; pthread_mutex_unlock(&done_chunks_lock); } torrent::HashString hash_for_index(uint32_t index) { char buffer[10]; std::memset(buffer, index, 10); torrent::Sha1 sha1; torrent::HashString hash; sha1.init(); sha1.update(buffer, 10); sha1.final_c(hash.data()); return hash; } bool verify_hash(const done_chunks_type* done_chunks, int index, const torrent::HashString& hash) { pthread_mutex_lock(&done_chunks_lock); done_chunks_type::const_iterator itr = done_chunks->find(index); if (itr == done_chunks->end()) { pthread_mutex_unlock(&done_chunks_lock); return false; } bool matches = itr->second == hash; pthread_mutex_unlock(&done_chunks_lock); if (!matches) { // std::cout << "chunk compare: " << index << " " // << torrent::hash_string_to_hex_str(itr->second) << ' ' << torrent::hash_string_to_hex_str(hash) << ' ' // << (itr != done_chunks->end() && itr->second == hash) // << std::endl; throw torrent::internal_error("Could not verify hash..."); } return true; } static torrent::Poll* create_select_poll() { return torrent::PollSelect::create(256); } static void do_nothing() {} void HashCheckQueueTest::setUp() { torrent::Poll::slot_create_poll() = tr1::bind(&create_select_poll); signal(SIGUSR1, (sig_t)&do_nothing); } void HashCheckQueueTest::tearDown() { } void HashCheckQueueTest::test_basic() { } void HashCheckQueueTest::test_single() { SETUP_CHUNK_LIST(); torrent::HashCheckQueue hash_queue; done_chunks_type done_chunks; hash_queue.slot_chunk_done() = tr1::bind(&chunk_done, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2); torrent::ChunkHandle handle_0 = chunk_list->get(0, torrent::ChunkList::get_blocking); hash_queue.push_back(new torrent::HashChunk(handle_0)); CPPUNIT_ASSERT(hash_queue.size() == 1); CPPUNIT_ASSERT(hash_queue.front()->handle().is_blocking()); CPPUNIT_ASSERT(hash_queue.front()->handle().object() == &((*chunk_list)[0])); hash_queue.perform(); CPPUNIT_ASSERT(done_chunks.find(0) != done_chunks.end()); CPPUNIT_ASSERT(done_chunks[0] == hash_for_index(0)); // Should not be needed... Also verify that HashChunk gets deleted. chunk_list->release(&handle_0); CLEANUP_CHUNK_LIST(); } void HashCheckQueueTest::test_multiple() { SETUP_CHUNK_LIST(); torrent::HashCheckQueue hash_queue; done_chunks_type done_chunks; hash_queue.slot_chunk_done() = tr1::bind(&chunk_done, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2); handle_list handles; for (unsigned int i = 0; i < 20; i++) { handles.push_back(chunk_list->get(i, torrent::ChunkList::get_blocking)); hash_queue.push_back(new torrent::HashChunk(handles.back())); CPPUNIT_ASSERT(hash_queue.size() == i + 1); CPPUNIT_ASSERT(hash_queue.back()->handle().is_blocking()); CPPUNIT_ASSERT(hash_queue.back()->handle().object() == &((*chunk_list)[i])); } hash_queue.perform(); for (unsigned int i = 0; i < 20; i++) { CPPUNIT_ASSERT(done_chunks.find(i) != done_chunks.end()); CPPUNIT_ASSERT(done_chunks[i] == hash_for_index(i)); // Should not be needed... chunk_list->release(&handles[i]); } CLEANUP_CHUNK_LIST(); } void HashCheckQueueTest::test_erase() { // SETUP_CHUNK_LIST(); // torrent::HashCheckQueue hash_queue; // done_chunks_type done_chunks; // hash_queue.slot_chunk_done() = tr1::bind(&chunk_done, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2); // handle_list handles; // for (unsigned int i = 0; i < 20; i++) { // handles.push_back(chunk_list->get(i, torrent::ChunkList::get_blocking)); // hash_queue.push_back(new torrent::HashChunk(handles.back())); // CPPUNIT_ASSERT(hash_queue.size() == i + 1); // CPPUNIT_ASSERT(hash_queue.back()->handle().is_blocking()); // CPPUNIT_ASSERT(hash_queue.back()->handle().object() == &((*chunk_list)[i])); // } // hash_queue.perform(); // for (unsigned int i = 0; i < 20; i++) { // CPPUNIT_ASSERT(done_chunks.find(i) != done_chunks.end()); // CPPUNIT_ASSERT(done_chunks[i] == hash_for_index(i)); // // Should not be needed... // chunk_list->release(&handles[i]); // } // CLEANUP_CHUNK_LIST(); } void HashCheckQueueTest::test_thread() { SETUP_CHUNK_LIST(); SETUP_THREAD(); thread_disk->start_thread(); torrent::HashCheckQueue* hash_queue = thread_disk->hash_queue(); done_chunks_type done_chunks; hash_queue->slot_chunk_done() = tr1::bind(&chunk_done, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2); for (int i = 0; i < 1000; i++) { pthread_mutex_lock(&done_chunks_lock); done_chunks.erase(0); pthread_mutex_unlock(&done_chunks_lock); torrent::ChunkHandle handle_0 = chunk_list->get(0, torrent::ChunkList::get_blocking); hash_queue->push_back(new torrent::HashChunk(handle_0)); thread_disk->interrupt(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&verify_hash, &done_chunks, 0, hash_for_index(0)))); chunk_list->release(&handle_0); } thread_disk->stop_thread(); CLEANUP_THREAD(); CLEANUP_CHUNK_LIST(); } libtorrent-0.13.2/test/data/hash_check_queue_test.h000644 000765 000024 00000001523 11716350717 023316 0ustar00rakshasastaff000000 000000 #include #include #include #include "data/hash_check_queue.h" #include "torrent/hash_string.h" class HashCheckQueueTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(HashCheckQueueTest); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_single); CPPUNIT_TEST(test_multiple); CPPUNIT_TEST(test_erase); CPPUNIT_TEST(test_thread); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_single(); void test_multiple(); void test_erase(); void test_thread(); }; typedef std::map done_chunks_type; typedef std::vector handle_list; torrent::HashString hash_for_index(uint32_t index); bool verify_hash(const done_chunks_type* done_chunks, int index, const torrent::HashString& hash); libtorrent-0.13.2/test/data/hash_queue_test.cc000644 000765 000024 00000012742 11717365231 022322 0ustar00rakshasastaff000000 000000 #include "config.h" #include #include #include "data/hash_queue_node.h" #include "torrent/chunk_manager.h" #include "torrent/exceptions.h" #include "torrent/hash_string.h" #include "torrent/poll_select.h" #include "torrent/utils/thread_base_test.h" #include "globals.h" #include "thread_disk.h" #include "chunk_list_test.h" #include "hash_queue_test.h" #include "hash_check_queue_test.h" CPPUNIT_TEST_SUITE_REGISTRATION(HashQueueTest); namespace tr1 { using namespace std::tr1; } typedef std::map done_chunks_type; static void chunk_done(torrent::ChunkList* chunk_list, done_chunks_type* done_chunks, torrent::ChunkHandle handle, const char* hash_value) { if (hash_value != NULL) (*done_chunks)[handle.index()] = *torrent::HashString::cast_from(hash_value); chunk_list->release(&handle); } bool check_for_chunk_done(torrent::HashQueue* hash_queue, done_chunks_type* done_chunks, int index) { hash_queue->work(); return done_chunks->find(index) != done_chunks->end(); } static torrent::Poll* create_select_poll() { return torrent::PollSelect::create(256); } static void do_nothing() {} void HashQueueTest::setUp() { CPPUNIT_ASSERT(torrent::taskScheduler.empty()); torrent::Poll::slot_create_poll() = tr1::bind(&create_select_poll); signal(SIGUSR1, (sig_t)&do_nothing); } void HashQueueTest::tearDown() { torrent::taskScheduler.clear(); } void HashQueueTest::test_basic() { // SETUP_CHUNK_LIST(); // SETUP_THREAD(); // thread_disk->start_thread(); // torrent::HashQueue* hash_queue = new torrent::HashQueue(thread_disk); // // Do stuff? // delete hash_queue; // thread_disk->stop_thread(); // CLEANUP_THREAD(); // CLEANUP_CHUNK_LIST(); } static void fill_queue() { } void HashQueueTest::test_single() { SETUP_CHUNK_LIST(); SETUP_THREAD(); thread_disk->start_thread(); done_chunks_type done_chunks; torrent::HashQueue* hash_queue = new torrent::HashQueue(thread_disk); hash_queue->slot_has_work() = tr1::bind(&fill_queue); torrent::ChunkHandle handle_0 = chunk_list->get(0, torrent::ChunkList::get_blocking); hash_queue->push_back(handle_0, NULL, tr1::bind(&chunk_done, chunk_list, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2)); CPPUNIT_ASSERT(hash_queue->size() == 1); CPPUNIT_ASSERT(hash_queue->front().handle().is_blocking()); CPPUNIT_ASSERT(hash_queue->front().handle().object() == &((*chunk_list)[0])); hash_queue->work(); CPPUNIT_ASSERT(wait_for_true(tr1::bind(&check_for_chunk_done, hash_queue, &done_chunks, 0))); CPPUNIT_ASSERT(done_chunks[0] == hash_for_index(0)); // chunk_list->release(&handle_0); CPPUNIT_ASSERT(thread_disk->hash_queue()->empty()); delete hash_queue; thread_disk->stop_thread(); CLEANUP_THREAD(); CLEANUP_CHUNK_LIST(); } void HashQueueTest::test_multiple() { SETUP_CHUNK_LIST(); SETUP_THREAD(); thread_disk->start_thread(); done_chunks_type done_chunks; torrent::HashQueue* hash_queue = new torrent::HashQueue(thread_disk); hash_queue->slot_has_work() = tr1::bind(&fill_queue); for (unsigned int i = 0; i < 20; i++) { hash_queue->push_back(chunk_list->get(i, torrent::ChunkList::get_blocking), NULL, tr1::bind(&chunk_done, chunk_list, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2)); CPPUNIT_ASSERT(hash_queue->size() == i + 1); CPPUNIT_ASSERT(hash_queue->back().handle().is_blocking()); CPPUNIT_ASSERT(hash_queue->back().handle().object() == &((*chunk_list)[i])); } for (unsigned int i = 0; i < 20; i++) { CPPUNIT_ASSERT(wait_for_true(tr1::bind(&check_for_chunk_done, hash_queue, &done_chunks, i))); CPPUNIT_ASSERT(done_chunks[i] == hash_for_index(i)); } CPPUNIT_ASSERT(thread_disk->hash_queue()->empty()); delete hash_queue; thread_disk->stop_thread(); CLEANUP_THREAD(); CLEANUP_CHUNK_LIST(); } void HashQueueTest::test_erase() { SETUP_CHUNK_LIST(); SETUP_THREAD(); torrent::HashQueue* hash_queue = new torrent::HashQueue(thread_disk); hash_queue->slot_has_work() = tr1::bind(&fill_queue); done_chunks_type done_chunks; for (unsigned int i = 0; i < 20; i++) { hash_queue->push_back(chunk_list->get(i, torrent::ChunkList::get_blocking), NULL, tr1::bind(&chunk_done, chunk_list, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2)); CPPUNIT_ASSERT(hash_queue->size() == i + 1); } hash_queue->remove(NULL); CPPUNIT_ASSERT(hash_queue->empty()); CPPUNIT_ASSERT(thread_disk->hash_queue()->empty()); delete hash_queue; delete thread_disk; CLEANUP_CHUNK_LIST(); } void HashQueueTest::test_erase_stress() { SETUP_CHUNK_LIST(); SETUP_THREAD(); thread_disk->start_thread(); torrent::HashQueue* hash_queue = new torrent::HashQueue(thread_disk); hash_queue->slot_has_work() = tr1::bind(&fill_queue); done_chunks_type done_chunks; for (unsigned int i = 0; i < 1000; i++) { for (unsigned int i = 0; i < 20; i++) { hash_queue->push_back(chunk_list->get(i, torrent::ChunkList::get_blocking), NULL, tr1::bind(&chunk_done, chunk_list, &done_chunks, tr1::placeholders::_1, tr1::placeholders::_2)); CPPUNIT_ASSERT(hash_queue->size() == i + 1); } hash_queue->remove(NULL); CPPUNIT_ASSERT(hash_queue->empty()); } CPPUNIT_ASSERT(thread_disk->hash_queue()->empty()); delete hash_queue; thread_disk->stop_thread(); CLEANUP_THREAD(); CLEANUP_CHUNK_LIST(); } // Test erase of different id's. // Current code doesn't work well if we remove a hash... libtorrent-0.13.2/test/data/hash_queue_test.h000644 000765 000024 00000001000 11716350717 022147 0ustar00rakshasastaff000000 000000 #include #include "data/hash_queue.h" class HashQueueTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(HashQueueTest); CPPUNIT_TEST(test_basic); CPPUNIT_TEST(test_single); CPPUNIT_TEST(test_multiple); CPPUNIT_TEST(test_erase); CPPUNIT_TEST(test_erase_stress); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); void test_basic(); void test_single(); void test_multiple(); void test_erase(); void test_erase_stress(); }; libtorrent-0.13.2/src/data/000755 000765 000024 00000000000 11744204513 016422 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/dht/000755 000765 000024 00000000000 11744204513 016270 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/download/000755 000765 000024 00000000000 11744204513 017320 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/globals.cc000644 000765 000024 00000003513 11726115754 017455 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "globals.h" #include "torrent/common.h" namespace torrent { LIBTORRENT_EXPORT rak::priority_queue_default taskScheduler; LIBTORRENT_EXPORT rak::timer cachedTime; } libtorrent-0.13.2/src/globals.h000644 000765 000024 00000003561 11705767056 017327 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_GLOBALS_H #define LIBTORRENT_GLOBALS_H #include #include namespace torrent { extern rak::priority_queue_default taskScheduler; extern rak::timer cachedTime; } #endif libtorrent-0.13.2/src/Makefile.am000644 000765 000024 00000001414 11716353601 017547 0ustar00rakshasastaff000000 000000 SUBDIRS = \ torrent \ data \ dht \ download \ net \ protocol \ tracker \ utils lib_LTLIBRARIES = libtorrent.la libtorrent_la_LDFLAGS = -version-info $(LIBTORRENT_INTERFACE_VERSION_INFO) libtorrent_la_LIBADD = \ torrent/libsub_torrent.la \ torrent/data/libsub_torrentdata.la \ torrent/download/libsub_torrentdownload.la \ torrent/peer/libsub_torrentpeer.la \ torrent/utils/libsub_torrentutils.la \ data/libsub_data.la \ dht/libsub_dht.la \ download/libsub_download.la \ net/libsub_net.la \ protocol/libsub_protocol.la \ tracker/libsub_tracker.la \ utils/libsub_utils.la libtorrent_la_SOURCES = \ globals.cc \ globals.h \ manager.cc \ manager.h \ thread_disk.cc \ thread_disk.h \ thread_main.cc \ thread_main.h INCLUDES = -I$(srcdir) -I$(top_srcdir) libtorrent-0.13.2/src/Makefile.in000644 000765 000024 00000061150 11744204216 017561 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libtorrent_la_DEPENDENCIES = torrent/libsub_torrent.la \ torrent/data/libsub_torrentdata.la \ torrent/download/libsub_torrentdownload.la \ torrent/peer/libsub_torrentpeer.la \ torrent/utils/libsub_torrentutils.la data/libsub_data.la \ dht/libsub_dht.la download/libsub_download.la \ net/libsub_net.la protocol/libsub_protocol.la \ tracker/libsub_tracker.la utils/libsub_utils.la am_libtorrent_la_OBJECTS = globals.lo manager.lo thread_disk.lo \ thread_main.lo libtorrent_la_OBJECTS = $(am_libtorrent_la_OBJECTS) libtorrent_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(libtorrent_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtorrent_la_SOURCES) DIST_SOURCES = $(libtorrent_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = \ torrent \ data \ dht \ download \ net \ protocol \ tracker \ utils lib_LTLIBRARIES = libtorrent.la libtorrent_la_LDFLAGS = -version-info $(LIBTORRENT_INTERFACE_VERSION_INFO) libtorrent_la_LIBADD = \ torrent/libsub_torrent.la \ torrent/data/libsub_torrentdata.la \ torrent/download/libsub_torrentdownload.la \ torrent/peer/libsub_torrentpeer.la \ torrent/utils/libsub_torrentutils.la \ data/libsub_data.la \ dht/libsub_dht.la \ download/libsub_download.la \ net/libsub_net.la \ protocol/libsub_protocol.la \ tracker/libsub_tracker.la \ utils/libsub_utils.la libtorrent_la_SOURCES = \ globals.cc \ globals.h \ manager.cc \ manager.h \ thread_disk.cc \ thread_disk.h \ thread_main.cc \ thread_main.h INCLUDES = -I$(srcdir) -I$(top_srcdir) all: all-recursive .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtorrent.la: $(libtorrent_la_OBJECTS) $(libtorrent_la_DEPENDENCIES) $(EXTRA_libtorrent_la_DEPENDENCIES) $(libtorrent_la_LINK) -rpath $(libdir) $(libtorrent_la_OBJECTS) $(libtorrent_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globals.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_disk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_main.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/manager.cc000644 000765 000024 00000014400 11744202446 017434 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/exceptions.h" #include "download/download_wrapper.h" #include "download/download_main.h" #include "data/hash_torrent.h" #include "data/chunk_list.h" #include "protocol/handshake_manager.h" #include "data/hash_queue.h" #include "net/listen.h" #include "torrent/chunk_manager.h" #include "torrent/connection_manager.h" #include "torrent/dht_manager.h" #include "torrent/data/file_manager.h" #include "torrent/download/choke_group.h" #include "torrent/download/choke_queue.h" #include "torrent/download/download_manager.h" #include "torrent/download/resource_manager.h" #include "torrent/peer/client_list.h" #include "torrent/throttle.h" #include "manager.h" namespace tr1 { using namespace std::tr1; } namespace torrent { Manager* manager = NULL; Manager::Manager() : m_downloadManager(new DownloadManager), m_fileManager(new FileManager), m_handshakeManager(new HandshakeManager), m_resourceManager(new ResourceManager), m_chunkManager(new ChunkManager), m_clientList(new ClientList), m_connectionManager(new ConnectionManager), m_dhtManager(new DhtManager), m_uploadThrottle(Throttle::create_throttle()), m_downloadThrottle(Throttle::create_throttle()), m_ticks(0) { m_hashQueue = new HashQueue(&m_main_thread_disk); m_hashQueue->slot_has_work() = tr1::bind(&thread_base::send_event_signal, &m_main_thread_main, m_main_thread_main.signal_bitfield()->add_signal(tr1::bind(&HashQueue::work, m_hashQueue)), tr1::placeholders::_1); m_taskTick.slot() = std::tr1::bind(&Manager::receive_tick, this); priority_queue_insert(&taskScheduler, &m_taskTick, cachedTime.round_seconds()); m_handshakeManager->slot_download_id(rak::make_mem_fun(m_downloadManager, &DownloadManager::find_main)); m_handshakeManager->slot_download_id_obfuscated(rak::make_mem_fun(m_downloadManager, &DownloadManager::find_main_obfuscated)); m_connectionManager->listen()->slot_incoming(rak::make_mem_fun(m_handshakeManager, &HandshakeManager::add_incoming)); // m_resourceManager->push_group("default"); // m_resourceManager->group_back()->up_queue()->set_heuristics(choke_queue::HEURISTICS_UPLOAD_LEECH); // m_resourceManager->group_back()->down_queue()->set_heuristics(choke_queue::HEURISTICS_DOWNLOAD_LEECH); } Manager::~Manager() { priority_queue_erase(&taskScheduler, &m_taskTick); m_handshakeManager->clear(); m_downloadManager->clear(); delete m_downloadManager; delete m_fileManager; delete m_handshakeManager; delete m_hashQueue; delete m_resourceManager; delete m_dhtManager; delete m_connectionManager; delete m_chunkManager; delete m_clientList; Throttle::destroy_throttle(m_uploadThrottle); Throttle::destroy_throttle(m_downloadThrottle); } void Manager::initialize_download(DownloadWrapper* d) { d->main()->slot_count_handshakes(rak::make_mem_fun(m_handshakeManager, &HandshakeManager::size_info)); d->main()->slot_start_handshake(rak::make_mem_fun(m_handshakeManager, &HandshakeManager::add_outgoing)); d->main()->slot_stop_handshakes(rak::make_mem_fun(m_handshakeManager, &HandshakeManager::erase_download)); // TODO: The resource manager doesn't need to know about this // download until we start/stop the torrent. m_downloadManager->insert(d); m_resourceManager->insert(d->main(), 1); m_chunkManager->insert(d->main()->chunk_list()); d->main()->chunk_list()->set_chunk_size(d->main()->file_list()->chunk_size()); d->main()->set_upload_throttle(m_uploadThrottle->throttle_list()); d->main()->set_download_throttle(m_downloadThrottle->throttle_list()); } void Manager::cleanup_download(DownloadWrapper* d) { d->main()->stop(); d->close(); m_resourceManager->erase(d->main()); m_chunkManager->erase(d->main()->chunk_list()); m_downloadManager->erase(d); } void Manager::receive_tick() { m_ticks++; m_resourceManager->receive_tick(); m_chunkManager->periodic_sync(); // To ensure the downloads get equal chance over time at using // various limited resources, like sockets for handshakes, cycle the // group in reverse order. if (!m_downloadManager->empty()) { DownloadManager::iterator split = m_downloadManager->end() - m_ticks % m_downloadManager->size() - 1; std::for_each(split, m_downloadManager->end(), std::bind2nd(std::mem_fun(&DownloadWrapper::receive_tick), m_ticks)); std::for_each(m_downloadManager->begin(), split, std::bind2nd(std::mem_fun(&DownloadWrapper::receive_tick), m_ticks)); } // If you change the interval, make sure the keepalives gets // triggered every 120 seconds. priority_queue_insert(&taskScheduler, &m_taskTick, (cachedTime + rak::timer::from_seconds(30)).round_seconds()); } } libtorrent-0.13.2/src/manager.h000644 000765 000024 00000010605 11716362616 017306 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_MANAGER_H #define LIBTORRENT_MANAGER_H #include #include #include #include "thread_disk.h" #include "thread_main.h" #include "net/socket_fd.h" namespace torrent { class Poll; class HashQueue; class HandshakeManager; class DownloadManager; class DownloadWrapper; class DownloadMain; class FileManager; class ResourceManager; class PeerInfo; class ChunkManager; class ConnectionManager; class Throttle; class DhtManager; typedef std::list EncodingList; class Manager { public: Manager(); ~Manager(); DownloadManager* download_manager() { return m_downloadManager; } FileManager* file_manager() { return m_fileManager; } HandshakeManager* handshake_manager() { return m_handshakeManager; } HashQueue* hash_queue() { return m_hashQueue; } ResourceManager* resource_manager() { return m_resourceManager; } ChunkManager* chunk_manager() { return m_chunkManager; } ClientList* client_list() { return m_clientList; } ConnectionManager* connection_manager() { return m_connectionManager; } DhtManager* dht_manager() { return m_dhtManager; } Poll* poll() { return m_main_thread_main.poll(); } thread_main* main_thread_main() { return &m_main_thread_main; } thread_disk* main_thread_disk() { return &m_main_thread_disk; } EncodingList* encoding_list() { return &m_encodingList; } Throttle* upload_throttle() { return m_uploadThrottle; } Throttle* download_throttle() { return m_downloadThrottle; } void initialize_download(DownloadWrapper* d); void cleanup_download(DownloadWrapper* d); void receive_tick(); private: DownloadManager* m_downloadManager; FileManager* m_fileManager; HandshakeManager* m_handshakeManager; HashQueue* m_hashQueue; ResourceManager* m_resourceManager; ChunkManager* m_chunkManager; ClientList* m_clientList; ConnectionManager* m_connectionManager; DhtManager* m_dhtManager; thread_main m_main_thread_main; thread_disk m_main_thread_disk; EncodingList m_encodingList; Throttle* m_uploadThrottle; Throttle* m_downloadThrottle; unsigned int m_ticks; rak::priority_item m_taskTick; }; extern Manager* manager; } #endif libtorrent-0.13.2/src/net/000755 000765 000024 00000000000 11744204513 016277 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/protocol/000755 000765 000024 00000000000 11744204513 017352 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/thread_disk.cc000644 000765 000024 00000005037 11716350717 020315 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "thread_disk.h" #include "torrent/exceptions.h" #include "torrent/poll.h" #include "torrent/utils/log.h" namespace torrent { void thread_disk::init_thread() { if (!Poll::slot_create_poll()) throw internal_error("thread_disk::init_thread(): Poll::slot_create_poll() not valid."); m_poll = Poll::slot_create_poll()(); m_state = STATE_INITIALIZED; } void thread_disk::call_events() { // lt_log_print_locked(torrent::LOG_THREAD_NOTICE, "Got thread_disk tick."); // TODO: Consider moving this into timer events instead. if ((m_flags & flag_do_shutdown)) { if ((m_flags & flag_did_shutdown)) throw internal_error("Already trigged shutdown."); __sync_or_and_fetch(&m_flags, flag_did_shutdown); throw shutdown_exception(); } m_hash_queue.perform(); } int64_t thread_disk::next_timeout_usec() { return rak::timer::from_seconds(10).usec(); } } libtorrent-0.13.2/src/thread_disk.h000644 000765 000024 00000004171 11716350717 020155 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_THREAD_DISK_H #define LIBTORRENT_THREAD_DISK_H #include "data/hash_check_queue.h" #include "torrent/utils/thread_base.h" namespace torrent { class thread_disk : public thread_base { public: const char* name() const { return "worker_disk"; } virtual void init_thread(); HashCheckQueue* hash_queue() { return &m_hash_queue; } protected: virtual void call_events(); virtual int64_t next_timeout_usec(); HashCheckQueue m_hash_queue; }; } #endif libtorrent-0.13.2/src/thread_main.cc000644 000765 000024 00000005773 11716356561 020321 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "thread_main.h" #include "globals.h" #include "torrent/exceptions.h" #include "torrent/poll.h" #include "torrent/utils/log.h" namespace torrent { void thread_main::init_thread() { acquire_global_lock(); if (!Poll::slot_create_poll()) throw internal_error("thread_main::init_thread(): Poll::slot_create_poll() not valid."); m_poll = Poll::slot_create_poll()(); m_poll->set_flags(Poll::flag_waive_global_lock); m_state = STATE_INITIALIZED; m_thread = pthread_self(); m_flags |= flag_main_thread; } void thread_main::call_events() { cachedTime = rak::timer::current(); // Ensure we don't call rak::timer::current() twice if there was no // scheduled tasks called. if (taskScheduler.empty() || taskScheduler.top()->time() > cachedTime) return; while (!taskScheduler.empty() && taskScheduler.top()->time() <= cachedTime) { rak::priority_item* v = taskScheduler.top(); taskScheduler.pop(); v->clear_time(); v->slot()(); } // Update the timer again to ensure we get accurate triggering of // msec timers. cachedTime = rak::timer::current(); } int64_t thread_main::next_timeout_usec() { cachedTime = rak::timer::current(); if (!taskScheduler.empty()) return std::max(taskScheduler.top()->time() - cachedTime, rak::timer()).usec(); else return rak::timer::from_seconds(60).usec(); } } libtorrent-0.13.2/src/thread_main.h000644 000765 000024 00000004017 11716353601 020141 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_THREAD_MAIN_H #define LIBTORRENT_THREAD_MAIN_H #include "data/hash_check_queue.h" #include "torrent/utils/thread_base.h" namespace torrent { class thread_main : public thread_base { public: const char* name() const { return "main"; } virtual void init_thread(); protected: virtual void call_events(); virtual int64_t next_timeout_usec(); }; } #endif libtorrent-0.13.2/src/torrent/000755 000765 000024 00000000000 11744204512 017205 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/tracker/000755 000765 000024 00000000000 11744204513 017144 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/utils/000755 000765 000024 00000000000 11744204514 016652 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/utils/diffie_hellman.cc000644 000765 000024 00000005621 11705767057 022130 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #ifdef USE_OPENSSL #include #endif #include "diffie_hellman.h" #include "torrent/exceptions.h" namespace torrent { DiffieHellman::DiffieHellman(const unsigned char *prime, int primeLength, const unsigned char *generator, int generatorLength) : m_secret(NULL), m_size(0) { #ifdef USE_OPENSSL m_dh = DH_new(); m_dh->p = BN_bin2bn(prime, primeLength, NULL); m_dh->g = BN_bin2bn(generator, generatorLength, NULL); DH_generate_key(m_dh); #else throw internal_error("Compiled without encryption support."); #endif }; DiffieHellman::~DiffieHellman() { delete [] m_secret; #ifdef USE_OPENSSL DH_free(m_dh); #endif }; void DiffieHellman::compute_secret(const unsigned char *pubkey, unsigned int length) { #ifdef USE_OPENSSL BIGNUM* k = BN_bin2bn(pubkey, length, NULL); delete [] m_secret; m_secret = new char[DH_size(m_dh)]; m_size = DH_compute_key((unsigned char*)m_secret, k, m_dh); BN_free(k); #endif }; void DiffieHellman::store_pub_key(unsigned char* dest, unsigned int length) { #ifdef USE_OPENSSL std::memset(dest, 0, length); if ((int)length >= BN_num_bytes(m_dh->pub_key)) BN_bn2bin(m_dh->pub_key, dest + length - BN_num_bytes(m_dh->pub_key)); #endif } }; libtorrent-0.13.2/src/utils/diffie_hellman.h000644 000765 000024 00000005122 11705767057 021766 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DIFFIE_HELLMAN_H #define LIBTORRENT_DIFFIE_HELLMAN_H #include "config.h" #include #ifdef USE_OPENSSL #include #endif namespace torrent { class DiffieHellman { public: DiffieHellman(const unsigned char prime[], int primeLength, const unsigned char generator[], int generatorLength); ~DiffieHellman(); void compute_secret(const unsigned char pubkey[], unsigned int length); void store_pub_key(unsigned char* dest, unsigned int length); unsigned int size() const { return m_size; } const char* c_str() const { return m_secret; } std::string secret_str() const { return std::string(m_secret, m_size); } private: DiffieHellman(const DiffieHellman& dh); DiffieHellman& operator = (const DiffieHellman& dh); #ifdef USE_OPENSSL DH* m_dh; #endif char* m_secret; unsigned int m_size; }; }; #endif libtorrent-0.13.2/src/utils/Makefile.am000644 000765 000024 00000000320 11705767057 020716 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_utils.la libsub_utils_la_SOURCES = \ diffie_hellman.cc \ diffie_hellman.h \ rc4.h \ sha1.h \ sha_fast.cc \ sha_fast.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrent-0.13.2/src/utils/Makefile.in000644 000765 000024 00000037350 11744204216 020726 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/utils DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_utils_la_LIBADD = am_libsub_utils_la_OBJECTS = diffie_hellman.lo sha_fast.lo libsub_utils_la_OBJECTS = $(am_libsub_utils_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_utils_la_SOURCES) DIST_SOURCES = $(libsub_utils_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_utils.la libsub_utils_la_SOURCES = \ diffie_hellman.cc \ diffie_hellman.h \ rc4.h \ sha1.h \ sha_fast.cc \ sha_fast.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/utils/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/utils/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_utils.la: $(libsub_utils_la_OBJECTS) $(libsub_utils_la_DEPENDENCIES) $(EXTRA_libsub_utils_la_DEPENDENCIES) $(CXXLINK) $(libsub_utils_la_OBJECTS) $(libsub_utils_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diffie_hellman.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha_fast.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/utils/rc4.h000644 000765 000024 00000005750 11705767057 017537 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_RC4_H #define LIBTORRENT_RC4_H #include "config.h" #ifdef USE_CYRUS_RC4 extern "C" { #include } #else #ifdef USE_OPENSSL #include #endif #endif namespace torrent { class RC4 { public: RC4() { } #ifdef USE_CYRUS_RC4 RC4(const unsigned char key[], int len) { rc4_init(&m_key, key, len); } void crypt(const void* indata, void* outdata, unsigned int length) { rc4_encrypt(&m_key, (const char*)indata, (char*)outdata, length); } void crypt(void* data, unsigned int length) { rc4_encrypt(&m_key, (const char*)data, (char*)data, length); } private: rc4_context_t m_key; #else #ifdef USE_OPENSSL RC4(const unsigned char key[], int len) { RC4_set_key(&m_key, len, key); } void crypt(const void* indata, void* outdata, unsigned int length) { ::RC4(&m_key, length, (const unsigned char*)indata, (unsigned char*)outdata); } void crypt(void* data, unsigned int length) { ::RC4(&m_key, length, (unsigned char*)data, (unsigned char*)data); } private: RC4_KEY m_key; #else RC4(const unsigned char key[], int len) { } void crypt(const void* indata, void* outdata, unsigned int length) { } void crypt(void* data, unsigned int length) {} #endif #endif }; }; #endif libtorrent-0.13.2/src/utils/sha1.h000644 000765 000024 00000006571 11705767057 017705 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_HASH_COMPUTE_H #define LIBTORRENT_HASH_COMPUTE_H #include #if defined USE_NSS_SHA #include "sha_fast.h" #elif defined USE_OPENSSL_SHA #include #else #error "No SHA1 implementation selected, choose between Mozilla's NSS and OpenSSL." #endif namespace torrent { class Sha1 { public: void init(); void update(const void* data, unsigned int length); void final_c(char* buffer); #if defined USE_NSS_SHA private: SHA1Context m_ctx; }; inline void Sha1::init() { SHA1_Begin(&m_ctx); } inline void Sha1::update(const void* data, unsigned int length) { SHA1_Update(&m_ctx, (unsigned char*)data, length); } inline void Sha1::final_c(char* buffer) { unsigned int len; SHA1_End(&m_ctx, (unsigned char*)buffer, &len, 20); } #elif defined USE_OPENSSL_SHA private: SHA_CTX m_ctx; }; inline void Sha1::init() { SHA1_Init(&m_ctx); } inline void Sha1::update(const void* data, unsigned int length) { SHA1_Update(&m_ctx, (const void*)data, length); } inline void Sha1::final_c(char* buffer) { SHA1_Final((unsigned char*)buffer, &m_ctx); } #else }; #endif inline void sha1_salt(const char* salt, unsigned int saltLength, const char* key, unsigned int keyLength, void* out) { Sha1 sha1; sha1.init(); sha1.update(salt, saltLength); sha1.update(key, keyLength); sha1.final_c((char*)out); } inline void sha1_salt(const char* salt, unsigned int saltLength, const char* key1, unsigned int key1Length, const char* key2, unsigned int key2Length, void* out) { Sha1 sha1; sha1.init(); sha1.update(salt, saltLength); sha1.update(key1, key1Length); sha1.update(key2, key2Length); sha1.final_c((char*)out); } } #endif libtorrent-0.13.2/src/utils/sha_fast.cc000644 000765 000024 00000031635 11705767057 020776 0ustar00rakshasastaff000000 000000 // The OpenSSL library exception does not cover the program if you // compile the code below. #include "config.h" #ifdef USE_NSS_SHA /* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is SHA 180-1 Reference Implementation (Optimized) * * The Initial Developer of the Original Code is Paul Kocher of * Cryptography Research. Portions created by Paul Kocher are * Copyright (C) 1995-9 by Cryptography Research, Inc. All * Rights Reserved. * * Contributor(s): * * Paul Kocher * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. */ #include #include "sha_fast.h" namespace torrent { #define SHA1_INPUT_LEN 64 #define SHA1_LENGTH 20 #define SHA_MASK 0x00FF00FF #if defined(IS_LITTLE_ENDIAN) #define SHA_HTONL(x) (A = (x), A = (A << 16) | (A >> 16), \ ((A & SHA_MASK) << 8) | ((A >> 8) & SHA_MASK)) #else #define SHA_HTONL(x) (x) #endif #define SHA_BYTESWAP(x) x = SHA_HTONL(x) static void shaCompress(SHA1Context *ctx); #define W u.w #define B u.b #if defined(_MSC_VER) && defined(_X86_) #pragma intrinsic (_lrotr, _lrotl) #define SHA_ROTL(x,n) _lrotl(x,n) #else #define SHA_ROTL(X,n) (((X) << (n)) | ((X) >> (32-(n)))) #endif #define SHA_F1(X,Y,Z) ((((Y)^(Z))&(X))^(Z)) #define SHA_F2(X,Y,Z) ((X)^(Y)^(Z)) #define SHA_F3(X,Y,Z) (((X)&(Y))|((Z)&((X)|(Y)))) #define SHA_F4(X,Y,Z) ((X)^(Y)^(Z)) #define SHA_MIX(t) ctx->W[t] = \ (A = ctx->W[t-3] ^ ctx->W[t-8] ^ ctx->W[t-14] ^ ctx->W[t-16], SHA_ROTL(A, 1)) #define PORT_Assert(x) /* * SHA: Zeroize and initialize context */ void SHA1_Begin(SHA1Context *ctx) { memset(ctx, 0, sizeof(SHA1Context)); /* * Initialize H with constants from FIPS180-1. */ ctx->H[0] = 0x67452301L; ctx->H[1] = 0xefcdab89L; ctx->H[2] = 0x98badcfeL; ctx->H[3] = 0x10325476L; ctx->H[4] = 0xc3d2e1f0L; } /* * SHA: Add data to context. */ void SHA1_Update(SHA1Context *ctx, const unsigned char *dataIn, unsigned int len) { register unsigned int lenB = ctx->sizeLo & 63; register unsigned int togo; if (!len) return; /* accumulate the byte count. */ ctx->sizeLo += len; ctx->sizeHi += (ctx->sizeLo < len); /* * Read the data into W and process blocks as they get full */ if (lenB > 0) { togo = 64 - lenB; if (len < togo) togo = len; memcpy(ctx->B + lenB, dataIn, togo); len -= togo; dataIn += togo; lenB = (lenB + togo) & 63; if (!lenB) { shaCompress(ctx); } } while (len >= 64) { memcpy(ctx->B, dataIn, 64); dataIn += 64; len -= 64; shaCompress(ctx); } if (len) { memcpy(ctx->B, dataIn, len); } } /* * SHA: Generate hash value from context */ void SHA1_End(SHA1Context *ctx, unsigned char *hashout, unsigned int *pDigestLen, unsigned int maxDigestLen) { register uint32_t sizeHi, sizeLo, lenB; static const unsigned char bulk_pad[64] = { 0x80,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; #define A lenB PORT_Assert (maxDigestLen >= SHA1_LENGTH); /* * Pad with a binary 1 (e.g. 0x80), then zeroes, then length in bits */ sizeHi = ctx->sizeHi; sizeLo = ctx->sizeLo; lenB = sizeLo & 63; SHA1_Update(ctx, bulk_pad, (((55+64) - lenB) & 63) + 1); PORT_Assert((ctx->sizeLo & 63) == 56); /* Convert size{Hi,Lo} from bytes to bits. */ sizeHi = (sizeHi << 3) | (sizeLo >> 29); sizeLo <<= 3; ctx->W[14] = SHA_HTONL(sizeHi); ctx->W[15] = SHA_HTONL(sizeLo); shaCompress(ctx); /* * Output hash */ #if defined(IS_LITTLE_ENDIAN) SHA_BYTESWAP(ctx->H[0]); SHA_BYTESWAP(ctx->H[1]); SHA_BYTESWAP(ctx->H[2]); SHA_BYTESWAP(ctx->H[3]); SHA_BYTESWAP(ctx->H[4]); #endif memcpy(hashout, ctx->H, SHA1_LENGTH); *pDigestLen = SHA1_LENGTH; /* * Re-initialize the context (also zeroizes contents) */ SHA1_Begin(ctx); } #undef A #undef B /* * SHA: Compression function, unrolled. */ static void shaCompress(SHA1Context *ctx) { register uint32_t A, B, C, D, E; #if defined(IS_LITTLE_ENDIAN) SHA_BYTESWAP(ctx->W[0]); SHA_BYTESWAP(ctx->W[1]); SHA_BYTESWAP(ctx->W[2]); SHA_BYTESWAP(ctx->W[3]); SHA_BYTESWAP(ctx->W[4]); SHA_BYTESWAP(ctx->W[5]); SHA_BYTESWAP(ctx->W[6]); SHA_BYTESWAP(ctx->W[7]); SHA_BYTESWAP(ctx->W[8]); SHA_BYTESWAP(ctx->W[9]); SHA_BYTESWAP(ctx->W[10]); SHA_BYTESWAP(ctx->W[11]); SHA_BYTESWAP(ctx->W[12]); SHA_BYTESWAP(ctx->W[13]); SHA_BYTESWAP(ctx->W[14]); SHA_BYTESWAP(ctx->W[15]); #endif /* * This can be moved into the main code block below, but doing * so can cause some compilers to run out of registers and resort * to storing intermediates in RAM. */ SHA_MIX(16); SHA_MIX(17); SHA_MIX(18); SHA_MIX(19); SHA_MIX(20); SHA_MIX(21); SHA_MIX(22); SHA_MIX(23); SHA_MIX(24); SHA_MIX(25); SHA_MIX(26); SHA_MIX(27); SHA_MIX(28); SHA_MIX(29); SHA_MIX(30); SHA_MIX(31); SHA_MIX(32); SHA_MIX(33); SHA_MIX(34); SHA_MIX(35); SHA_MIX(36); SHA_MIX(37); SHA_MIX(38); SHA_MIX(39); SHA_MIX(40); SHA_MIX(41); SHA_MIX(42); SHA_MIX(43); SHA_MIX(44); SHA_MIX(45); SHA_MIX(46); SHA_MIX(47); SHA_MIX(48); SHA_MIX(49); SHA_MIX(50); SHA_MIX(51); SHA_MIX(52); SHA_MIX(53); SHA_MIX(54); SHA_MIX(55); SHA_MIX(56); SHA_MIX(57); SHA_MIX(58); SHA_MIX(59); SHA_MIX(60); SHA_MIX(61); SHA_MIX(62); SHA_MIX(63); SHA_MIX(64); SHA_MIX(65); SHA_MIX(66); SHA_MIX(67); SHA_MIX(68); SHA_MIX(69); SHA_MIX(70); SHA_MIX(71); SHA_MIX(72); SHA_MIX(73); SHA_MIX(74); SHA_MIX(75); SHA_MIX(76); SHA_MIX(77); SHA_MIX(78); SHA_MIX(79); A = ctx->H[0]; B = ctx->H[1]; C = ctx->H[2]; D = ctx->H[3]; E = ctx->H[4]; E = SHA_ROTL(A,5)+SHA_F1(B,C,D)+E+ctx->W[ 0]+0x5a827999L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F1(A,B,C)+D+ctx->W[ 1]+0x5a827999L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F1(E,A,B)+C+ctx->W[ 2]+0x5a827999L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F1(D,E,A)+B+ctx->W[ 3]+0x5a827999L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F1(C,D,E)+A+ctx->W[ 4]+0x5a827999L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F1(B,C,D)+E+ctx->W[ 5]+0x5a827999L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F1(A,B,C)+D+ctx->W[ 6]+0x5a827999L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F1(E,A,B)+C+ctx->W[ 7]+0x5a827999L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F1(D,E,A)+B+ctx->W[ 8]+0x5a827999L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F1(C,D,E)+A+ctx->W[ 9]+0x5a827999L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F1(B,C,D)+E+ctx->W[10]+0x5a827999L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F1(A,B,C)+D+ctx->W[11]+0x5a827999L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F1(E,A,B)+C+ctx->W[12]+0x5a827999L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F1(D,E,A)+B+ctx->W[13]+0x5a827999L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F1(C,D,E)+A+ctx->W[14]+0x5a827999L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F1(B,C,D)+E+ctx->W[15]+0x5a827999L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F1(A,B,C)+D+ctx->W[16]+0x5a827999L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F1(E,A,B)+C+ctx->W[17]+0x5a827999L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F1(D,E,A)+B+ctx->W[18]+0x5a827999L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F1(C,D,E)+A+ctx->W[19]+0x5a827999L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F2(B,C,D)+E+ctx->W[20]+0x6ed9eba1L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F2(A,B,C)+D+ctx->W[21]+0x6ed9eba1L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F2(E,A,B)+C+ctx->W[22]+0x6ed9eba1L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F2(D,E,A)+B+ctx->W[23]+0x6ed9eba1L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F2(C,D,E)+A+ctx->W[24]+0x6ed9eba1L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F2(B,C,D)+E+ctx->W[25]+0x6ed9eba1L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F2(A,B,C)+D+ctx->W[26]+0x6ed9eba1L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F2(E,A,B)+C+ctx->W[27]+0x6ed9eba1L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F2(D,E,A)+B+ctx->W[28]+0x6ed9eba1L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F2(C,D,E)+A+ctx->W[29]+0x6ed9eba1L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F2(B,C,D)+E+ctx->W[30]+0x6ed9eba1L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F2(A,B,C)+D+ctx->W[31]+0x6ed9eba1L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F2(E,A,B)+C+ctx->W[32]+0x6ed9eba1L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F2(D,E,A)+B+ctx->W[33]+0x6ed9eba1L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F2(C,D,E)+A+ctx->W[34]+0x6ed9eba1L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F2(B,C,D)+E+ctx->W[35]+0x6ed9eba1L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F2(A,B,C)+D+ctx->W[36]+0x6ed9eba1L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F2(E,A,B)+C+ctx->W[37]+0x6ed9eba1L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F2(D,E,A)+B+ctx->W[38]+0x6ed9eba1L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F2(C,D,E)+A+ctx->W[39]+0x6ed9eba1L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F3(B,C,D)+E+ctx->W[40]+0x8f1bbcdcL; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F3(A,B,C)+D+ctx->W[41]+0x8f1bbcdcL; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F3(E,A,B)+C+ctx->W[42]+0x8f1bbcdcL; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F3(D,E,A)+B+ctx->W[43]+0x8f1bbcdcL; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F3(C,D,E)+A+ctx->W[44]+0x8f1bbcdcL; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F3(B,C,D)+E+ctx->W[45]+0x8f1bbcdcL; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F3(A,B,C)+D+ctx->W[46]+0x8f1bbcdcL; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F3(E,A,B)+C+ctx->W[47]+0x8f1bbcdcL; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F3(D,E,A)+B+ctx->W[48]+0x8f1bbcdcL; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F3(C,D,E)+A+ctx->W[49]+0x8f1bbcdcL; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F3(B,C,D)+E+ctx->W[50]+0x8f1bbcdcL; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F3(A,B,C)+D+ctx->W[51]+0x8f1bbcdcL; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F3(E,A,B)+C+ctx->W[52]+0x8f1bbcdcL; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F3(D,E,A)+B+ctx->W[53]+0x8f1bbcdcL; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F3(C,D,E)+A+ctx->W[54]+0x8f1bbcdcL; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F3(B,C,D)+E+ctx->W[55]+0x8f1bbcdcL; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F3(A,B,C)+D+ctx->W[56]+0x8f1bbcdcL; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F3(E,A,B)+C+ctx->W[57]+0x8f1bbcdcL; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F3(D,E,A)+B+ctx->W[58]+0x8f1bbcdcL; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F3(C,D,E)+A+ctx->W[59]+0x8f1bbcdcL; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F4(B,C,D)+E+ctx->W[60]+0xca62c1d6L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F4(A,B,C)+D+ctx->W[61]+0xca62c1d6L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F4(E,A,B)+C+ctx->W[62]+0xca62c1d6L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F4(D,E,A)+B+ctx->W[63]+0xca62c1d6L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F4(C,D,E)+A+ctx->W[64]+0xca62c1d6L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F4(B,C,D)+E+ctx->W[65]+0xca62c1d6L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F4(A,B,C)+D+ctx->W[66]+0xca62c1d6L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F4(E,A,B)+C+ctx->W[67]+0xca62c1d6L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F4(D,E,A)+B+ctx->W[68]+0xca62c1d6L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F4(C,D,E)+A+ctx->W[69]+0xca62c1d6L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F4(B,C,D)+E+ctx->W[70]+0xca62c1d6L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F4(A,B,C)+D+ctx->W[71]+0xca62c1d6L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F4(E,A,B)+C+ctx->W[72]+0xca62c1d6L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F4(D,E,A)+B+ctx->W[73]+0xca62c1d6L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F4(C,D,E)+A+ctx->W[74]+0xca62c1d6L; C=SHA_ROTL(C,30); E = SHA_ROTL(A,5)+SHA_F4(B,C,D)+E+ctx->W[75]+0xca62c1d6L; B=SHA_ROTL(B,30); D = SHA_ROTL(E,5)+SHA_F4(A,B,C)+D+ctx->W[76]+0xca62c1d6L; A=SHA_ROTL(A,30); C = SHA_ROTL(D,5)+SHA_F4(E,A,B)+C+ctx->W[77]+0xca62c1d6L; E=SHA_ROTL(E,30); B = SHA_ROTL(C,5)+SHA_F4(D,E,A)+B+ctx->W[78]+0xca62c1d6L; D=SHA_ROTL(D,30); A = SHA_ROTL(B,5)+SHA_F4(C,D,E)+A+ctx->W[79]+0xca62c1d6L; C=SHA_ROTL(C,30); ctx->H[0] += A; ctx->H[1] += B; ctx->H[2] += C; ctx->H[3] += D; ctx->H[4] += E; } } #endif // USE_NSS_SHA libtorrent-0.13.2/src/utils/sha_fast.h000644 000765 000024 00000005465 11705767057 020642 0ustar00rakshasastaff000000 000000 // The OpenSSL library exception does not cover the program if you // compile the code below. #ifdef USE_NSS_SHA /* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is SHA 180-1 Reference Implementation (Optimized) * * The Initial Developer of the Original Code is Paul Kocher of * Cryptography Research. Portions created by Paul Kocher are * Copyright (C) 1995-9 by Cryptography Research, Inc. All * Rights Reserved. * * Contributor(s): * * Paul Kocher * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. */ #ifndef _SHA_FAST_H_ #define _SHA_FAST_H_ #include namespace torrent { struct SHA1ContextStr { union { uint32_t w[80]; /* input buffer, plus 64 words */ uint8_t b[320]; } u; uint32_t H[5]; /* 5 state variables */ uint32_t sizeHi,sizeLo; /* 64-bit count of hashed bytes. */ }; typedef SHA1ContextStr SHA1Context; /******************************************/ /* ** SHA-1 secure hash function */ /* ** Reset a SHA-1 context, preparing it for a fresh round of hashing */ extern void SHA1_Begin(SHA1Context *cx); /* ** Update the SHA-1 hash function with more data. ** "cx" the context ** "input" the data to hash ** "inputLen" the amount of data to hash */ extern void SHA1_Update(SHA1Context *cx, const unsigned char *input, unsigned int inputLen); /* ** Finish the SHA-1 hash function. Produce the digested results in "digest" ** "cx" the context ** "digest" where the 16 bytes of digest data are stored ** "digestLen" where the digest length (20) is stored ** "maxDigestLen" the maximum amount of data that can ever be ** stored in "digest" */ extern void SHA1_End(SHA1Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen); } #endif /* _SHA_FAST_H_ */ #endif // USE_NSS_SHA libtorrent-0.13.2/src/tracker/Makefile.am000644 000765 000024 00000000346 11705767057 021221 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_tracker.la libsub_tracker_la_SOURCES = \ tracker_dht.cc \ tracker_dht.h \ tracker_http.cc \ tracker_http.h \ tracker_udp.cc \ tracker_udp.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrent-0.13.2/src/tracker/Makefile.in000644 000765 000024 00000037574 11744204216 021231 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/tracker DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_tracker_la_LIBADD = am_libsub_tracker_la_OBJECTS = tracker_dht.lo tracker_http.lo \ tracker_udp.lo libsub_tracker_la_OBJECTS = $(am_libsub_tracker_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_tracker_la_SOURCES) DIST_SOURCES = $(libsub_tracker_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_tracker.la libsub_tracker_la_SOURCES = \ tracker_dht.cc \ tracker_dht.h \ tracker_http.cc \ tracker_http.h \ tracker_udp.cc \ tracker_udp.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tracker/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/tracker/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_tracker.la: $(libsub_tracker_la_OBJECTS) $(libsub_tracker_la_DEPENDENCIES) $(EXTRA_libsub_tracker_la_DEPENDENCIES) $(CXXLINK) $(libsub_tracker_la_OBJECTS) $(libsub_tracker_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracker_dht.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracker_http.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracker_udp.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/tracker/tracker_dht.cc000644 000765 000024 00000011300 11731615115 021740 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "dht/dht_router.h" #include "torrent/connection_manager.h" #include "torrent/download_info.h" #include "torrent/dht_manager.h" #include "torrent/exceptions.h" #include "torrent/tracker_list.h" #include "torrent/utils/log.h" #include "tracker_dht.h" #include "globals.h" #include "manager.h" namespace torrent { const char* TrackerDht::states[] = { "Idle", "Searching", "Announcing" }; bool TrackerDht::is_allowed() { return manager->dht_manager()->is_valid(); } TrackerDht::TrackerDht(TrackerList* parent, const std::string& url, int flags) : Tracker(parent, url, flags), m_state(state_idle) { if (!manager->dht_manager()->is_valid()) throw internal_error("Trying to add DHT tracker with no DHT manager."); } TrackerDht::~TrackerDht() { if (is_busy()) manager->dht_manager()->router()->cancel_announce(NULL, this); } bool TrackerDht::is_busy() const { return m_state != state_idle; } bool TrackerDht::is_usable() const { return is_enabled() && manager->dht_manager()->is_active(); } void TrackerDht::send_state(int state) { if (m_parent == NULL) throw internal_error("TrackerDht::send_state(...) does not have a valid m_parent."); if (is_busy()) { manager->dht_manager()->router()->cancel_announce(m_parent->info(), this); if (is_busy()) throw internal_error("TrackerDht::send_state cancel_announce did not cancel announce."); } m_latest_event = state; if (state == DownloadInfo::STOPPED) return; m_state = state_searching; if (!manager->dht_manager()->is_active()) return receive_failed("DHT server not active."); manager->dht_manager()->router()->announce(m_parent->info(), this); set_normal_interval(20 * 60); set_min_interval(0); } void TrackerDht::close() { if (is_busy()) manager->dht_manager()->router()->cancel_announce(m_parent->info(), this); } void TrackerDht::disown() { close(); } TrackerDht::Type TrackerDht::type() const { return TRACKER_DHT; } void TrackerDht::receive_peers(raw_list peers) { if (!is_busy()) throw internal_error("TrackerDht::receive_peers called while not busy."); m_peers.parse_address_bencode(peers); } void TrackerDht::receive_success() { if (!is_busy()) throw internal_error("TrackerDht::receive_success called while not busy."); m_state = state_idle; m_parent->receive_success(this, &m_peers); m_peers.clear(); } void TrackerDht::receive_failed(const char* msg) { if (!is_busy()) throw internal_error("TrackerDht::receive_failed called while not busy."); m_state = state_idle; m_parent->receive_failed(this, msg); m_peers.clear(); } void TrackerDht::receive_progress(int replied, int contacted) { if (!is_busy()) throw internal_error("TrackerDht::receive_status called while not busy."); m_replied = replied; m_contacted = contacted; } void TrackerDht::get_status(char* buffer, int length) { if (!is_busy()) throw internal_error("TrackerDht::get_status called while not busy."); snprintf(buffer, length, "[%s: %d/%d nodes replied]", states[m_state], m_replied, m_contacted); } } libtorrent-0.13.2/src/tracker/tracker_dht.h000644 000765 000024 00000005702 11731615115 021613 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TRACKER_TRACKER_DHT_H #define LIBTORRENT_TRACKER_TRACKER_DHT_H #include "net/address_list.h" #include "torrent/object.h" #include "torrent/tracker.h" namespace torrent { class TrackerDht : public Tracker { public: TrackerDht(TrackerList* parent, const std::string& url, int flags); ~TrackerDht(); typedef enum { state_idle, state_searching, state_announcing, } state_type; static const char* states[]; static bool is_allowed(); virtual bool is_busy() const; virtual bool is_usable() const; virtual void send_state(int state); virtual void close(); virtual void disown(); virtual Type type() const; virtual void get_status(char* buffer, int length); void set_state(state_type state) { m_state = state; } state_type get_state() const { return m_state; } bool has_peers() const { return !m_peers.empty(); } void receive_peers(raw_list peers); void receive_success(); void receive_failed(const char* msg); void receive_progress(int replied, int contacted); private: AddressList m_peers; state_type m_state; int m_replied; int m_contacted; }; } #endif libtorrent-0.13.2/src/tracker/tracker_http.cc000644 000765 000024 00000026157 11731615115 022160 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #define __STDC_FORMAT_MACROS #include #include #include #include #include "net/address_list.h" #include "torrent/connection_manager.h" #include "torrent/download_info.h" #include "torrent/exceptions.h" #include "torrent/http.h" #include "torrent/object_stream.h" #include "torrent/tracker_list.h" #include "torrent/utils/log.h" #include "torrent/utils/option_strings.h" #include "tracker_http.h" #include "globals.h" #include "manager.h" #define LT_LOG_TRACKER(log_level, log_fmt, ...) \ lt_log_print_info(LOG_TRACKER_##log_level, m_parent->info(), "tracker", "[%u] " log_fmt, group(), __VA_ARGS__); #define LT_LOG_TRACKER_DUMP(log_level, log_dump_data, log_dump_size, log_fmt, ...) \ lt_log_print_info_dump(LOG_TRACKER_##log_level, log_dump_data, log_dump_size, m_parent->info(), "tracker", "[%u] " log_fmt, group(), __VA_ARGS__); namespace tr1 { using namespace std::tr1; } namespace torrent { TrackerHttp::TrackerHttp(TrackerList* parent, const std::string& url, int flags) : Tracker(parent, url, flags), m_get(Http::slot_factory()()), m_data(NULL) { m_get->signal_done().push_back(tr1::bind(&TrackerHttp::receive_done, this)); m_get->signal_failed().push_back(tr1::bind(&TrackerHttp::receive_failed, this, tr1::placeholders::_1)); // Haven't considered if this needs any stronger error detection, // can dropping the '?' be used for malicious purposes? size_t delim_options = url.rfind('?'); m_dropDeliminator = delim_options != std::string::npos && url.find('/', delim_options) == std::string::npos; // Check the url if we can use scrape. size_t delim_slash = url.rfind('/'); if (delim_slash != std::string::npos && url.find("/announce", delim_slash) == delim_slash) m_flags |= flag_can_scrape; } TrackerHttp::~TrackerHttp() { delete m_get; delete m_data; } bool TrackerHttp::is_busy() const { return m_data != NULL; } void TrackerHttp::request_prefix(std::stringstream* stream, const std::string& url) { char hash[61]; *rak::copy_escape_html(m_parent->info()->hash().begin(), m_parent->info()->hash().end(), hash) = '\0'; *stream << url << (m_dropDeliminator ? '&' : '?') << "info_hash=" << hash; } void TrackerHttp::send_state(int state) { close_directly(); if (m_parent == NULL) throw internal_error("TrackerHttp::send_state(...) does not have a valid m_parent."); m_latest_event = state; std::stringstream s; s.imbue(std::locale::classic()); char localId[61]; DownloadInfo* info = m_parent->info(); request_prefix(&s, m_url); *rak::copy_escape_html(info->local_id().begin(), info->local_id().end(), localId) = '\0'; s << "&peer_id=" << localId; if (m_parent->key()) s << "&key=" << std::hex << std::setw(8) << std::setfill('0') << m_parent->key() << std::dec; if (!m_tracker_id.empty()) s << "&trackerid=" << rak::copy_escape_html(m_tracker_id); const rak::socket_address* localAddress = rak::socket_address::cast_from(manager->connection_manager()->local_address()); if (localAddress->family() == rak::socket_address::af_inet && !localAddress->sa_inet()->is_address_any()) s << "&ip=" << localAddress->address_str(); if (info->is_compact()) s << "&compact=1"; if (m_parent->numwant() >= 0 && state != DownloadInfo::STOPPED) s << "&numwant=" << m_parent->numwant(); if (manager->connection_manager()->listen_port()) s << "&port=" << manager->connection_manager()->listen_port(); uint64_t uploaded_adjusted = info->uploaded_adjusted(); uint64_t completed_adjusted = info->completed_adjusted(); uint64_t download_left = info->slot_left()(); s << "&uploaded=" << uploaded_adjusted << "&downloaded=" << completed_adjusted << "&left=" << download_left; switch(state) { case DownloadInfo::STARTED: s << "&event=started"; break; case DownloadInfo::STOPPED: s << "&event=stopped"; break; case DownloadInfo::COMPLETED: s << "&event=completed"; break; default: break; } m_data = new std::stringstream(); std::string request_url = s.str(); LT_LOG_TRACKER_DUMP(DEBUG, request_url.c_str(), request_url.size(), "Tracker HTTP request: state:%s up_adj:%" PRIu64 " completed_adj:%" PRIu64 " left_adj:%" PRIu64 ".", option_as_string(OPTION_TRACKER_EVENT, state), uploaded_adjusted, completed_adjusted, download_left); m_get->set_url(request_url); m_get->set_stream(m_data); m_get->set_timeout(2 * 60); m_get->start(); } void TrackerHttp::send_scrape() { if (m_data != NULL) return; m_latest_event = EVENT_SCRAPE; std::stringstream s; s.imbue(std::locale::classic()); request_prefix(&s, scrape_url_from(m_url)); m_data = new std::stringstream(); std::string request_url = s.str(); LT_LOG_TRACKER_DUMP(DEBUG, request_url.c_str(), request_url.size(), "Tracker HTTP scrape.", 0); m_get->set_url(request_url); m_get->set_stream(m_data); m_get->set_timeout(2 * 60); m_get->start(); } void TrackerHttp::close() { if (m_data == NULL) return; LT_LOG_TRACKER(DEBUG, "Tracker HTTP request cancelled: state:%s url:%s.", option_as_string(OPTION_TRACKER_EVENT, m_latest_event), m_url.c_str()); close_directly(); } void TrackerHttp::disown() { if (m_data == NULL) return; LT_LOG_TRACKER(DEBUG, "Tracker HTTP request disowned: state:%s url:%s.", option_as_string(OPTION_TRACKER_EVENT, m_latest_event), m_url.c_str()); m_get->set_delete_self(); m_get->set_delete_stream(); m_get->signal_done().clear(); m_get->signal_failed().clear(); // Allocate this dynamically, so that we don't need to do this here. m_get = Http::slot_factory()(); m_data = NULL; } TrackerHttp::Type TrackerHttp::type() const { return TRACKER_HTTP; } void TrackerHttp::close_directly() { if (m_data == NULL) return; m_get->close(); m_get->set_stream(NULL); delete m_data; m_data = NULL; } void TrackerHttp::receive_done() { if (m_data == NULL) throw internal_error("TrackerHttp::receive_done() called on an invalid object"); if (lt_log_is_valid(LOG_TRACKER_DEBUG)) { std::string dump = m_data->str(); LT_LOG_TRACKER_DUMP(DEBUG, dump.c_str(), dump.size(), "Tracker HTTP reply.", 0); } Object b; *m_data >> b; if (m_data->fail()) return receive_failed("Could not parse bencoded data"); if (!b.is_map()) return receive_failed("Root not a bencoded map"); if (b.has_key("failure reason")) return receive_failed("Failure reason \"" + (b.get_key("failure reason").is_string() ? b.get_key_string("failure reason") : std::string("failure reason not a string")) + "\""); if (m_latest_event == EVENT_SCRAPE) process_scrape(b); else process_success(b); } void TrackerHttp::receive_failed(std::string msg) { if (lt_log_is_valid(LOG_TRACKER_DEBUG)) { std::string dump = m_data->str(); LT_LOG_TRACKER_DUMP(DEBUG, dump.c_str(), dump.size(), "Tracker HTTP failed.", 0); } close_directly(); if (m_latest_event == EVENT_SCRAPE) m_parent->receive_scrape_failed(this, msg); else m_parent->receive_failed(this, msg); } void TrackerHttp::process_success(const Object& object) { if (object.has_key_value("interval")) set_normal_interval(object.get_key_value("interval")); if (object.has_key_value("min interval")) set_min_interval(object.get_key_value("min interval")); if (object.has_key_string("tracker id")) m_tracker_id = object.get_key_string("tracker id"); if (object.has_key_value("complete") && object.has_key_value("incomplete")) { m_scrape_complete = std::max(object.get_key_value("complete"), 0); m_scrape_incomplete = std::max(object.get_key_value("incomplete"), 0); m_scrape_time_last = cachedTime.seconds(); } if (object.has_key_value("downloaded")) m_scrape_downloaded = std::max(object.get_key_value("downloaded"), 0); AddressList l; try { // Due to some trackers sending the wrong type when no peers are // available, don't bork on it. if (object.get_key("peers").is_string()) l.parse_address_compact(object.get_key_string("peers")); else if (object.get_key("peers").is_list()) l.parse_address_normal(object.get_key_list("peers")); } catch (bencode_error& e) { return receive_failed(e.what()); } close_directly(); m_parent->receive_success(this, &l); } void TrackerHttp::process_scrape(const Object& object) { if (!object.has_key_map("files")) return receive_failed("Tracker scrape does not have files entry."); // Add better validation here... const Object& files = object.get_key("files"); if (!files.has_key_map(m_parent->info()->hash().str())) return receive_failed("Tracker scrape replay did not contain infohash."); const Object& stats = files.get_key(m_parent->info()->hash().str()); if (stats.has_key_value("complete")) m_scrape_complete = std::max(stats.get_key_value("complete"), 0); if (stats.has_key_value("incomplete")) m_scrape_incomplete = std::max(stats.get_key_value("incomplete"), 0); if (stats.has_key_value("downloaded")) m_scrape_downloaded = std::max(stats.get_key_value("downloaded"), 0); LT_LOG_TRACKER(INFO, "Tracker scrape for %u torrents: complete:%u incomplete:%u downloaded:%u.", files.as_map().size(), m_scrape_complete, m_scrape_incomplete, m_scrape_downloaded); close_directly(); m_parent->receive_scrape_success(this); } } libtorrent-0.13.2/src/tracker/tracker_http.h000644 000765 000024 00000005170 11731615115 022012 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TRACKER_TRACKER_HTTP_H #define LIBTORRENT_TRACKER_TRACKER_HTTP_H #include #include "torrent/object.h" #include "torrent/tracker.h" namespace torrent { class Http; class TrackerHttp : public Tracker { public: TrackerHttp(TrackerList* parent, const std::string& url, int flags); ~TrackerHttp(); virtual bool is_busy() const; virtual void send_state(int state); virtual void send_scrape(); virtual void close(); virtual void disown(); virtual Type type() const; private: void close_directly(); void request_prefix(std::stringstream* stream, const std::string& url); void receive_done(); void receive_failed(std::string msg); void process_success(const Object& object); void process_scrape(const Object& object); Http* m_get; std::stringstream* m_data; bool m_dropDeliminator; }; } #endif libtorrent-0.13.2/src/tracker/tracker_udp.cc000644 000765 000024 00000026633 11744202530 021765 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #define __STDC_FORMAT_MACROS #include #include #include #include #include "net/address_list.h" #include "torrent/exceptions.h" #include "torrent/connection_manager.h" #include "torrent/download_info.h" #include "torrent/poll.h" #include "torrent/tracker_list.h" #include "torrent/utils/log.h" #include "torrent/utils/option_strings.h" #include "tracker_udp.h" #include "manager.h" #define LT_LOG_TRACKER(log_level, log_fmt, ...) \ lt_log_print_info(LOG_TRACKER_##log_level, m_parent->info(), "tracker", "[%u] " log_fmt, group(), __VA_ARGS__); #define LT_LOG_TRACKER_DUMP(log_level, log_dump_data, log_dump_size, log_fmt, ...) \ lt_log_print_info_dump(LOG_TRACKER_##log_level, log_dump_data, log_dump_size, m_parent->info(), "tracker", "[%u] " log_fmt, group(), __VA_ARGS__); namespace torrent { TrackerUdp::TrackerUdp(TrackerList* parent, const std::string& url, int flags) : Tracker(parent, url, flags), m_slotResolver(NULL), m_readBuffer(NULL), m_writeBuffer(NULL) { m_taskTimeout.slot() = std::tr1::bind(&TrackerUdp::receive_timeout, this); } TrackerUdp::~TrackerUdp() { if (m_slotResolver != NULL) static_cast(m_slotResolver)->blocked(); close_directly(); } bool TrackerUdp::is_busy() const { return get_fd().is_valid(); } void TrackerUdp::send_state(int state) { close_directly(); m_latest_event = state; char hostname[1024]; if (std::sscanf(m_url.c_str(), "udp://%1023[^:]:%i", hostname, &m_port) != 2 || hostname[0] == '\0' || m_port <= 0 || m_port >= (1 << 16)) return receive_failed("Could not parse UDP hostname or port."); // Because we can only remember one slot, set any pending resolves blocked // so that if this tracker is deleted, the member function won't be called. if (m_slotResolver != NULL) static_cast(m_slotResolver)->blocked(); m_sendState = state; m_slotResolver = manager->connection_manager()->resolver()(hostname, PF_INET, SOCK_DGRAM, sigc::mem_fun(this, &TrackerUdp::start_announce)); } void TrackerUdp::start_announce(const sockaddr* sa, int err) { m_slotResolver = NULL; if (sa == NULL) return receive_failed("Could not resolve hostname."); m_connectAddress = *rak::socket_address::cast_from(sa); m_connectAddress.set_port(m_port); if (!m_connectAddress.is_valid()) return receive_failed("Invalid tracker address."); if (!get_fd().open_datagram() || !get_fd().set_nonblock() || !get_fd().bind(*rak::socket_address::cast_from(manager->connection_manager()->bind_address()))) return receive_failed("Could not open UDP socket."); m_readBuffer = new ReadBuffer; m_writeBuffer = new WriteBuffer; prepare_connect_input(); manager->poll()->open(this); manager->poll()->insert_read(this); manager->poll()->insert_write(this); manager->poll()->insert_error(this); m_tries = m_parent->info()->udp_tries(); priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_parent->info()->udp_timeout())).round_seconds()); } void TrackerUdp::close() { if (!get_fd().is_valid()) return; LT_LOG_TRACKER(DEBUG, "Tracker UDP request cancelled: state:%s url:%s.", option_as_string(OPTION_TRACKER_EVENT, m_latest_event), m_url.c_str()); close_directly(); } void TrackerUdp::disown() { if (!get_fd().is_valid()) return; LT_LOG_TRACKER(DEBUG, "Tracker UDP request disowned: state:%s url:%s.", option_as_string(OPTION_TRACKER_EVENT, m_latest_event), m_url.c_str()); close_directly(); } void TrackerUdp::close_directly() { if (!get_fd().is_valid()) return; delete m_readBuffer; delete m_writeBuffer; m_readBuffer = NULL; m_writeBuffer = NULL; priority_queue_erase(&taskScheduler, &m_taskTimeout); manager->poll()->remove_read(this); manager->poll()->remove_write(this); manager->poll()->remove_error(this); manager->poll()->close(this); get_fd().close(); get_fd().clear(); } TrackerUdp::Type TrackerUdp::type() const { return TRACKER_UDP; } void TrackerUdp::receive_failed(const std::string& msg) { close_directly(); m_parent->receive_failed(this, msg); } void TrackerUdp::receive_timeout() { if (m_taskTimeout.is_queued()) throw internal_error("TrackerUdp::receive_timeout() called but m_taskTimeout is still scheduled."); if (--m_tries == 0) { receive_failed("Unable to connect to UDP tracker."); } else { priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_parent->info()->udp_timeout())).round_seconds()); manager->poll()->insert_write(this); } } void TrackerUdp::event_read() { rak::socket_address sa; int s = read_datagram(m_readBuffer->begin(), m_readBuffer->reserved(), &sa); if (s < 0) return; m_readBuffer->reset_position(); m_readBuffer->set_end(s); LT_LOG_TRACKER_DUMP(DEBUG, (const char*)m_readBuffer->begin(), s, "Tracker UDP reply.", 0); if (s < 4) return; // Make sure sa is from the source we expected? // Do something with the content here. switch (m_readBuffer->read_32()) { case 0: if (m_action != 0 || !process_connect_output()) return; prepare_announce_input(); priority_queue_erase(&taskScheduler, &m_taskTimeout); priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_parent->info()->udp_timeout())).round_seconds()); m_tries = m_parent->info()->udp_tries(); manager->poll()->insert_write(this); return; case 1: if (m_action != 1 || !process_announce_output()) return; return; case 3: if (!process_error_output()) return; return; default: return; }; } void TrackerUdp::event_write() { if (m_writeBuffer->size_end() == 0) throw internal_error("TrackerUdp::write() called but the write buffer is empty."); int __UNUSED s = write_datagram(m_writeBuffer->begin(), m_writeBuffer->size_end(), &m_connectAddress); // TODO: If send failed, retry shortly or do i call receive_failed? // if (s != m_writeBuffer->size_end()) // ; manager->poll()->remove_write(this); } void TrackerUdp::event_error() { } void TrackerUdp::prepare_connect_input() { m_writeBuffer->reset(); m_writeBuffer->write_64(m_connectionId = magic_connection_id); m_writeBuffer->write_32(m_action = 0); m_writeBuffer->write_32(m_transactionId = random()); LT_LOG_TRACKER_DUMP(DEBUG, m_writeBuffer->begin(), m_writeBuffer->size_end(), "Tracker UDP connect: id:%" PRIx32 ".", m_transactionId); } void TrackerUdp::prepare_announce_input() { DownloadInfo* info = m_parent->info(); m_writeBuffer->reset(); m_writeBuffer->write_64(m_connectionId); m_writeBuffer->write_32(m_action = 1); m_writeBuffer->write_32(m_transactionId = random()); m_writeBuffer->write_range(info->hash().begin(), info->hash().end()); m_writeBuffer->write_range(info->local_id().begin(), info->local_id().end()); uint64_t uploaded_adjusted = info->uploaded_adjusted(); uint64_t completed_adjusted = info->completed_adjusted(); uint64_t download_left = info->slot_left()(); m_writeBuffer->write_64(completed_adjusted); m_writeBuffer->write_64(download_left); m_writeBuffer->write_64(uploaded_adjusted); m_writeBuffer->write_32(m_sendState); const rak::socket_address* localAddress = rak::socket_address::cast_from(manager->connection_manager()->local_address()); // This code assumes we're have a inet address. if (localAddress->family() != rak::socket_address::af_inet) throw internal_error("TrackerUdp::prepare_announce_input() info->local_address() not of family AF_INET."); m_writeBuffer->write_32_n(localAddress->sa_inet()->address_n()); m_writeBuffer->write_32(m_parent->key()); m_writeBuffer->write_32(m_parent->numwant()); m_writeBuffer->write_16(manager->connection_manager()->listen_port()); if (m_writeBuffer->size_end() != 98) throw internal_error("TrackerUdp::prepare_announce_input() ended up with the wrong size"); LT_LOG_TRACKER_DUMP(DEBUG, m_writeBuffer->begin(), m_writeBuffer->size_end(), "Tracker UDP announce: state:%s id:%" PRIx32 " up_adj:%" PRIu64 " completed_adj:%" PRIu64 " left_adj:%" PRIu64 ".", option_as_string(OPTION_TRACKER_EVENT, m_sendState), m_transactionId, uploaded_adjusted, completed_adjusted, download_left); } bool TrackerUdp::process_connect_output() { if (m_readBuffer->size_end() < 16 || m_readBuffer->read_32() != m_transactionId) return false; m_connectionId = m_readBuffer->read_64(); return true; } bool TrackerUdp::process_announce_output() { if (m_readBuffer->size_end() < 20 || m_readBuffer->read_32() != m_transactionId) return false; set_normal_interval(m_readBuffer->read_32()); m_scrape_incomplete = m_readBuffer->read_32(); // leechers m_scrape_complete = m_readBuffer->read_32(); // seeders m_scrape_time_last = rak::timer::current().seconds(); AddressList l; std::copy(reinterpret_cast(m_readBuffer->position()), reinterpret_cast(m_readBuffer->end() - m_readBuffer->remaining() % sizeof(SocketAddressCompact)), std::back_inserter(l)); // Some logic here to decided on whetever we're going to close the // connection or not? close_directly(); m_parent->receive_success(this, &l); return true; } bool TrackerUdp::process_error_output() { if (m_readBuffer->size_end() < 8 || m_readBuffer->read_32() != m_transactionId) return false; receive_failed("Received error message: " + std::string(m_readBuffer->position(), m_readBuffer->end())); return true; } } libtorrent-0.13.2/src/tracker/tracker_udp.h000644 000765 000024 00000006604 11744202530 021623 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TRACKER_TRACKER_UDP_H #define LIBTORRENT_TRACKER_TRACKER_UDP_H #include #include "net/protocol_buffer.h" #include "net/socket_datagram.h" #include "torrent/tracker.h" #include "globals.h" namespace torrent { class TrackerUdp : public SocketDatagram, public Tracker { public: typedef ProtocolBuffer<512> ReadBuffer; typedef ProtocolBuffer<512> WriteBuffer; static const uint64_t magic_connection_id = 0x0000041727101980ll; TrackerUdp(TrackerList* parent, const std::string& url, int flags); ~TrackerUdp(); const char* type_name() const { return "tracker_udp"; } virtual bool is_busy() const; virtual void send_state(int state); virtual void close(); virtual void disown(); virtual Type type() const; virtual void event_read(); virtual void event_write(); virtual void event_error(); private: void close_directly(); void receive_failed(const std::string& msg); void receive_timeout(); void start_announce(const sockaddr* sa, int err); void prepare_connect_input(); void prepare_announce_input(); bool process_connect_output(); bool process_announce_output(); bool process_error_output(); rak::socket_address m_connectAddress; int m_port; int m_sendState; void* m_slotResolver; uint32_t m_action; uint64_t m_connectionId; uint32_t m_transactionId; ReadBuffer* m_readBuffer; WriteBuffer* m_writeBuffer; uint32_t m_tries; rak::priority_item m_taskTimeout; }; } #endif libtorrent-0.13.2/src/torrent/bitfield.cc000644 000765 000024 00000007163 11705767056 021323 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "rak/algorithm.h" #include "bitfield.h" #include "exceptions.h" namespace torrent { void Bitfield::set_size_bits(size_type s) { if (m_data != NULL) throw internal_error("Bitfield::set_size_bits(size_type s) m_data != NULL."); m_size = s; } void Bitfield::set_size_set(size_type s) { if (s > m_size || m_data != NULL) throw internal_error("Bitfield::set_size_set(size_type s) s > m_size."); m_set = s; } void Bitfield::update() { // Clears the unused bits. clear_tail(); m_set = 0; iterator itr = m_data; iterator last = end(); while (itr + sizeof(unsigned int) <= last) { m_set += rak::popcount_wrapper(*reinterpret_cast(itr)); itr += sizeof(unsigned int); } while (itr != last) { m_set += rak::popcount_wrapper(*itr++); } } void Bitfield::copy(const Bitfield& bf) { m_size = bf.m_size; m_set = bf.m_set; if (bf.m_data == NULL) { m_data = NULL; } else { m_data = new value_type[size_bytes()]; std::memcpy(m_data, bf.m_data, size_bytes()); } } void Bitfield::swap(Bitfield& bf) { std::swap(m_size, bf.m_size); std::swap(m_set, bf.m_set); std::swap(m_data, bf.m_data); } void Bitfield::set_all() { m_set = m_size; std::memset(m_data, ~value_type(), size_bytes()); clear_tail(); } void Bitfield::unset_all() { m_set = 0; std::memset(m_data, value_type(), size_bytes()); } // Quick hack. Speed improvements would require that m_set is kept // up-to-date. void Bitfield::set_range(size_type first, size_type last) { while (first != last) set(first++); } void Bitfield::unset_range(size_type first, size_type last) { while (first != last) unset(first++); } // size_type // Bitfield::count_range(size_type first, size_type last) { // size_type count = 0; // // Some archs have bitcounting instructions, look into writing a // // wrapper for those. // for (iterator itr = m_data, last = end(); itr != last; ++itr) // m_set += bit_count_256[*itr]; // } } libtorrent-0.13.2/src/torrent/bitfield.h000644 000765 000024 00000012161 11705767056 021157 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_BITFIELD_H #define LIBTORRENT_BITFIELD_H #include #include namespace torrent { class LIBTORRENT_EXPORT Bitfield { public: typedef uint32_t size_type; typedef uint8_t value_type; typedef const uint8_t const_value_type; typedef value_type* iterator; typedef const value_type* const_iterator; Bitfield() : m_size(0), m_set(0), m_data(NULL) {} ~Bitfield() { clear(); } bool empty() const { return m_data == NULL; } bool is_all_set() const { return m_set == m_size; } bool is_all_unset() const { return m_set == 0; } bool is_tail_cleared() const { return m_size % 8 == 0 || !((*(end() - 1) & mask_from(m_size % 8))); } size_type size_bits() const { return m_size; } size_type size_bytes() const { return (m_size + 7) / 8; } size_type size_set() const { return m_set; } size_type size_unset() const { return m_size - m_set; } void set_size_bits(size_type s); void set_size_set(size_type s); // Call update if you've changed the data directly and want to // update the counters and unset the last unused bits. // // Resize clears the data? void update(); void allocate() { if (m_data == NULL) m_data = new value_type[size_bytes()]; } void unallocate() { delete [] m_data; m_data = NULL; } void clear() { unallocate(); m_size = 0; m_set = 0; } void clear_tail() { if (m_size % 8) *(end() - 1) &= mask_before(m_size % 8); } void copy(const Bitfield& bf); void swap(Bitfield& bf); void set_all(); void set_range(size_type first, size_type last); void unset_all(); void unset_range(size_type first, size_type last); // size_type count_range(size_type first, size_type last) const; bool get(size_type idx) const { return m_data[idx / 8] & mask_at(idx % 8); } void set(size_type idx) { m_set += !get(idx); m_data[idx / 8] |= mask_at(idx % 8); } void unset(size_type idx) { m_set -= get(idx); m_data[idx / 8] &= ~mask_at(idx % 8); } iterator begin() { return m_data; } const_iterator begin() const { return m_data; } iterator end() { return m_data + size_bytes(); } const_iterator end() const { return m_data + size_bytes(); } size_type position(const_iterator itr) const { return (itr - m_data) * 8; } void from_c_str(const char* str) { std::memcpy(m_data, str, size_bytes()); update(); } // Remember to use modulo. static value_type mask_at(size_type idx) { return 1 << (7 - idx); } static value_type mask_before(size_type idx) { return (value_type)~0 << (8 - idx); } static value_type mask_from(size_type idx) { return (value_type)~0 >> idx; } private: Bitfield(const Bitfield& bf); Bitfield& operator = (const Bitfield& bf); size_type m_size; size_type m_set; value_type* m_data; }; } #endif libtorrent-0.13.2/src/torrent/chunk_manager.cc000644 000765 000024 00000014303 11705767056 022335 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "data/chunk_list.h" #include "utils/log_files.h" #include "exceptions.h" #include "chunk_manager.h" #include "globals.h" namespace torrent { ChunkManager::ChunkManager() : m_memoryUsage(0), m_memoryBlockCount(0), m_safeSync(false), m_timeoutSync(600), m_timeoutSafeSync(900), m_preloadType(0), m_preloadMinSize(256 << 10), m_preloadRequiredRate(5 << 10), m_statsPreloaded(0), m_statsNotPreloaded(0), m_timerStarved(0), m_lastFreed(0) { // 1/5 of the available memory should be enough for the client. If // the client really requires alot more memory it should call this // itself. m_maxMemoryUsage = (estimate_max_memory_usage() * 4) / 5; } ChunkManager::~ChunkManager() { if (m_memoryUsage != 0 || m_memoryBlockCount != 0) throw internal_error("ChunkManager::~ChunkManager() m_memoryUsage != 0 || m_memoryBlockCount != 0."); } uint64_t ChunkManager::sync_queue_memory_usage() const { uint64_t size = 0; for (const_iterator itr = begin(), last = end(); itr != last; itr++) size += (*itr)->queue_size() * (*itr)->chunk_size(); return size; } uint32_t ChunkManager::sync_queue_size() const { uint32_t size = 0; for (const_iterator itr = begin(), last = end(); itr != last; itr++) size += (*itr)->queue_size(); return size; } uint64_t ChunkManager::estimate_max_memory_usage() { rlimit rlp; #ifdef RLIMIT_AS if (getrlimit(RLIMIT_AS, &rlp) == 0 && rlp.rlim_cur != RLIM_INFINITY) #else if (getrlimit(RLIMIT_DATA, &rlp) == 0 && rlp.rlim_cur != RLIM_INFINITY) #endif return rlp.rlim_cur; return (uint64_t)DEFAULT_ADDRESS_SPACE_SIZE << 20; } uint64_t ChunkManager::safe_free_diskspace() const { return m_memoryUsage + ((uint64_t)512 << 20); } void ChunkManager::insert(ChunkList* chunkList) { chunkList->set_manager(this); base_type::push_back(chunkList); } void ChunkManager::erase(ChunkList* chunkList) { if (chunkList->queue_size() != 0) throw internal_error("ChunkManager::erase(...) chunkList->queue_size() != 0."); iterator itr = std::find(base_type::begin(), base_type::end(), chunkList); if (itr == base_type::end()) throw internal_error("ChunkManager::erase(...) itr == base_type::end()."); std::iter_swap(itr, --base_type::end()); base_type::pop_back(); chunkList->set_manager(NULL); } bool ChunkManager::allocate(uint32_t size, int flags) { if (m_memoryUsage + size > (3 * m_maxMemoryUsage) / 4) try_free_memory((1 * m_maxMemoryUsage) / 4); if (m_memoryUsage + size > m_maxMemoryUsage) { if (log_files[LOG_MINCORE_STATS].is_open() && !(flags & allocate_dont_log)) log_mincore_stats_func_alloc_failed(1); return false; } if (log_files[LOG_MINCORE_STATS].is_open() && !(flags & allocate_dont_log)) log_mincore_stats_func_alloc(size); m_memoryUsage += size; m_memoryBlockCount++; return true; } void ChunkManager::deallocate(uint32_t size, int flags) { if (size > m_memoryUsage) throw internal_error("ChunkManager::deallocate(...) size > m_memoryUsage."); if (log_files[LOG_MINCORE_STATS].is_open() && !(flags & allocate_dont_log)) { if (flags & allocate_revert_log) log_mincore_stats_func_alloc(-size); else log_mincore_stats_func_dealloc(size); } m_memoryUsage -= size; m_memoryBlockCount--; } void ChunkManager::try_free_memory(uint64_t size) { // Ensure that we don't call this function too often when futile as // it might be somewhat expensive. // // Note that it won't be able to free chunks that are scheduled for // hash checking, so a too low max memory setting will give problem // at high transfer speed. if (m_timerStarved + 10 >= cachedTime.seconds()) return; sync_all(0, size <= m_memoryUsage ? (m_memoryUsage - size) : 0); // The caller must ensure he tries to free a sufficiently large // amount of memory to ensure it, and other users, has enough memory // space for at least 10 seconds. m_timerStarved = cachedTime.seconds(); } void ChunkManager::periodic_sync() { sync_all(ChunkList::sync_use_timeout, 0); } void ChunkManager::sync_all(int flags, uint64_t target) { if (empty()) return; // Start from the next entry so that we don't end up repeatedly // syncing the same torrent. m_lastFreed = m_lastFreed % base_type::size() + 1; iterator itr = base_type::begin() + m_lastFreed; do { if (itr == base_type::end()) itr = base_type::begin(); (*itr)->sync_chunks(flags); } while (++itr != base_type::begin() + m_lastFreed && m_memoryUsage >= target); m_lastFreed = itr - begin(); } } libtorrent-0.13.2/src/torrent/chunk_manager.h000644 000765 000024 00000015277 11705767056 022212 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Add some helpfull words here. #ifndef LIBTORRENT_CHUNK_MANAGER_H #define LIBTORRENT_CHUNK_MANAGER_H #include #include namespace torrent { // TODO: Currently all chunk lists are inserted, despite the download // not being open/active. class LIBTORRENT_EXPORT ChunkManager : private std::vector { public: typedef std::vector base_type; typedef uint32_t size_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::const_iterator; using base_type::begin; using base_type::end; using base_type::size; using base_type::empty; ChunkManager(); ~ChunkManager(); uint64_t memory_usage() const { return m_memoryUsage; } uint64_t sync_queue_memory_usage() const; uint32_t memory_block_count() const { return m_memoryBlockCount; } uint32_t sync_queue_size() const; // Should we allow the client to reserve some memory? // The client should set this automatically if ulimit is set. uint64_t max_memory_usage() const { return m_maxMemoryUsage; } void set_max_memory_usage(uint64_t bytes) { m_maxMemoryUsage = bytes; } // Estimate the max memory usage possible, capped at 1GB. static uint64_t estimate_max_memory_usage(); uint64_t safe_free_diskspace() const; bool safe_sync() const { return m_safeSync; } void set_safe_sync(uint32_t state) { m_safeSync = state; } // Set the interval to wait after the last write to a chunk before // trying to sync it. By not forcing a sync too early it should give // the kernel an oppertunity to sync at its convenience. uint32_t timeout_sync() const { return m_timeoutSync; } void set_timeout_sync(uint32_t seconds) { m_timeoutSync = seconds; } uint32_t timeout_safe_sync() const { return m_timeoutSafeSync; } void set_timeout_safe_sync(uint32_t seconds) { m_timeoutSafeSync = seconds; } // Set to 0 to disable preloading. // // How the value is used is yet to be determined, but it won't be // able to use actual requests in the request queue as we can easily // stay ahead of it causing preloading to fail. uint32_t preload_type() const { return m_preloadType; } void set_preload_type(uint32_t t) { m_preloadType = t; } uint32_t preload_min_size() const { return m_preloadMinSize; } void set_preload_min_size(uint32_t bytes) { m_preloadMinSize = bytes; } // Required rate before attempting to preload chunk, per whole // megabyte of chunk size. uint32_t preload_required_rate() const { return m_preloadRequiredRate; } void set_preload_required_rate(uint32_t bytes) { m_preloadRequiredRate = bytes; } void insert(ChunkList* chunkList); void erase(ChunkList* chunkList); // The client may use these functions to affect the library's memory // usage by indicating how much it uses. This shouldn't really be // nessesary unless the client maps large amounts of memory. // // If the caller finds out the allocated memory quota isn't needed // due to e.g. other errors then 'deallocate_unused' must be called // within the context of the original 'allocate' caller in order to // properly be reflected when logging. // // The primary user of these functions is ChunkList. static const int allocate_revert_log = (1 << 0); static const int allocate_dont_log = (1 << 1); bool allocate(uint32_t size, int flags = 0); void deallocate(uint32_t size, int flags = 0); void try_free_memory(uint64_t size); void periodic_sync(); // Not sure if I wnt these here. Consider implementing a generic // statistics API. uint32_t stats_preloaded() const { return m_statsPreloaded; } void inc_stats_preloaded() { m_statsPreloaded++; } uint32_t stats_not_preloaded() const { return m_statsNotPreloaded; } void inc_stats_not_preloaded() { m_statsNotPreloaded++; } private: ChunkManager(const ChunkManager&); void operator = (const ChunkManager&); void sync_all(int flags, uint64_t target) LIBTORRENT_NO_EXPORT; uint64_t m_memoryUsage; uint64_t m_maxMemoryUsage; uint32_t m_memoryBlockCount; bool m_safeSync; uint32_t m_timeoutSync; uint32_t m_timeoutSafeSync; uint32_t m_preloadType; uint32_t m_preloadMinSize; uint32_t m_preloadRequiredRate; uint32_t m_statsPreloaded; uint32_t m_statsNotPreloaded; int32_t m_timerStarved; size_type m_lastFreed; }; } #endif libtorrent-0.13.2/src/torrent/common.h000644 000765 000024 00000005763 11705767056 020677 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_COMMON_H #define LIBTORRENT_COMMON_H #include #include struct sockaddr; namespace torrent { enum priority_enum { PRIORITY_OFF = 0, PRIORITY_NORMAL, PRIORITY_HIGH }; typedef priority_enum priority_t; // Just forward declare everything here so we can keep the actual // headers clean. class AvailableList; class Bitfield; class Block; class BlockFailed; class BlockList; class BlockTransfer; class Chunk; class ChunkList; class ChunkManager; class ChunkSelector; class ClientInfo; class ClientList; class ConnectionList; class ConnectionManager; class DhtManager; class DhtRouter; class Download; class DownloadMain; class DownloadWrapper; class FileList; class Event; class File; class FileList; class Handshake; class HandshakeManager; class HashString; class Listen; class MemoryChunk; class Object; class Path; class Peer; class PeerConnectionBase; class PeerInfo; class PeerList; class Piece; class Poll; class ProtocolExtension; class Rate; class SocketSet; class Throttle; class Tracker; class TrackerList; class TransferList; // This should only need to be set when compiling libtorrent. #ifdef SUPPORT_ATTRIBUTE_VISIBILITY #define LIBTORRENT_NO_EXPORT __attribute__ ((visibility("hidden"))) #define LIBTORRENT_EXPORT __attribute__ ((visibility("default"))) #else #define LIBTORRENT_NO_EXPORT #define LIBTORRENT_EXPORT #endif } #endif libtorrent-0.13.2/src/torrent/connection_manager.cc000644 000765 000024 00000012011 11744202530 023336 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "net/listen.h" #include "connection_manager.h" #include "error.h" #include "exceptions.h" namespace torrent { static ConnectionManager::slot_resolver_result_type* resolve_host(const char* host, int family, int socktype, ConnectionManager::slot_resolver_result_type slot) { rak::address_info* ai; int err; if ((err = rak::address_info::get_address_info(host, family, socktype, &ai)) != 0) { slot(NULL, err); return NULL; } rak::socket_address sa; sa.copy(*ai->address(), ai->length()); rak::address_info::free_address_info(ai); slot(sa.c_sockaddr(), 0); return NULL; } ConnectionManager::ConnectionManager() : m_size(0), m_maxSize(0), m_priority(iptos_throughput), m_sendBufferSize(0), m_receiveBufferSize(0), m_encryptionOptions(encryption_none), m_listen(new Listen), m_listenPort(0), m_slotResolver(&resolve_host) { m_bindAddress = (new rak::socket_address())->c_sockaddr(); rak::socket_address::cast_from(m_bindAddress)->sa_inet()->clear(); m_localAddress = (new rak::socket_address())->c_sockaddr(); rak::socket_address::cast_from(m_localAddress)->sa_inet()->clear(); m_proxyAddress = (new rak::socket_address())->c_sockaddr(); rak::socket_address::cast_from(m_proxyAddress)->sa_inet()->clear(); } ConnectionManager::~ConnectionManager() { delete m_listen; delete m_bindAddress; delete m_localAddress; delete m_proxyAddress; } bool ConnectionManager::can_connect() const { return m_size < m_maxSize; } void ConnectionManager::set_send_buffer_size(uint32_t s) { m_sendBufferSize = s; } void ConnectionManager::set_receive_buffer_size(uint32_t s) { m_receiveBufferSize = s; } void ConnectionManager::set_encryption_options(uint32_t options) { #ifdef USE_OPENSSL m_encryptionOptions = options; #else throw input_error("Compiled without encryption support."); #endif } void ConnectionManager::set_bind_address(const sockaddr* sa) { const rak::socket_address* rsa = rak::socket_address::cast_from(sa); if (rsa->family() != rak::socket_address::af_inet) throw input_error("Tried to set a bind address that is not an af_inet address."); rak::socket_address::cast_from(m_bindAddress)->copy(*rsa, rsa->length()); } void ConnectionManager::set_local_address(const sockaddr* sa) { const rak::socket_address* rsa = rak::socket_address::cast_from(sa); if (rsa->family() != rak::socket_address::af_inet) throw input_error("Tried to set a local address that is not an af_inet address."); rak::socket_address::cast_from(m_localAddress)->copy(*rsa, rsa->length()); } void ConnectionManager::set_proxy_address(const sockaddr* sa) { const rak::socket_address* rsa = rak::socket_address::cast_from(sa); if (rsa->family() != rak::socket_address::af_inet) throw input_error("Tried to set a proxy address that is not an af_inet address."); rak::socket_address::cast_from(m_proxyAddress)->copy(*rsa, rsa->length()); } uint32_t ConnectionManager::filter(const sockaddr* sa) { if (m_slotFilter.empty()) return 1; else return m_slotFilter(sa); } bool ConnectionManager::listen_open(port_type begin, port_type end) { if (!m_listen->open(begin, end, rak::socket_address::cast_from(m_bindAddress))) return false; m_listenPort = m_listen->port(); return true; } void ConnectionManager::listen_close() { m_listen->close(); } } libtorrent-0.13.2/src/torrent/connection_manager.h000644 000765 000024 00000021465 11744202530 023215 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Add some helpfull words here. #ifndef LIBTORRENT_CONNECTION_MANAGER_H #define LIBTORRENT_CONNECTION_MANAGER_H #include #include #include #include #include #include #include #include #include namespace torrent { // Standard pair of up/down throttles. // First element is upload throttle, second element is download throttle. typedef std::pair ThrottlePair; class LIBTORRENT_EXPORT ConnectionManager { public: typedef uint32_t size_type; typedef uint16_t port_type; typedef uint8_t priority_type; typedef sigc::slot slot_filter_type; static const priority_type iptos_default = 0; static const priority_type iptos_lowdelay = IPTOS_LOWDELAY; static const priority_type iptos_throughput = IPTOS_THROUGHPUT; static const priority_type iptos_reliability = IPTOS_RELIABILITY; #if defined IPTOS_MINCOST static const priority_type iptos_mincost = IPTOS_MINCOST; #elif defined IPTOS_LOWCOST static const priority_type iptos_mincost = IPTOS_LOWCOST; #else static const priority_type iptos_mincost = iptos_throughput; #endif static const uint32_t encryption_none = 0; static const uint32_t encryption_allow_incoming = (1 << 0); static const uint32_t encryption_try_outgoing = (1 << 1); static const uint32_t encryption_require = (1 << 2); static const uint32_t encryption_require_RC4 = (1 << 3); static const uint32_t encryption_enable_retry = (1 << 4); static const uint32_t encryption_prefer_plaintext = (1 << 5); // Internal to libtorrent. static const uint32_t encryption_use_proxy = (1 << 6); static const uint32_t encryption_retrying = (1 << 7); enum { handshake_incoming = 1, handshake_outgoing = 2, handshake_outgoing_encrypted = 3, handshake_outgoing_proxy = 4, handshake_success = 5, handshake_dropped = 6, handshake_failed = 7, handshake_retry_plaintext = 8, handshake_retry_encrypted = 9 }; // The sockaddr argument in the result slot call is NULL if the resolve failed, and the int holds the errno. typedef sigc::slot2 slot_resolver_result_type; typedef sigc::slot4 slot_resolver_type; typedef sigc::slot4 slot_handshake_type; typedef sigc::signal4 signal_handshake_type; typedef sigc::slot1 slot_address_throttle_type; ConnectionManager(); ~ConnectionManager(); // Check that we have not surpassed the max number of open sockets // and that we're allowed to connect to the socket address. // // Consider only checking max number of open sockets. bool can_connect() const; // Call this to keep the socket count up to date. void inc_socket_count() { m_size++; } void dec_socket_count() { m_size--; } size_type size() const { return m_size; } size_type max_size() const { return m_maxSize; } priority_type priority() const { return m_priority; } uint32_t send_buffer_size() const { return m_sendBufferSize; } uint32_t receive_buffer_size() const { return m_receiveBufferSize; } uint32_t encryption_options() { return m_encryptionOptions; } void set_max_size(size_type s) { m_maxSize = s; } void set_priority(priority_type p) { m_priority = p; } void set_send_buffer_size(uint32_t s); void set_receive_buffer_size(uint32_t s); void set_encryption_options(uint32_t options); // Setting the addresses creates a copy of the address. const sockaddr* bind_address() const { return m_bindAddress; } const sockaddr* local_address() const { return m_localAddress; } const sockaddr* proxy_address() const { return m_proxyAddress; } void set_bind_address(const sockaddr* sa); void set_local_address(const sockaddr* sa); void set_proxy_address(const sockaddr* sa); uint32_t filter(const sockaddr* sa); void set_filter(const slot_filter_type& s) { m_slotFilter = s; } bool listen_open(port_type begin, port_type end); void listen_close(); signal_handshake_type& signal_handshake_log() { return m_signalHandshakeLog; } sigc::connection set_signal_handshake_log(slot_handshake_type s) { return m_signalHandshakeLog.connect(s); } // The resolver returns a pointer to its copy of the result slot // which the caller may set blocked to prevent the slot from being // called. The pointer must be NULL if the result slot was already // called because the resolve was synchronous. const slot_resolver_type& resolver() const { return m_slotResolver; } void set_resolver(const slot_resolver_type& s) { m_slotResolver = s; } // Since trackers need our port number, it doesn't get cleared after // 'listen_close()'. The client may change the reported port number, // but do note that it gets overwritten after 'listen_open(...)'. port_type listen_port() const { return m_listenPort; } void set_listen_port(port_type p) { m_listenPort = p; } // The slot returns a ThrottlePair to use for the given address, or NULLs to use the default throttle. const slot_address_throttle_type& address_throttle() const { return m_slotAddressThrottle; } void set_address_throttle(const slot_address_throttle_type& s) { m_slotAddressThrottle = s; } // For internal usage. Listen* listen() { return m_listen; } private: ConnectionManager(const ConnectionManager&); void operator = (const ConnectionManager&); size_type m_size; size_type m_maxSize; priority_type m_priority; uint32_t m_sendBufferSize; uint32_t m_receiveBufferSize; int m_encryptionOptions; sockaddr* m_bindAddress; sockaddr* m_localAddress; sockaddr* m_proxyAddress; Listen* m_listen; port_type m_listenPort; slot_filter_type m_slotFilter; signal_handshake_type m_signalHandshakeLog; slot_resolver_type m_slotResolver; slot_address_throttle_type m_slotAddressThrottle; }; } #endif libtorrent-0.13.2/src/torrent/data/000755 000765 000024 00000000000 11744204512 020116 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/torrent/dht_manager.cc000644 000765 000024 00000007150 11705767056 022006 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "manager.h" #include "dht/dht_router.h" #include "dht_manager.h" namespace torrent { DhtManager::~DhtManager() { stop(); delete m_router; } void DhtManager::initialize(const Object& dhtCache) { if (m_router != NULL) throw internal_error("DhtManager::initialize called with DHT already active."); m_router = new DhtRouter(dhtCache, rak::socket_address::cast_from(manager->connection_manager()->bind_address())); } void DhtManager::start(port_type port) { if (m_router == NULL) throw internal_error("DhtManager::start called without initializing first."); m_port = port; m_router->start(port); } void DhtManager::stop() { if (m_router != NULL) m_router->stop(); } bool DhtManager::is_active() const { return m_router != NULL && m_router->is_active(); } void DhtManager::add_node(const sockaddr* addr, int port) { if (m_router != NULL) m_router->contact(rak::socket_address::cast_from(addr), port); } void DhtManager::add_node(const std::string& host, int port) { if (m_router != NULL) m_router->add_contact(host, port); } Object* DhtManager::store_cache(Object* container) const { if (m_router == NULL) throw internal_error("DhtManager::store_cache called but DHT not initialized."); return m_router->store_cache(container); } DhtManager::statistics_type DhtManager::get_statistics() const { return m_router->get_statistics(); } void DhtManager::reset_statistics() { m_router->reset_statistics(); } void DhtManager::set_upload_throttle(Throttle* t) { if (m_router->is_active()) throw internal_error("DhtManager::set_upload_throttle() called while DHT server active."); m_router->set_upload_throttle(t->throttle_list()); } void DhtManager::set_download_throttle(Throttle* t) { if (m_router->is_active()) throw internal_error("DhtManager::set_download_throttle() called while DHT server active."); m_router->set_download_throttle(t->throttle_list()); } } libtorrent-0.13.2/src/torrent/dht_manager.h000644 000765 000024 00000010766 11705767056 021657 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Add some helpfull words here. #ifndef LIBTORRENT_DHT_MANAGER_H #define LIBTORRENT_DHT_MANAGER_H #include #include namespace torrent { class ThrottleList; class LIBTORRENT_EXPORT DhtManager { public: typedef ConnectionManager::port_type port_type; struct statistics_type { // Cycle; 0=inactive, 1=initial bootstrapping, 2 and up=normal operation unsigned int cycle; // UDP transfer rates. const Rate& up_rate; const Rate& down_rate; // DHT query statistics. unsigned int queries_received; unsigned int queries_sent; unsigned int replies_received; unsigned int errors_received; unsigned int errors_caught; // DHT node info. unsigned int num_nodes; unsigned int num_buckets; // DHT tracker info. unsigned int num_peers; unsigned int max_peers; unsigned int num_trackers; statistics_type(const Rate& up, const Rate& down) : up_rate(up), down_rate(down) { } }; DhtManager() : m_router(NULL), m_portSent(0), m_canReceive(true) { }; ~DhtManager(); void initialize(const Object& dhtCache); void start(port_type port); void stop(); // Store DHT cache in the given container and return the container. Object* store_cache(Object* container) const; bool is_valid() const { return m_router; } bool is_active() const; port_type port() const { return m_port; } bool can_receive_queries() const { return m_canReceive; } // Call this after sending the port to a client, so the router knows // that it should be getting requests. void port_sent() { m_portSent++; } // Add a node by host (from a torrent file), or by address from explicit add_node // command or the BT PORT message. void add_node(const std::string& host, int port); void add_node(const sockaddr* addr, int port); statistics_type get_statistics() const; void reset_statistics(); void set_upload_throttle(Throttle* t); void set_download_throttle(Throttle* t); // To be called if upon examining the statistics, the client decides that // we can't receive outside requests and therefore shouldn't advertise our // UDP port after the BT handshake. void set_can_receive(bool can) { m_canReceive = can; } // Internal libTorrent use only DhtRouter* router() { return m_router; } private: DhtRouter* m_router; port_type m_port; int m_portSent; bool m_canReceive; }; } #endif libtorrent-0.13.2/src/torrent/download/000755 000765 000024 00000000000 11744204512 021014 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/torrent/download.cc000644 000765 000024 00000042775 11744202530 021340 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #define __STDC_FORMAT_MACROS #include #include #include #include "data/block.h" #include "data/block_list.h" #include "data/chunk_list.h" #include "data/hash_queue.h" #include "data/hash_torrent.h" #include "download/available_list.h" #include "download/chunk_selector.h" #include "download/chunk_statistics.h" #include "download/download_wrapper.h" #include "protocol/peer_connection_base.h" #include "protocol/peer_factory.h" #include "peer/peer_info.h" #include "torrent/download/choke_group.h" #include "torrent/download/choke_queue.h" #include "torrent/download_info.h" #include "torrent/data/file.h" #include "torrent/peer/connection_list.h" #include "torrent/tracker_controller.h" #include "torrent/tracker_list.h" #include "torrent/utils/log.h" #include "exceptions.h" #include "download.h" #include "object.h" #include "throttle.h" #include "tracker_list.h" #define LT_LOG_THIS(log_level, log_fmt, ...) \ lt_log_print_info(LOG_TORRENT_##log_level, m_ptr->info(), "download", log_fmt, __VA_ARGS__); namespace torrent { const DownloadInfo* Download::info() const { return m_ptr->info(); } const download_data* Download::data() const { return m_ptr->data(); } void Download::open(int flags) { if (m_ptr->info()->is_open()) return; LT_LOG_THIS(INFO, "Opening torrent: flags:%0x.", flags); // Currently always open with no_create, as start will make sure // they are created. Need to fix this. m_ptr->main()->open(FileList::open_no_create); m_ptr->hash_checker()->hashing_ranges().insert(0, m_ptr->main()->file_list()->size_chunks()); // Mark the files by default to be created and resized. The client // should be allowed to pass a flag that will keep the old settings, // although loading resume data should really handle everything // properly. int fileFlags = File::flag_create_queued | File::flag_resize_queued; if (flags & open_enable_fallocate) fileFlags |= File::flag_fallocate; for (FileList::iterator itr = m_ptr->main()->file_list()->begin(), last = m_ptr->main()->file_list()->end(); itr != last; itr++) (*itr)->set_flags(fileFlags); } void Download::close(int flags) { if (m_ptr->info()->is_active()) stop(0); LT_LOG_THIS(INFO, "Closing torrent: flags:%0x.", flags); m_ptr->close(); } void Download::start(int flags) { DownloadInfo* info = m_ptr->info(); if (!m_ptr->hash_checker()->is_checked()) throw internal_error("Tried to start an unchecked download."); if (!info->is_open()) throw internal_error("Tried to start a closed download."); if (m_ptr->data()->mutable_completed_bitfield()->empty()) throw internal_error("Tried to start a download with empty bitfield."); if (info->is_active()) return; LT_LOG_THIS(INFO, "Starting torrent: flags:%0x.", flags); m_ptr->data()->verify_wanted_chunks("Download::start(...)"); // file_list()->open(flags); // If the FileList::open_no_create flag was not set, our new // behavior is to create all zero-length files with // flag_queued_create set. file_list()->open(flags & ~FileList::open_no_create); if (m_ptr->connection_type() == CONNECTION_INITIAL_SEED) { if (!m_ptr->main()->start_initial_seeding()) set_connection_type(CONNECTION_SEED); } m_ptr->main()->start(); m_ptr->main()->tracker_controller()->enable((flags & start_skip_tracker) ? TrackerController::enable_dont_reset_stats : 0); // Reset the uploaded/download baseline when we restart the download // so that broken trackers get the right uploaded ratio. if (!(flags & start_keep_baseline)) { info->set_uploaded_baseline(info->up_rate()->total()); info->set_completed_baseline(m_ptr->main()->file_list()->completed_bytes()); lt_log_print_info(LOG_TRACKER_INFO, info, "download", "Setting new baseline on start: uploaded:%" PRIu64 " completed:%" PRIu64 ".", info->uploaded_baseline(), info->completed_baseline()); } if (!(flags & start_skip_tracker)) m_ptr->main()->tracker_controller()->send_start_event(); } void Download::stop(int flags) { if (!m_ptr->info()->is_active()) return; LT_LOG_THIS(INFO, "Stopping torrent: flags:%0x.", flags); m_ptr->main()->stop(); m_ptr->main()->tracker_controller()->disable(); if (!(flags & stop_skip_tracker)) m_ptr->main()->tracker_controller()->send_stop_event(); } bool Download::hash_check(bool tryQuick) { if (m_ptr->hash_checker()->is_checking()) throw internal_error("Download::hash_check(...) called but the hash is already being checked."); if (!m_ptr->info()->is_open() || m_ptr->info()->is_active()) throw internal_error("Download::hash_check(...) called on a closed or active download."); if (m_ptr->hash_checker()->is_checked()) throw internal_error("Download::hash_check(...) called but already hash checked."); Bitfield* bitfield = m_ptr->data()->mutable_completed_bitfield(); LT_LOG_THIS(INFO, "Checking hash: allocated:%i try_quick:%i.", !bitfield->empty(), (int)tryQuick); if (bitfield->empty()) { // The bitfield still hasn't been allocated, so no resume data was // given. bitfield->allocate(); bitfield->unset_all(); m_ptr->hash_checker()->hashing_ranges().insert(0, m_ptr->main()->file_list()->size_chunks()); } m_ptr->main()->file_list()->update_completed(); return m_ptr->hash_checker()->start(tryQuick); } // Propably not correct, need to clear content, etc. void Download::hash_stop() { if (!m_ptr->hash_checker()->is_checking()) return; LT_LOG_THIS(INFO, "Hashing stopped.", 0); m_ptr->hash_checker()->hashing_ranges().erase(0, m_ptr->hash_checker()->position()); m_ptr->hash_queue()->remove(m_ptr->data()); m_ptr->hash_checker()->clear(); } bool Download::is_hash_checked() const { return m_ptr->hash_checker()->is_checked(); } bool Download::is_hash_checking() const { return m_ptr->hash_checker()->is_checking(); } void Download::set_pex_enabled(bool enabled) { if (enabled) m_ptr->info()->set_pex_enabled(); else m_ptr->info()->unset_flags(DownloadInfo::flag_pex_enabled); } Object* Download::bencode() { return m_ptr->bencode(); } const Object* Download::bencode() const { return m_ptr->bencode(); } FileList* Download::file_list() const { return m_ptr->main()->file_list(); } TrackerController* Download::tracker_controller() const { return m_ptr->main()->tracker_controller(); } TrackerList* Download::tracker_list() const { return m_ptr->main()->tracker_list(); } PeerList* Download::peer_list() { return m_ptr->main()->peer_list(); } const PeerList* Download::peer_list() const { return m_ptr->main()->peer_list(); } const TransferList* Download::transfer_list() const { return m_ptr->main()->delegator()->transfer_list(); } ConnectionList* Download::connection_list() { return m_ptr->main()->connection_list(); } const ConnectionList* Download::connection_list() const { return m_ptr->main()->connection_list(); } uint64_t Download::bytes_done() const { uint64_t a = 0; Delegator* d = m_ptr->main()->delegator(); for (TransferList::const_iterator itr1 = d->transfer_list()->begin(), last1 = d->transfer_list()->end(); itr1 != last1; ++itr1) for (BlockList::const_iterator itr2 = (*itr1)->begin(), last2 = (*itr1)->end(); itr2 != last2; ++itr2) if (itr2->is_finished()) a += itr2->piece().length(); return a + m_ptr->main()->file_list()->completed_bytes(); } uint32_t Download::chunks_hashed() const { return m_ptr->hash_checker()->position(); } const uint8_t* Download::chunks_seen() const { return !m_ptr->main()->chunk_statistics()->empty() ? &*m_ptr->main()->chunk_statistics()->begin() : NULL; } void Download::set_chunks_done(uint32_t chunks_done, uint32_t chunks_wanted) { if (m_ptr->info()->is_open() || !m_ptr->data()->mutable_completed_bitfield()->empty()) throw input_error("Download::set_chunks_done(...) Invalid state."); chunks_done = std::min(chunks_done, m_ptr->file_list()->size_chunks()); chunks_wanted = std::min(chunks_wanted, m_ptr->file_list()->size_chunks() - chunks_done); m_ptr->data()->mutable_completed_bitfield()->set_size_set(chunks_done); m_ptr->data()->set_wanted_chunks(chunks_wanted); } void Download::set_bitfield(bool allSet) { if (m_ptr->hash_checker()->is_checked() || m_ptr->hash_checker()->is_checking()) throw input_error("Download::set_bitfield(...) Download in invalid state."); Bitfield* bitfield = m_ptr->data()->mutable_completed_bitfield(); bitfield->allocate(); if (allSet) bitfield->set_all(); else bitfield->unset_all(); m_ptr->data()->update_wanted_chunks(); m_ptr->hash_checker()->hashing_ranges().clear(); } void Download::set_bitfield(uint8_t* first, uint8_t* last) { if (m_ptr->hash_checker()->is_checked() || m_ptr->hash_checker()->is_checking()) throw input_error("Download::set_bitfield(...) Download in invalid state."); if (std::distance(first, last) != (ptrdiff_t)m_ptr->main()->file_list()->bitfield()->size_bytes()) throw input_error("Download::set_bitfield(...) Invalid length."); Bitfield* bitfield = m_ptr->data()->mutable_completed_bitfield(); bitfield->allocate(); std::memcpy(bitfield->begin(), first, bitfield->size_bytes()); bitfield->update(); m_ptr->data()->update_wanted_chunks(); m_ptr->hash_checker()->hashing_ranges().clear(); } void Download::update_range(int flags, uint32_t first, uint32_t last) { if (m_ptr->hash_checker()->is_checked() || m_ptr->hash_checker()->is_checking() || m_ptr->main()->file_list()->bitfield()->empty()) throw input_error("Download::clear_range(...) Download in invalid state."); if (flags & update_range_recheck) m_ptr->hash_checker()->hashing_ranges().insert(first, last); if (flags & (update_range_clear | update_range_recheck)) { m_ptr->data()->mutable_completed_bitfield()->unset_range(first, last); m_ptr->data()->update_wanted_chunks(); } } void Download::sync_chunks() { m_ptr->main()->chunk_list()->sync_chunks(ChunkList::sync_all | ChunkList::sync_force); } uint32_t Download::peers_complete() const { return m_ptr->main()->chunk_statistics()->complete(); } uint32_t Download::peers_accounted() const { return m_ptr->main()->chunk_statistics()->accounted(); } uint32_t Download::peers_currently_unchoked() const { return m_ptr->main()->choke_group()->up_queue()->size_unchoked(); } uint32_t Download::peers_currently_interested() const { return m_ptr->main()->choke_group()->up_queue()->size_total(); } uint32_t Download::size_pex() const { return m_ptr->main()->info()->size_pex(); } uint32_t Download::max_size_pex() const { return m_ptr->main()->info()->max_size_pex(); } bool Download::accepting_new_peers() const { return m_ptr->info()->is_accepting_new_peers(); } // DEPRECATE uint32_t Download::uploads_max() const { if (m_ptr->main()->up_group_entry()->max_slots() == DownloadInfo::unlimited) return 0; return m_ptr->main()->up_group_entry()->max_slots(); } uint32_t Download::uploads_min() const { // if (m_ptr->main()->up_group_entry()->min_slots() == DownloadInfo::unlimited) // return 0; return m_ptr->main()->up_group_entry()->min_slots(); } uint32_t Download::downloads_max() const { if (m_ptr->main()->down_group_entry()->max_slots() == DownloadInfo::unlimited) return 0; return m_ptr->main()->down_group_entry()->max_slots(); } uint32_t Download::downloads_min() const { // if (m_ptr->main()->down_group_entry()->min_slots() == DownloadInfo::unlimited) // return 0; return m_ptr->main()->down_group_entry()->min_slots(); } void Download::set_upload_throttle(Throttle* t) { if (m_ptr->info()->is_active()) throw internal_error("Download::set_upload_throttle() called on active download."); m_ptr->main()->set_upload_throttle(t->throttle_list()); } void Download::set_download_throttle(Throttle* t) { if (m_ptr->info()->is_active()) throw internal_error("Download::set_download_throttle() called on active download."); m_ptr->main()->set_download_throttle(t->throttle_list()); } void Download::send_completed() { m_ptr->main()->tracker_controller()->send_completed_event(); } void Download::manual_request(bool force) { m_ptr->main()->tracker_controller()->manual_request(force); } void Download::manual_cancel() { m_ptr->main()->tracker_controller()->close(); } // DEPRECATE void Download::set_uploads_max(uint32_t v) { if (v > (1 << 16)) throw input_error("Max uploads must be between 0 and 2^16."); // For the moment, treat 0 as unlimited. m_ptr->main()->up_group_entry()->set_max_slots(v == 0 ? DownloadInfo::unlimited : v); m_ptr->main()->choke_group()->up_queue()->balance_entry(m_ptr->main()->up_group_entry()); } void Download::set_uploads_min(uint32_t v) { if (v > (1 << 16)) throw input_error("Min uploads must be between 0 and 2^16."); // For the moment, treat 0 as unlimited. m_ptr->main()->up_group_entry()->set_min_slots(v); m_ptr->main()->choke_group()->up_queue()->balance_entry(m_ptr->main()->up_group_entry()); } void Download::set_downloads_max(uint32_t v) { if (v > (1 << 16)) throw input_error("Max downloads must be between 0 and 2^16."); // For the moment, treat 0 as unlimited. m_ptr->main()->down_group_entry()->set_max_slots(v == 0 ? DownloadInfo::unlimited : v); m_ptr->main()->choke_group()->down_queue()->balance_entry(m_ptr->main()->down_group_entry()); } void Download::set_downloads_min(uint32_t v) { if (v > (1 << 16)) throw input_error("Min downloads must be between 0 and 2^16."); // For the moment, treat 0 as unlimited. m_ptr->main()->down_group_entry()->set_min_slots(v); m_ptr->main()->choke_group()->down_queue()->balance_entry(m_ptr->main()->down_group_entry()); } Download::ConnectionType Download::connection_type() const { return (ConnectionType)m_ptr->connection_type(); } void Download::set_connection_type(ConnectionType t) { if (m_ptr->info()->is_meta_download()) { m_ptr->main()->connection_list()->slot_new_connection(&createPeerConnectionMetadata); return; } switch (t) { case CONNECTION_LEECH: m_ptr->main()->connection_list()->slot_new_connection(&createPeerConnectionDefault); break; case CONNECTION_SEED: m_ptr->main()->connection_list()->slot_new_connection(&createPeerConnectionSeed); break; case CONNECTION_INITIAL_SEED: if (info()->is_active() && m_ptr->main()->initial_seeding() == NULL) throw input_error("Can't switch to initial seeding: download is active."); m_ptr->main()->connection_list()->slot_new_connection(&createPeerConnectionInitialSeed); break; default: throw input_error("torrent::Download::set_connection_type(...) received an unknown type."); }; m_ptr->set_connection_type(t); } Download::HeuristicType Download::upload_choke_heuristic() const { return (Download::HeuristicType)m_ptr->main()->choke_group()->up_queue()->heuristics(); } void Download::set_upload_choke_heuristic(HeuristicType t) { if ((choke_queue::heuristics_enum)t >= choke_queue::HEURISTICS_MAX_SIZE) throw input_error("Invalid heuristics value."); m_ptr->main()->choke_group()->up_queue()->set_heuristics((choke_queue::heuristics_enum)t); } Download::HeuristicType Download::download_choke_heuristic() const { return (Download::HeuristicType)m_ptr->main()->choke_group()->down_queue()->heuristics(); } void Download::set_download_choke_heuristic(HeuristicType t) { if ((choke_queue::heuristics_enum)t >= choke_queue::HEURISTICS_MAX_SIZE) throw input_error("Invalid heuristics value."); m_ptr->main()->choke_group()->down_queue()->set_heuristics((choke_queue::heuristics_enum)t); } void Download::update_priorities() { m_ptr->receive_update_priorities(); } void Download::add_peer(const sockaddr* sa, int port) { if (m_ptr->info()->is_private()) return; rak::socket_address sa_port = *rak::socket_address::cast_from(sa); sa_port.set_port(port); m_ptr->main()->add_peer(sa_port); } DownloadMain* Download::main() { return m_ptr->main(); } } libtorrent-0.13.2/src/torrent/download.h000644 000765 000024 00000015732 11744202530 021173 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_H #define LIBTORRENT_DOWNLOAD_H #include #include #include #include #include #include #include namespace torrent { class ConnectionList; class DownloadInfo; class DownloadMain; class download_data; class TrackerController; // Download is safe to copy and destory as it is just a pointer to an // internal class. class LIBTORRENT_EXPORT Download { public: static const uint32_t numwanted_diabled = ~uint32_t(); // Start and open flags can be stored in the same integer, same for // stop and close flags. static const int open_enable_fallocate = (1 << 0); static const int start_no_create = (1 << 1); static const int start_keep_baseline = (1 << 2); static const int start_skip_tracker = (1 << 3); static const int stop_skip_tracker = (1 << 0); Download(DownloadWrapper* d = NULL) : m_ptr(d) {} const DownloadInfo* info() const; const download_data* data() const; // Not active atm. Opens and prepares/closes the files. void open(int flags = 0); void close(int flags = 0); // When 'tryQuick' is true, it will only check if the chunks can be // mmaped and stops if one is encountered. If it doesn't find any // mappable chunks it will return true to indicate that it is // finished and a hash done signal has been queued. // // Chunk ranges that have valid resume data won't be checked. bool hash_check(bool tryQuick); void hash_stop(); // Start/stop the download. The torrent must be open. void start(int flags = 0); void stop(int flags = 0); // Does not check if the download has been removed. bool is_valid() const { return m_ptr; } bool is_hash_checked() const; bool is_hash_checking() const; void set_pex_enabled(bool enabled); Object* bencode(); const Object* bencode() const; TrackerController* tracker_controller() const; TrackerList* tracker_list() const; FileList* file_list() const; PeerList* peer_list(); const PeerList* peer_list() const; const TransferList* transfer_list() const; ConnectionList* connection_list(); const ConnectionList* connection_list() const; // Bytes completed. uint64_t bytes_done() const; uint32_t chunks_hashed() const; const uint8_t* chunks_seen() const; // Set the number of finished chunks for closed torrents. void set_chunks_done(uint32_t chunks_done, uint32_t chunks_wanted); // Use the below to set the resume data and what chunk ranges need // to be hash checked. If they arn't called then by default it will // use an cleared bitfield and check the whole range. // // These must be called when is_open, !is_checked and !is_checking. void set_bitfield(bool allSet); void set_bitfield(uint8_t* first, uint8_t* last); static const int update_range_recheck = (1 << 0); static const int update_range_clear = (1 << 1); void update_range(int flags, uint32_t first, uint32_t last); // Temporary hack for syncing chunks to disk before hash resume is // saved. void sync_chunks(); uint32_t peers_complete() const; uint32_t peers_accounted() const; uint32_t peers_currently_unchoked() const; uint32_t peers_currently_interested() const; uint32_t size_pex() const; uint32_t max_size_pex() const; bool accepting_new_peers() const; uint32_t uploads_max() const; void set_uploads_max(uint32_t v); uint32_t uploads_min() const; void set_uploads_min(uint32_t v); uint32_t downloads_max() const; void set_downloads_max(uint32_t v); uint32_t downloads_min() const; void set_downloads_min(uint32_t v); void set_upload_throttle(Throttle* t); void set_download_throttle(Throttle* t); // Some temporary functions that are routed to // TrackerManager... Clean this up. void send_completed(); void manual_request(bool force); void manual_cancel(); typedef enum { CONNECTION_LEECH, CONNECTION_SEED, CONNECTION_INITIAL_SEED, CONNECTION_METADATA, } ConnectionType; ConnectionType connection_type() const; void set_connection_type(ConnectionType t); typedef enum { } HeuristicType; HeuristicType upload_choke_heuristic() const; void set_upload_choke_heuristic(HeuristicType t); HeuristicType download_choke_heuristic() const; void set_download_choke_heuristic(HeuristicType t); // Call this when you want the modifications of the download priorities // in the entries to take effect. It is slightly expensive as it rechecks // all the peer bitfields to see if we are still interested. void update_priorities(); void add_peer(const sockaddr* addr, int port); DownloadWrapper* ptr() { return m_ptr; } DownloadMain* main(); private: DownloadWrapper* m_ptr; }; } #endif libtorrent-0.13.2/src/torrent/download_info.h000644 000765 000024 00000024710 11740502002 022173 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_INFO_H #define LIBTORRENT_DOWNLOAD_INFO_H #include #include #include #include #include #include namespace torrent { class FileList; class DownloadMain; // This will become a Download 'handle' of kinds. class DownloadInfo { public: typedef std::tr1::function slot_stat_type; typedef std::tr1::function slot_chunk_type; typedef std::list > signal_void_type; typedef std::list > signal_string_type; typedef std::list signal_chunk_type; typedef std::list > signal_dump_type; enum State { NONE, COMPLETED, STARTED, STOPPED }; static const int flag_open = (1 << 0); static const int flag_active = (1 << 1); static const int flag_compact = (1 << 2); static const int flag_accepting_new_peers = (1 << 3); static const int flag_accepting_seeders = (1 << 4); // Only used during leeching. static const int flag_private = (1 << 5); static const int flag_meta_download = (1 << 6); static const int flag_pex_enabled = (1 << 7); static const int flag_pex_active = (1 << 8); static const int public_flags = flag_accepting_seeders; static const uint32_t unlimited = ~uint32_t(); DownloadInfo(); const std::string& name() const { return m_name; } void set_name(const std::string& s) { m_name = s; } const HashString& hash() const { return m_hash; } HashString& mutable_hash() { return m_hash; } const HashString& hash_obfuscated() const { return m_hashObfuscated; } HashString& mutable_hash_obfuscated() { return m_hashObfuscated; } const HashString& local_id() const { return m_localId; } HashString& mutable_local_id() { return m_localId; } bool is_open() const { return m_flags & flag_open; } bool is_active() const { return m_flags & flag_active; } bool is_compact() const { return m_flags & flag_compact; } bool is_accepting_new_peers() const { return m_flags & flag_accepting_new_peers; } bool is_accepting_seeders() const { return m_flags & flag_accepting_seeders; } bool is_private() const { return m_flags & flag_private; } bool is_meta_download() const { return m_flags & flag_meta_download; } bool is_pex_enabled() const { return m_flags & flag_pex_enabled; } bool is_pex_active() const { return m_flags & flag_pex_active; } int flags() const { return m_flags; } void set_flags(int flags) { m_flags |= flags; } void unset_flags(int flags) { m_flags &= ~flags; } void change_flags(int flags, bool state) { if (state) set_flags(flags); else unset_flags(flags); } void public_set_flags(int flags) const { m_flags |= (flags & public_flags); } void public_unset_flags(int flags) const { m_flags &= ~(flags & public_flags); } void public_change_flags(int flags, bool state) const { if (state) public_set_flags(flags); else public_unset_flags(flags); } void set_private() { set_flags(flag_private); unset_flags(flag_pex_enabled); } void set_pex_enabled() { if (!is_private()) set_flags(flag_pex_enabled); } const Rate* up_rate() const { return &m_upRate; } const Rate* down_rate() const { return &m_downRate; } const Rate* skip_rate() const { return &m_skipRate; } Rate* mutable_up_rate() const { return &m_upRate; } Rate* mutable_down_rate() const { return &m_downRate; } Rate* mutable_skip_rate() const { return &m_skipRate; } uint64_t uploaded_baseline() const { return m_uploadedBaseline; } uint64_t uploaded_adjusted() const { return std::max(m_upRate.total() - uploaded_baseline(), 0); } void set_uploaded_baseline(uint64_t b) { m_uploadedBaseline = b; } uint64_t completed_baseline() const { return m_completedBaseline; } uint64_t completed_adjusted() const { return std::max(m_slotStatCompleted() - completed_baseline(), 0); } void set_completed_baseline(uint64_t b) { m_completedBaseline = b; } size_t metadata_size() const { return m_metadataSize; } void set_metadata_size(size_t size) { m_metadataSize = size; } uint32_t size_pex() const { return m_sizePex; } void set_size_pex(uint32_t b) { m_sizePex = b; } uint32_t max_size_pex() const { return m_maxSizePex; } void set_max_size_pex(uint32_t b) { m_maxSizePex = b; } uint32_t max_size_pex_list() const { return 200; } // Unix epoche, 0 == unknown. uint32_t creation_date() const { return m_creationDate; } uint32_t load_date() const { return m_loadDate; } uint32_t http_timeout() const { return 60; } uint32_t udp_timeout() const { return 30; } uint32_t udp_tries() const { return 2; } uint32_t upload_unchoked() const { return m_upload_unchoked; } uint32_t download_unchoked() const { return m_download_unchoked; } signal_string_type& signal_network_log() const { return m_signalNetworkLog; } signal_string_type& signal_storage_error() const { return m_signalStorageError; } // The list of addresses is guaranteed to be sorted and unique. signal_void_type& signal_tracker_success() const { return m_signalTrackerSuccess; } signal_string_type& signal_tracker_failed() const { return m_signalTrackerFailed; } signal_chunk_type& signal_chunk_passed() const { return m_signalChunkPassed; } signal_chunk_type& signal_chunk_failed() const { return m_signalChunkFailed; } // // Libtorrent internal: // void set_creation_date(uint32_t d) { m_creationDate = d; } void set_upload_unchoked(uint32_t num) { m_upload_unchoked = num; } void set_download_unchoked(uint32_t num) { m_download_unchoked = num; } slot_stat_type& slot_left() { return m_slotStatLeft; } slot_stat_type& slot_completed() { return m_slotStatCompleted; } private: std::string m_name; HashString m_hash; HashString m_hashObfuscated; HashString m_localId; mutable int m_flags; mutable Rate m_upRate; mutable Rate m_downRate; mutable Rate m_skipRate; uint64_t m_uploadedBaseline; uint64_t m_completedBaseline; uint32_t m_sizePex; uint32_t m_maxSizePex; size_t m_metadataSize; uint32_t m_creationDate; uint32_t m_loadDate; uint32_t m_upload_unchoked; uint32_t m_download_unchoked; slot_stat_type m_slotStatLeft; slot_stat_type m_slotStatCompleted; mutable signal_string_type m_signalNetworkLog; mutable signal_string_type m_signalStorageError; mutable signal_void_type m_signalTrackerSuccess; mutable signal_string_type m_signalTrackerFailed; mutable signal_chunk_type m_signalChunkPassed; mutable signal_chunk_type m_signalChunkFailed; }; } #endif libtorrent-0.13.2/src/torrent/error.cc000644 000765 000024 00000006213 11705767056 020665 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "error.h" namespace torrent { static const char* errorStrings[e_last + 1] = { "unknown error", // e_none "not BitTorrent protocol", // eh_not_bittorrent "not accepting connections", // eh_not_accepting_connections "duplicate peer ID", // eh_duplicate "unknown download", // eh_unknown_download "download inactive", // eh_inactive_download "seeder rejected", // eh_unwanted_connection "is self", // eh_is_self "invalid value received", // eh_invalid_value "unencrypted connection rejected", // eh_unencrypted_rejected "invalid encryption method", // eh_invalid_encryption "encryption sync failed", // eh_encryption_sync_failed "network error", // eh_network_error "network unreachable", // eh_network_unreachable "network timeout", // eh_network_timeout "invalid message order", // eh_invalid_order "too many failed chunks", // eh_toomanyfailed // "", // e_handshake_incoming // "", // e_handshake_outgoing // "", // e_handshake_outgoing_encrypted // "", // e_handshake_outgoing_proxy // "", // e_handshake_success // "", // e_handshake_retry_plaintext // "" // e_handshake_retry_encrypted }; const char* strerror(int err) { if (err < 0 || err > e_last) return "Unknown error"; return errorStrings[err]; } } libtorrent-0.13.2/src/torrent/error.h000644 000765 000024 00000006254 11705767056 020534 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TORRENT_ERROR_H #define LIBTORRENT_TORRENT_ERROR_H #include namespace torrent { const int e_none = 0; // Handshake errors passed to signal handler const int e_handshake_not_bittorrent = 1; const int e_handshake_not_accepting_connections = 2; const int e_handshake_duplicate = 3; const int e_handshake_unknown_download = 4; const int e_handshake_inactive_download = 5; const int e_handshake_unwanted_connection = 6; const int e_handshake_is_self = 7; const int e_handshake_invalid_value = 8; const int e_handshake_unencrypted_rejected = 9; const int e_handshake_invalid_encryption = 10; const int e_handshake_encryption_sync_failed = 11; const int e_handshake_network_error = 12; const int e_handshake_network_unreachable = 13; const int e_handshake_network_timeout = 14; const int e_handshake_invalid_order = 15; const int e_handshake_toomanyfailed = 16; // const int e_handshake_incoming = 13; // const int e_handshake_outgoing = 14; // const int e_handshake_outgoing_encrypted = 15; // const int e_handshake_outgoing_proxy = 16; // const int e_handshake_success = 17; // const int e_handshake_retry_plaintext = 18; // const int e_handshake_retry_encrypted = 19; const int e_last = 16; const char* strerror(int err) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/event.h000644 000765 000024 00000004462 11716630446 020515 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TORRENT_EVENT_H #define LIBTORRENT_TORRENT_EVENT_H #include namespace torrent { class LIBTORRENT_EXPORT Event { public: virtual ~Event() {} // These are not virtual as the fd is heavily used in select based // polling, thus fast access is critical to performance. int file_descriptor() const { return m_fileDesc; } virtual void event_read() = 0; virtual void event_write() = 0; virtual void event_error() = 0; // Require all event types to define this function. virtual const char* type_name() const { return "default"; } // Event closed? protected: int m_fileDesc; }; } #endif libtorrent-0.13.2/src/torrent/exceptions.cc000644 000765 000024 00000004605 11716350717 021712 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "exceptions.h" namespace torrent { // Use actual functions, instead of inlined, for the ctor of // exceptions. This allows us to create breakpoints at throws. This is // limited to rarely thrown exceptions. void internal_error::initialize(const std::string& msg) { m_msg = msg; } // while (true) sleep(1); } void communication_error::initialize(const std::string& msg) { m_msg = msg; } void storage_error::initialize(const std::string& msg) { m_msg = msg; } void resource_error::initialize(const std::string& msg) { m_msg = msg; } void input_error::initialize(const std::string& msg) { m_msg = msg; } const char* connection_error::what() const throw() { return std::strerror(m_errno); } } libtorrent-0.13.2/src/torrent/exceptions.h000644 000765 000024 00000013121 11705767056 021553 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Note that some of the exception classes below are strictly speaking // _NOT DOING THE RIGHT THING_. One is really not supposed to use any // calls to malloc/new in an exception's ctor. // // Will be fixed next API update. #ifndef LIBTORRENT_EXCEPTIONS_H #define LIBTORRENT_EXCEPTIONS_H #include #include #include namespace torrent { // All exceptions inherit from std::exception to make catching // everything libtorrent related at the root easier. class LIBTORRENT_EXPORT base_error : public std::exception { public: virtual ~base_error() throw() {} }; // The library or application did some borking it shouldn't have, bug // tracking time! class LIBTORRENT_EXPORT internal_error : public base_error { public: internal_error(const char* msg) { initialize(msg); } internal_error(const std::string& msg) { initialize(msg); } virtual ~internal_error() throw() {} virtual const char* what() const throw() { return m_msg.c_str(); } private: // Use this function for breaking on throws. void initialize(const std::string& msg); std::string m_msg; }; // For some reason we couldn't talk with a protocol/tracker, migth be a // library bug, connection problem or bad input. class LIBTORRENT_EXPORT network_error : public base_error { public: virtual ~network_error() throw() {} }; class LIBTORRENT_EXPORT communication_error : public network_error { public: communication_error(const char* msg) { initialize(msg); } communication_error(const std::string& msg) { initialize(msg); } virtual ~communication_error() throw() {} virtual const char* what() const throw() { return m_msg.c_str(); } private: // Use this function for breaking on throws. void initialize(const std::string& msg); std::string m_msg; }; class LIBTORRENT_EXPORT connection_error : public network_error { public: connection_error(int err) : m_errno(err) {} virtual ~connection_error() throw() {} virtual const char* what() const throw(); private: int m_errno; }; class LIBTORRENT_EXPORT close_connection : public network_error { public: virtual ~close_connection() throw() {} }; class LIBTORRENT_EXPORT blocked_connection : public network_error { public: virtual ~blocked_connection() throw() {} }; // Stuff like bad torrent file, disk space and permissions. class LIBTORRENT_EXPORT local_error : public base_error { public: virtual ~local_error() throw() {} }; class LIBTORRENT_EXPORT storage_error : public local_error { public: storage_error(const char* msg) { initialize(msg); } storage_error(const std::string& msg) { initialize(msg); } virtual ~storage_error() throw() {} virtual const char* what() const throw() { return m_msg.c_str(); } private: // Use this function for breaking on throws. void initialize(const std::string& msg); std::string m_msg; }; class LIBTORRENT_EXPORT resource_error : public local_error { public: resource_error(const char* msg) { initialize(msg); } resource_error(const std::string& msg) { initialize(msg); } virtual ~resource_error() throw() {} virtual const char* what() const throw() { return m_msg.c_str(); } private: // Use this function for breaking on throws. void initialize(const std::string& msg); std::string m_msg; }; class LIBTORRENT_EXPORT input_error : public local_error { public: input_error(const char* msg) { initialize(msg); } input_error(const std::string& msg) { initialize(msg); } virtual ~input_error() throw() {} virtual const char* what() const throw() { return m_msg.c_str(); } private: // Use this function for breaking on throws. void initialize(const std::string& msg); std::string m_msg; }; class LIBTORRENT_EXPORT bencode_error : public input_error { public: bencode_error(const char* msg) : input_error(msg) {} bencode_error(const std::string& msg) : input_error(msg) {} virtual ~bencode_error() throw() {} }; class LIBTORRENT_EXPORT shutdown_exception : public base_error { public: virtual ~shutdown_exception() throw() {} }; } #endif libtorrent-0.13.2/src/torrent/hash_string.cc000644 000765 000024 00000004720 11705767056 022046 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "hash_string.h" namespace torrent { const char* hash_string_from_hex_c_str(const char* first, HashString& hash) { const char* hash_first = first; torrent::HashString::iterator itr = hash.begin(); while (itr != hash.end()) { if (!std::isxdigit(*first) || !std::isxdigit(*(first + 1))) return hash_first; *itr++ = (rak::hexchar_to_value(*first) << 4) + rak::hexchar_to_value(*(first + 1)); first += 2; } return first; } char* hash_string_to_hex(const HashString& hash, char* first) { return rak::transform_hex(hash.begin(), hash.end(), first); } std::string hash_string_to_hex_str(const HashString& hash) { std::string str(HashString::size_data * 2, '\0'); rak::transform_hex(hash.begin(), hash.end(), str.begin()); return str; } } libtorrent-0.13.2/src/torrent/hash_string.h000644 000765 000024 00000013146 11705767056 021712 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // A fixed with char array used to store 20 byte with hashes. This // should really be replaced with std::array<20>. #ifndef LIBTORRENT_HASH_STRING_H #define LIBTORRENT_HASH_STRING_H #include #include #include #include namespace torrent { class LIBTORRENT_EXPORT HashString { public: typedef char value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef value_type* iterator; typedef const value_type* const_iterator; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; static const size_type size_data = 20; size_type size() const { return size_data; } iterator begin() { return m_data; } const_iterator begin() const { return m_data; } iterator end() { return m_data + size(); } const_iterator end() const { return m_data + size(); } reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } reference operator [] (size_type n) { return *(m_data + n); } const_reference operator [] (size_type n) const { return *(m_data + n); } value_type* data() { return m_data; } const value_type* data() const { return m_data; } const value_type* c_str() const { return m_data; } std::string str() const { return std::string(m_data, size_data); } void clear(int v = 0) { std::memset(data(), v, size()); } void assign(const value_type* src) { std::memcpy(data(), src, size()); } bool equal_to(const char* hash) const { return std::memcmp(m_data, hash, size()) == 0; } bool not_equal_to(const char* hash) const { return std::memcmp(m_data, hash, size()) != 0; } // It is the users responsibility to ensure src.length() >= // size_data. static const HashString* cast_from(const char* src) { return (const HashString*)src; } static const HashString* cast_from(const std::string& src) { return (const HashString*)src.c_str(); } static HashString* cast_from(char* src) { return (HashString*)src; } private: char m_data[size_data]; }; const char* hash_string_from_hex_c_str(const char* first, HashString& hash) LIBTORRENT_EXPORT; char* hash_string_to_hex(const HashString& hash, char* first) LIBTORRENT_EXPORT; std::string hash_string_to_hex_str(const HashString& hash) LIBTORRENT_EXPORT; inline const char* hash_string_to_hex_first(const HashString& hash, char* first) { hash_string_to_hex(hash, first); return first; } inline bool operator == (const HashString& one, const HashString& two) { return std::memcmp(one.begin(), two.begin(), HashString::size_data) == 0; } inline bool operator != (const HashString& one, const HashString& two) { return std::memcmp(one.begin(), two.begin(), HashString::size_data) != 0; } inline bool operator < (const HashString& one, const HashString& two) { return std::memcmp(one.begin(), two.begin(), HashString::size_data) < 0; } inline bool operator <= (const HashString& one, const HashString& two) { return std::memcmp(one.begin(), two.begin(), HashString::size_data) <= 0; } } #endif libtorrent-0.13.2/src/torrent/http.cc000644 000765 000024 00000004376 11740502002 020474 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "rak/functional.h" #include "torrent/exceptions.h" #include "http.h" namespace torrent { Http::slot_http Http::m_factory; Http::~Http() { } void Http::trigger_done() { rak::slot_list_call(signal_done()); if (m_flags & flag_delete_stream) { delete m_stream; m_stream = NULL; } if (m_flags & flag_delete_self) delete this; } void Http::trigger_failed(const std::string& message) { rak::slot_list_call(signal_failed(), message); if (m_flags & flag_delete_stream) { delete m_stream; m_stream = NULL; } if (m_flags & flag_delete_self) delete this; } } libtorrent-0.13.2/src/torrent/http.h000644 000765 000024 00000010630 11716350717 020345 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_HTTP_H #define LIBTORRENT_HTTP_H #include #include #include #include #include namespace torrent { // The client should set the user agent to something like // "CLIENT_NAME/CLIENT_VERSION/LIBRARY_VERSION". // Keep in mind that these objects get reused. class LIBTORRENT_EXPORT Http { public: typedef std::tr1::function slot_void; typedef std::tr1::function slot_string; typedef std::tr1::function slot_http; typedef std::list signal_void; typedef std::list signal_string; static const int flag_delete_self = 0x1; static const int flag_delete_stream = 0x2; Http() : m_flags(0), m_stream(NULL), m_timeout(0) {} virtual ~Http(); // Start must never throw on bad input. Calling start/stop on an // object in the wrong state should throw a torrent::internal_error. virtual void start() = 0; virtual void close() = 0; int flags() const { return m_flags; } void set_delete_self() { m_flags |= flag_delete_self; } void set_delete_stream() { m_flags |= flag_delete_stream; } const std::string& url() const { return m_url; } void set_url(const std::string& url) { m_url = url; } // Make sure the output stream does not have any bad/failed bits set. std::iostream* stream() { return m_stream; } void set_stream(std::iostream* str) { m_stream = str; } uint32_t timeout() const { return m_timeout; } void set_timeout(uint32_t seconds) { m_timeout = seconds; } // The owner of the Http object must close it as soon as possible // after receiving the signal, as the implementation may allocate // limited resources during its lifetime. signal_void& signal_done() { return m_signal_done; } signal_string& signal_failed() { return m_signal_failed; } // Guaranteed to return a valid object or throw a internal_error. The // caller takes ownership of the returned object. static slot_http& slot_factory() { return m_factory; } protected: void trigger_done(); void trigger_failed(const std::string& message); int m_flags; std::string m_url; std::iostream* m_stream; uint32_t m_timeout; signal_void m_signal_done; signal_string m_signal_failed; private: Http(const Http&); void operator = (const Http&); static slot_http m_factory; }; } #endif libtorrent-0.13.2/src/torrent/Makefile.am000644 000765 000024 00000002667 11716350717 021264 0ustar00rakshasastaff000000 000000 SUBDIRS = \ data \ download \ peer \ utils noinst_LTLIBRARIES = libsub_torrent.la libsub_torrent_la_SOURCES = \ bitfield.cc \ bitfield.h \ chunk_manager.cc \ chunk_manager.h \ common.h \ connection_manager.cc \ connection_manager.h \ dht_manager.cc \ dht_manager.h \ download.cc \ download.h \ download_info.h \ error.cc \ error.h \ event.h \ exceptions.cc \ exceptions.h \ hash_string.cc \ hash_string.h \ http.cc \ http.h \ object.cc \ object.h \ object_raw_bencode.h \ object_static_map.cc \ object_static_map.h \ object_stream.cc \ object_stream.h \ path.cc \ path.h \ poll.h \ poll_epoll.cc \ poll_epoll.h \ poll_kqueue.h \ poll_kqueue.cc \ poll_select.h \ poll_select.cc \ rate.cc \ rate.h \ throttle.cc \ throttle.h \ torrent.cc \ torrent.h \ tracker.cc \ tracker.h \ tracker_controller.cc \ tracker_controller.h \ tracker_list.cc \ tracker_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent libtorrentinclude_HEADERS = \ bitfield.h \ chunk_manager.h \ common.h \ connection_manager.h \ dht_manager.h \ download.h \ download_info.h \ error.h \ exceptions.h \ event.h \ hash_string.h \ http.h \ object.h \ object_raw_bencode.h \ object_static_map.h \ object_stream.h \ path.h \ poll.h \ poll_epoll.h \ poll_kqueue.h \ poll_select.h \ rate.h \ throttle.h \ torrent.h \ tracker.h \ tracker_controller.h \ tracker_list.h libtorrent-0.13.2/src/torrent/Makefile.in000644 000765 000024 00000064667 11744204216 021276 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/torrent DIST_COMMON = $(libtorrentinclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_torrent_la_LIBADD = am_libsub_torrent_la_OBJECTS = bitfield.lo chunk_manager.lo \ connection_manager.lo dht_manager.lo download.lo error.lo \ exceptions.lo hash_string.lo http.lo object.lo \ object_static_map.lo object_stream.lo path.lo poll_epoll.lo \ poll_kqueue.lo poll_select.lo rate.lo throttle.lo torrent.lo \ tracker.lo tracker_controller.lo tracker_list.lo libsub_torrent_la_OBJECTS = $(am_libsub_torrent_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_torrent_la_SOURCES) DIST_SOURCES = $(libsub_torrent_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libtorrentincludedir)" HEADERS = $(libtorrentinclude_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = \ data \ download \ peer \ utils noinst_LTLIBRARIES = libsub_torrent.la libsub_torrent_la_SOURCES = \ bitfield.cc \ bitfield.h \ chunk_manager.cc \ chunk_manager.h \ common.h \ connection_manager.cc \ connection_manager.h \ dht_manager.cc \ dht_manager.h \ download.cc \ download.h \ download_info.h \ error.cc \ error.h \ event.h \ exceptions.cc \ exceptions.h \ hash_string.cc \ hash_string.h \ http.cc \ http.h \ object.cc \ object.h \ object_raw_bencode.h \ object_static_map.cc \ object_static_map.h \ object_stream.cc \ object_stream.h \ path.cc \ path.h \ poll.h \ poll_epoll.cc \ poll_epoll.h \ poll_kqueue.h \ poll_kqueue.cc \ poll_select.h \ poll_select.cc \ rate.cc \ rate.h \ throttle.cc \ throttle.h \ torrent.cc \ torrent.h \ tracker.cc \ tracker.h \ tracker_controller.cc \ tracker_controller.h \ tracker_list.cc \ tracker_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent libtorrentinclude_HEADERS = \ bitfield.h \ chunk_manager.h \ common.h \ connection_manager.h \ dht_manager.h \ download.h \ download_info.h \ error.h \ exceptions.h \ event.h \ hash_string.h \ http.h \ object.h \ object_raw_bencode.h \ object_static_map.h \ object_stream.h \ path.h \ poll.h \ poll_epoll.h \ poll_kqueue.h \ poll_select.h \ rate.h \ throttle.h \ torrent.h \ tracker.h \ tracker_controller.h \ tracker_list.h all: all-recursive .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/torrent/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/torrent/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_torrent.la: $(libsub_torrent_la_OBJECTS) $(libsub_torrent_la_DEPENDENCIES) $(EXTRA_libsub_torrent_la_DEPENDENCIES) $(CXXLINK) $(libsub_torrent_la_OBJECTS) $(libsub_torrent_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitfield.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk_manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exceptions.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash_string.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_static_map.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_stream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/path.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_epoll.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_kqueue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_select.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/throttle.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/torrent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracker.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracker_controller.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracker_list.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-libtorrentincludeHEADERS: $(libtorrentinclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(libtorrentincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libtorrentincludedir)" @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtorrentincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtorrentincludedir)" || exit $$?; \ done uninstall-libtorrentincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libtorrentincludedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libtorrentincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-libtorrentincludeHEADERS install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-libtorrentincludeHEADERS .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic clean-libtool \ clean-noinstLTLIBRARIES ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libtorrentincludeHEADERS install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-libtorrentincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/torrent/object.cc000644 000765 000024 00000017040 11705767056 021002 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "object.h" #include "object_stream.h" namespace torrent { Object& Object::get_key(const std::string& k) { check_throw(TYPE_MAP); map_type::iterator itr = _map().find(k); if (itr == _map().end()) throw bencode_error("Object operator [" + k + "] could not find element"); return itr->second; } const Object& Object::get_key(const std::string& k) const { check_throw(TYPE_MAP); map_type::const_iterator itr = _map().find(k); if (itr == _map().end()) throw bencode_error("Object operator [" + k + "] could not find element"); return itr->second; } Object& Object::get_key(const char* k) { check_throw(TYPE_MAP); map_type::iterator itr = _map().find(std::string(k)); if (itr == _map().end()) throw bencode_error("Object operator [" + std::string(k) + "] could not find element"); return itr->second; } const Object& Object::get_key(const char* k) const { check_throw(TYPE_MAP); map_type::const_iterator itr = _map().find(std::string(k)); if (itr == _map().end()) throw bencode_error("Object operator [" + std::string(k) + "] could not find element"); return itr->second; } Object::map_insert_type Object::insert_preserve_type(const key_type& k, Object& b) { check_throw(TYPE_MAP); map_insert_type result = _map().insert(map_type::value_type(k, b)); if (!result.second && result.first->second.type() != b.type()) { result.first->second.move(b); result.second = true; } return result; } Object& Object::move(Object& src) { if (this == &src) return *this; *this = create_empty(src.type()); swap_same_type(*this, src); return *this; } Object& Object::swap(Object& src) { if (this == &src) return *this; if (type() != src.type()) { torrent::Object tmp = create_empty(src.type()); swap_same_type(tmp, src); src = create_empty(this->type()); swap_same_type(src, *this); *this = create_empty(tmp.type()); swap_same_type(*this, tmp); } else { swap_same_type(*this, src); } return *this; } Object& Object::merge_copy(const Object& object, uint32_t skip_mask, uint32_t maxDepth) { if (maxDepth == 0 || m_flags & skip_mask) return (*this = object); if (object.is_map()) { if (!is_map()) *this = create_map(); map_type& dest = as_map(); map_type::iterator destItr = dest.begin(); map_type::const_iterator srcItr = object.as_map().begin(); map_type::const_iterator srcLast = object.as_map().end(); while (srcItr != srcLast) { destItr = std::find_if(destItr, dest.end(), rak::less_equal(srcItr->first, rak::mem_ref(&map_type::value_type::first))); if (srcItr->first < destItr->first) // destItr remains valid and pointing to the next possible // position. dest.insert(destItr, *srcItr); else destItr->second.merge_copy(srcItr->second, maxDepth - 1); srcItr++; } // } else if (object.is_list()) { // if (!is_list()) // *this = create_list(); // list_type& dest = as_list(); // list_type::iterator destItr = dest.begin(); // list_type::const_iterator srcItr = object.as_list().begin(); // list_type::const_iterator srcLast = object.as_list().end(); // while (srcItr != srcLast) { // if (destItr == dest.end()) // destItr = dest.insert(destItr, *srcItr); // else // destItr->merge_copy(*srcItr, maxDepth - 1); // destItr++; // } } else { *this = object; } return *this; } Object& Object::operator = (const Object& src) { if (&src == this) return *this; clear(); // Need some more magic here? m_flags = src.m_flags & (mask_type | mask_public); switch (type()) { case TYPE_STRING: new (&_string()) string_type(src._string()); break; case TYPE_LIST: new (&_list()) list_type(src._list()); break; case TYPE_MAP: _map_ptr() = new map_type(src._map()); break; case TYPE_DICT_KEY: new (&_dict_key()) dict_key_type(src._dict_key()); _dict_key().second = new Object(*src._dict_key().second); break; default: t_pod = src.t_pod; break; } return *this; } Object object_create_normal(const raw_bencode& obj) { torrent::Object result; if (object_read_bencode_c(obj.begin(), obj.end(), &result, 128) != obj.end()) throw bencode_error("Invalid bencode data."); return result; } Object object_create_normal(const raw_list& obj) { torrent::Object result = Object::create_list(); raw_list::iterator first = obj.begin(); raw_list::iterator last = obj.end(); while (first != last) { Object::list_iterator new_entry = result.as_list().insert(result.as_list().end(), Object()); first = object_read_bencode_c(first, last, &*new_entry, 128); // The unordered flag is inherited also from list elements who // have been marked as unordered, though e.g. unordered strings // in the list itself does not cause this flag to be set. if (new_entry->flags() & Object::flag_unordered) result.set_internal_flags(Object::flag_unordered); } return result; } Object object_create_normal(const raw_map& obj) { torrent::Object result = Object::create_map(); raw_list::iterator first = obj.begin(); raw_list::iterator last = obj.end(); Object::string_type prev; while (first != last) { raw_string raw_str = object_read_bencode_c_string(first, last); first = raw_str.end(); Object::string_type key_str = raw_str.as_string(); // We do not set flag_unordered if the first key was zero // length, while multiple zero length keys will trigger the // unordered_flag. if (key_str <= prev && !result.as_map().empty()) result.set_internal_flags(Object::flag_unordered); Object* value = &result.as_map()[key_str]; first = object_read_bencode_c(first, last, value, 128); if (value->flags() & Object::flag_unordered) result.set_internal_flags(Object::flag_unordered); key_str.swap(prev); } return result; } } libtorrent-0.13.2/src/torrent/object.h000644 000765 000024 00000057306 11716350717 020647 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_OBJECT_H #define LIBTORRENT_OBJECT_H #include #include #include #include #include #include namespace torrent { class LIBTORRENT_EXPORT Object { public: typedef int64_t value_type; typedef std::string string_type; typedef std::vector list_type; typedef std::map map_type; typedef map_type* map_ptr_type; typedef map_type::key_type key_type; typedef std::pair dict_key_type; typedef list_type::iterator list_iterator; typedef list_type::const_iterator list_const_iterator; typedef list_type::reverse_iterator list_reverse_iterator; typedef list_type::const_reverse_iterator list_const_reverse_iterator; typedef map_type::iterator map_iterator; typedef map_type::const_iterator map_const_iterator; typedef map_type::reverse_iterator map_reverse_iterator; typedef map_type::const_reverse_iterator map_const_reverse_iterator; typedef std::pair map_insert_type; // Flags in the range of 0xffff0000 may be set by the user, however // 0x00ff0000 are reserved for keywords defined by libtorrent. static const uint32_t mask_type = 0xff; static const uint32_t mask_flags = ~mask_type; static const uint32_t mask_internal = 0xffff; static const uint32_t mask_public = ~mask_internal; static const uint32_t flag_unordered = 0x100; // bencode dictionary was not sorted static const uint32_t flag_static_data = 0x010000; // Object does not change across sessions. static const uint32_t flag_session_data = 0x020000; // Object changes between sessions. static const uint32_t flag_function = 0x040000; // A function object. static const uint32_t flag_function_q1 = 0x080000; // A quoted function object. static const uint32_t flag_function_q2 = 0x100000; // A double-quoted function object. static const uint32_t mask_function = 0x1C0000; // Mask for function objects. enum type_type { TYPE_NONE, TYPE_RAW_BENCODE, TYPE_RAW_STRING, TYPE_RAW_LIST, TYPE_RAW_MAP, TYPE_VALUE, TYPE_STRING, TYPE_LIST, TYPE_MAP, TYPE_DICT_KEY }; Object() : m_flags(TYPE_NONE) {} Object(const value_type v) : m_flags(TYPE_VALUE) { new (&_value()) value_type(v); } Object(const char* s) : m_flags(TYPE_STRING) { new (&_string()) string_type(s); } Object(const string_type& s) : m_flags(TYPE_STRING) { new (&_string()) string_type(s); } Object(const raw_bencode& r) : m_flags(TYPE_RAW_BENCODE) { new (&_raw_bencode()) raw_bencode(r); } Object(const raw_string& r) : m_flags(TYPE_RAW_STRING) { new (&_raw_string()) raw_string(r); } Object(const raw_list& r) : m_flags(TYPE_RAW_LIST) { new (&_raw_list()) raw_list(r); } Object(const raw_map& r) : m_flags(TYPE_RAW_MAP) { new (&_raw_map()) raw_map(r); } Object(const Object& b); ~Object() { clear(); } // TODO: Move this out of the class namespace, call them // make_object_. static Object create_empty(type_type t); static Object create_value() { return Object(value_type()); } static Object create_string() { return Object(string_type()); } static Object create_list() { Object tmp; tmp.m_flags = TYPE_LIST; new (&tmp._list()) list_type(); return tmp; } static Object create_map() { Object tmp; tmp.m_flags = TYPE_MAP; tmp._map_ptr() = new map_type(); return tmp; } static Object create_dict_key(); static Object create_raw_bencode(raw_bencode obj = raw_bencode()); static Object create_raw_string(raw_string obj = raw_string()); static Object create_raw_list(raw_list obj = raw_list()); static Object create_raw_map(raw_map obj = raw_map()); template static Object create_list_range(ForwardIterator first, ForwardIterator last); static Object from_list(const list_type& src) { Object tmp; tmp.m_flags = TYPE_LIST; new (&tmp._list()) list_type(src); return tmp; } // Clear should probably not be inlined due to size and not being // optimized away in pretty much any case. Might not work well in // cases where we pass constant rvalues. void clear(); type_type type() const { return (type_type)(m_flags & mask_type); } uint32_t flags() const { return m_flags & mask_flags; } void set_flags(uint32_t f) { m_flags |= f & mask_public; } void unset_flags(uint32_t f) { m_flags &= ~(f & mask_public); } void set_internal_flags(uint32_t f) { m_flags |= f & (mask_internal & ~mask_type); } void unset_internal_flags(uint32_t f) { m_flags &= ~(f & (mask_internal & ~mask_type)); } // Add functions for setting/clearing the public flags. bool is_empty() const { return type() == TYPE_NONE; } bool is_not_empty() const { return type() != TYPE_NONE; } bool is_value() const { return type() == TYPE_VALUE; } bool is_string() const { return type() == TYPE_STRING; } bool is_string_empty() const { return type() != TYPE_STRING || _string().empty(); } bool is_list() const { return type() == TYPE_LIST; } bool is_map() const { return type() == TYPE_MAP; } bool is_dict_key() const { return type() == TYPE_DICT_KEY; } bool is_raw_bencode() const { return type() == TYPE_RAW_BENCODE; } bool is_raw_string() const { return type() == TYPE_RAW_STRING; } bool is_raw_list() const { return type() == TYPE_RAW_LIST; } bool is_raw_map() const { return type() == TYPE_RAW_MAP; } value_type& as_value() { check_throw(TYPE_VALUE); return _value(); } const value_type& as_value() const { check_throw(TYPE_VALUE); return _value(); } string_type& as_string() { check_throw(TYPE_STRING); return _string(); } const string_type& as_string() const { check_throw(TYPE_STRING); return _string(); } const string_type& as_string_c() const { check_throw(TYPE_STRING); return _string(); } list_type& as_list() { check_throw(TYPE_LIST); return _list(); } const list_type& as_list() const { check_throw(TYPE_LIST); return _list(); } map_type& as_map() { check_throw(TYPE_MAP); return _map(); } const map_type& as_map() const { check_throw(TYPE_MAP); return _map(); } string_type& as_dict_key() { check_throw(TYPE_DICT_KEY); return _dict_key().first; } const string_type& as_dict_key() const { check_throw(TYPE_DICT_KEY); return _dict_key().first; } Object& as_dict_obj() { check_throw(TYPE_DICT_KEY); return *_dict_key().second; } const Object& as_dict_obj() const { check_throw(TYPE_DICT_KEY); return *_dict_key().second; } raw_bencode& as_raw_bencode() { check_throw(TYPE_RAW_BENCODE); return _raw_bencode(); } const raw_bencode& as_raw_bencode() const { check_throw(TYPE_RAW_BENCODE); return _raw_bencode(); } raw_string& as_raw_string() { check_throw(TYPE_RAW_STRING); return _raw_string(); } const raw_string& as_raw_string() const { check_throw(TYPE_RAW_STRING); return _raw_string(); } raw_list& as_raw_list() { check_throw(TYPE_RAW_LIST); return _raw_list(); } const raw_list& as_raw_list() const { check_throw(TYPE_RAW_LIST); return _raw_list(); } raw_map& as_raw_map() { check_throw(TYPE_RAW_MAP); return _raw_map(); } const raw_map& as_raw_map() const { check_throw(TYPE_RAW_MAP); return _raw_map(); } bool has_key(const key_type& k) const { check_throw(TYPE_MAP); return _map().find(k) != _map().end(); } bool has_key_value(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_VALUE); } bool has_key_string(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_STRING); } bool has_key_list(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_LIST); } bool has_key_map(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_MAP); } bool has_key_raw_bencode(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_BENCODE); } bool has_key_raw_string(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_STRING); } bool has_key_raw_list(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_LIST); } bool has_key_raw_map(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_MAP); } // Should have an interface for that returns pointer or something, // so we don't need to search twice. // Make these inline... Object& get_key(const key_type& k); const Object& get_key(const key_type& k) const; Object& get_key(const char* k); const Object& get_key(const char* k) const; template value_type& get_key_value(const T& k) { return get_key(k).as_value(); } template const value_type& get_key_value(const T& k) const { return get_key(k).as_value(); } template string_type& get_key_string(const T& k) { return get_key(k).as_string(); } template const string_type& get_key_string(const T& k) const { return get_key(k).as_string(); } template list_type& get_key_list(const T& k) { return get_key(k).as_list(); } template const list_type& get_key_list(const T& k) const { return get_key(k).as_list(); } template map_type& get_key_map(const T& k) { return get_key(k).as_map(); } template const map_type& get_key_map(const T& k) const { return get_key(k).as_map(); } Object& insert_key(const key_type& k, const Object& b) { check_throw(TYPE_MAP); return _map()[k] = b; } Object& insert_key_move(const key_type& k, Object& b) { check_throw(TYPE_MAP); return _map()[k].move(b); } // 'insert_preserve_*' inserts the object 'b' if the key 'k' does // not exist, else it returns the old entry. The type specific // versions also require the old entry to be of the same type. // // Consider making insert_preserve_* return std::pair or // something similar. map_insert_type insert_preserve_any(const key_type& k, const Object& b) { check_throw(TYPE_MAP); return _map().insert(map_type::value_type(k, b)); } map_insert_type insert_preserve_type(const key_type& k, Object& b); map_insert_type insert_preserve_copy(const key_type& k, Object b) { return insert_preserve_type(k, b); } void erase_key(const key_type& k) { check_throw(TYPE_MAP); _map().erase(k); } Object& insert_front(const Object& b) { check_throw(TYPE_LIST); return *_list().insert(_list().begin(), b); } Object& insert_back(const Object& b) { check_throw(TYPE_LIST); return *_list().insert(_list().end(), b); } // Copy and merge operations: Object& move(Object& b); Object& swap(Object& b); Object& swap_same_type(Object& b); // Only map entries are merged. Object& merge_move(Object& object, uint32_t maxDepth = ~uint32_t()); Object& merge_copy(const Object& object, uint32_t skip_mask = flag_static_data, uint32_t maxDepth = ~uint32_t()); Object& operator = (const Object& b); // Internal: void swap_same_type(Object& left, Object& right); private: inline bool check(map_type::const_iterator itr, type_type t) const { return itr != _map().end() && itr->second.type() == t; } inline void check_throw(type_type t) const { if (t != type()) throw bencode_error("Wrong object type."); } uint32_t m_flags; #ifdef HAVE_CXX11 value_type& _value() { return t_value; } const value_type& _value() const { return t_value; } string_type& _string() { return t_string; } const string_type& _string() const { return t_string; } list_type& _list() { return t_list; } const list_type& _list() const { return t_list; } map_type& _map() { return *t_map; } const map_type& _map() const { return *t_map; } map_ptr_type& _map_ptr() { return t_map; } const map_ptr_type& _map_ptr() const { return t_map; } dict_key_type& _dict_key() { return t_dict_key; } const dict_key_type& _dict_key() const { return t_dict_key; } raw_object& _raw_object() { return t_raw_object; } const raw_object& _raw_object() const { return t_raw_object; } raw_bencode& _raw_bencode() { return t_raw_bencode; } const raw_bencode& _raw_bencode() const { return t_raw_bencode; } raw_string& _raw_string() { return t_raw_string; } const raw_string& _raw_string() const { return t_raw_string; } raw_list& _raw_list() { return t_raw_list; } const raw_list& _raw_list() const { return t_raw_list; } raw_map& _raw_map() { return t_raw_map; } const raw_map& _raw_map() const { return t_raw_map; } union pod_types { value_type t_value; raw_object t_raw_object; raw_bencode t_raw_bencode; raw_string t_raw_string; raw_list t_raw_list; raw_map t_raw_map; }; union { pod_types t_pod; value_type t_value; string_type t_string; list_type t_list; map_type* t_map; dict_key_type t_dict_key; raw_object t_raw_object; raw_bencode t_raw_bencode; raw_string t_raw_string; raw_list t_raw_list; raw_map t_raw_map; }; #else // #error "WTF we're testing C++11 now." value_type& _value() { return reinterpret_cast(t_pod); } const value_type& _value() const { return reinterpret_cast(t_pod); } string_type& _string() { return reinterpret_cast(t_string); } const string_type& _string() const { return reinterpret_cast(t_string); } list_type& _list() { return reinterpret_cast(t_list); } const list_type& _list() const { return reinterpret_cast(t_list); } map_type& _map() { return *reinterpret_cast(t_pod); } const map_type& _map() const { return *reinterpret_cast(t_pod); } map_ptr_type& _map_ptr() { return reinterpret_cast(t_pod); } const map_ptr_type& _map_ptr() const { return reinterpret_cast(t_pod); } dict_key_type& _dict_key() { return reinterpret_cast(t_pod); } const dict_key_type& _dict_key() const { return reinterpret_cast(t_pod); } raw_object& _raw_object() { return reinterpret_cast(t_pod); } const raw_object& _raw_object() const { return reinterpret_cast(t_pod); } raw_bencode& _raw_bencode() { return reinterpret_cast(t_pod); } const raw_bencode& _raw_bencode() const { return reinterpret_cast(t_pod); } raw_string& _raw_string() { return reinterpret_cast(t_pod); } const raw_string& _raw_string() const { return reinterpret_cast(t_pod); } raw_list& _raw_list() { return reinterpret_cast(t_pod); } const raw_list& _raw_list() const { return reinterpret_cast(t_pod); } raw_map& _raw_map() { return reinterpret_cast(t_pod); } const raw_map& _raw_map() const { return reinterpret_cast(t_pod); } union pod_types { value_type t_value; map_type* t_map; char t_raw_object[sizeof(raw_object)]; }; union { pod_types t_pod; char t_string[sizeof(string_type)]; char t_list[sizeof(list_type)]; char t_dict_key[sizeof(dict_key_type)]; }; #endif }; inline Object::Object(const Object& b) { m_flags = b.m_flags & (mask_type | mask_public); switch (type()) { case TYPE_NONE: case TYPE_RAW_BENCODE: case TYPE_RAW_STRING: case TYPE_RAW_LIST: case TYPE_RAW_MAP: case TYPE_VALUE: t_pod = b.t_pod; break; case TYPE_STRING: new (&_string()) string_type(b._string()); break; case TYPE_LIST: new (&_list()) list_type(b._list()); break; case TYPE_MAP: _map_ptr() = new map_type(b._map()); break; case TYPE_DICT_KEY: new (&_dict_key().first) string_type(b._dict_key().first); _dict_key().second = new Object(*b._dict_key().second); break; } } inline Object Object::create_empty(type_type t) { switch (t) { case TYPE_RAW_BENCODE: return create_raw_bencode(); case TYPE_RAW_STRING: return create_raw_string(); case TYPE_RAW_LIST: return create_raw_list(); case TYPE_RAW_MAP: return create_raw_map(); case TYPE_VALUE: return create_value(); case TYPE_STRING: return create_string(); case TYPE_LIST: return create_list(); case TYPE_MAP: return create_map(); case TYPE_DICT_KEY: return create_dict_key(); case TYPE_NONE: default: return torrent::Object(); } } inline Object object_create_raw_bencode_c_str(const char str[]) { return Object::create_raw_bencode(raw_bencode(str, strlen(str))); } // TODO: These do not preserve the flag... Object object_create_normal(const raw_bencode& obj) LIBTORRENT_EXPORT; Object object_create_normal(const raw_list& obj) LIBTORRENT_EXPORT; Object object_create_normal(const raw_map& obj) LIBTORRENT_EXPORT; inline Object object_create_normal(const raw_string& obj) { return torrent::Object(obj.as_string()); } inline Object Object::create_dict_key() { Object tmp; tmp.m_flags = TYPE_DICT_KEY; new (&tmp._dict_key()) dict_key_type(); tmp._dict_key().second = new Object(); return tmp; } inline Object Object::create_raw_bencode(raw_bencode obj) { Object tmp; tmp.m_flags = TYPE_RAW_BENCODE; new (&tmp._raw_bencode()) raw_bencode(obj); return tmp; } inline Object Object::create_raw_string(raw_string obj) { Object tmp; tmp.m_flags = TYPE_RAW_STRING; new (&tmp._raw_string()) raw_string(obj); return tmp; } inline Object Object::create_raw_list(raw_list obj) { Object tmp; tmp.m_flags = TYPE_RAW_LIST; new (&tmp._raw_list()) raw_list(obj); return tmp; } inline Object Object::create_raw_map(raw_map obj) { Object tmp; tmp.m_flags = TYPE_RAW_MAP; new (&tmp._raw_map()) raw_map(obj); return tmp; } inline Object object_create_normal(const Object& obj) { switch (obj.type()) { case Object::TYPE_RAW_BENCODE: return object_create_normal(obj.as_raw_bencode()); case Object::TYPE_RAW_STRING: return object_create_normal(obj.as_raw_string()); case Object::TYPE_RAW_LIST: return object_create_normal(obj.as_raw_list()); case Object::TYPE_RAW_MAP: return object_create_normal(obj.as_raw_map()); default: return obj; } } inline std::string object_create_string(const torrent::Object& obj) { switch (obj.type()) { case Object::TYPE_RAW_BENCODE: return obj.as_raw_bencode().as_raw_string().as_string(); case Object::TYPE_RAW_STRING: return obj.as_raw_string().as_string(); default: return obj.as_string(); } } template inline Object Object::create_list_range(ForwardIterator first, ForwardIterator last) { Object tmp; tmp.m_flags = TYPE_LIST; new (&tmp._list()) list_type(first, last); return tmp; } inline void Object::clear() { switch (type()) { case TYPE_STRING: _string().~string_type(); break; case TYPE_LIST: _list().~list_type(); break; case TYPE_MAP: delete _map_ptr(); break; case TYPE_DICT_KEY: delete _dict_key().second; _dict_key().~dict_key_type(); break; default: break; } // Only clear type? m_flags = TYPE_NONE; } inline void Object::swap_same_type(Object& left, Object& right) { std::swap(left.m_flags, right.m_flags); switch (left.type()) { case Object::TYPE_STRING: left._string().swap(right._string()); break; case Object::TYPE_LIST: left._list().swap(right._list()); break; case Object::TYPE_DICT_KEY: std::swap(left._dict_key().first, right._dict_key().first); std::swap(left._dict_key().second, right._dict_key().second); break; default: std::swap(left.t_pod, right.t_pod); break; } } inline void swap(Object& left, Object& right) { left.swap(right); } inline bool object_equal(const Object& left, const Object& right) { if (left.type() != right.type()) return false; switch (left.type()) { case Object::TYPE_NONE: return true; case Object::TYPE_VALUE: return left.as_value() == right.as_value(); case Object::TYPE_STRING: return left.as_string() == right.as_string(); default: return false; } } } #endif libtorrent-0.13.2/src/torrent/object_raw_bencode.h000644 000765 000024 00000015577 11716350717 023203 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_OBJECT_RAW_BENCODE_H #define LIBTORRENT_OBJECT_RAW_BENCODE_H #include #include #include #include namespace torrent { class raw_bencode; class raw_string; class raw_list; class raw_map; // The base class for static constant version of Objects. This class // should never be used directly. class raw_object { public: typedef const char value_type; typedef const char* iterator; typedef const char* const_iterator; typedef uint32_t size_type; raw_object() : m_data(), m_size() {} raw_object(value_type* src_data, size_type src_size) : m_data(src_data), m_size(src_size) {} bool empty() const { return m_size == 0; } size_type size() const { return m_size; } iterator begin() const { return m_data; } iterator end() const { return m_data + m_size; } value_type* data() const { return m_data; } bool operator == (const raw_object& rhs) const { return m_size == rhs.m_size && std::memcmp(m_data, rhs.m_data, m_size) == 0; } bool operator != (const raw_object& rhs) const { return m_size != rhs.m_size || std::memcmp(m_data, rhs.m_data, m_size) != 0; } protected: iterator m_data; size_type m_size; }; #define RAW_BENCODE_SET_USING \ using raw_object::value_type; \ using raw_object::iterator; \ using raw_object::const_iterator; \ using raw_object::size_type; \ using raw_object::empty; \ using raw_object::size; \ using raw_object::begin; \ using raw_object::end; \ using raw_object::data; \ \ bool operator == (const this_type& rhs) const { return raw_object::operator==(rhs); } \ bool operator != (const this_type& rhs) const { return raw_object::operator!=(rhs); } \ // A raw_bencode object shall always contain valid bencode data or be // empty. class raw_bencode : protected raw_object { public: typedef raw_bencode this_type; RAW_BENCODE_SET_USING raw_bencode() : raw_object() {} raw_bencode(value_type* src_data, size_type src_size) : raw_object(src_data, src_size) {} bool is_empty() const { return m_size == 0; } bool is_value() const { return m_size >= 3 && m_data[0] >= 'i'; } bool is_raw_string() const { return m_size >= 2 && m_data[0] >= '0' && m_data[0] <= '9'; } bool is_raw_list() const { return m_size >= 2 && m_data[0] >= 'l'; } bool is_raw_map() const { return m_size >= 2 && m_data[0] >= 'd'; } std::string as_value_string() const; raw_string as_raw_string() const; raw_list as_raw_list() const; raw_map as_raw_map() const; static raw_bencode from_c_str(const char* str) { return raw_bencode(str, std::strlen(str)); } }; class raw_string : protected raw_object { public: typedef raw_string this_type; RAW_BENCODE_SET_USING raw_string() {} raw_string(value_type* src_data, size_type src_size) : raw_object(src_data, src_size) {} std::string as_string() const { return std::string(m_data, m_size); } static raw_string from_c_str(const char* str) { return raw_string(str, std::strlen(str)); } static raw_string from_string(const std::string& str) { return raw_string(str.data(), str.size()); } }; class raw_list : protected raw_object { public: typedef raw_list this_type; RAW_BENCODE_SET_USING raw_list() {} raw_list(value_type* src_data, size_type src_size) : raw_object(src_data, src_size) {} static raw_list from_c_str(const char* str) { return raw_list(str, std::strlen(str)); } }; class raw_map : protected raw_object { public: typedef raw_map this_type; RAW_BENCODE_SET_USING raw_map() {} raw_map(value_type* src_data, size_type src_size) : raw_object(src_data, src_size) {} }; // // // inline std::string raw_bencode::as_value_string() const { if (!is_value()) throw bencode_error("Wrong object type."); return std::string(data() + 1, size() - 2); } inline raw_string raw_bencode::as_raw_string() const { if (!is_raw_string()) throw bencode_error("Wrong object type."); const_iterator itr = std::find(begin(), end(), ':'); if (itr == end()) throw internal_error("Invalid bencode in raw_bencode."); return raw_string(itr + 1, std::distance(itr + 1, end())); } inline raw_list raw_bencode::as_raw_list() const { if (!is_raw_list()) throw bencode_error("Wrong object type."); return raw_list(m_data + 1, m_size - 2); } inline raw_map raw_bencode::as_raw_map() const { if (!is_raw_map()) throw bencode_error("Wrong object type."); return raw_map(m_data + 1, m_size - 2); } // // Redo... // inline bool raw_bencode_equal(const raw_bencode& left, const raw_bencode& right) { return left.size() == right.size() && std::memcmp(left.begin(), right.begin(), left.size()) == 0; } template inline bool raw_bencode_equal(const tmpl_raw_object& left, const char* right, size_t right_size) { return left.size() == right_size && std::memcmp(left.begin(), right, right_size) == 0; } template inline bool raw_bencode_equal_c_str(const tmpl_raw_object& left, const char* right) { return raw_bencode_equal(left, right, strlen(right)); } } #endif libtorrent-0.13.2/src/torrent/object_static_map.cc000644 000765 000024 00000005102 11705767056 023202 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "object_static_map.h" namespace torrent { const static_map_key_search_result find_key_match(const static_map_mapping_type* first, const static_map_mapping_type* last, const char* key_first, const char* key_last) { // unsigned int key_length = strlen(key); const static_map_mapping_type* itr = first; while (itr != last) { unsigned int base = rak::count_base(key_first, key_last, itr->key, itr->key + itr->max_key_size); if (key_first[base] != '\0') { // Return not found here if we know the entry won't come after // this. itr++; continue; } if (itr->key[base] == '\0' || itr->key[base] == '*' || (itr->key[base] == ':' && itr->key[base + 1] == ':') || (itr->key[base] == '[' && itr->key[base + 1] == ']')) return static_map_key_search_result(itr, base); break; } return static_map_key_search_result(first, 0); } } libtorrent-0.13.2/src/torrent/object_static_map.h000644 000765 000024 00000010144 11705767056 023046 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_OBJECT_STATIC_MAP_H #define LIBTORRENT_OBJECT_STATIC_MAP_H #include #include #include namespace torrent { struct static_map_mapping_type { static const size_t max_key_size = 16; bool is_end() const { return key[0] == '\0'; } static bool is_not_key_char(char c) { return c == '\0' || c == ':' || c == '[' || c == '*'; } const char* find_key_end(const char* pos) const { return std::find_if(pos, key + max_key_size, &is_not_key_char); } uint32_t index; const char key[max_key_size]; }; struct static_map_entry_type { torrent::Object object; }; template class static_map_type { public: typedef Object value_type; typedef tmpl_key_type key_type; typedef static_map_entry_type entry_type; typedef static_map_mapping_type mapping_type; typedef mapping_type key_list_type[tmpl_length]; typedef entry_type value_list_type[tmpl_length]; static const size_t size = tmpl_length; static const key_list_type keys; entry_type* values() { return m_values; } const entry_type* values() const { return m_values; } Object& operator [] (key_type key) { return m_values[key].object; } const Object& operator [] (key_type key) const { return m_values[key].object; } private: value_list_type m_values; }; // // Helper functions/classes for parsing keys: // struct static_map_stack_type { void set_key_index(uint32_t start_index, uint32_t end_index, uint32_t delim_size, torrent::Object::type_type type = Object::TYPE_MAP) { key_index = start_index; next_key = end_index + delim_size; obj_type = type; } void clear() { key_index = 0; next_key = 0; obj_type = Object::TYPE_MAP; } uint32_t key_index; uint32_t next_key; Object::type_type obj_type; }; typedef std::pair static_map_key_search_result; // Note that the key for both functions must be null-terminated at // 'key_last'. const static_map_key_search_result find_key_match(const static_map_mapping_type* first, const static_map_mapping_type* last, const char* key_first, const char* key_last) LIBTORRENT_EXPORT; inline const static_map_key_search_result find_key_match(const static_map_mapping_type* first, const static_map_mapping_type* last, const char* key) { return find_key_match(first, last, key, key + strlen(key)); } } #endif libtorrent-0.13.2/src/torrent/object_stream.cc000644 000765 000024 00000062640 11736247566 022366 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include #include "utils/sha1.h" #include "object.h" #include "object_stream.h" #include "object_static_map.h" namespace torrent { bool object_read_string(std::istream* input, std::string& str) { uint32_t size; *input >> size; if (input->fail() || input->get() != ':') return false; str.resize(size); for (std::string::iterator itr = str.begin(); itr != str.end() && input->good(); ++itr) *itr = input->get(); return !input->fail(); } const char* object_read_bencode_c_value(const char* first, const char* last, int64_t& value) { if (first == last) return first; bool neg = false; if (*first == '-') { // Don't allow '-0', or '-' followed by non-numeral. if ((first + 1) == last || *(first + 1) <= '0' || *(first + 1) > '9') return first; neg = true; first++; } value = 0; while (first != last && *first >= '0' && *first <= '9') value = value * 10 + (*first++ - '0'); if (neg) value = -value; return first; } raw_string object_read_bencode_c_string(const char* first, const char* last) { // Set the most-significant bit so that if there are no numbers in // the input it will fail the length check, while "0" will shift the // bit out. unsigned int length = 0x1 << (std::numeric_limits::digits - 1); while (first != last && *first >= '0' && *first <= '9') length = length * 10 + (*first++ - '0'); if (length + 1 > (unsigned int)std::distance(first, last) || *first++ != ':') throw torrent::bencode_error("Invalid bencode data."); return raw_string(first, length); } // Could consider making this non-recursive, but they seldomly are // deep enough to make that worth-while. void object_read_bencode(std::istream* input, Object* object, uint32_t depth) { int c; switch ((c = input->peek())) { case 'i': input->get(); *object = Object::create_value(); *input >> object->as_value(); if (input->get() != 'e') break; return; case 'l': input->get(); *object = Object::create_list(); if (++depth >= 1024) break; while (input->good()) { if (input->peek() == 'e') { input->get(); return; } Object::list_iterator itr = object->as_list().insert(object->as_list().end(), Object()); object_read_bencode(input, &*itr, depth); // The unordered flag is inherited also from list elements who // have been marked as unordered, though e.g. unordered strings // in the list itself does not cause this flag to be set. if (itr->flags() & Object::flag_unordered) object->set_internal_flags(Object::flag_unordered); } break; case 'd': { input->get(); *object = Object::create_map(); if (++depth >= 1024) break; Object::string_type last; while (input->good()) { if (input->peek() == 'e') { input->get(); return; } Object::string_type str; if (!object_read_string(input, str)) break; // We do not set flag_unordered if the first key was zero // length, while multiple zero length keys will trigger the // unordered_flag. if (str <= last && !object->as_map().empty()) object->set_internal_flags(Object::flag_unordered); Object* value = &object->as_map()[str]; object_read_bencode(input, value, depth); if (value->flags() & Object::flag_unordered) object->set_internal_flags(Object::flag_unordered); str.swap(last); } break; } default: if (c >= '0' && c <= '9') { *object = Object::create_string(); if (object_read_string(input, object->as_string())) return; } break; } input->setstate(std::istream::failbit); object->clear(); } const char* object_read_bencode_c(const char* first, const char* last, Object* object, uint32_t depth) { if (first == last) throw torrent::bencode_error("Invalid bencode data."); switch (*first) { case 'i': *object = Object::create_value(); first = object_read_bencode_c_value(first + 1, last, object->as_value()); if (first == last || *first++ != 'e') break; return first; case 'l': if (++depth >= 1024) break; first++; *object = Object::create_list(); while (first != last) { if (*first == 'e') return first + 1; Object::list_iterator itr = object->as_list().insert(object->as_list().end(), Object()); first = object_read_bencode_c(first, last, &*itr, depth); // The unordered flag is inherited also from list elements who // have been marked as unordered, though e.g. unordered strings // in the list itself does not cause this flag to be set. if (itr->flags() & Object::flag_unordered) object->set_internal_flags(Object::flag_unordered); } break; case 'd': { if (++depth >= 1024) break; first++; *object = Object::create_map(); Object::string_type prev; while (first != last) { if (*first == 'e') return first + 1; raw_string raw_str = object_read_bencode_c_string(first, last); first = raw_str.end(); Object::string_type str = raw_str.as_string(); // We do not set flag_unordered if the first key was zero // length, while multiple zero length keys will trigger the // unordered_flag. if (str <= prev && !object->as_map().empty()) object->set_internal_flags(Object::flag_unordered); Object* value = &object->as_map()[str]; first = object_read_bencode_c(first, last, value, depth); if (value->flags() & Object::flag_unordered) object->set_internal_flags(Object::flag_unordered); str.swap(prev); } break; } default: if (*first < '0' || *first > '9') throw torrent::bencode_error("Invalid bencode data."); raw_string raw_str = object_read_bencode_c_string(first, last); *object = raw_str.as_string(); return raw_str.end(); } object->clear(); throw torrent::bencode_error("Invalid bencode data."); } inline bool object_is_not_digit(char c) { return c < '0' || c > '9'; } const char* object_read_bencode_skip_c(const char* first, const char* last) { char stack[128] = { 0 }; char* stack_itr = stack; while (first != last) { if (*first == 'e') { if (stack_itr-- == stack) throw torrent::bencode_error("Invalid bencode data."); first++; if (stack_itr == stack) return first; continue; } // Currently reading a dictionary, so ensure the first entry is a // string. if (*stack_itr && (first = object_read_bencode_c_string(first, last).end()) == last) break; switch (*first) { case 'i': if (first != last && *++first == '-') { if (first != last && *++first == '0') throw torrent::bencode_error("Invalid bencode data."); } first = std::find_if(first, last, &object_is_not_digit); if (first == last || *first++ != 'e') throw torrent::bencode_error("Invalid bencode data."); break; case 'l': case 'd': if (++stack_itr == stack + 128) throw torrent::bencode_error("Invalid bencode data."); *stack_itr = (*first++ == 'd'); continue; default: first = object_read_bencode_c_string(first, last).end(); }; if (stack_itr == stack) return first; } throw torrent::bencode_error("Invalid bencode data."); } const char* object_read_bencode_raw_c(const char* first, const char* last, torrent::Object* object, char type) { const char* tmp = first; first = object_read_bencode_skip_c(first, last); raw_bencode obj = raw_bencode(tmp, std::distance(tmp, first)); // if (obj.is_empty()) // throw torrent::bencode_error("Invalid bencode data."); switch (type) { case 'S': if (obj.is_raw_string()) *object = obj.as_raw_string(); break; case 'L': if (obj.is_raw_list()) *object = obj.as_raw_list(); break; case 'M': if (obj.is_raw_map()) *object = obj.as_raw_map(); break; default: *object = obj; }; return first; } // Would be nice to have a straight stream to hash conversion. std::string object_sha1(const Object* object) { Sha1 sha; char buffer[1024]; sha.init(); object_write_bencode_c(&object_write_to_sha1, &sha, object_buffer_t(buffer, buffer + 1024), object); sha.final_c(buffer); return std::string(buffer, 20); } std::istream& operator >> (std::istream& input, Object& object) { std::locale locale = input.imbue(std::locale::classic()); object.clear(); object_read_bencode(&input, &object); input.imbue(locale); return input; } std::ostream& operator << (std::ostream& output, const Object& object) { object_write_bencode(&output, &object); return output; } struct object_write_data_t { object_write_t writeFunc; void* data; object_buffer_t buffer; char* pos; }; void object_write_bencode_c_string(object_write_data_t* output, const char* srcData, uint32_t srcLength) { while (srcLength != 0) { uint32_t len = std::min(srcLength, std::distance(output->pos, output->buffer.second)); std::memcpy(output->pos, srcData, len); output->pos += len; if (output->pos == output->buffer.second) { output->buffer = output->writeFunc(output->data, output->buffer); output->pos = output->buffer.first; if (output->buffer.first == output->buffer.second) return; } srcData += len; srcLength -= len; } } void object_write_bencode_c_char(object_write_data_t* output, char src) { if (output->pos == output->buffer.second) { output->buffer = output->writeFunc(output->data, output->buffer); output->pos = output->buffer.first; if (output->buffer.first == output->buffer.second) return; } *output->pos++ = src; } // A new wheel. Look, how shiny and new. void object_write_bencode_c_value(object_write_data_t* output, int64_t src) { if (src == 0) return object_write_bencode_c_char(output, '0'); if (src < 0) { object_write_bencode_c_char(output, '-'); src = -src; } char buffer[20]; char* first = buffer + 20; // We don't need locale support, so just do this directly. while (src != 0) { *--first = '0' + src % 10; src /= 10; } object_write_bencode_c_string(output, first, 20 - std::distance(buffer, first)); } inline void object_write_bencode_c_obj_value(object_write_data_t* output, int64_t value) { object_write_bencode_c_char(output, 'i'); object_write_bencode_c_value(output, value); object_write_bencode_c_char(output, 'e'); } inline void object_write_bencode_c_obj_string(object_write_data_t* output, const char* data, uint32_t size) { object_write_bencode_c_value(output, size); object_write_bencode_c_char(output, ':'); object_write_bencode_c_string(output, data, size); } inline void object_write_bencode_c_obj_string(object_write_data_t* output, const std::string& str) { object_write_bencode_c_obj_string(output, str.c_str(), str.size()); } void object_write_bencode_c_object(object_write_data_t* output, const Object* object, uint32_t skip_mask) { switch (object->type()) { case Object::TYPE_NONE: break; case Object::TYPE_RAW_BENCODE: { raw_bencode raw = object->as_raw_bencode(); object_write_bencode_c_string(output, raw.begin(), raw.size()); break; } case Object::TYPE_RAW_STRING: { raw_string raw = object->as_raw_string(); object_write_bencode_c_value(output, raw.size()); object_write_bencode_c_char(output, ':'); object_write_bencode_c_string(output, raw.begin(), raw.size()); break; } case Object::TYPE_RAW_LIST: { raw_list raw = object->as_raw_list(); object_write_bencode_c_char(output, 'l'); object_write_bencode_c_string(output, raw.begin(), raw.size()); object_write_bencode_c_char(output, 'e'); break; } case Object::TYPE_RAW_MAP: { raw_map raw = object->as_raw_map(); object_write_bencode_c_char(output, 'd'); object_write_bencode_c_string(output, raw.begin(), raw.size()); object_write_bencode_c_char(output, 'e'); break; } case Object::TYPE_VALUE: object_write_bencode_c_obj_value(output, object->as_value()); break; case Object::TYPE_STRING: object_write_bencode_c_obj_string(output, object->as_string()); break; case Object::TYPE_LIST: object_write_bencode_c_char(output, 'l'); for (Object::list_const_iterator itr = object->as_list().begin(), last = object->as_list().end(); itr != last; ++itr) { if (itr->is_empty() || itr->flags() & skip_mask) continue; object_write_bencode_c_object(output, &*itr, skip_mask); } object_write_bencode_c_char(output, 'e'); break; case Object::TYPE_MAP: object_write_bencode_c_char(output, 'd'); for (Object::map_const_iterator itr = object->as_map().begin(), last = object->as_map().end(); itr != last; ++itr) { if (itr->second.is_empty() || itr->second.flags() & skip_mask) continue; object_write_bencode_c_obj_string(output, itr->first); object_write_bencode_c_object(output, &itr->second, skip_mask); } object_write_bencode_c_char(output, 'e'); break; case Object::TYPE_DICT_KEY: throw torrent::bencode_error("Cannot bencode internal dict_key type."); break; } } void object_write_bencode(std::ostream* output, const Object* object, uint32_t skip_mask) { char buffer[1024]; object_write_bencode_c(&object_write_to_stream, output, object_buffer_t(buffer, buffer + 1024), object, skip_mask); } object_buffer_t object_write_bencode(char* first, char* last, const Object* object, uint32_t skip_mask) { object_buffer_t buffer = object_buffer_t(first, last); return object_write_bencode_c(&object_write_to_buffer, &buffer, buffer, object, skip_mask); } object_buffer_t object_write_bencode_c(object_write_t writeFunc, void* data, object_buffer_t buffer, const Object* object, uint32_t skip_mask) { object_write_data_t output; output.writeFunc = writeFunc; output.data = data; output.buffer = buffer; output.pos = buffer.first; if (!(object->flags() & skip_mask)) object_write_bencode_c_object(&output, object, skip_mask); // Don't flush the buffer. if (output.pos == output.buffer.first) return output.buffer; return output.writeFunc(output.data, object_buffer_t(output.buffer.first, output.pos)); } object_buffer_t object_write_to_buffer(void* data, object_buffer_t buffer) { if (buffer.first == buffer.second) throw internal_error("object_write_to_buffer(...) buffer overflow."); // Hmm... this does something weird... return object_buffer_t(buffer.second, buffer.second); } object_buffer_t object_write_to_sha1(void* data, object_buffer_t buffer) { reinterpret_cast(data)->update(buffer.first, std::distance(buffer.first, buffer.second)); return buffer; } object_buffer_t object_write_to_stream(void* data, object_buffer_t buffer) { reinterpret_cast(data)->write(buffer.first, std::distance(buffer.first, buffer.second)); if (reinterpret_cast(data)->bad()) return object_buffer_t(buffer.first, buffer.first); return buffer; } object_buffer_t object_write_to_size(void* data, object_buffer_t buffer) { *reinterpret_cast(data) += std::distance(buffer.first, buffer.second); return buffer; } // // static_map operations: // const char* static_map_read_bencode_c(const char* first, const char* last, static_map_entry_type* entry_values, const static_map_mapping_type* first_key, const static_map_mapping_type* last_key) { // Temp hack... validate that we got valid bencode data... // { // torrent::Object obj; // if (object_read_bencode_c(first, last, &obj) != last) { // std::string escaped = rak::copy_escape_html(first, last); // char buffer[1024]; // sprintf(buffer, "Verified wrong, %u, '%u', '%s'.", std::distance(first, last), (unsigned int)*first, escaped.c_str()); // throw torrent::internal_error("Invalid bencode data."); // } // } if (first == last || *first++ != 'd') throw torrent::bencode_error("Invalid bencode data."); static_map_stack_type stack[8]; static_map_stack_type* stack_itr = stack; stack_itr->clear(); char current_key[static_map_mapping_type::max_key_size + 2] = ""; while (first != last) { // End a dictionary/list or the whole stream. if (*first == 'e') { first++; if (stack_itr == stack) return first; stack_itr--; continue; } raw_string raw_key = object_read_bencode_c_string(first, last); first = raw_key.end(); // Optimze this buy directly copying into 'current_key'. // // The max length of 'current_key' is one char more than the // mapping key so any bencode which exceeds that will always fail // to find a match. if (raw_key.size() >= static_map_mapping_type::max_key_size - stack_itr->next_key) { first = object_read_bencode_skip_c(first, last); continue; } memcpy(current_key + stack_itr->next_key, raw_key.data(), raw_key.size()); current_key[stack_itr->next_key + raw_key.size()] = '\0'; // Locate the right key. Optimize this by remembering previous // position... static_map_key_search_result key_search = find_key_match(first_key, last_key, current_key); // We're not interest in this object, skip it. if (key_search.second == 0) { first = object_read_bencode_skip_c(first, last); continue; } // Check if we're interested in any dictionaries/lists entries // under this key. // // Note that 'find_key_match' only returns 'key_search.second != // 0' for keys where the next characters are '\0', '::' or '[]'. switch (key_search.first->key[key_search.second]) { case '\0': first = object_read_bencode_c(first, last, &entry_values[key_search.first->index].object); first_key = key_search.first + 1; break; case '*': first = object_read_bencode_raw_c(first, last, &entry_values[key_search.first->index].object, key_search.first->key[key_search.second + 1]); first_key = key_search.first + 1; break; case ':': if (first == last) break; // The bencode object isn't a list. This should either skip it // or produce an error. if (*first++ != 'd') { first = object_read_bencode_skip_c(first - 1, last); break; } stack_itr++; stack_itr->set_key_index((stack_itr - 1)->next_key, key_search.second, 2); current_key[key_search.second] = ':'; current_key[key_search.second + 1] = ':'; break; case '[': { if (first == last) break; // The bencode object isn't a list. This should either skip it // or produce an error. if (*first++ != 'l') { first = object_read_bencode_skip_c(first - 1, last); break; } first_key = key_search.first; while (first != last) { if (*first == 'e') { first++; break; } if (first_key->key[key_search.second + 2] == '*') { first = object_read_bencode_raw_c(first, last, &entry_values[first_key->index].object, key_search.first->key[key_search.second + 1]); } else { first = object_read_bencode_c(first, last, &entry_values[first_key->index].object); } if (++first_key == last_key || strcmp(first_key->key, (first_key - 1)->key) != 0) { while (first != last) { if (*first == 'e') { first++; break; } first = object_read_bencode_skip_c(first, last); } break; } } break; } default: throw internal_error("static_map_read_bencode_c: key_search.first->key[base] returned invalid character."); }; } throw torrent::bencode_error("Invalid bencode data."); } void static_map_write_bencode_c_values(object_write_data_t* output, const static_map_entry_type* entry_values, const static_map_mapping_type* first_key, const static_map_mapping_type* last_key) { const char* prev_key = NULL; static_map_stack_type stack[8]; static_map_stack_type* stack_itr = stack; stack_itr->clear(); object_write_bencode_c_char(output, 'd'); while (first_key != last_key) { if (entry_values[first_key->index].object.is_empty()) { first_key++; continue; } // Compare the keys to see if they are part of the same // dictionaries/lists. unsigned int base_size = rak::count_base(first_key->key, first_key->key + stack_itr->next_key, prev_key, prev_key + stack_itr->next_key); while (base_size < stack_itr->next_key) { object_write_bencode_c_char(output, 'e'); stack_itr--; } const char* key_begin = first_key->key + stack_itr->next_key; do { const char* key_end = first_key->find_key_end(key_begin); if (stack_itr->obj_type == Object::TYPE_MAP) object_write_bencode_c_obj_string(output, key_begin, std::distance(key_begin, key_end)); // Check if '::' or '[' were found... if (*key_end == ':' && *(key_end + 1) == ':') { (++stack_itr)->set_key_index(std::distance(first_key->key, key_begin), std::distance(first_key->key, key_end), 2); key_begin = key_end + 2; object_write_bencode_c_char(output, 'd'); continue; } // Handle "foo[]..." entries. We iterate once for each "foo[]" // found in the key list. if (*key_end == '[' && *(key_end + 1) == ']') { (++stack_itr)->set_key_index(std::distance(first_key->key, key_begin), std::distance(first_key->key, key_end), 2, Object::TYPE_LIST); key_begin = key_end + 2; object_write_bencode_c_char(output, 'l'); continue; } // We have a leaf object. if (*key_end != '\0' && *key_end != '*') throw internal_error("static_map_type key is invalid."); object_write_bencode_c_object(output, &entry_values[first_key->index].object, 0); break; } while (true); prev_key = (first_key++)->key; } do { object_write_bencode_c_char(output, 'e'); } while (stack_itr-- != stack); } object_buffer_t static_map_write_bencode_c_wrap(object_write_t writeFunc, void* data, object_buffer_t buffer, const static_map_entry_type* entry_values, const static_map_mapping_type* first_key, const static_map_mapping_type* last_key) { object_write_data_t output; output.writeFunc = writeFunc; output.data = data; output.buffer = buffer; output.pos = buffer.first; static_map_write_bencode_c_values(&output, entry_values, first_key, last_key); // DEBUG: Remove this. // { // torrent::Object obj; // if (object_read_bencode_c(output.buffer.first, output.pos, &obj) != output.pos) { // std::string escaped = rak::copy_escape_html(output.buffer.first, output.pos); // //char buffer[1024]; // // sprintf(buffer, "Verified wrong, %u, '%u', '%s'.", std::distanescaped.c_str()); // throw torrent::internal_error("Invalid bencode data generated: '" + escaped + "'"); // } // } // Don't flush the buffer. if (output.pos == output.buffer.first) return output.buffer; return output.writeFunc(output.data, object_buffer_t(output.buffer.first, output.pos)); } } libtorrent-0.13.2/src/torrent/object_stream.h000644 000765 000024 00000013035 11705767056 022217 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_OBJECT_STREAM_H #define LIBTORRENT_OBJECT_STREAM_H #include #include #include namespace torrent { class raw_string; std::string object_sha1(const Object* object) LIBTORRENT_EXPORT; raw_string object_read_bencode_c_string(const char* first, const char* last) LIBTORRENT_EXPORT; // Assumes the stream's locale has been set to POSIX or C. Max depth // is 1024, this ensures files consisting of only 'l' don't segfault // the client. void object_read_bencode(std::istream* input, Object* object, uint32_t depth = 0) LIBTORRENT_EXPORT; const char* object_read_bencode_c(const char* first, const char* last, Object* object, uint32_t depth = 0) LIBTORRENT_EXPORT; const char* object_read_bencode_skip_c(const char* first, const char* last) LIBTORRENT_EXPORT; std::istream& operator >> (std::istream& input, Object& object) LIBTORRENT_EXPORT; std::ostream& operator << (std::ostream& output, const Object& object) LIBTORRENT_EXPORT; // object_buffer_t contains the start and end of the buffer. typedef std::pair object_buffer_t; typedef object_buffer_t (*object_write_t)(void* data, object_buffer_t buffer); // Assumes the stream's locale has been set to POSIX or C. void object_write_bencode(std::ostream* output, const Object* object, uint32_t skip_mask = 0) LIBTORRENT_EXPORT; object_buffer_t object_write_bencode(char* first, char* last, const Object* object, uint32_t skip_mask = 0) LIBTORRENT_EXPORT; object_buffer_t object_write_bencode_c(object_write_t writeFunc, void* data, object_buffer_t buffer, const Object* object, uint32_t skip_mask = 0) LIBTORRENT_EXPORT; // To char buffer. 'data' is NULL. object_buffer_t object_write_to_buffer(void* data, object_buffer_t buffer) LIBTORRENT_EXPORT; object_buffer_t object_write_to_sha1(void* data, object_buffer_t buffer) LIBTORRENT_EXPORT; object_buffer_t object_write_to_stream(void* data, object_buffer_t buffer) LIBTORRENT_EXPORT; // Measures bencode size, 'data' is uint64_t*. object_buffer_t object_write_to_size(void* data, object_buffer_t buffer) LIBTORRENT_EXPORT; // // static_map operations: // template class static_map_type; struct static_map_mapping_type; struct static_map_entry_type; // Convert buffer to static key map. Inlined because we don't want // a separate wrapper function for each template argument. template inline const char* static_map_read_bencode(const char* first, const char* last, static_map_type& object) { return static_map_read_bencode_c(first, last, object.values(), object.keys, object.keys + object.size); }; template inline object_buffer_t static_map_write_bencode_c(object_write_t writeFunc, void* data, object_buffer_t buffer, const static_map_type& object) { return static_map_write_bencode_c_wrap(writeFunc, data, buffer, object.values(), object.keys, object.keys + object.size); } const char* static_map_read_bencode_c(const char* first, const char* last, static_map_entry_type* entry_values, const static_map_mapping_type* first_key, const static_map_mapping_type* last_key) LIBTORRENT_EXPORT; object_buffer_t static_map_write_bencode_c_wrap(object_write_t writeFunc, void* data, object_buffer_t buffer, const static_map_entry_type* entry_values, const static_map_mapping_type* first_key, const static_map_mapping_type* last_key) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/path.cc000644 000765 000024 00000004423 11705767056 020471 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "exceptions.h" #include "path.h" namespace torrent { void Path::insert_path(iterator pos, const std::string& path) { std::string::const_iterator first = path.begin(); std::string::const_iterator last; while (first != path.end()) { pos = insert(pos, std::string(first, (last = std::find(first, path.end(), '/')))); if (last == path.end()) return; first = last; first++; } } std::string Path::as_string() const { if (empty()) return std::string(); std::string s; for (const_iterator itr = begin(); itr != end(); ++itr) { s += '/'; s += *itr; } return s; } } libtorrent-0.13.2/src/torrent/path.h000644 000765 000024 00000007072 11705767056 020336 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PATH_H #define LIBTORRENT_PATH_H #include #include #include namespace torrent { // Use a blank first path to get root and "." to get current dir. class LIBTORRENT_EXPORT Path : private std::vector { public: typedef std::vector base_type; typedef base_type::value_type value_type; typedef base_type::pointer pointer; typedef base_type::const_pointer const_pointer; typedef base_type::reference reference; typedef base_type::const_reference const_reference; typedef base_type::size_type size_type; typedef base_type::difference_type difference_type; typedef base_type::allocator_type allocator_type; typedef base_type::iterator iterator; typedef base_type::reverse_iterator reverse_iterator; typedef base_type::const_iterator const_iterator; typedef base_type::const_reverse_iterator const_reverse_iterator; using base_type::clear; using base_type::empty; using base_type::size; using base_type::reserve; using base_type::front; using base_type::back; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::push_back; using base_type::at; using base_type::operator[]; void insert_path(iterator pos, const std::string& path); // Return the path as a string with '/' deliminator. The deliminator // is only inserted between path elements. std::string as_string() const; const std::string encoding() const { return m_encoding; } void set_encoding(const std::string& enc) { m_encoding = enc; } base_type* base() { return this; } const base_type* base() const { return this; } private: std::string m_encoding; }; } #endif libtorrent-0.13.2/src/torrent/peer/000755 000765 000024 00000000000 11744204513 020141 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/torrent/poll.h000644 000765 000024 00000007341 11716356561 020344 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TORRENT_POLL_H #define LIBTORRENT_TORRENT_POLL_H #include #include namespace torrent { class Event; class LIBTORRENT_EXPORT Poll { public: typedef std::tr1::function slot_poll; static const int poll_worker_thread = 0x1; static const uint32_t flag_waive_global_lock = 0x1; Poll() : m_flags(0) {} virtual ~Poll() {} uint32_t flags() const { return m_flags; } void set_flags(uint32_t flags) { m_flags = flags; } virtual void do_poll(int64_t timeout_usec, int flags = 0) = 0; // The open max value is used when initializing libtorrent, it // should be less than or equal to sysconf(_SC_OPEN_MAX). virtual uint32_t open_max() const = 0; // Event::get_fd() is guaranteed to be valid and remain constant // from open(...) is called to close(...) returns. The implementor // of this class should not open nor close the file descriptor. virtual void open(Event* event) = 0; virtual void close(Event* event) = 0; // More efficient interface when closing the file descriptor. // Automatically removes the event from all polls. // Event::get_fd() may or may not be closed already. virtual void closed(Event* event) = 0; // Functions for checking whetever the Event is listening to r/w/e? virtual bool in_read(Event* event) = 0; virtual bool in_write(Event* event) = 0; virtual bool in_error(Event* event) = 0; // These functions may be called on 'event's that might, or might // not, already be in the set. virtual void insert_read(Event* event) = 0; virtual void insert_write(Event* event) = 0; virtual void insert_error(Event* event) = 0; virtual void remove_read(Event* event) = 0; virtual void remove_write(Event* event) = 0; virtual void remove_error(Event* event) = 0; // Add one for HUP? Or would that be in event? static slot_poll& slot_create_poll() { return m_slot_create_poll; } private: static slot_poll m_slot_create_poll; uint32_t m_flags; }; } #endif libtorrent-0.13.2/src/torrent/poll_epoll.cc000644 000765 000024 00000025300 11716630446 021665 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include #include #include "torrent.h" #include "poll_epoll.h" #include "utils/log.h" #include "utils/thread_base.h" #include "rak/error_number.h" #include "rak/timer.h" #ifdef USE_EPOLL #include #endif #define LT_LOG_EVENT(event, log_level, log_fmt, ...) \ lt_log_print(LOG_SOCKET_##log_level, "epoll->%s(%i): " log_fmt, event->type_name(), event->file_descriptor(), __VA_ARGS__); namespace torrent { #ifdef USE_EPOLL inline uint32_t PollEPoll::event_mask(Event* e) { Table::value_type entry = m_table[e->file_descriptor()]; return entry.second != e ? 0 : entry.first; } inline void PollEPoll::set_event_mask(Event* e, uint32_t m) { m_table[e->file_descriptor()] = Table::value_type(m, e); } inline void PollEPoll::modify(Event* event, int op, uint32_t mask) { if (event_mask(event) == mask) return; LT_LOG_EVENT(event, DEBUG, "Modify event: op:%hx mask:%hx.", op, mask); epoll_event e; e.data.u64 = 0; // Make valgrind happy? Remove please. e.data.fd = event->file_descriptor(); e.events = mask; set_event_mask(event, mask); if (epoll_ctl(m_fd, op, event->file_descriptor(), &e)) { // Socket was probably already closed. Ignore this. if (op == EPOLL_CTL_DEL && errno == ENOENT) return; // Handle some libcurl/c-ares bugs by retrying once. int retry = op; if (op == EPOLL_CTL_ADD && errno == EEXIST) { retry = EPOLL_CTL_MOD; errno = 0; } else if (op == EPOLL_CTL_MOD && errno == ENOENT) { retry = EPOLL_CTL_ADD; errno = 0; } if (errno || epoll_ctl(m_fd, retry, event->file_descriptor(), &e)) { char errmsg[1024]; snprintf(errmsg, sizeof(errmsg), "PollEPoll::modify(...) epoll_ctl(%d, %d -> %d, %d, [%p:%x]) = %d: %s", m_fd, op, retry, event->file_descriptor(), event, mask, errno, strerror(errno)); throw internal_error(errmsg); } } } PollEPoll* PollEPoll::create(int maxOpenSockets) { int fd = epoll_create(maxOpenSockets); if (fd == -1) return NULL; return new PollEPoll(fd, 1024, maxOpenSockets); } PollEPoll::PollEPoll(int fd, int maxEvents, int maxOpenSockets) : m_fd(fd), m_maxEvents(maxEvents), m_waitingEvents(0), m_events(new epoll_event[m_maxEvents]) { m_table.resize(maxOpenSockets); } PollEPoll::~PollEPoll() { m_table.clear(); delete [] m_events; ::close(m_fd); } int PollEPoll::poll(int msec) { int nfds = epoll_wait(m_fd, m_events, m_maxEvents, msec); if (nfds == -1) return -1; return m_waitingEvents = nfds; } // We check m_table to make sure the Event is still listening to the // event, so it is safe to remove Event's while in working. // // TODO: Do we want to guarantee if the Event has been removed from // some event but not closed, it won't call that event? Think so... void PollEPoll::perform() { for (epoll_event *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr) { if (itr->data.fd < 0 || (size_t)itr->data.fd >= m_table.size()) continue; if ((flags() & flag_waive_global_lock) && thread_base::global_queue_size() != 0) thread_base::waive_global_lock(); Table::iterator evItr = m_table.begin() + itr->data.fd; // Each branch must check for data.ptr != NULL to allow the socket // to remove itself between the calls. // // TODO: Make it so that it checks that read/write is wanted, that // it wasn't removed from one of them but not closed. if (itr->events & EPOLLERR && evItr->second != NULL && evItr->first & EPOLLERR) evItr->second->event_error(); if (itr->events & EPOLLIN && evItr->second != NULL && evItr->first & EPOLLIN) evItr->second->event_read(); if (itr->events & EPOLLOUT && evItr->second != NULL && evItr->first & EPOLLOUT) evItr->second->event_write(); } m_waitingEvents = 0; } void PollEPoll::do_poll(int64_t timeout_usec, int flags) { rak::timer timeout = rak::timer(timeout_usec); timeout += 10; if (!(flags & poll_worker_thread)) { thread_base::release_global_lock(); thread_base::entering_main_polling(); } int status = poll((timeout.usec() + 999) / 1000); if (!(flags & poll_worker_thread)) { thread_base::leaving_main_polling(); thread_base::acquire_global_lock(); } if (status == -1 && rak::error_number::current().value() != rak::error_number::e_intr) throw std::runtime_error("Poll::work(): " + std::string(rak::error_number::current().c_str())); perform(); } uint32_t PollEPoll::open_max() const { return m_table.size(); } void PollEPoll::open(Event* event) { LT_LOG_EVENT(event, DEBUG, "Open event.", 0); if (event_mask(event) != 0) throw internal_error("PollEPoll::open(...) called but the file descriptor is active"); } void PollEPoll::close(Event* event) { LT_LOG_EVENT(event, DEBUG, "Close event.", 0); if (event_mask(event) != 0) throw internal_error("PollEPoll::close(...) called but the file descriptor is active"); m_table[event->file_descriptor()] = Table::value_type(); // Clear the event list just in case we open a new socket with the // same fd while in the middle of calling PollEPoll::perform. for (epoll_event *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr) if (itr->data.fd == event->file_descriptor()) itr->events = 0; } void PollEPoll::closed(Event* event) { LT_LOG_EVENT(event, DEBUG, "Closed event.", 0); // Kernel removes closed FDs automatically, so just clear the mask and remove it from pending calls. // Don't touch if the FD was re-used before we received the close notification. if (m_table[event->file_descriptor()].second == event) m_table[event->file_descriptor()] = Table::value_type(); // for (epoll_event *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr) { // if (itr->data.fd == event->file_descriptor()) // itr->events = 0; // } } // Use custom defines for EPOLL* to make the below code compile with // and with epoll. bool PollEPoll::in_read(Event* event) { return event_mask(event) & EPOLLIN; } bool PollEPoll::in_write(Event* event) { return event_mask(event) & EPOLLOUT; } bool PollEPoll::in_error(Event* event) { return event_mask(event) & EPOLLERR; } void PollEPoll::insert_read(Event* event) { LT_LOG_EVENT(event, DEBUG, "Insert read.", 0); modify(event, event_mask(event) ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, event_mask(event) | EPOLLIN); } void PollEPoll::insert_write(Event* event) { LT_LOG_EVENT(event, DEBUG, "Insert write.", 0); modify(event, event_mask(event) ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, event_mask(event) | EPOLLOUT); } void PollEPoll::insert_error(Event* event) { LT_LOG_EVENT(event, DEBUG, "Insert error.", 0); modify(event, event_mask(event) ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, event_mask(event) | EPOLLERR); } void PollEPoll::remove_read(Event* event) { LT_LOG_EVENT(event, DEBUG, "Remove read.", 0); uint32_t mask = event_mask(event) & ~EPOLLIN; modify(event, mask ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, mask); } void PollEPoll::remove_write(Event* event) { LT_LOG_EVENT(event, DEBUG, "Remove write.", 0); uint32_t mask = event_mask(event) & ~EPOLLOUT; modify(event, mask ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, mask); } void PollEPoll::remove_error(Event* event) { LT_LOG_EVENT(event, DEBUG, "Remove error.", 0); uint32_t mask = event_mask(event) & ~EPOLLERR; modify(event, mask ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, mask); } #else // USE_EPOLL PollEPoll* PollEPoll::create(int maxOpenSockets) { return NULL; } PollEPoll::~PollEPoll() {} int PollEPoll::poll(int msec) { throw internal_error("An PollEPoll function was called, but it is disabled."); } void PollEPoll::perform() { throw internal_error("An PollEPoll function was called, but it is disabled."); } void PollEPoll::do_poll(int64_t timeout_usec, int flags) { throw internal_error("An PollEPoll function was called, but it is disabled."); } uint32_t PollEPoll::open_max() const { throw internal_error("An PollEPoll function was called, but it is disabled."); } void PollEPoll::open(torrent::Event* event) {} void PollEPoll::close(torrent::Event* event) {} void PollEPoll::closed(torrent::Event* event) {} bool PollEPoll::in_read(torrent::Event* event) { throw internal_error("An PollEPoll function was called, but it is disabled."); } bool PollEPoll::in_write(torrent::Event* event) { throw internal_error("An PollEPoll function was called, but it is disabled."); } bool PollEPoll::in_error(torrent::Event* event) { throw internal_error("An PollEPoll function was called, but it is disabled."); } void PollEPoll::insert_read(torrent::Event* event) {} void PollEPoll::insert_write(torrent::Event* event) {} void PollEPoll::insert_error(torrent::Event* event) {} void PollEPoll::remove_read(torrent::Event* event) {} void PollEPoll::remove_write(torrent::Event* event) {} void PollEPoll::remove_error(torrent::Event* event) {} PollEPoll::PollEPoll(int fd, int maxEvents, int maxOpenSockets) { throw internal_error("An PollEPoll function was called, but it is disabled."); } #endif // USE_EPOLL } libtorrent-0.13.2/src/torrent/poll_epoll.h000644 000765 000024 00000007237 11716350717 021540 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TORRENT_POLL_EPOLL_H #define LIBTORRENT_TORRENT_POLL_EPOLL_H #include #include struct epoll_event; namespace torrent { class LIBTORRENT_EXPORT PollEPoll : public torrent::Poll { public: typedef std::vector > Table; static PollEPoll* create(int maxOpenSockets); virtual ~PollEPoll(); int poll(int msec); void perform(); void do_poll(int64_t timeout_usec, int flags = 0); int file_descriptor() { return m_fd; } virtual uint32_t open_max() const; // torrent::Event::get_fd() is guaranteed to be valid and remain constant // from open(...) is called to close(...) returns. virtual void open(torrent::Event* event); virtual void close(torrent::Event* event); // torrent::Event::get_fd() was closed outside of our control. virtual void closed(torrent::Event* event); // Functions for checking whetever the torrent::Event is listening to r/w/e? virtual bool in_read(torrent::Event* event); virtual bool in_write(torrent::Event* event); virtual bool in_error(torrent::Event* event); // These functions may be called on 'event's that might, or might // not, already be in the set. virtual void insert_read(torrent::Event* event); virtual void insert_write(torrent::Event* event); virtual void insert_error(torrent::Event* event); virtual void remove_read(torrent::Event* event); virtual void remove_write(torrent::Event* event); virtual void remove_error(torrent::Event* event); private: PollEPoll(int fd, int maxEvents, int maxOpenSockets); inline uint32_t event_mask(Event* e); inline void set_event_mask(Event* e, uint32_t m); inline void modify(torrent::Event* event, int op, uint32_t mask); int m_fd; int m_maxEvents; int m_waitingEvents; Table m_table; epoll_event* m_events; }; } #endif libtorrent-0.13.2/src/torrent/poll_kqueue.cc000644 000765 000024 00000031450 11716630446 022054 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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.213 // If you delete this exception statement from all source files in the // program, then also delete it here. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include #include #include "poll_kqueue.h" #include "torrent.h" #include "rak/timer.h" #include "rak/error_number.h" #include "utils/log.h" #include "utils/thread_base.h" #ifdef USE_KQUEUE #include #include #include #include #endif #include #define LT_LOG_EVENT(event, log_level, log_fmt, ...) \ lt_log_print(LOG_SOCKET_##log_level, "kqueue->%s(%i): " log_fmt, event->type_name(), event->file_descriptor(), __VA_ARGS__); namespace torrent { #ifdef USE_KQUEUE inline uint32_t PollKQueue::event_mask(Event* e) { assert(e->file_descriptor() != -1); Table::value_type entry = m_table[e->file_descriptor()]; return entry.second != e ? 0 : entry.first; } inline void PollKQueue::set_event_mask(Event* e, uint32_t m) { assert(e->file_descriptor() != -1); m_table[e->file_descriptor()] = Table::value_type(m, e); } void PollKQueue::flush_events() { timespec timeout = { 0, 0 }; int nfds = kevent(m_fd, m_changes, m_changedEvents, m_events + m_waitingEvents, m_maxEvents - m_waitingEvents, &timeout); if (nfds == -1) throw internal_error("PollKQueue::flush_events() error: " + std::string(rak::error_number::current().c_str())); m_changedEvents = 0; m_waitingEvents += nfds; } void PollKQueue::modify(Event* event, unsigned short op, short mask) { LT_LOG_EVENT(event, DEBUG, "Modify event: op:%hx mask:%hx changed:%u.", op, mask, m_changedEvents); // Flush the changed filters to the kernel if the buffer is full. if (m_changedEvents == m_maxEvents) { if (kevent(m_fd, m_changes, m_changedEvents, NULL, 0, NULL) == -1) throw internal_error("PollKQueue::modify() error: " + std::string(rak::error_number::current().c_str())); m_changedEvents = 0; } struct kevent* itr = m_changes + (m_changedEvents++); assert(event == m_table[event->file_descriptor()].second); EV_SET(itr, event->file_descriptor(), mask, op, 0, 0, NULL); } PollKQueue* PollKQueue::create(int maxOpenSockets) { int fd = kqueue(); if (fd == -1) return NULL; return new PollKQueue(fd, 1024, maxOpenSockets); } PollKQueue::PollKQueue(int fd, int maxEvents, int maxOpenSockets) : m_fd(fd), m_maxEvents(maxEvents), m_waitingEvents(0), m_changedEvents(0), m_stdinEvent(NULL) { m_events = new struct kevent[m_maxEvents]; m_changes = new struct kevent[maxOpenSockets]; m_table.resize(maxOpenSockets); } PollKQueue::~PollKQueue() { m_table.clear(); delete [] m_events; delete [] m_changes; ::close(m_fd); } int PollKQueue::poll(int msec) { #if KQUEUE_SOCKET_ONLY if (m_stdinEvent != NULL) { // Flush all changes to the kqueue poll before we start select // polling, so that they get included. if (m_changedEvents != 0) flush_events(); if (poll_select(msec) == -1) return -1; // The timeout was already handled in select(). msec = 0; } #endif timespec timeout = { msec / 1000, (msec % 1000) * 1000000 }; int nfds = kevent(m_fd, m_changes, m_changedEvents, m_events + m_waitingEvents, m_maxEvents - m_waitingEvents, &timeout); // Clear the changed events even on fail as we might have received a // signal or similar, and the changed events have already been // consumed. // // There's a chance a bad changed event could make kevent return -1, // but it won't as long as there is room enough in m_events. m_changedEvents = 0; if (nfds == -1) return -1; m_waitingEvents += nfds; return nfds; } #if KQUEUE_SOCKET_ONLY int PollKQueue::poll_select(int msec) { if (m_waitingEvents >= m_maxEvents) return 0; timeval selectTimeout = { msec / 1000, (msec % 1000) * 1000 }; // If m_fd isn't the first FD opened by the client and has // a low number, using ::poll() here would perform better. // // This kinda assumes fd_set's internal type is int. int readBuffer[m_fd + 1]; fd_set* readSet = (fd_set*)&readBuffer; std::memset(readBuffer, 0, m_fd + 1); FD_SET(0, readSet); FD_SET(m_fd, readSet); int nfds = select(m_fd + 1, readSet, NULL, NULL, &selectTimeout); if (nfds == -1) return nfds; if (FD_ISSET(0, readSet)) { m_events[m_waitingEvents].ident = 0; m_events[m_waitingEvents].filter = EVFILT_READ; m_events[m_waitingEvents].flags = 0; m_waitingEvents++; } return nfds; } #endif void PollKQueue::perform() { for (struct kevent *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr) { if (itr->ident >= m_table.size()) continue; if ((flags() & flag_waive_global_lock) && thread_base::global_queue_size() != 0) thread_base::waive_global_lock(); Table::iterator evItr = m_table.begin() + itr->ident; if ((itr->flags & EV_ERROR) && evItr->second != NULL) { if (evItr->first & flag_error) evItr->second->event_error(); continue; } // Also check current mask. if (itr->filter == EVFILT_READ && evItr->second != NULL && evItr->first & flag_read) evItr->second->event_read(); if (itr->filter == EVFILT_WRITE && evItr->second != NULL && evItr->first & flag_write) evItr->second->event_write(); } m_waitingEvents = 0; } void PollKQueue::do_poll(int64_t timeout_usec, int flags) { rak::timer timeout = rak::timer(timeout_usec); timeout += 10; if (!(flags & poll_worker_thread)) { thread_base::release_global_lock(); thread_base::entering_main_polling(); } int status = poll((timeout.usec() + 999) / 1000); if (!(flags & poll_worker_thread)) { thread_base::leaving_main_polling(); thread_base::acquire_global_lock(); } if (status == -1 && rak::error_number::current().value() != rak::error_number::e_intr) throw std::runtime_error("Poll::work(): " + std::string(rak::error_number::current().c_str())); perform(); } uint32_t PollKQueue::open_max() const { return m_table.size(); } void PollKQueue::open(Event* event) { LT_LOG_EVENT(event, DEBUG, "Open event.", 0); if (event_mask(event) != 0) throw internal_error("PollKQueue::open(...) called but the file descriptor is active"); } void PollKQueue::close(Event* event) { LT_LOG_EVENT(event, DEBUG, "Close event.", 0); #if KQUEUE_SOCKET_ONLY if (event->file_descriptor() == 0) { m_stdinEvent = NULL; return; } #endif if (event_mask(event) != 0) throw internal_error("PollKQueue::close(...) called but the file descriptor is active"); m_table[event->file_descriptor()] = Table::value_type(); /* Shouldn't be needed anymore. for (struct kevent *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr) if (itr->udata == event) itr->udata = NULL; m_changedEvents = std::remove_if(m_changes, m_changes + m_changedEvents, rak::equal(event, rak::mem_ref(&kevent::udata))) - m_changes; */ } void PollKQueue::closed(Event* event) { LT_LOG_EVENT(event, DEBUG, "Closed event.", 0); #if KQUEUE_SOCKET_ONLY if (event->file_descriptor() == 0) { m_stdinEvent = NULL; return; } #endif // Kernel removes closed FDs automatically, so just clear the mask // and remove it from pending calls. Don't touch if the FD was // re-used before we received the close notification. if (m_table[event->file_descriptor()].second == event) m_table[event->file_descriptor()] = Table::value_type(); /* for (struct kevent *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr) { if (itr->udata == event) itr->udata = NULL; } m_changedEvents = std::remove_if(m_changes, m_changes + m_changedEvents, rak::equal(event, rak::mem_ref(&kevent::udata))) - m_changes; */ } // Use custom defines for EPOLL* to make the below code compile with // and with epoll. bool PollKQueue::in_read(Event* event) { return event_mask(event) & flag_read; } bool PollKQueue::in_write(Event* event) { return event_mask(event) & flag_write; } bool PollKQueue::in_error(Event* event) { return event_mask(event) & flag_error; } void PollKQueue::insert_read(Event* event) { if (event_mask(event) & flag_read) return; LT_LOG_EVENT(event, DEBUG, "Insert read.", 0); set_event_mask(event, event_mask(event) | flag_read); #if KQUEUE_SOCKET_ONLY if (event->file_descriptor() == 0) { m_stdinEvent = event; return; } #endif modify(event, EV_ADD, EVFILT_READ); } void PollKQueue::insert_write(Event* event) { if (event_mask(event) & flag_write) return; LT_LOG_EVENT(event, DEBUG, "Insert write.", 0); set_event_mask(event, event_mask(event) | flag_write); modify(event, EV_ADD, EVFILT_WRITE); } void PollKQueue::insert_error(Event* event) { LT_LOG_EVENT(event, DEBUG, "Insert error.", 0); } void PollKQueue::remove_read(Event* event) { if (!(event_mask(event) & flag_read)) return; LT_LOG_EVENT(event, DEBUG, "Remove read.", 0); set_event_mask(event, event_mask(event) & ~flag_read); #if KQUEUE_SOCKET_ONLY if (event->file_descriptor() == 0) { m_stdinEvent = NULL; return; } #endif modify(event, EV_DELETE, EVFILT_READ); } void PollKQueue::remove_write(Event* event) { if (!(event_mask(event) & flag_write)) return; LT_LOG_EVENT(event, DEBUG, "Remove write.", 0); set_event_mask(event, event_mask(event) & ~flag_write); modify(event, EV_DELETE, EVFILT_WRITE); } void PollKQueue::remove_error(Event* event) { LT_LOG_EVENT(event, DEBUG, "Remove error.", 0); } #else // USE_QUEUE PollKQueue* PollKQueue::create(__UNUSED int maxOpenSockets) { return NULL; } PollKQueue::~PollKQueue() { } int PollKQueue::poll(__UNUSED int msec) { throw internal_error("An PollKQueue function was called, but it is disabled."); } void PollKQueue::perform() { throw internal_error("An PollKQueue function was called, but it is disabled."); } void PollKQueue::do_poll(int64_t timeout_usec, int flags) { throw internal_error("An PollKQueue function was called, but it is disabled."); } uint32_t PollKQueue::open_max() const { throw internal_error("An PollKQueue function was called, but it is disabled."); } void PollKQueue::open(__UNUSED torrent::Event* event) { } void PollKQueue::close(__UNUSED torrent::Event* event) { } void PollKQueue::closed(__UNUSED torrent::Event* event) { } bool PollKQueue::in_read(__UNUSED torrent::Event* event) { throw internal_error("An PollKQueue function was called, but it is disabled."); } bool PollKQueue::in_write(__UNUSED torrent::Event* event) { throw internal_error("An PollKQueue function was called, but it is disabled."); } bool PollKQueue::in_error(__UNUSED torrent::Event* event) { throw internal_error("An PollKQueue function was called, but it is disabled."); } void PollKQueue::insert_read(__UNUSED torrent::Event* event) { } void PollKQueue::insert_write(__UNUSED torrent::Event* event) { } void PollKQueue::insert_error(__UNUSED torrent::Event* event) { } void PollKQueue::remove_read(__UNUSED torrent::Event* event) { } void PollKQueue::remove_write(__UNUSED torrent::Event* event) { } void PollKQueue::remove_error(__UNUSED torrent::Event* event) { } PollKQueue::PollKQueue(__UNUSED int fd, __UNUSED int maxEvents, __UNUSED int maxOpenSockets) { throw internal_error("An PollKQueue function was called, but it is disabled."); } #endif // USE_KQUEUE } libtorrent-0.13.2/src/torrent/poll_kqueue.h000644 000765 000024 00000010267 11716350717 021721 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TORRENT_POLL_KQUEUE_H #define LIBTORRENT_TORRENT_POLL_KQUEUE_H #include #include struct kevent; namespace torrent { class LIBTORRENT_EXPORT PollKQueue : public torrent::Poll { public: typedef std::vector > Table; static const uint32_t flag_read = (1 << 0); static const uint32_t flag_write = (1 << 1); static const uint32_t flag_error = (1 << 2); static PollKQueue* create(int maxOpenSockets); virtual ~PollKQueue(); int poll(int msec); void perform(); void do_poll(int64_t timeout_usec, int flags = 0); int file_descriptor() { return m_fd; } virtual uint32_t open_max() const; // torrent::Event::get_fd() is guaranteed to be valid and remain constant // from open(...) is called to close(...) returns. virtual void open(torrent::Event* event); virtual void close(torrent::Event* event); // torrent::Event::get_fd() was closed outside of our control. virtual void closed(torrent::Event* event); // Functions for checking whetever the torrent::Event is listening to r/w/e? virtual bool in_read(torrent::Event* event); virtual bool in_write(torrent::Event* event); virtual bool in_error(torrent::Event* event); // These functions may be called on 'event's that might, or might // not, already be in the set. virtual void insert_read(torrent::Event* event); virtual void insert_write(torrent::Event* event); virtual void insert_error(torrent::Event* event); virtual void remove_read(torrent::Event* event); virtual void remove_write(torrent::Event* event); virtual void remove_error(torrent::Event* event); private: PollKQueue(int fd, int maxEvents, int maxOpenSockets) LIBTORRENT_NO_EXPORT; inline uint32_t event_mask(Event* e) LIBTORRENT_NO_EXPORT; inline void set_event_mask(Event* e, uint32_t m) LIBTORRENT_NO_EXPORT; int poll_select(int msec) LIBTORRENT_NO_EXPORT; void flush_events() LIBTORRENT_NO_EXPORT; void modify(torrent::Event* event, unsigned short op, short mask) LIBTORRENT_NO_EXPORT; int m_fd; unsigned int m_maxEvents; unsigned int m_waitingEvents; unsigned int m_changedEvents; Table m_table; struct kevent* m_events; struct kevent* m_changes; // Work-around the stdin bug in MacOSX's kqueue implementation. Event* m_stdinEvent; }; } #endif libtorrent-0.13.2/src/torrent/poll_select.cc000644 000765 000024 00000024634 11716630446 022042 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include "net/socket_set.h" #include "rak/allocators.h" #include "event.h" #include "exceptions.h" #include "poll_select.h" #include "torrent.h" #include "rak/timer.h" #include "rak/error_number.h" #include "utils/log.h" #include "utils/thread_base.h" #define LT_LOG_EVENT(event, log_level, log_fmt, ...) \ lt_log_print(LOG_SOCKET_##log_level, "select->%s(%i): " log_fmt, event->type_name(), event->file_descriptor(), __VA_ARGS__); namespace torrent { Poll::slot_poll Poll::m_slot_create_poll; template struct poll_check_t { poll_check_t(Poll* p, fd_set* s, _Operation op) : m_poll(p), m_set(s), m_op(op) {} void operator () (Event* s) { // This check is nessesary as other events may remove a socket // from the set. if (s == NULL) return; // This check is not nessesary, just for debugging. if (s->file_descriptor() < 0) throw internal_error("poll_check: s->fd < 0"); if (FD_ISSET(s->file_descriptor(), m_set)) { m_op(s); // We waive the global lock after an event has been processed in // order to ensure that 's' doesn't get removed before the op is // called. if ((m_poll->flags() & Poll::flag_waive_global_lock) && thread_base::global_queue_size() != 0) thread_base::waive_global_lock(); } } Poll* m_poll; fd_set* m_set; _Operation m_op; }; template inline poll_check_t<_Operation> poll_check(Poll* p, fd_set* s, _Operation op) { return poll_check_t<_Operation>(p, s, op); } struct poll_mark { poll_mark(fd_set* s, unsigned int* m) : m_max(m), m_set(s) {} void operator () (Event* s) { // Neither of these checks are nessesary, just for debugging. if (s == NULL) throw internal_error("poll_mark: s == NULL"); if (s->file_descriptor() < 0) throw internal_error("poll_mark: s->fd < 0"); *m_max = std::max(*m_max, (unsigned int)s->file_descriptor()); FD_SET(s->file_descriptor(), m_set); } unsigned int* m_max; fd_set* m_set; }; PollSelect* PollSelect::create(int maxOpenSockets) { if (maxOpenSockets <= 0) throw internal_error("PollSelect::set_open_max(...) received an invalid value"); // Just a temp hack, make some special template function for this... // // Also consider how portable this is for specialized C++ // allocators. struct block_type { PollSelect t1; SocketSet t2; SocketSet t3; SocketSet t4; }; rak::cacheline_allocator cl_alloc; block_type* block = new (cl_alloc) block_type; PollSelect* p = new (&block->t1) PollSelect; p->m_readSet = new (&block->t2) SocketSet; p->m_writeSet = new (&block->t3) SocketSet; p->m_exceptSet = new (&block->t4) SocketSet; p->m_readSet->reserve(maxOpenSockets); p->m_writeSet->reserve(maxOpenSockets); p->m_exceptSet->reserve(maxOpenSockets); return p; } PollSelect::~PollSelect() { m_readSet->prepare(); m_writeSet->prepare(); m_exceptSet->prepare(); // Re-add this check when you've cleaned up the client shutdown procedure. if (!m_readSet->empty() || !m_writeSet->empty() || !m_exceptSet->empty()) { throw internal_error("PollSelect::~PollSelect() called but the sets are not empty"); // for (SocketSet::const_iterator itr = m_readSet->begin(); itr != m_readSet->end(); itr++) // std::cout << "R" << (*itr)->file_descriptor() << std::endl; // for (SocketSet::const_iterator itr = m_writeSet->begin(); itr != m_writeSet->end(); itr++) // std::cout << "W" << (*itr)->file_descriptor() << std::endl; // for (SocketSet::const_iterator itr = m_exceptSet->begin(); itr != m_exceptSet->end(); itr++) // std::cout << "E" << (*itr)->file_descriptor() << std::endl; } // delete m_readSet; // delete m_writeSet; // delete m_exceptSet; m_readSet = m_writeSet = m_exceptSet = NULL; } uint32_t PollSelect::open_max() const { return m_readSet->max_size(); } unsigned int PollSelect::fdset(fd_set* readSet, fd_set* writeSet, fd_set* exceptSet) { unsigned int maxFd = 0; m_readSet->prepare(); std::for_each(m_readSet->begin(), m_readSet->end(), poll_mark(readSet, &maxFd)); m_writeSet->prepare(); std::for_each(m_writeSet->begin(), m_writeSet->end(), poll_mark(writeSet, &maxFd)); m_exceptSet->prepare(); std::for_each(m_exceptSet->begin(), m_exceptSet->end(), poll_mark(exceptSet, &maxFd)); return maxFd; } void PollSelect::perform(fd_set* readSet, fd_set* writeSet, fd_set* exceptSet) { // Make sure we don't do read/write on fd's that are in except. This should // not be a problem as any except call should remove it from the m_*Set's. m_exceptSet->prepare(); std::for_each(m_exceptSet->begin(), m_exceptSet->end(), poll_check(this, exceptSet, std::mem_fun(&Event::event_error))); m_readSet->prepare(); std::for_each(m_readSet->begin(), m_readSet->end(), poll_check(this, readSet, std::mem_fun(&Event::event_read))); m_writeSet->prepare(); std::for_each(m_writeSet->begin(), m_writeSet->end(), poll_check(this, writeSet, std::mem_fun(&Event::event_write))); } void PollSelect::do_poll(int64_t timeout_usec, int flags) { rak::timer timeout = rak::timer(timeout_usec); timeout += 10; uint32_t set_size = open_max(); char read_set_buffer[set_size]; char write_set_buffer[set_size]; char error_set_buffer[set_size]; fd_set* read_set = (fd_set*)read_set_buffer; fd_set* write_set = (fd_set*)write_set_buffer; fd_set* error_set = (fd_set*)error_set_buffer; std::memset(read_set_buffer, 0, set_size); std::memset(write_set_buffer, 0, set_size); std::memset(error_set_buffer, 0, set_size); unsigned int maxFd = fdset(read_set, write_set, error_set); timeval t = timeout.tval(); if (!(flags & poll_worker_thread)) { thread_base::entering_main_polling(); thread_base::release_global_lock(); } int status = select(maxFd + 1, read_set, write_set, error_set, &t); if (!(flags & poll_worker_thread)) { thread_base::leaving_main_polling(); thread_base::acquire_global_lock(); } if (status == -1 && rak::error_number::current().value() != rak::error_number::e_intr) throw std::runtime_error("Poll::work(): " + std::string(rak::error_number::current().c_str())); perform(read_set, write_set, error_set); } inline static void log_poll_open(Event* event) { #ifdef LT_LOG_POLL_OPEN static int log_fd = -1; char buffer[256]; if (log_fd == -1) { snprintf(buffer, 256, LT_LOG_POLL_OPEN, getpid()); if ((log_fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC)) == -1) throw internal_error("Could not open poll open log file."); } unsigned int buf_lenght = snprintf(buffer, 256, "open %i\n", event->fd()); #endif } void PollSelect::open(Event* event) { LT_LOG_EVENT(event, DEBUG, "Open event.", 0); if ((uint32_t)event->file_descriptor() >= m_readSet->max_size()) throw internal_error("Tried to add a socket to PollSelect that is larger than PollSelect::get_open_max()"); if (in_read(event) || in_write(event) || in_error(event)) throw internal_error("PollSelect::open(...) called on an inserted event"); } void PollSelect::close(Event* event) { LT_LOG_EVENT(event, DEBUG, "Close event.", 0); if ((uint32_t)event->file_descriptor() >= m_readSet->max_size()) throw internal_error("PollSelect::close(...) called with an invalid file descriptor"); if (in_read(event) || in_write(event) || in_error(event)) throw internal_error("PollSelect::close(...) called on an inserted event"); } void PollSelect::closed(Event* event) { LT_LOG_EVENT(event, DEBUG, "Closed event.", 0); // event->get_fd() was closed, remove it from the sets. m_readSet->erase(event); m_writeSet->erase(event); m_exceptSet->erase(event); } bool PollSelect::in_read(Event* event) { return m_readSet->find(event) != m_readSet->end(); } bool PollSelect::in_write(Event* event) { return m_writeSet->find(event) != m_writeSet->end(); } bool PollSelect::in_error(Event* event) { return m_exceptSet->find(event) != m_exceptSet->end(); } void PollSelect::insert_read(Event* event) { LT_LOG_EVENT(event, DEBUG, "Insert read.", 0); m_readSet->insert(event); } void PollSelect::insert_write(Event* event) { LT_LOG_EVENT(event, DEBUG, "Insert write.", 0); m_writeSet->insert(event); } void PollSelect::insert_error(Event* event) { LT_LOG_EVENT(event, DEBUG, "Insert error.", 0); m_exceptSet->insert(event); } void PollSelect::remove_read(Event* event) { LT_LOG_EVENT(event, DEBUG, "Remove read.", 0); m_readSet->erase(event); } void PollSelect::remove_write(Event* event) { LT_LOG_EVENT(event, DEBUG, "Remove write.", 0); m_writeSet->erase(event); } void PollSelect::remove_error(Event* event) { LT_LOG_EVENT(event, DEBUG, "Remove error.", 0); m_exceptSet->erase(event); } } libtorrent-0.13.2/src/torrent/poll_select.h000644 000765 000024 00000006401 11716350717 021674 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_POLL_SELECT_H #define LIBTORRENT_NET_POLL_SELECT_H #include #include #include namespace torrent { // The default Poll implementation using fd_set's. // // You should call torrent::perform() (or whatever the function will // be called) immidiately before and after the call to work(...). This // ensures we dealt with scheduled tasks and updated the cache'ed time. class LIBTORRENT_EXPORT PollSelect : public Poll { public: static PollSelect* create(int maxOpenSockets); virtual ~PollSelect(); virtual uint32_t open_max() const; // Returns the largest fd marked. unsigned int fdset(fd_set* readSet, fd_set* writeSet, fd_set* exceptSet); void perform(fd_set* readSet, fd_set* writeSet, fd_set* exceptSet); void do_poll(int64_t timeout_usec, int flags = 0); virtual void open(Event* event); virtual void close(Event* event); virtual void closed(Event* event); virtual bool in_read(Event* event); virtual bool in_write(Event* event); virtual bool in_error(Event* event); virtual void insert_read(Event* event); virtual void insert_write(Event* event); virtual void insert_error(Event* event); virtual void remove_read(Event* event); virtual void remove_write(Event* event); virtual void remove_error(Event* event); private: PollSelect() {} PollSelect(const PollSelect&); void operator = (const PollSelect&); SocketSet* m_readSet; SocketSet* m_writeSet; SocketSet* m_exceptSet; }; } #endif libtorrent-0.13.2/src/torrent/rate.cc000644 000765 000024 00000004720 11705767057 020471 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "globals.h" #include "rate.h" #include "exceptions.h" namespace torrent { inline void Rate::discard_old() const { while (!m_container.empty() && m_container.back().first < cachedTime.seconds() - m_span) { m_current -= m_container.back().second; m_container.pop_back(); } } Rate::rate_type Rate::rate() const { discard_old(); return m_current / m_span; } void Rate::insert(rate_type bytes) { discard_old(); if (m_current > ((rate_type)1 << 40) || bytes > ((rate_type)1 << 28)) throw internal_error("Rate::insert(bytes) received out-of-bounds values.."); if (m_container.empty() || m_container.front().first != cachedTime.seconds()) m_container.push_front(value_type(cachedTime.seconds(), bytes)); else m_container.front().second += bytes; m_total += bytes; m_current += bytes; } } libtorrent-0.13.2/src/torrent/rate.h000644 000765 000024 00000007502 11705767057 020334 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_RATE_H #define LIBTORRENT_UTILS_RATE_H #include #include namespace torrent { // Keep the current rate count up to date for each call to rate() and // insert(...). This requires a mutable since rate() can be const, but // is justified as we avoid iterating the deque for each call. class LIBTORRENT_EXPORT Rate { public: typedef int32_t timer_type; typedef uint64_t rate_type; typedef uint64_t total_type; typedef std::pair value_type; typedef std::deque queue_type; Rate(timer_type span) : m_current(0), m_total(0), m_span(span) {} // Bytes per second. rate_type rate() const; // Total bytes transfered. total_type total() const { return m_total; } void set_total(total_type bytes) { m_total = bytes; } // Interval in seconds used to calculate the rate. timer_type span() const { return m_span; } void set_span(timer_type s) { m_span = s; } void insert(rate_type bytes); void reset_rate() { m_current = 0; m_container.clear(); } bool operator < (Rate& r) const { return rate() < r.rate(); } bool operator > (Rate& r) const { return rate() > r.rate(); } bool operator == (Rate& r) const { return rate() == r.rate(); } bool operator != (Rate& r) const { return rate() != r.rate(); } bool operator < (rate_type r) const { return rate() < r; } bool operator > (rate_type r) const { return rate() > r; } bool operator == (rate_type r) const { return rate() == r; } bool operator != (rate_type r) const { return rate() != r; } private: inline void discard_old() const; mutable queue_type m_container; mutable rate_type m_current; total_type m_total; timer_type m_span; }; } #endif libtorrent-0.13.2/src/torrent/throttle.cc000644 000765 000024 00000010240 11705767057 021375 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "net/throttle_internal.h" #include "net/throttle_list.h" #include "globals.h" #include "exceptions.h" #include "throttle.h" namespace torrent { // Plans: // // Make ThrottleList do a callback when it needs more? This would // allow us to remove us from the task scheduler when we're full. Also // this would let us be abit more flexible with the interval. Throttle* Throttle::create_throttle() { ThrottleInternal* throttle = new ThrottleInternal(ThrottleInternal::flag_root); throttle->m_maxRate = 0; throttle->m_throttleList = new ThrottleList(); return throttle; } void Throttle::destroy_throttle(Throttle* throttle) { delete throttle->m_ptr()->m_throttleList; delete throttle->m_ptr(); } Throttle* Throttle::create_slave() { return m_ptr()->create_slave(); } bool Throttle::is_throttled() { return m_maxRate != 0 && m_maxRate != std::numeric_limits::max(); } void Throttle::set_max_rate(uint32_t v) { if (v == m_maxRate) return; if (v > (1 << 30)) throw input_error("Throttle rate must be between 0 and 2^30."); uint32_t oldRate = m_maxRate; m_maxRate = v; m_throttleList->set_min_chunk_size(calculate_min_chunk_size()); m_throttleList->set_max_chunk_size(calculate_max_chunk_size()); if (!m_ptr()->is_root()) return; if (oldRate == 0) m_ptr()->enable(); else if (m_maxRate == 0) m_ptr()->disable(); } const Rate* Throttle::rate() const { return m_throttleList->rate_slow(); } uint32_t Throttle::calculate_min_chunk_size() const { // Just for each modification, make this into a function, rather // than if-else chain. if (m_maxRate <= (8 << 10)) return (1 << 9); else if (m_maxRate <= (32 << 10)) return (2 << 9); else if (m_maxRate <= (64 << 10)) return (3 << 9); else if (m_maxRate <= (128 << 10)) return (4 << 9); else if (m_maxRate <= (512 << 10)) return (8 << 9); else if (m_maxRate <= (2048 << 10)) return (16 << 9); else return (32 << 9); } uint32_t Throttle::calculate_max_chunk_size() const { // Make this return a lower value for very low throttle settings. return calculate_min_chunk_size() * 4; } uint32_t Throttle::calculate_interval() const { uint32_t rate = m_throttleList->rate_slow()->rate(); if (rate < 1024) return 10 * 100000; // At least two max chunks per tick. uint32_t interval = (5 * m_throttleList->max_chunk_size()) / rate; if (interval == 0) return 1 * 100000; else if (interval > 10) return 10 * 100000; else return interval * 100000; } } libtorrent-0.13.2/src/torrent/throttle.h000644 000765 000024 00000005423 11705767057 021246 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TORRENT_THROTTLE_H #define LIBTORRENT_TORRENT_THROTTLE_H #include namespace torrent { class ThrottleList; class ThrottleInternal; class LIBTORRENT_EXPORT Throttle { public: static Throttle* create_throttle(); static void destroy_throttle(Throttle* throttle); Throttle* create_slave(); bool is_throttled(); // 0 == UNLIMITED. uint32_t max_rate() const { return m_maxRate; } void set_max_rate(uint32_t v); const Rate* rate() const; ThrottleList* throttle_list() { return m_throttleList; } protected: Throttle() {} ~Throttle() {} ThrottleInternal* m_ptr() { return reinterpret_cast(this); } const ThrottleInternal* c_ptr() const { return reinterpret_cast(this); } uint32_t calculate_min_chunk_size() const LIBTORRENT_NO_EXPORT; uint32_t calculate_max_chunk_size() const LIBTORRENT_NO_EXPORT; uint32_t calculate_interval() const LIBTORRENT_NO_EXPORT; uint32_t m_maxRate; ThrottleList* m_throttleList; }; } #endif libtorrent-0.13.2/src/torrent/torrent.cc000644 000765 000024 00000017612 11716362616 021231 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "exceptions.h" #include "torrent.h" #include "object.h" #include "object_stream.h" #include "throttle.h" #include "connection_manager.h" #include "poll.h" #include "manager.h" #include "protocol/handshake_manager.h" #include "protocol/peer_factory.h" #include "data/file_manager.h" #include "data/hash_queue.h" #include "data/hash_torrent.h" #include "download/download_constructor.h" #include "download/download_manager.h" #include "download/download_wrapper.h" #include "torrent/peer/connection_list.h" #include "torrent/download/resource_manager.h" namespace torrent { uint32_t calculate_max_open_files(uint32_t openMax) { if (openMax >= 8096) return 256; else if (openMax >= 1024) return 128; else if (openMax >= 512) return 64; else if (openMax >= 128) return 16; else // Assumes we don't try less than 64. return 4; } uint32_t calculate_reserved(uint32_t openMax) { if (openMax >= 8096) return 256; else if (openMax >= 1024) return 128; else if (openMax >= 512) return 64; else if (openMax >= 128) return 32; else // Assumes we don't try less than 64. return 16; } void initialize() { if (manager != NULL) throw internal_error("torrent::initialize(...) called but the library has already been initialized"); cachedTime = rak::timer::current(); manager = new Manager; manager->main_thread_main()->init_thread(); uint32_t maxFiles = calculate_max_open_files(manager->poll()->open_max()); manager->connection_manager()->set_max_size(manager->poll()->open_max() - maxFiles - calculate_reserved(manager->poll()->open_max())); manager->file_manager()->set_max_open_files(maxFiles); manager->main_thread_disk()->init_thread(); manager->main_thread_disk()->start_thread(); } // Clean up and close stuff. Stopping all torrents and waiting for // them to finish is not required, but recommended. void cleanup() { if (manager == NULL) throw internal_error("torrent::cleanup() called but the library is not initialized."); manager->main_thread_disk()->stop_thread_wait(); delete manager; manager = NULL; } bool is_inactive() { return manager == NULL || std::find_if(manager->download_manager()->begin(), manager->download_manager()->end(), std::not1(std::mem_fun(&DownloadWrapper::is_stopped))) == manager->download_manager()->end(); } thread_base* main_thread() { return manager->main_thread_main(); } ChunkManager* chunk_manager() { return manager->chunk_manager(); } ClientList* client_list() { return manager->client_list(); } FileManager* file_manager() { return manager->file_manager(); } ConnectionManager* connection_manager() { return manager->connection_manager(); } DhtManager* dht_manager() { return manager->dht_manager(); } ResourceManager* resource_manager() { return manager->resource_manager(); } uint32_t total_handshakes() { return manager->handshake_manager()->size(); } Throttle* down_throttle_global() { return manager->download_throttle(); } Throttle* up_throttle_global() { return manager->upload_throttle(); } const Rate* down_rate() { return manager->download_throttle()->rate(); } const Rate* up_rate() { return manager->upload_throttle()->rate(); } const char* version() { return VERSION; } uint32_t hash_queue_size() { return manager->hash_queue()->size(); } EncodingList* encoding_list() { return manager->encoding_list(); } Download download_add(Object* object) { std::auto_ptr download(new DownloadWrapper); DownloadConstructor ctor; ctor.set_download(download.get()); ctor.set_encoding_list(manager->encoding_list()); ctor.initialize(*object); std::string infoHash; if (download->info()->is_meta_download()) infoHash = object->get_key("info").get_key("pieces").as_string(); else infoHash = object_sha1(&object->get_key("info")); if (manager->download_manager()->find(infoHash) != manager->download_manager()->end()) throw input_error("Info hash already used by another torrent."); if (!download->info()->is_meta_download()) { char buffer[1024]; uint64_t metadata_size = 0; object_write_bencode_c(&object_write_to_size, &metadata_size, object_buffer_t(buffer, buffer + sizeof(buffer)), &object->get_key("info")); download->main()->set_metadata_size(metadata_size); } download->set_hash_queue(manager->hash_queue()); download->initialize(infoHash, PEER_NAME + rak::generate_random(20 - std::string(PEER_NAME).size())); // Add trackers, etc, after setting the info hash so that log // entries look sane. ctor.parse_tracker(*object); // Default PeerConnection factory functions. download->main()->connection_list()->slot_new_connection(&createPeerConnectionDefault); // Consider move as much as possible into this function // call. Anything that won't cause possible torrent creation errors // go in there. manager->initialize_download(download.get()); download->set_bencode(object); return Download(download.release()); } void download_remove(Download d) { manager->cleanup_download(d.ptr()); } // Add all downloads to dlist. Make sure it's cleared. void download_list(DList& dlist) { for (DownloadManager::const_iterator itr = manager->download_manager()->begin(); itr != manager->download_manager()->end(); ++itr) dlist.push_back(Download(*itr)); } // Make sure you check that it's valid. Download download_find(const std::string& infohash) { return *manager->download_manager()->find(infohash); } uint32_t download_priority(Download d) { ResourceManager::iterator itr = manager->resource_manager()->find(d.ptr()->main()); if (itr == manager->resource_manager()->end()) throw internal_error("torrent::download_priority(...) could not find the download in the resource manager."); return itr->priority(); } void download_set_priority(Download d, uint32_t pri) { ResourceManager::iterator itr = manager->resource_manager()->find(d.ptr()->main()); if (itr == manager->resource_manager()->end()) throw internal_error("torrent::download_set_priority(...) could not find the download in the resource manager."); if (pri > 1024) throw internal_error("torrent::download_set_priority(...) received an invalid priority."); manager->resource_manager()->set_priority(itr, pri); } } libtorrent-0.13.2/src/torrent/torrent.h000644 000765 000024 00000010015 11716353601 021053 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TORRENT_H #define LIBTORRENT_TORRENT_H #include #include #include #include namespace torrent { // Make sure you seed srandom and srand48 if available. void initialize() LIBTORRENT_EXPORT; // Clean up and close stuff. Stopping all torrents and waiting for // them to finish is not required, but recommended. void cleanup() LIBTORRENT_EXPORT; bool is_inactive() LIBTORRENT_EXPORT; class FileManager; class ResourceManager; class thread_base; thread_base* main_thread() LIBTORRENT_EXPORT; ChunkManager* chunk_manager() LIBTORRENT_EXPORT; ClientList* client_list() LIBTORRENT_EXPORT; FileManager* file_manager() LIBTORRENT_EXPORT; ConnectionManager* connection_manager() LIBTORRENT_EXPORT; DhtManager* dht_manager() LIBTORRENT_EXPORT; ResourceManager* resource_manager() LIBTORRENT_EXPORT; uint32_t total_handshakes() LIBTORRENT_EXPORT; Throttle* down_throttle_global() LIBTORRENT_EXPORT; Throttle* up_throttle_global() LIBTORRENT_EXPORT; const Rate* down_rate() LIBTORRENT_EXPORT; const Rate* up_rate() LIBTORRENT_EXPORT; const char* version() LIBTORRENT_EXPORT; // Disk access tuning. uint32_t hash_queue_size() LIBTORRENT_EXPORT; typedef std::list DList; typedef std::list EncodingList; EncodingList* encoding_list() LIBTORRENT_EXPORT; // Will always return a valid Download. On errors it // throws. 'encodingList' contains a list of prefered encodings to use // for file names. // // The Object must be on the heap allocated with 'new'. If // 'download_add' throws the client must handle the deletion, else it // is done by 'download_remove'. // // Might consider redesigning that... Download download_add(Object* s) LIBTORRENT_EXPORT; void download_remove(Download d) LIBTORRENT_EXPORT; // Add all downloads to dlist. The client is responsible for clearing // it before the call. void download_list(DList& dlist) LIBTORRENT_EXPORT; // Make sure you check the returned Download's is_valid(). Download download_find(const std::string& infohash) LIBTORRENT_EXPORT; uint32_t download_priority(Download d) LIBTORRENT_EXPORT; void download_set_priority(Download d, uint32_t pri) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/tracker.cc000644 000765 000024 00000007643 11716350717 021171 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "exceptions.h" #include "globals.h" #include "tracker.h" #include "tracker_list.h" namespace torrent { Tracker::Tracker(TrackerList* parent, const std::string& url, int flags) : m_flags(flags), m_parent(parent), m_group(0), m_url(url), m_normal_interval(1800), m_min_interval(600), m_latest_event(EVENT_NONE), m_latest_new_peers(0), m_latest_sum_peers(0), m_success_time_last(0), m_success_counter(0), m_failed_time_last(0), m_failed_counter(0), m_scrape_time_last(0), m_scrape_counter(0), m_scrape_complete(0), m_scrape_incomplete(0), m_scrape_downloaded(0), m_request_time_last(torrent::cachedTime.seconds()), m_request_counter(0) { } void Tracker::enable() { if (is_enabled()) return; m_flags |= flag_enabled; if (m_parent->slot_tracker_enabled()) m_parent->slot_tracker_enabled()(this); } void Tracker::disable() { if (!is_enabled()) return; close(); m_flags &= ~flag_enabled; if (m_parent->slot_tracker_disabled()) m_parent->slot_tracker_disabled()(this); } uint32_t Tracker::success_time_next() const { if (m_success_counter == 0) return 0; return m_success_time_last + m_normal_interval; } uint32_t Tracker::failed_time_next() const { if (m_failed_counter == 0) return 0; return m_failed_time_last + (5 << std::min(m_failed_counter - 1, (uint32_t)6)); } std::string Tracker::scrape_url_from(std::string url) { size_t delim_slash = url.rfind('/'); if (delim_slash == std::string::npos || url.find("/announce", delim_slash) != delim_slash) throw internal_error("Tried to make scrape url from invalid url."); return url.replace(delim_slash, sizeof("/announce") - 1, "/scrape"); } void Tracker::send_scrape() { throw internal_error("Tracker type does not support scrape."); } void Tracker::inc_request_counter() { m_request_counter -= std::min(m_request_counter, (uint32_t)cachedTime.seconds() - m_request_time_last); m_request_counter++; m_request_time_last = cachedTime.seconds(); if (m_request_counter >= 10) throw internal_error("Tracker request had more than 10 requests in 10 seconds."); } void Tracker::clear_stats() { m_latest_new_peers = 0; m_latest_sum_peers = 0; m_success_counter = 0; m_failed_counter = 0; m_scrape_counter = 0; } } libtorrent-0.13.2/src/torrent/tracker.h000644 000765 000024 00000016141 11740502002 021003 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TRACKER_H #define LIBTORRENT_TRACKER_H #include #include #include namespace torrent { class AddressList; class TrackerList; class LIBTORRENT_EXPORT Tracker { public: friend class TrackerList; typedef enum { TRACKER_NONE, TRACKER_HTTP, TRACKER_UDP, TRACKER_DHT, } Type; enum tracker_event { EVENT_NONE, EVENT_COMPLETED, EVENT_STARTED, EVENT_STOPPED, EVENT_SCRAPE }; static const int flag_enabled = 0x1; static const int flag_extra_tracker = 0x2; static const int flag_can_scrape = 0x4; static const int max_flag_size = 0x10; static const int mask_base_flags = 0x10 - 1; virtual ~Tracker() {} int flags() const { return m_flags; } bool is_enabled() const { return (m_flags & flag_enabled); } bool is_extra_tracker() const { return (m_flags & flag_extra_tracker); } bool is_in_use() const { return is_enabled() && m_success_counter != 0; } bool can_scrape() const { return (m_flags & flag_can_scrape); } virtual bool is_busy() const = 0; bool is_busy_not_scrape() const { return m_latest_event != EVENT_SCRAPE && is_busy(); } virtual bool is_usable() const { return is_enabled(); } bool can_request_state() const; void enable(); void disable(); TrackerList* parent() { return m_parent; } uint32_t group() const { return m_group; } virtual Type type() const = 0; const std::string& url() const { return m_url; } void set_url(const std::string& url) { m_url = url; } const std::string& tracker_id() const { return m_tracker_id; } void set_tracker_id(const std::string& id) { m_tracker_id = id; } uint32_t normal_interval() const { return m_normal_interval; } uint32_t min_interval() const { return m_min_interval; } int latest_event() const { return m_latest_event; } uint32_t latest_new_peers() const { return m_latest_new_peers; } uint32_t latest_sum_peers() const { return m_latest_sum_peers; } uint32_t success_time_next() const; uint32_t success_time_last() const { return m_success_time_last; } uint32_t success_counter() const { return m_success_counter; } uint32_t failed_time_next() const; uint32_t failed_time_last() const { return m_failed_time_last; } uint32_t failed_counter() const { return m_failed_counter; } uint32_t activity_time_last() const { return failed_counter() ? m_failed_time_last : m_success_time_last; } uint32_t activity_time_next() const { return failed_counter() ? failed_time_next() : success_time_next(); } uint32_t scrape_time_last() const { return m_scrape_time_last; } uint32_t scrape_counter() const { return m_scrape_counter; } uint32_t scrape_complete() const { return m_scrape_complete; } uint32_t scrape_incomplete() const { return m_scrape_incomplete; } uint32_t scrape_downloaded() const { return m_scrape_downloaded; } virtual void get_status(char* buffer, int length) { buffer[0] = 0; } static std::string scrape_url_from(std::string url); protected: Tracker(TrackerList* parent, const std::string& url, int flags = 0); Tracker(const Tracker& t); void operator = (const Tracker& t); virtual void send_state(int state) = 0; virtual void send_scrape(); virtual void close() = 0; virtual void disown() = 0; // Safeguard to catch bugs that lead to hammering of trackers. void inc_request_counter(); void clear_stats(); void set_group(uint32_t v) { m_group = v; } void set_normal_interval(int v) { if (v >= 600 && v <= 3600) m_normal_interval = v; } void set_min_interval(int v) { if (v >= 300 && v <= 1800) m_min_interval = v; } int m_flags; TrackerList* m_parent; uint32_t m_group; std::string m_url; std::string m_tracker_id; uint32_t m_normal_interval; uint32_t m_min_interval; int m_latest_event; uint32_t m_latest_new_peers; uint32_t m_latest_sum_peers; uint32_t m_success_time_last; uint32_t m_success_counter; uint32_t m_failed_time_last; uint32_t m_failed_counter; uint32_t m_scrape_time_last; uint32_t m_scrape_counter; uint32_t m_scrape_complete; uint32_t m_scrape_incomplete; uint32_t m_scrape_downloaded; // Timing of the last request, and a counter for how many requests // there's been in the recent past. uint32_t m_request_time_last; uint32_t m_request_counter; }; inline bool Tracker::can_request_state() const { return !(is_busy() && latest_event() != EVENT_SCRAPE) && is_usable(); } } #endif libtorrent-0.13.2/src/torrent/tracker_controller.cc000644 000765 000024 00000043161 11741025651 023421 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "exceptions.h" #include "download_info.h" #include "tracker.h" #include "tracker_controller.h" #include "tracker_list.h" #include "rak/priority_queue_default.h" #include "utils/log.h" #include "globals.h" #define LT_LOG_TRACKER(log_level, log_fmt, ...) \ lt_log_print_info(LOG_TRACKER_##log_level, m_tracker_list->info(), "tracker_controller", log_fmt, __VA_ARGS__); namespace tr1 { using namespace std::tr1; } namespace torrent { struct tracker_controller_private { rak::priority_item task_timeout; rak::priority_item task_scrape; }; // End temp hacks... void TrackerController::update_timeout(uint32_t seconds_to_next) { if (!(m_flags & flag_active)) throw internal_error("TrackerController cannot set timeout when inactive."); rak::timer next_timeout = cachedTime; if (seconds_to_next != 0) next_timeout = (cachedTime + rak::timer::from_seconds(seconds_to_next)).round_seconds(); priority_queue_erase(&taskScheduler, &m_private->task_timeout); priority_queue_insert(&taskScheduler, &m_private->task_timeout, next_timeout); } inline int TrackerController::current_send_state() const { switch ((m_flags & mask_send)) { case flag_send_start: return Tracker::EVENT_STARTED; case flag_send_stop: return Tracker::EVENT_STOPPED; case flag_send_completed: return Tracker::EVENT_COMPLETED; case flag_send_update: default: return Tracker::EVENT_NONE; } } TrackerController::TrackerController(TrackerList* trackers) : m_flags(0), m_tracker_list(trackers), m_private(new tracker_controller_private) { m_private->task_timeout.slot() = std::tr1::bind(&TrackerController::do_timeout, this); m_private->task_scrape.slot() = std::tr1::bind(&TrackerController::do_scrape, this); } TrackerController::~TrackerController() { priority_queue_erase(&taskScheduler, &m_private->task_timeout); priority_queue_erase(&taskScheduler, &m_private->task_scrape); delete m_private; } rak::priority_item* TrackerController::task_timeout() { return &m_private->task_timeout; } rak::priority_item* TrackerController::task_scrape() { return &m_private->task_scrape; } int64_t TrackerController::next_timeout() const { return m_private->task_timeout.time().usec(); } int64_t TrackerController::next_scrape() const { return m_private->task_scrape.time().usec(); } uint32_t TrackerController::seconds_to_next_timeout() const { return std::max(m_private->task_timeout.time() - cachedTime, rak::timer()).seconds_ceiling(); } uint32_t TrackerController::seconds_to_next_scrape() const { return std::max(m_private->task_scrape.time() - cachedTime, rak::timer()).seconds_ceiling(); } void TrackerController::manual_request(bool request_now) { if (!m_private->task_timeout.is_queued()) return; // Add functions to get the lowest timeout, etc... send_update_event(); } void TrackerController::scrape_request(uint32_t seconds_to_request) { rak::timer next_timeout = cachedTime; if (seconds_to_request != 0) next_timeout = (cachedTime + rak::timer::from_seconds(seconds_to_request)).round_seconds(); priority_queue_erase(&taskScheduler, &m_private->task_scrape); priority_queue_insert(&taskScheduler, &m_private->task_scrape, next_timeout); } // The send_*_event() functions tries to ensure the relevant trackers // receive the event. // // When we just want more peers the start_requesting() function is // used. This is all independent of the regular updates sent to the // trackers. void TrackerController::send_start_event() { // This will now be 'lazy', rather than a definite event. We tell // the controller that a 'start' event should be sent, and it will // send it when the tracker controller get's enabled. // If the controller is already running, we insert this new event. // Return, or something, if already active and sending? if (m_flags & flag_send_start) { // Do we just return, or bork? At least we need to check to see // that there's something requesting 'start' event or fail hard. } m_flags &= ~mask_send; m_flags |= flag_send_start; if (!(m_flags & flag_active) || !m_tracker_list->has_usable()) { LT_LOG_TRACKER(INFO, "Queueing started event.", 0); return; } // Start with requesting from the first tracker. Add timer to // catch when we don't get any response within the first few // seconds, at which point we go promiscious. // Do we use the old 'focus' thing?... Rather react on no reply, // go into promiscious. LT_LOG_TRACKER(INFO, "Sending started event.", 0); close(); m_tracker_list->send_state_itr(m_tracker_list->find_usable(m_tracker_list->begin()), Tracker::EVENT_STARTED); if (m_tracker_list->count_usable() > 1) { m_flags |= flag_promiscuous_mode; update_timeout(3); } } void TrackerController::send_stop_event() { if (m_flags & flag_send_stop) { // Do we just return, or bork? At least we need to check to see // that there's something requesting 'start' event or fail hard. } m_flags &= ~mask_send; if (!(m_flags & flag_active) || !m_tracker_list->has_usable()) { LT_LOG_TRACKER(INFO, "Skipping stopped event as no tracker need it.", 0); return; } m_flags |= flag_send_stop; LT_LOG_TRACKER(INFO, "Sending stopped event.", 0); close(); for (TrackerList::iterator itr = m_tracker_list->begin(); itr != m_tracker_list->end(); itr++) { if (!(*itr)->is_in_use()) continue; m_tracker_list->send_state(*itr, Tracker::EVENT_STOPPED); } // Timer... } void TrackerController::send_completed_event() { if (m_flags & flag_send_completed) { // Do we just return, or bork? At least we need to check to see // that there's something requesting 'start' event or fail hard. } m_flags &= ~mask_send; m_flags |= flag_send_completed; if (!(m_flags & flag_active) || !m_tracker_list->has_usable()) { LT_LOG_TRACKER(INFO, "Queueing completed event.", 0); return; } LT_LOG_TRACKER(INFO, "Sending completed event.", 0); // Send to all trackers that would want to know. close(); for (TrackerList::iterator itr = m_tracker_list->begin(); itr != m_tracker_list->end(); itr++) { if (!(*itr)->is_in_use()) continue; m_tracker_list->send_state(*itr, Tracker::EVENT_COMPLETED); } // Timer... } void TrackerController::send_update_event() { if (!(m_flags & flag_active) || !m_tracker_list->has_usable()) return; if ((m_flags & mask_send) && m_tracker_list->has_active()) return; // We can lose a state here... if (!(m_flags & mask_send)) m_flags |= flag_send_update; LT_LOG_TRACKER(INFO, "Sending update event.", 0); m_tracker_list->send_state_itr(m_tracker_list->find_usable(m_tracker_list->begin()), Tracker::EVENT_NONE); // if (m_tracker_list->has_active()) // priority_queue_erase(&taskScheduler, &m_private->task_timeout); } // Currently being used by send_state, fixme. void TrackerController::close(int flags) { m_flags &= ~(flag_requesting | flag_promiscuous_mode); if ((flags & (close_disown_stop | close_disown_completed))) m_tracker_list->disown_all_including(close_disown_stop | close_disown_completed); m_tracker_list->close_all(); priority_queue_erase(&taskScheduler, &m_private->task_timeout); } void TrackerController::enable(int enable_flags) { if ((m_flags & flag_active)) return; // Clearing send stop here in case we cycle disable/enable too // fast. In the future do this based on flags passed. m_flags |= flag_active; m_flags &= ~flag_send_stop; m_tracker_list->close_all_excluding((1 << Tracker::EVENT_COMPLETED)); if (!(enable_flags & enable_dont_reset_stats)) m_tracker_list->clear_stats(); LT_LOG_TRACKER(INFO, "Called enable with %u trackers.", m_tracker_list->size()); // Adding of the tracker requests gets done after the caller has had // a chance to override the default behavior. update_timeout(0); } void TrackerController::disable() { if (!(m_flags & flag_active)) return; // Disable other flags?... m_flags &= ~(flag_active | flag_requesting | flag_promiscuous_mode); m_tracker_list->close_all_excluding((1 << Tracker::EVENT_STOPPED) | (1 << Tracker::EVENT_COMPLETED)); priority_queue_erase(&taskScheduler, &m_private->task_timeout); LT_LOG_TRACKER(INFO, "Called disable with %u trackers.", m_tracker_list->size()); } void TrackerController::start_requesting() { if (!(m_flags & flag_active) || (m_flags & flag_requesting)) return; m_flags |= flag_requesting; update_timeout(0); LT_LOG_TRACKER(INFO, "Start requesting.", 0); } void TrackerController::stop_requesting() { if (!(m_flags & flag_active) || !(m_flags & flag_requesting)) return; m_flags &= ~flag_requesting; LT_LOG_TRACKER(INFO, "Stop requesting.", 0); } uint32_t tracker_next_timeout(Tracker* tracker, int controller_flags) { if ((controller_flags & TrackerController::flag_requesting)) return tracker_next_timeout_promiscuous(tracker); if ((tracker->is_busy() && tracker->latest_event() != Tracker::EVENT_SCRAPE) || !tracker->is_usable()) return ~uint32_t(); if ((controller_flags & TrackerController::flag_promiscuous_mode)) return 0; if ((controller_flags & TrackerController::flag_send_update)) return tracker_next_timeout_update(tracker); // if (tracker->success_counter() == 0 && tracker->failed_counter() == 0) // return 0; int32_t last_activity = cachedTime.seconds() - tracker->activity_time_last(); // TODO: Use min interval if we're requesting manual update. return tracker->normal_interval() - std::min(last_activity, (int32_t)tracker->normal_interval()); } uint32_t tracker_next_timeout_update(Tracker* tracker) { if ((tracker->is_busy() && tracker->latest_event() != Tracker::EVENT_SCRAPE) || !tracker->is_usable()) return ~uint32_t(); // Make sure we don't request _too_ often, check last activity. // int32_t last_activity = cachedTime.seconds() - tracker->activity_time_last(); return 0; } uint32_t tracker_next_timeout_promiscuous(Tracker* tracker) { if ((tracker->is_busy() && tracker->latest_event() != Tracker::EVENT_SCRAPE) || !tracker->is_usable()) return ~uint32_t(); int32_t interval; if (tracker->failed_counter()) interval = 5 << std::min(tracker->failed_counter() - 1, 6); else if (tracker->success_counter() < 2 && tracker->latest_sum_peers() < 10) interval = 10 << tracker->success_counter(); else interval = tracker->normal_interval(); int32_t min_interval = std::min(tracker->min_interval(), (uint32_t)600); int32_t use_interval = std::min(interval, min_interval); int32_t since_last = cachedTime.seconds() - (int32_t)tracker->activity_time_last(); return std::max(use_interval - since_last, 0); } TrackerList::iterator tracker_find_preferred(TrackerList::iterator first, TrackerList::iterator last, uint32_t* next_timeout) { TrackerList::iterator preferred = last; uint32_t preferred_time_last = ~uint32_t(); for (; first != last; first++) { uint32_t tracker_timeout = tracker_next_timeout_promiscuous(*first); if (tracker_timeout != 0) { *next_timeout = std::min(tracker_timeout, *next_timeout); continue; } if ((*first)->activity_time_last() < preferred_time_last) { preferred = first; preferred_time_last = (*first)->activity_time_last(); } } return preferred; } void TrackerController::do_timeout() { if (!(m_flags & flag_active) || !m_tracker_list->has_usable()) return; priority_queue_erase(&taskScheduler, &m_private->task_timeout); int send_state = current_send_state(); if ((m_flags & (flag_promiscuous_mode | flag_requesting))) { uint32_t next_timeout = ~uint32_t(); TrackerList::iterator itr = m_tracker_list->begin(); while (itr != m_tracker_list->end()) { uint32_t group = (*itr)->group(); if (m_tracker_list->has_active_not_scrape_in_group(group)) { itr = m_tracker_list->end_group(group); continue; } TrackerList::iterator group_end = m_tracker_list->end_group((*itr)->group()); TrackerList::iterator preferred = itr; if (!(*itr)->is_usable() || (*itr)->failed_counter()) { // The selected tracker in the group is either disabled or not // reachable, try the others to find a new one to use. preferred = tracker_find_preferred(preferred, group_end, &next_timeout); } else { uint32_t tracker_timeout = tracker_next_timeout_promiscuous(*preferred); if (tracker_timeout != 0) { next_timeout = std::min(tracker_timeout, next_timeout); preferred = group_end; } } if (preferred != group_end) m_tracker_list->send_state_itr(preferred, send_state); itr = group_end; } if (next_timeout != ~uint32_t()) update_timeout(next_timeout); // TODO: Send for start/completed also? } else { TrackerList::iterator itr = m_tracker_list->find_next_to_request(m_tracker_list->begin()); if (itr == m_tracker_list->end()) return; if ((m_flags & flag_send_update)) { // TODO: Also watch out for failed trackers requiring timeouts. m_tracker_list->send_state_itr(itr, send_state); } else { TrackerList::iterator itr = m_tracker_list->find_next_to_request(m_tracker_list->begin()); int32_t next_timeout = (*itr)->activity_time_next(); if (next_timeout <= cachedTime.seconds()) m_tracker_list->send_state_itr(itr, send_state); else update_timeout(next_timeout - cachedTime.seconds()); } } if (m_slot_timeout) m_slot_timeout(); } void TrackerController::do_scrape() { TrackerList::iterator itr = m_tracker_list->begin(); while (itr != m_tracker_list->end()) { uint32_t group = (*itr)->group(); if (m_tracker_list->has_active_in_group(group)) { itr = m_tracker_list->end_group(group); continue; } TrackerList::iterator group_end = m_tracker_list->end_group((*itr)->group()); while (itr != group_end) { if ((*itr)->can_scrape() && (*itr)->is_usable()) { m_tracker_list->send_scrape(*itr); break; } itr++; } itr = group_end; } } uint32_t TrackerController::receive_success(Tracker* tb, TrackerController::address_list* l) { if (!(m_flags & flag_active)) return m_slot_success(l); // if () { m_flags &= ~(mask_send | flag_promiscuous_mode | flag_failure_mode); // } // If we still have active trackers, skip the timeout. // Calculate the next timeout according to a list of in-use // trackers, with the first timeout as the interval. if ((m_flags & flag_requesting)) update_timeout(30); else if (!m_tracker_list->has_active()) // TODO: Instead find the lowest timeout, correct timeout? update_timeout(tb->normal_interval()); return m_slot_success(l); } void TrackerController::receive_failure(Tracker* tb, const std::string& msg) { if (!(m_flags & flag_active)) { m_slot_failure(msg); return; } if (tb == NULL) { LT_LOG_TRACKER(INFO, "Received failure msg:'%s'.", msg.c_str()); m_slot_failure(msg); return; } if (tb->failed_counter() == 1 && tb->success_counter() > 0) m_flags |= flag_failure_mode; do_timeout(); m_slot_failure(msg); } void TrackerController::receive_scrape(Tracker* tb) { if (!(m_flags & flag_active)) { return; } } void TrackerController::receive_tracker_enabled(Tracker* tb) { // TODO: This won't be needed if we rely only on Tracker::m_enable, // rather than a virtual function. if (!m_tracker_list->has_usable()) return; if ((m_flags & flag_active)) { if (!m_private->task_timeout.is_queued() && !m_tracker_list->has_active()) { // TODO: Figure out the proper timeout to use here based on when the // tracker last connected, etc. update_timeout(0); } } if (m_slot_tracker_enabled) m_slot_tracker_enabled(tb); } void TrackerController::receive_tracker_disabled(Tracker* tb) { if ((m_flags & flag_active) && !m_private->task_timeout.is_queued()) update_timeout(0); if (m_slot_tracker_disabled) m_slot_tracker_disabled(tb); } } libtorrent-0.13.2/src/torrent/tracker_controller.h000644 000765 000024 00000013655 11731615115 023267 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TRACKER_CONTROLLER_H #define LIBTORRENT_TRACKER_CONTROLLER_H #include #include #include #include // Refactor: namespace rak { class priority_item; } namespace torrent { class AddressList; class TrackerList; struct tracker_controller_private; class LIBTORRENT_EXPORT TrackerController { public: typedef AddressList address_list; typedef std::tr1::function slot_void; typedef std::tr1::function slot_string; typedef std::tr1::function slot_address_list; typedef std::tr1::function slot_tracker; static const int flag_send_update = 0x1; static const int flag_send_completed = 0x2; static const int flag_send_start = 0x4; static const int flag_send_stop = 0x8; static const int flag_active = 0x10; static const int flag_requesting = 0x20; static const int flag_failure_mode = 0x40; static const int flag_promiscuous_mode = 0x80; static const int mask_send = flag_send_update | flag_send_start | flag_send_stop | flag_send_completed; static const int enable_dont_reset_stats = 0x1; static const int close_disown_stop = 0x1 << Tracker::EVENT_STOPPED; static const int close_disown_completed = 0x1 << Tracker::EVENT_COMPLETED; TrackerController(TrackerList* trackers); ~TrackerController(); int flags() const { return m_flags; } bool is_active() const { return m_flags & flag_active; } bool is_requesting() const { return m_flags & flag_requesting; } bool is_failure_mode() const { return m_flags & flag_failure_mode; } bool is_promiscuous_mode() const { return m_flags & flag_promiscuous_mode; } TrackerList* tracker_list() { return m_tracker_list; } TrackerList* tracker_list() const { return m_tracker_list; } int64_t next_timeout() const; int64_t next_scrape() const; uint32_t seconds_to_next_timeout() const; uint32_t seconds_to_next_scrape() const; void manual_request(bool request_now); void scrape_request(uint32_t seconds_to_request); //protected: void send_start_event(); void send_stop_event(); void send_completed_event(); void send_update_event(); void close(int flags = close_disown_stop | close_disown_completed); void enable(int enable_flags = 0); void disable(); void start_requesting(); void stop_requesting(); uint32_t receive_success(Tracker* tb, address_list* l); void receive_failure(Tracker* tb, const std::string& msg); void receive_scrape(Tracker* tb); void receive_tracker_enabled(Tracker* tb); void receive_tracker_disabled(Tracker* tb); slot_void& slot_timeout() { return m_slot_timeout; } slot_address_list& slot_success() { return m_slot_success; } slot_string& slot_failure() { return m_slot_failure; } slot_tracker& slot_tracker_enabled() { return m_slot_tracker_enabled; } slot_tracker& slot_tracker_disabled() { return m_slot_tracker_disabled; } // TEMP: rak::priority_item* task_timeout(); rak::priority_item* task_scrape(); private: void do_timeout(); void do_scrape(); void update_timeout(uint32_t seconds_to_next); inline int current_send_state() const; TrackerController(); void operator = (const TrackerController&); int m_flags; TrackerList* m_tracker_list; slot_void m_slot_timeout; slot_address_list m_slot_success; slot_string m_slot_failure; slot_tracker m_slot_tracker_enabled; slot_tracker m_slot_tracker_disabled; // Refactor this out. tracker_controller_private* m_private; }; uint32_t tracker_next_timeout(Tracker* tracker, int controller_flags); uint32_t tracker_next_timeout_update(Tracker* tracker); uint32_t tracker_next_timeout_promiscuous(Tracker* tracker); } #endif libtorrent-0.13.2/src/torrent/tracker_list.cc000644 000765 000024 00000025542 11740502002 022201 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "net/address_list.h" #include "torrent/utils/log.h" #include "torrent/utils/log_files.h" #include "torrent/utils/option_strings.h" #include "torrent/download_info.h" #include "tracker/tracker_dht.h" #include "tracker/tracker_http.h" #include "tracker/tracker_udp.h" #include "globals.h" #include "exceptions.h" #include "tracker.h" #include "tracker_list.h" #define LT_LOG_TRACKER(log_level, log_fmt, ...) \ lt_log_print_info(LOG_TRACKER_##log_level, info(), "tracker_list", log_fmt, __VA_ARGS__); namespace tr1 { using namespace std::tr1; } namespace torrent { TrackerList::TrackerList() : m_info(NULL), m_state(DownloadInfo::STOPPED), m_key(0), m_numwant(-1) { } bool TrackerList::has_active() const { return std::find_if(begin(), end(), std::mem_fun(&Tracker::is_busy)) != end(); } bool TrackerList::has_active_not_scrape() const { return std::find_if(begin(), end(), std::mem_fun(&Tracker::is_busy_not_scrape)) != end(); } bool TrackerList::has_active_in_group(uint32_t group) const { return std::find_if(begin_group(group), end_group(group), std::mem_fun(&Tracker::is_busy)) != end_group(group); } bool TrackerList::has_active_not_scrape_in_group(uint32_t group) const { return std::find_if(begin_group(group), end_group(group), std::mem_fun(&Tracker::is_busy_not_scrape)) != end_group(group); } // Need a custom predicate because the is_usable function is virtual. struct tracker_usable_t : public std::unary_function { bool operator () (const TrackerList::value_type& value) const { return value->is_usable(); } }; bool TrackerList::has_usable() const { return std::find_if(begin(), end(), tracker_usable_t()) != end(); } unsigned int TrackerList::count_active() const { return std::count_if(begin(), end(), std::mem_fun(&Tracker::is_busy)); } unsigned int TrackerList::count_usable() const { return std::count_if(begin(), end(), tracker_usable_t()); } void TrackerList::close_all_excluding(int event_bitmap) { for (iterator itr = begin(); itr != end(); itr++) { if ((event_bitmap & (1 << (*itr)->latest_event()))) continue; (*itr)->close(); } } void TrackerList::disown_all_including(int event_bitmap) { for (iterator itr = begin(); itr != end(); itr++) { if ((event_bitmap & (1 << (*itr)->latest_event()))) (*itr)->disown(); } } void TrackerList::clear() { std::for_each(begin(), end(), rak::call_delete()); base_type::clear(); } void TrackerList::clear_stats() { std::for_each(begin(), end(), std::mem_fun(&Tracker::clear_stats)); } void TrackerList::send_state(Tracker* tracker, int new_event) { if (!tracker->is_usable() || new_event == Tracker::EVENT_SCRAPE) return; if (tracker->is_busy()) { if (tracker->latest_event() != Tracker::EVENT_SCRAPE) return; tracker->close(); } tracker->send_state(new_event); tracker->inc_request_counter(); LT_LOG_TRACKER(INFO, "Sending '%s' to group:%u url:'%s'.", option_as_string(OPTION_TRACKER_EVENT, new_event), tracker->group(), tracker->url().c_str()); } void TrackerList::send_scrape(Tracker* tracker) { if (tracker->is_busy() || !tracker->is_usable()) return; if (!(tracker->flags() & Tracker::flag_can_scrape)) return; if (rak::timer::from_seconds(tracker->scrape_time_last()) + rak::timer::from_seconds(10 * 60) > cachedTime ) return; tracker->send_scrape(); tracker->inc_request_counter(); LT_LOG_TRACKER(INFO, "Sending 'scrape' to group:%u url:'%s'.", tracker->group(), tracker->url().c_str()); } TrackerList::iterator TrackerList::insert(unsigned int group, Tracker* tracker) { tracker->set_group(group); iterator itr = base_type::insert(end_group(group), tracker); if (m_slot_tracker_enabled) m_slot_tracker_enabled(tracker); return itr; } // TODO: Use proper flags for insert options. void TrackerList::insert_url(unsigned int group, const std::string& url, bool extra_tracker) { Tracker* tracker; int flags = Tracker::flag_enabled; if (extra_tracker) flags |= Tracker::flag_extra_tracker; if (std::strncmp("http://", url.c_str(), 7) == 0 || std::strncmp("https://", url.c_str(), 8) == 0) { tracker = new TrackerHttp(this, url, flags); } else if (std::strncmp("udp://", url.c_str(), 6) == 0) { tracker = new TrackerUdp(this, url, flags); } else if (std::strncmp("dht://", url.c_str(), 6) == 0 && TrackerDht::is_allowed()) { tracker = new TrackerDht(this, url, flags); } else { LT_LOG_TRACKER(WARN, "Could find matching tracker protocol for url: '%s'.", url.c_str()); if (extra_tracker) throw torrent::input_error("Could find matching tracker protocol for url: '" + url + "'."); return; } LT_LOG_TRACKER(INFO, "Added tracker group:%i url:'%s'.", group, url.c_str()); insert(group, tracker); } TrackerList::iterator TrackerList::find_url(const std::string& url) { return std::find_if(begin(), end(), tr1::bind(std::equal_to(), url, tr1::bind(&Tracker::url, tr1::placeholders::_1))); } TrackerList::iterator TrackerList::find_usable(iterator itr) { while (itr != end() && !tracker_usable_t()(*itr)) ++itr; return itr; } TrackerList::const_iterator TrackerList::find_usable(const_iterator itr) const { while (itr != end() && !tracker_usable_t()(*itr)) ++itr; return itr; } TrackerList::iterator TrackerList::find_next_to_request(iterator itr) { TrackerList::iterator preferred = itr = std::find_if(itr, end(), std::mem_fun(&Tracker::can_request_state)); if (preferred == end() || (*preferred)->failed_counter() == 0) return preferred; while (++itr != end()) { if (!(*itr)->can_request_state()) continue; if ((*itr)->failed_counter() != 0) { if ((*itr)->failed_time_next() < (*preferred)->failed_time_next()) preferred = itr; } else { if ((*itr)->success_time_next() < (*preferred)->failed_time_next()) preferred = itr; break; } } return preferred; } TrackerList::iterator TrackerList::begin_group(unsigned int group) { return std::find_if(begin(), end(), rak::less_equal(group, std::mem_fun(&Tracker::group))); } TrackerList::const_iterator TrackerList::begin_group(unsigned int group) const { return std::find_if(begin(), end(), rak::less_equal(group, std::mem_fun(&Tracker::group))); } TrackerList::size_type TrackerList::size_group() const { return !empty() ? back()->group() + 1 : 0; } void TrackerList::cycle_group(unsigned int group) { iterator itr = begin_group(group); iterator prev = itr; if (itr == end() || (*itr)->group() != group) return; while (++itr != end() && (*itr)->group() == group) { std::iter_swap(itr, prev); prev = itr; } } TrackerList::iterator TrackerList::promote(iterator itr) { iterator first = begin_group((*itr)->group()); if (first == end()) throw internal_error("torrent::TrackerList::promote(...) Could not find beginning of group."); std::swap(*first, *itr); return first; } void TrackerList::randomize_group_entries() { // Random random random. iterator itr = begin(); while (itr != end()) { iterator tmp = end_group((*itr)->group()); std::random_shuffle(itr, tmp); itr = tmp; } } void TrackerList::receive_success(Tracker* tb, AddressList* l) { iterator itr = find(tb); if (itr == end() || tb->is_busy()) throw internal_error("TrackerList::receive_success(...) called but the iterator is invalid."); // Promote the tracker to the front of the group since it was // successfull. itr = promote(itr); l->sort(); l->erase(std::unique(l->begin(), l->end()), l->end()); LT_LOG_TRACKER(INFO, "Received %u peers from tracker url:'%s'.", l->size(), tb->url().c_str()); tb->m_success_time_last = cachedTime.seconds(); tb->m_success_counter++; tb->m_failed_counter = 0; tb->m_latest_sum_peers = l->size(); tb->m_latest_new_peers = m_slot_success(tb, l); } void TrackerList::receive_failed(Tracker* tb, const std::string& msg) { iterator itr = find(tb); if (itr == end() || tb->is_busy()) throw internal_error("TrackerList::receive_failed(...) called but the iterator is invalid."); LT_LOG_TRACKER(INFO, "Failed to connect to tracker url:'%s' msg:'%s'.", tb->url().c_str(), msg.c_str()); tb->m_failed_time_last = cachedTime.seconds(); tb->m_failed_counter++; m_slot_failed(tb, msg); } void TrackerList::receive_scrape_success(Tracker* tb) { iterator itr = find(tb); if (itr == end() || tb->is_busy()) throw internal_error("TrackerList::receive_success(...) called but the iterator is invalid."); LT_LOG_TRACKER(INFO, "Received scrape from tracker url:'%s'.", tb->url().c_str()); tb->m_scrape_time_last = cachedTime.seconds(); tb->m_scrape_counter++; if (m_slot_scrape_success) m_slot_scrape_success(tb); } void TrackerList::receive_scrape_failed(Tracker* tb, const std::string& msg) { iterator itr = find(tb); if (itr == end() || tb->is_busy()) throw internal_error("TrackerList::receive_failed(...) called but the iterator is invalid."); LT_LOG_TRACKER(INFO, "Failed to scrape tracker url:'%s' msg:'%s'.", tb->url().c_str(), msg.c_str()); if (m_slot_scrape_failed) m_slot_scrape_failed(tb, msg); } } libtorrent-0.13.2/src/torrent/tracker_list.h000644 000765 000024 00000016362 11740502002 022043 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TRACKER_LIST_H #define LIBTORRENT_TRACKER_LIST_H #include #include #include #include #include namespace torrent { class AddressList; class DownloadInfo; class DownloadWrapper; class Tracker; // The tracker list will contain a list of tracker, divided into // subgroups. Each group must be randomized before we start. When // starting the tracker request, always start from the beginning and // iterate if the request failed. Upon request success move the // tracker to the beginning of the subgroup and start from the // beginning of the whole list. class LIBTORRENT_EXPORT TrackerList : private std::vector { public: friend class DownloadWrapper; typedef std::vector base_type; typedef AddressList address_list; typedef std::tr1::function slot_tracker; typedef std::tr1::function slot_string; typedef std::tr1::function slot_address_list; using base_type::value_type; using base_type::iterator; using base_type::const_iterator; using base_type::reverse_iterator; using base_type::const_reverse_iterator; using base_type::size; using base_type::empty; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::front; using base_type::back; using base_type::at; using base_type::operator[]; TrackerList(); bool has_active() const; bool has_active_not_scrape() const; bool has_active_in_group(uint32_t group) const; bool has_active_not_scrape_in_group(uint32_t group) const; bool has_usable() const; unsigned int count_active() const; unsigned int count_usable() const; void close_all() { close_all_excluding(0); } void close_all_excluding(int event_bitmap); void disown_all_including(int event_bitmap); void clear(); void clear_stats(); iterator insert(unsigned int group, Tracker* tracker); void insert_url(unsigned int group, const std::string& url, bool extra_tracker = false); void send_state(Tracker* tracker, int new_event); void send_state_idx(unsigned idx, int new_event); void send_state_itr(iterator itr, int new_event); void send_scrape(Tracker* tracker); DownloadInfo* info() { return m_info; } int state() { return m_state; } uint32_t key() const { return m_key; } void set_key(uint32_t key) { m_key = key; } int32_t numwant() const { return m_numwant; } void set_numwant(int32_t n) { m_numwant = n; } iterator find(Tracker* tb) { return std::find(begin(), end(), tb); } iterator find_url(const std::string& url); iterator find_usable(iterator itr); const_iterator find_usable(const_iterator itr) const; iterator find_next_to_request(iterator itr); iterator begin_group(unsigned int group); const_iterator begin_group(unsigned int group) const; iterator end_group(unsigned int group) { return begin_group(group + 1); } const_iterator end_group(unsigned int group) const { return begin_group(group + 1); } size_type size_group() const; void cycle_group(unsigned int group); iterator promote(iterator itr); void randomize_group_entries(); void receive_success(Tracker* tb, AddressList* l); void receive_failed(Tracker* tb, const std::string& msg); void receive_scrape_success(Tracker* tb); void receive_scrape_failed(Tracker* tb, const std::string& msg); // Used by libtorrent internally. slot_address_list& slot_success() { return m_slot_success; } slot_string& slot_failure() { return m_slot_failed; } slot_tracker& slot_scrape_success() { return m_slot_scrape_success; } slot_string& slot_scrape_failure() { return m_slot_scrape_failed; } slot_tracker& slot_tracker_enabled() { return m_slot_tracker_enabled; } slot_tracker& slot_tracker_disabled() { return m_slot_tracker_disabled; } protected: void set_info(DownloadInfo* info) { m_info = info; } void set_state(int s) { m_state = s; } private: TrackerList(const TrackerList&) LIBTORRENT_NO_EXPORT; void operator = (const TrackerList&) LIBTORRENT_NO_EXPORT; DownloadInfo* m_info; int m_state; uint32_t m_key; int32_t m_numwant; slot_address_list m_slot_success; slot_string m_slot_failed; slot_tracker m_slot_scrape_success; slot_string m_slot_scrape_failed; slot_tracker m_slot_tracker_enabled; slot_tracker m_slot_tracker_disabled; }; inline void TrackerList::send_state_idx(unsigned idx, int new_event) { send_state(at(idx), new_event); } inline void TrackerList::send_state_itr(iterator itr, int new_event) { if (itr == end()) return; send_state(*itr, new_event); } } #endif libtorrent-0.13.2/src/torrent/utils/000755 000765 000024 00000000000 11744204513 020346 5ustar00rakshasastaff000000 000000 libtorrent-0.13.2/src/torrent/utils/extents.h000644 000765 000024 00000020230 11721626402 022206 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_EXTENTS_H #define LIBTORRENT_UTILS_EXTENTS_H #include namespace torrent { template struct extents_base { typedef Key key_type; typedef std::pair range_type; typedef std::pair mapped_type; typedef Tp mapped_value_type; typedef std::tr1::array table_type; extents_base(key_type pos, unsigned int mb, mapped_value_type val) : mask_bits(mb), position(pos) { table.assign(mapped_type(NULL, mapped_value_type())); } extents_base(extents_base* parent, typename table_type::const_iterator itr) : mask_bits(parent->mask_bits - TableBits), position(parent->partition_pos(itr)) { table.assign(mapped_type(NULL, itr->second)); } ~extents_base(); bool is_divisible(key_type key) const { return key % mask_bits == 0; } bool is_leaf_branch() const { return mask_bits == 0; } bool is_equal_range(key_type first, key_type last, const mapped_value_type& val) const; unsigned int sizeof_data() const; typename table_type::iterator partition_at(key_type key) { return table.begin() + ((key >> mask_bits) & (TableSize - 1)); } typename table_type::const_iterator partition_at(key_type key) const { return table.begin() + ((key >> mask_bits) & (TableSize - 1)); } unsigned int mask_distance(unsigned int mb) { return (~(~key_type() << mb) >> mask_bits); } key_type partition_pos(typename table_type::const_iterator part) const { return position + (std::distance(table.begin(), part) << mask_bits); } void insert(key_type pos, unsigned int mb, const mapped_value_type& val); const mapped_value_type& at(key_type key) const; unsigned int mask_bits; key_type position; table_type table; }; template class extents : private extents_base { public: typedef extents_base base_type; typedef typename base_type::key_type key_type; typedef base_type value_type; typedef typename base_type::range_type range_type; typedef typename base_type::mapped_type mapped_type; typedef typename base_type::mapped_value_type mapped_value_type; typedef typename base_type::table_type table_type; static const key_type mask_bits = MaskBits; static const key_type table_bits = TableBits; static const key_type table_size = TableSize; using base_type::at; using base_type::sizeof_data; extents(); bool is_equal_range(key_type first, key_type last, const mapped_value_type& val) const; void insert(key_type pos, unsigned int mb, const mapped_value_type& val); base_type* data() { return this; } }; template extents::extents() : base_type(key_type(), mask_bits - table_bits, mapped_value_type()) { } template extents_base::~extents_base() { for (typename table_type::const_iterator itr = table.begin(), last = table.end(); itr != last; itr++) delete itr->first; } template unsigned int extents_base::sizeof_data() const { unsigned int sum = sizeof(*this); for (typename table_type::const_iterator itr = table.begin(), last = table.end(); itr != last; itr++) if (itr->first != NULL) sum += itr->first->sizeof_data(); return sum; } template void extents::insert(key_type pos, unsigned int mb, const mapped_value_type& val) { key_type mask = ~key_type() << mb; base_type::insert(pos & mask, mb, val); } template void extents_base::insert(key_type pos, unsigned int mb, const mapped_value_type& val) { // RESTRICTED typename table_type::iterator first = partition_at(pos); typename table_type::iterator last = partition_at(pos) + mask_distance(mb) + 1; if (mb < mask_bits) { if (first->first == NULL) first->first = new extents_base(this, first); first->first->insert(pos, mb, val); return; } while (first != last) { if (first->first != NULL) { delete first->first; first->first = NULL; } (first++)->second = val; } } template bool extents::is_equal_range(key_type first, key_type last, const mapped_value_type& val) const { // RESTRICTED first = std::max(first, key_type()); last = std::min(last, key_type() + (~key_type() >> (sizeof(key_type) * 8 - MaskBits))); if (first <= last) return base_type::is_equal_range(first, last, val); else return true; } template bool extents_base::is_equal_range(key_type key_first, key_type key_last, const mapped_value_type& val) const { // RESTRICTED typename table_type::const_iterator first = partition_at(key_first); typename table_type::const_iterator last = partition_at(key_last) + 1; do { // std::cout << "shift_amount " << key_first << ' ' << key_last << std::endl; if (first->first == NULL && val != first->second) return false; if (first->first != NULL && !first->first->is_equal_range(std::max(key_first, partition_pos(first)), std::min(key_last, partition_pos(first + 1) - 1), val)) return false; } while (++first != last); return true; } // Assumes 'key' is within the range of the range. template const typename extents_base::mapped_value_type& extents_base::at(key_type key) const { typename table_type::const_iterator itr = partition_at(key); while (itr->first != NULL) itr = itr->first->partition_at(key); return itr->second; } } #endif libtorrent-0.13.2/src/torrent/utils/log.cc000644 000765 000024 00000030345 11732116730 021443 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "log.h" #include "log_buffer.h" #include "globals.h" #include "rak/algorithm.h" #include "rak/timer.h" #include "torrent/exceptions.h" #include "torrent/download_info.h" #include "torrent/data/download_data.h" #include #include #include #include #include #include #include #include #include namespace tr1 { using namespace std::tr1; } namespace torrent { typedef std::vector log_slot_list; struct log_cache_entry { bool equal_outputs(uint64_t out) const { return out == outputs; } void allocate(unsigned int count) { cache_first = new log_slot[count]; cache_last = cache_first + count; } void clear() { delete [] cache_first; cache_first = NULL; cache_last = NULL; } uint64_t outputs; log_slot* cache_first; log_slot* cache_last; }; typedef std::vector log_cache_list; typedef std::vector > log_child_list; log_output_list log_outputs; log_child_list log_children; log_cache_list log_cache; log_group_list log_groups; pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; // Removing logs always triggers a check if we got any un-used // log_output objects. void log_update_child_cache(int index) { log_child_list::const_iterator first = std::find_if(log_children.begin(), log_children.end(), std::bind2nd(std::greater_equal >(), std::make_pair(index, 0))); if (first == log_children.end()) return; uint64_t outputs = log_groups[index].cached_outputs(); while (first != log_children.end() && first->first == index) { if ((outputs & log_groups[first->second].cached_outputs()) != outputs) { log_groups[first->second].set_cached_outputs(outputs | log_groups[first->second].cached_outputs()); log_update_child_cache(first->second); } first++; } // If we got any circular connections re-do the update to ensure all // children have our new outputs. if (outputs != log_groups[index].cached_outputs()) log_update_child_cache(index); } void log_rebuild_cache() { std::for_each(log_groups.begin(), log_groups.end(), std::mem_fun_ref(&log_group::clear_cached_outputs)); for (int i = 0; i < LOG_GROUP_MAX_SIZE; i++) log_update_child_cache(i); // Clear the cache... std::for_each(log_cache.begin(), log_cache.end(), std::mem_fun_ref(&log_cache_entry::clear)); log_cache.clear(); for (int idx = 0, last = log_groups.size(); idx != last; idx++) { uint64_t use_outputs = log_groups[idx].cached_outputs(); if (use_outputs == 0) { log_groups[idx].set_cached(NULL, NULL); continue; } log_cache_list::iterator cache_itr = std::find_if(log_cache.begin(), log_cache.end(), tr1::bind(&log_cache_entry::equal_outputs, tr1::placeholders::_1, use_outputs)); if (cache_itr == log_cache.end()) { cache_itr = log_cache.insert(log_cache.end(), log_cache_entry()); cache_itr->outputs = use_outputs; cache_itr->allocate(rak::popcount_wrapper(use_outputs)); log_slot* dest_itr = cache_itr->cache_first; for (log_output_list::iterator itr = log_outputs.begin(), last = log_outputs.end(); itr != last; itr++, use_outputs >>= 1) { if (use_outputs & 0x1) *dest_itr++ = itr->second; } } log_groups[idx].set_cached(cache_itr->cache_first, cache_itr->cache_last); } } void log_group::internal_print(const HashString* hash, const char* subsystem, const void* dump_data, size_t dump_size, const char* fmt, ...) { va_list ap; unsigned int buffer_size = 4096; char buffer[buffer_size]; char* first = buffer; if (hash != NULL && subsystem != NULL) { first = hash_string_to_hex(*hash, first); first += snprintf(first, 4096 - (first - buffer), "->%s: ", subsystem); } va_start(ap, fmt); int count = vsnprintf(first, 4096 - (first - buffer), fmt, ap); first += std::min(count, buffer_size - 1); va_end(ap); if (count <= 0) return; pthread_mutex_lock(&log_mutex); std::for_each(m_first, m_last, tr1::bind(&log_slot::operator(), tr1::placeholders::_1, buffer, std::distance(buffer, first), std::distance(log_groups.begin(), this))); if (dump_data != NULL) std::for_each(m_first, m_last, tr1::bind(&log_slot::operator(), tr1::placeholders::_1, (const char*)dump_data, dump_size, -1)); pthread_mutex_unlock(&log_mutex); } #define LOG_CASCADE(parent) LOG_CHILDREN_CASCADE(parent, parent) #define LOG_CHILDREN_CASCADE(parent, subgroup) \ log_children.push_back(std::make_pair(parent + LOG_ERROR, subgroup + LOG_CRITICAL)); \ log_children.push_back(std::make_pair(parent + LOG_WARN, subgroup + LOG_ERROR)); \ log_children.push_back(std::make_pair(parent + LOG_NOTICE, subgroup + LOG_WARN)); \ log_children.push_back(std::make_pair(parent + LOG_INFO, subgroup + LOG_NOTICE)); \ log_children.push_back(std::make_pair(parent + LOG_DEBUG, subgroup + LOG_INFO)); #define LOG_CHILDREN_SUBGROUP(parent, subgroup) \ log_children.push_back(std::make_pair(parent + LOG_CRITICAL, subgroup + LOG_CRITICAL)); \ log_children.push_back(std::make_pair(parent + LOG_ERROR, subgroup + LOG_ERROR)); \ log_children.push_back(std::make_pair(parent + LOG_WARN, subgroup + LOG_WARN)); \ log_children.push_back(std::make_pair(parent + LOG_NOTICE, subgroup + LOG_NOTICE)); \ log_children.push_back(std::make_pair(parent + LOG_INFO, subgroup + LOG_INFO)); \ log_children.push_back(std::make_pair(parent + LOG_DEBUG, subgroup + LOG_DEBUG)); void log_initialize() { pthread_mutex_lock(&log_mutex); LOG_CASCADE(LOG_CRITICAL); LOG_CASCADE(LOG_CONNECTION_CRITICAL); LOG_CASCADE(LOG_DHT_CRITICAL); LOG_CASCADE(LOG_PEER_CRITICAL); LOG_CASCADE(LOG_RPC_CRITICAL); LOG_CASCADE(LOG_SOCKET_CRITICAL); LOG_CASCADE(LOG_STORAGE_CRITICAL); LOG_CASCADE(LOG_THREAD_CRITICAL); LOG_CASCADE(LOG_TRACKER_CRITICAL); LOG_CASCADE(LOG_TORRENT_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_CONNECTION_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_DHT_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_PEER_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_RPC_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_SOCKET_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_STORAGE_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_THREAD_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_TRACKER_CRITICAL); LOG_CHILDREN_CASCADE(LOG_CRITICAL, LOG_TORRENT_CRITICAL); std::sort(log_children.begin(), log_children.end()); log_rebuild_cache(); pthread_mutex_unlock(&log_mutex); } void log_cleanup() { pthread_mutex_lock(&log_mutex); log_groups.assign(log_group()); log_outputs.clear(); log_children.clear(); std::for_each(log_cache.begin(), log_cache.end(), std::mem_fun_ref(&log_cache_entry::clear)); log_cache.clear(); pthread_mutex_unlock(&log_mutex); } log_output_list::iterator log_find_output_name(const char* name) { log_output_list::iterator itr = log_outputs.begin(); log_output_list::iterator last = log_outputs.end(); while (itr != last && itr->first != name) itr++; return itr; } // Add limit of 64 log entities... void log_open_output(const char* name, log_slot slot) { pthread_mutex_lock(&log_mutex); if (log_outputs.size() >= (size_t)std::numeric_limits::digits) { pthread_mutex_unlock(&log_mutex); throw input_error("Cannot open more than 64 log output handlers."); } if (log_find_output_name(name) != log_outputs.end()) { pthread_mutex_unlock(&log_mutex); throw input_error("Log name already used."); } log_outputs.push_back(std::make_pair(name, slot)); log_rebuild_cache(); pthread_mutex_unlock(&log_mutex); } void log_close_output(const char* name) { } void log_add_group_output(int group, const char* name) { pthread_mutex_lock(&log_mutex); log_output_list::iterator itr = log_find_output_name(name); if (itr == log_outputs.end()) { pthread_mutex_unlock(&log_mutex); throw input_error("Log name not found."); } log_groups[group].set_outputs(log_groups[group].outputs() | (0x1 << std::distance(log_outputs.begin(), itr))); log_rebuild_cache(); pthread_mutex_unlock(&log_mutex); } void log_remove_group_output(int group, const char* name) { } // The log_children list is since we build the output // cache by crawling from child to parent. void log_add_child(int group, int child) { pthread_mutex_lock(&log_mutex); if (std::find(log_children.begin(), log_children.end(), std::make_pair(group, child)) != log_children.end()) return; log_children.push_back(std::make_pair(group, child)); std::sort(log_children.begin(), log_children.end()); log_rebuild_cache(); pthread_mutex_unlock(&log_mutex); } void log_remove_child(int group, int child) { // Remove from all groups, then modify all outputs. } const char log_level_char[] = { 'C', 'E', 'W', 'N', 'I', 'D' }; void log_file_write(tr1::shared_ptr& outfile, const char* data, size_t length, int group) { // Add group name, data, etc as flags. // Normal groups are nul-terminated strings. if (group >= 0) { *outfile << cachedTime.seconds() << ' ' << log_level_char[group % 6] << ' ' << data << std::endl; } else if (group == -1) { *outfile << "---DUMP---" << std::endl; if (length != 0) { outfile->rdbuf()->sputn(data, length); *outfile << std::endl; } *outfile << "---END---" << std::endl; } } // TODO: Allow for different write functions that prepend timestamps, // etc. void log_open_file_output(const char* name, const char* filename) { tr1::shared_ptr outfile(new std::ofstream(filename)); if (!outfile->good()) throw input_error("Could not open log file '" + std::string(filename) + "'."); // log_open_output(name, tr1::bind(&std::ofstream::write, outfile, tr1::placeholders::_1, tr1::placeholders::_2)); log_open_output(name, tr1::bind(&log_file_write, outfile, tr1::placeholders::_1, tr1::placeholders::_2, tr1::placeholders::_3)); } log_buffer* log_open_log_buffer(const char* name) { log_buffer* buffer = new log_buffer; try { log_open_output(name, tr1::bind(&log_buffer::lock_and_push_log, buffer, tr1::placeholders::_1, tr1::placeholders::_2, tr1::placeholders::_3)); return buffer; } catch (torrent::input_error& e) { delete buffer; throw; } } } libtorrent-0.13.2/src/torrent/utils/log.h000644 000765 000024 00000015331 11744202447 021307 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_LOG_H #define LIBTORRENT_UTILS_LOG_H #include #include #include #include #include namespace torrent { // TODO: Add option_strings support. enum { LOG_CRITICAL, LOG_ERROR, LOG_WARN, LOG_NOTICE, LOG_INFO, LOG_DEBUG, LOG_CONNECTION_CRITICAL, LOG_CONNECTION_ERROR, LOG_CONNECTION_WARN, LOG_CONNECTION_NOTICE, LOG_CONNECTION_INFO, LOG_CONNECTION_DEBUG, LOG_DHT_CRITICAL, LOG_DHT_ERROR, LOG_DHT_WARN, LOG_DHT_NOTICE, LOG_DHT_INFO, LOG_DHT_DEBUG, LOG_PEER_CRITICAL, LOG_PEER_ERROR, LOG_PEER_WARN, LOG_PEER_NOTICE, LOG_PEER_INFO, LOG_PEER_DEBUG, LOG_RPC_CRITICAL, LOG_RPC_ERROR, LOG_RPC_WARN, LOG_RPC_NOTICE, LOG_RPC_INFO, LOG_RPC_DEBUG, LOG_SOCKET_CRITICAL, LOG_SOCKET_ERROR, LOG_SOCKET_WARN, LOG_SOCKET_NOTICE, LOG_SOCKET_INFO, LOG_SOCKET_DEBUG, LOG_STORAGE_CRITICAL, LOG_STORAGE_ERROR, LOG_STORAGE_WARN, LOG_STORAGE_NOTICE, LOG_STORAGE_INFO, LOG_STORAGE_DEBUG, LOG_THREAD_CRITICAL, LOG_THREAD_ERROR, LOG_THREAD_WARN, LOG_THREAD_NOTICE, LOG_THREAD_INFO, LOG_THREAD_DEBUG, LOG_TRACKER_CRITICAL, LOG_TRACKER_ERROR, LOG_TRACKER_WARN, LOG_TRACKER_NOTICE, LOG_TRACKER_INFO, LOG_TRACKER_DEBUG, LOG_TORRENT_CRITICAL, LOG_TORRENT_ERROR, LOG_TORRENT_WARN, LOG_TORRENT_NOTICE, LOG_TORRENT_INFO, LOG_TORRENT_DEBUG, LOG_GROUP_MAX_SIZE }; #define lt_log_is_valid(log_group) (torrent::log_groups[log_group].valid()) #define lt_log_print(log_group, ...) \ if (torrent::log_groups[log_group].valid()) \ torrent::log_groups[log_group].internal_print(NULL, NULL, NULL, NULL, __VA_ARGS__); #define lt_log_print_info(log_group, log_info, log_subsystem, ...) \ if (torrent::log_groups[log_group].valid()) \ torrent::log_groups[log_group].internal_print(&log_info->hash(), log_subsystem, NULL, NULL, __VA_ARGS__); #define lt_log_print_data(log_group, log_data, log_subsystem, ...) \ if (torrent::log_groups[log_group].valid()) \ torrent::log_groups[log_group].internal_print(&log_data->hash(), log_subsystem, NULL, NULL, __VA_ARGS__); #define lt_log_print_dump(log_group, log_dump_data, log_dump_size, ...) \ if (torrent::log_groups[log_group].valid()) \ torrent::log_groups[log_group].internal_print(NULL, NULL, log_dump_data, log_dump_size, __VA_ARGS__); \ #define lt_log_print_info_dump(log_group, log_dump_data, log_dump_size, log_info, log_subsystem, ...) \ if (torrent::log_groups[log_group].valid()) \ torrent::log_groups[log_group].internal_print(&log_info->hash(), log_subsystem, log_dump_data, log_dump_size, __VA_ARGS__); \ struct log_cached_outputs; class DownloadInfo; class download_data; class log_buffer; typedef std::tr1::function log_slot; typedef std::vector > log_output_list; class LIBTORRENT_EXPORT log_group { public: log_group() : m_outputs(0), m_cached_outputs(0), m_first(NULL), m_last(NULL) {} bool valid() const { return m_first != NULL; } bool empty() const { return m_first == NULL; } size_t size_outputs() const { return std::distance(m_first, m_last); } // // Internal: // void internal_print(const HashString* hash, const char* subsystem, const void* dump_data, size_t dump_size, const char* fmt, ...); uint64_t outputs() const { return m_outputs; } uint64_t cached_outputs() const { return m_cached_outputs; } void clear_cached_outputs() { m_cached_outputs = m_outputs; } void set_outputs(uint64_t val) { m_outputs = val; } void set_cached_outputs(uint64_t val) { m_cached_outputs = val; } void set_cached(log_slot* f, log_slot* l) { m_first = f; m_last = l; } private: uint64_t m_outputs; uint64_t m_cached_outputs; log_slot* m_first; log_slot* m_last; }; typedef std::tr1::array log_group_list; extern log_group_list log_groups LIBTORRENT_EXPORT; extern log_output_list log_outputs LIBTORRENT_EXPORT; // Called by torrent::initialize(). void log_initialize() LIBTORRENT_EXPORT; void log_cleanup() LIBTORRENT_EXPORT; void log_open_output(const char* name, log_slot slot) LIBTORRENT_EXPORT; void log_close_output(const char* name) LIBTORRENT_EXPORT; void log_add_group_output(int group, const char* name) LIBTORRENT_EXPORT; void log_remove_group_output(int group, const char* name) LIBTORRENT_EXPORT; void log_add_child(int group, int child) LIBTORRENT_EXPORT; void log_remove_child(int group, int child) LIBTORRENT_EXPORT; void log_open_file_output(const char* name, const char* filename) LIBTORRENT_EXPORT; log_buffer* log_open_log_buffer(const char* name) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/utils/log_buffer.cc000644 000765 000024 00000004635 11727634354 023012 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "log_buffer.h" #include #include #include "globals.h" namespace tr1 { using namespace std::tr1; } namespace torrent { // Rename function/args? log_buffer::const_iterator log_buffer::find_older(int32_t older_than) { if (empty() || !back().is_younger_than(older_than)) return end(); return std::find_if(begin(), end(), tr1::bind(&log_entry::is_younger_or_same, tr1::placeholders::_1, older_than)); } void log_buffer::lock_and_push_log(const char* data, size_t length, int group) { if (group < 0) return; lock(); if (size() >= max_size()) base_type::pop_front(); base_type::push_back(log_entry(cachedTime.seconds(), group % 6, std::string(data, length))); if (m_slot_update) m_slot_update(); unlock(); } } libtorrent-0.13.2/src/torrent/utils/log_buffer.h000644 000765 000024 00000006655 11727634354 022660 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_LOG_BUFFER_H #define LIBTORRENT_UTILS_LOG_BUFFER_H #include #include #include #include #include namespace torrent { struct log_entry { log_entry(int32_t t, int32_t grp, const std::string& msg) : timestamp(t), group(grp), message(msg) {} bool is_older_than(int32_t t) const { return timestamp < t; } bool is_younger_than(int32_t t) const { return timestamp > t; } bool is_younger_or_same(int32_t t) const { return timestamp >= t; } int32_t timestamp; int32_t group; std::string message; }; class LIBTORRENT_EXPORT log_buffer : private std::deque { public: typedef std::deque base_type; typedef std::tr1::function slot_void; using base_type::iterator; using base_type::const_iterator; using base_type::reverse_iterator; using base_type::const_reverse_iterator; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::front; using base_type::back; using base_type::empty; using base_type::size; log_buffer() : m_max_size(200) { pthread_mutex_init(&m_lock, NULL); } int max_size() const { return m_max_size; } // Always lock before calling any function. void lock() { pthread_mutex_lock(&m_lock); } void unlock() { pthread_mutex_unlock(&m_lock); } const_iterator find_older(int32_t older_than); void lock_and_set_update_slot(const slot_void& slot) { lock(); m_slot_update = slot; unlock(); } void lock_and_push_log(const char* data, size_t length, int group); private: pthread_mutex_t m_lock; int m_max_size; slot_void m_slot_update; }; } #endif libtorrent-0.13.2/src/torrent/utils/log_files.cc000644 000765 000024 00000017747 11705767057 022656 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include #include "rak/timer.h" #include "log_files.h" #include "torrent/download/group_entry.h" #include "protocol/peer_connection_base.h" namespace torrent { log_file log_files[LOG_MAX_SIZE] = { log_file("mincore_stats"), log_file("choke_changes") }; bool log_file::open_file(const char* filename) { if (m_fd != -1) return false; m_last_update = rak::timer::current().seconds(); return (m_fd = open(filename, O_APPEND | O_RDWR | O_CREAT, 0666)) != -1; } void log_file::close() { if (m_fd) return; ::close(m_fd); m_fd = -1; } log_file* find_log_file(const char* name) { for (log_file* first = log_files, *last = log_files + LOG_MAX_SIZE; first != last; first++) if (std::strcmp(name, first->name()) == 0) return first; return NULL; } // // Specific log handling: // struct log_mincore_stats { int counter_incore; int counter_not_incore; int counter_incore_new; int counter_not_incore_new; int counter_incore_break; int counter_sync_success; int counter_sync_failed; int counter_sync_not_synced; int counter_sync_not_deallocated; int counter_alloc_failed; uint64_t velocity_allocate; uint64_t velocity_deallocate; }; log_mincore_stats log_mincore_stats_instance = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; void log_mincore_stats_func_sync_success(int count) { log_mincore_stats_instance.counter_sync_success += count; } void log_mincore_stats_func_sync_failed(int count) { log_mincore_stats_instance.counter_sync_failed += count; } void log_mincore_stats_func_sync_not_synced(int count) { log_mincore_stats_instance.counter_sync_not_synced += count; } void log_mincore_stats_func_sync_not_deallocated(int count) { log_mincore_stats_instance.counter_sync_not_deallocated += count; } void log_mincore_stats_func_alloc_failed(int count) { log_mincore_stats_instance.counter_alloc_failed += count; } void log_mincore_stats_func_alloc(int velocity) { log_mincore_stats_instance.velocity_allocate += velocity; } void log_mincore_stats_func_dealloc(int velocity) { log_mincore_stats_instance.velocity_deallocate += velocity; } void log_mincore_stats_func(bool is_incore, bool new_index, bool& continous) { log_file* lf = &log_files[LOG_MINCORE_STATS]; if (rak::timer::current().seconds() >= lf->last_update() + 10) { char buffer[256]; // Log the result of mincore for every piece uploaded to a file. unsigned int buf_length = snprintf(buffer, 256, "%i %u %u %u %u %u %u %u %u %u %u %llu %llu\n", lf->last_update(), log_mincore_stats_instance.counter_incore, log_mincore_stats_instance.counter_incore_new, log_mincore_stats_instance.counter_not_incore, log_mincore_stats_instance.counter_not_incore_new, log_mincore_stats_instance.counter_incore_break, log_mincore_stats_instance.counter_sync_success, log_mincore_stats_instance.counter_sync_failed, log_mincore_stats_instance.counter_sync_not_synced, log_mincore_stats_instance.counter_sync_not_deallocated, log_mincore_stats_instance.counter_alloc_failed, (long long unsigned int)log_mincore_stats_instance.velocity_allocate, (long long unsigned int)log_mincore_stats_instance.velocity_deallocate); // Add a zero'ed log entry so that graphs will look right after a // long period with no activity. if (rak::timer::current().seconds() >= lf->last_update() + 20) buf_length += snprintf(buffer + buf_length, 256 - buf_length, "%i 0 0 0 0 0 0 0 0 0 0 0 0\n", lf->last_update() + 10); if (rak::timer::current().seconds() >= lf->last_update() + 30) buf_length += snprintf(buffer + buf_length, 256 - buf_length, "%i 0 0 0 0 0 0 0 0 0 0 0 0\n", rak::timer::current().seconds() / 10 * 10 - 10); int __UNUSED result = write(lf->file_descriptor(), buffer, buf_length); lf->set_last_update(rak::timer::current().seconds() / 10 * 10); std::memset(&log_mincore_stats_instance, 0, sizeof(log_mincore_stats)); } log_mincore_stats_instance.counter_incore += !new_index && is_incore; log_mincore_stats_instance.counter_incore_new += new_index && is_incore; log_mincore_stats_instance.counter_not_incore += !new_index && !is_incore; log_mincore_stats_instance.counter_not_incore_new += new_index && !is_incore; log_mincore_stats_instance.counter_incore_break += continous && !is_incore; continous = is_incore; } void log_choke_changes_func_new(void* address, const char* title, int quota, int adjust) { log_file* lf = &log_files[LOG_CHOKE_CHANGES]; lf->set_last_update(rak::timer::current().seconds()); char buffer[256]; unsigned int buf_length = snprintf(buffer, 256, "%p %i %s %i %i\n", address, lf->last_update(), title, quota, adjust); int __UNUSED result = write(lf->file_descriptor(), buffer, buf_length); } void log_choke_changes_func_peer(void* address, const char* title, weighted_connection* data) { log_file* lf = &log_files[LOG_CHOKE_CHANGES]; char buffer[256]; unsigned int buf_length = snprintf(buffer, 256, "%p %i %s %p %X %llu %llu\n", address, lf->last_update(), title, data->connection, data->weight, (long long unsigned int)data->connection->up_rate()->rate(), (long long unsigned int)data->connection->down_rate()->rate()); int __UNUSED result = write(lf->file_descriptor(), buffer, buf_length); } void log_choke_changes_func_allocate(void* address, const char* title, unsigned int index, uint32_t count, int dist) { log_file* lf = &log_files[LOG_CHOKE_CHANGES]; char buffer[256]; unsigned int buf_length = snprintf(buffer, 256, "%p %i %s %u %u %i\n", address, lf->last_update(), title, index, count, dist); int __UNUSED result = write(lf->file_descriptor(), buffer, buf_length); } } libtorrent-0.13.2/src/torrent/utils/log_files.h000644 000765 000024 00000006664 11705767057 022514 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_LOG_FILES_H #define LIBTORRENT_UTILS_LOG_FILES_H #include #include namespace torrent { class LIBTORRENT_EXPORT log_file { public: log_file(const char* str) : m_fd(-1), m_last_update(0), m_name(str) {} bool is_open() const { return m_fd != -1; } int file_descriptor() const { return m_fd; } int32_t last_update() const { return m_last_update; } const char* name() const { return m_name; } void set_last_update(int32_t seconds) { m_last_update = seconds; } bool open_file(const char* filename); void close(); private: int m_fd; int32_t m_last_update; const char* m_name; }; enum { LOG_MINCORE_STATS, LOG_CHOKE_CHANGES, LOG_MAX_SIZE }; extern log_file log_files[LOG_MAX_SIZE] LIBTORRENT_EXPORT; log_file* find_log_file(const char* name) LIBTORRENT_EXPORT; // // Internal to libtorrent: // // Update log files: void log_mincore_stats_func(bool is_incore, bool new_index, bool& continous); void log_mincore_stats_func_sync_success(int count); void log_mincore_stats_func_sync_failed(int count); void log_mincore_stats_func_sync_not_synced(int count); void log_mincore_stats_func_sync_not_deallocated(int count); void log_mincore_stats_func_alloc_failed(int count); void log_mincore_stats_func_alloc(int velocity); void log_mincore_stats_func_dealloc(int velocity); struct weighted_connection; void log_choke_changes_func_new(void* address, const char* title, int quota, int adjust); void log_choke_changes_func_peer(void* address, const char* title, weighted_connection* data); void log_choke_changes_func_allocate(void* address, const char* title, unsigned int index, uint32_t count, int dist); } #endif libtorrent-0.13.2/src/torrent/utils/Makefile.am000644 000765 000024 00000001152 11744202447 022405 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_torrentutils.la libsub_torrentutils_la_SOURCES = \ extents.h \ log.cc \ log.h \ log_buffer.cc \ log_buffer.h \ log_files.cc \ log_files.h \ option_strings.cc \ option_strings.h \ ranges.h \ resume.cc \ resume.h \ signal_bitfield.cc \ signal_bitfield.h \ thread_base.cc \ thread_base.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/utils libtorrentinclude_HEADERS = \ extents.h \ log.h \ log_buffer.h \ log_files.h \ option_strings.h \ ranges.h \ resume.h \ signal_bitfield.h \ thread_base.h libtorrent-0.13.2/src/torrent/utils/Makefile.in000644 000765 000024 00000046043 11744204216 022422 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/torrent/utils DIST_COMMON = $(libtorrentinclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_torrentutils_la_LIBADD = am_libsub_torrentutils_la_OBJECTS = log.lo log_buffer.lo log_files.lo \ option_strings.lo resume.lo signal_bitfield.lo thread_base.lo libsub_torrentutils_la_OBJECTS = $(am_libsub_torrentutils_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_torrentutils_la_SOURCES) DIST_SOURCES = $(libsub_torrentutils_la_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libtorrentincludedir)" HEADERS = $(libtorrentinclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_torrentutils.la libsub_torrentutils_la_SOURCES = \ extents.h \ log.cc \ log.h \ log_buffer.cc \ log_buffer.h \ log_files.cc \ log_files.h \ option_strings.cc \ option_strings.h \ ranges.h \ resume.cc \ resume.h \ signal_bitfield.cc \ signal_bitfield.h \ thread_base.cc \ thread_base.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/utils libtorrentinclude_HEADERS = \ extents.h \ log.h \ log_buffer.h \ log_files.h \ option_strings.h \ ranges.h \ resume.h \ signal_bitfield.h \ thread_base.h all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/torrent/utils/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/torrent/utils/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_torrentutils.la: $(libsub_torrentutils_la_OBJECTS) $(libsub_torrentutils_la_DEPENDENCIES) $(EXTRA_libsub_torrentutils_la_DEPENDENCIES) $(CXXLINK) $(libsub_torrentutils_la_OBJECTS) $(libsub_torrentutils_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log_buffer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log_files.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/option_strings.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resume.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signal_bitfield.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_base.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-libtorrentincludeHEADERS: $(libtorrentinclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(libtorrentincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libtorrentincludedir)" @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtorrentincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtorrentincludedir)" || exit $$?; \ done uninstall-libtorrentincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libtorrentincludedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libtorrentincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-libtorrentincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libtorrentincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libtorrentincludeHEADERS install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libtorrentincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/torrent/utils/option_strings.cc000644 000765 000024 00000017705 11744202447 023754 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "torrent/connection_manager.h" #include "torrent/object.h" #include "torrent/download/choke_group.h" #include "torrent/download/choke_queue.h" #include "exceptions.h" #include "download.h" #include "log.h" #include "option_strings.h" namespace torrent { struct option_single { unsigned int size; const char** name; }; struct option_pair { const char* name; unsigned int value; }; option_pair option_list_connection[] = { { "leech", Download::CONNECTION_LEECH }, { "seed", Download::CONNECTION_SEED }, { "initial_seed", Download::CONNECTION_INITIAL_SEED }, { "metadata", Download::CONNECTION_METADATA }, { NULL, 0 } }; option_pair option_list_heuristics[] = { { "upload_leech", choke_queue::HEURISTICS_UPLOAD_LEECH }, { "upload_leech_dummy", choke_queue::HEURISTICS_UPLOAD_LEECH_DUMMY }, { "download_leech", choke_queue::HEURISTICS_DOWNLOAD_LEECH }, { "download_leech_dummy", choke_queue::HEURISTICS_DOWNLOAD_LEECH_DUMMY }, { "invalid", choke_queue::HEURISTICS_MAX_SIZE }, { NULL, 0 } }; option_pair option_list_heuristics_download[] = { { "download_leech", choke_queue::HEURISTICS_DOWNLOAD_LEECH }, { "download_leech_dummy", choke_queue::HEURISTICS_DOWNLOAD_LEECH_DUMMY }, { NULL, 0 } }; option_pair option_list_heuristics_upload[] = { { "upload_leech", choke_queue::HEURISTICS_UPLOAD_LEECH }, { "upload_leech_dummy", choke_queue::HEURISTICS_UPLOAD_LEECH_DUMMY }, { NULL, 0 } }; option_pair option_list_encryption[] = { { "none", torrent::ConnectionManager::encryption_none }, { "allow_incoming", torrent::ConnectionManager::encryption_allow_incoming }, { "try_outgoing", torrent::ConnectionManager::encryption_try_outgoing }, { "require", torrent::ConnectionManager::encryption_require }, { "require_RC4", torrent::ConnectionManager::encryption_require_RC4 }, { "require_rc4", torrent::ConnectionManager::encryption_require_RC4 }, { "enable_retry", torrent::ConnectionManager::encryption_enable_retry }, { "prefer_plaintext", torrent::ConnectionManager::encryption_prefer_plaintext }, { NULL, 0 } }; option_pair option_list_ip_filter[] = { { "unwanted", PeerInfo::flag_unwanted }, { "preferred", PeerInfo::flag_preferred }, { NULL, 0 } }; option_pair option_list_ip_tos[] = { { "default", torrent::ConnectionManager::iptos_default }, { "lowdelay", torrent::ConnectionManager::iptos_lowdelay }, { "throughput", torrent::ConnectionManager::iptos_throughput }, { "reliability", torrent::ConnectionManager::iptos_reliability }, { "mincost", torrent::ConnectionManager::iptos_mincost }, { NULL, 0 } }; option_pair option_list_tracker_mode[] = { { "normal", choke_group::TRACKER_MODE_NORMAL }, { "aggressive", choke_group::TRACKER_MODE_AGGRESSIVE }, { NULL, 0 } }; const char* option_list_log_group[] = { "critical", "error", "warn", "notice", "info", "debug", "connection_critical", "connection_error", "connection_warn", "connection_notice", "connection_info", "connection_debug", "dht_critical", "dht_error", "dht_warn", "dht_notice", "dht_info", "dht_debug", "peer_critical", "peer_error", "peer_warn", "peer_notice", "peer_info", "peer_debug", "rpc_critical", "rpc_error", "rpc_warn", "rpc_notice", "rpc_info", "rpc_debug", "socket_critical", "socket_error", "socket_warn", "socket_notice", "socket_info", "socket_debug", "storage_critical", "storage_error", "storage_warn", "storage_notice", "storage_info", "storage_debug", "thread_critical", "thread_error", "thread_warn", "thread_notice", "thread_info", "thread_debug", "tracker_critical", "tracker_error", "tracker_warn", "tracker_notice", "tracker_info", "tracker_debug", "torrent_critical", "torrent_error", "torrent_warn", "torrent_notice", "torrent_info", "torrent_debug", NULL }; const char* option_list_tracker_event[] = { "updated", "completed", "started", "stopped", "scrape", NULL }; option_pair* option_pair_lists[OPTION_START_COMPACT] = { option_list_connection, option_list_heuristics, option_list_heuristics_download, option_list_heuristics_upload, option_list_encryption, option_list_ip_filter, option_list_ip_tos, option_list_tracker_mode, }; #define OPTION_SINGLE_ENTRY(single_name) \ { sizeof(single_name) / sizeof(const char*) - 1, single_name } option_single option_single_lists[OPTION_SINGLE_SIZE] = { OPTION_SINGLE_ENTRY(option_list_log_group), OPTION_SINGLE_ENTRY(option_list_tracker_event), }; int option_find_string(option_enum opt_enum, const char* name) { if (opt_enum < OPTION_START_COMPACT) { option_pair* itr = option_pair_lists[opt_enum]; do { if (std::strcmp(itr->name, name) == 0) return itr->value; } while ((++itr)->name != NULL); } else if (opt_enum < OPTION_MAX_SIZE) { const char** itr = option_single_lists[opt_enum - OPTION_START_COMPACT].name; do { if (std::strcmp(*itr, name) == 0) return std::distance(option_single_lists[opt_enum - OPTION_START_COMPACT].name, itr); } while (*++itr != NULL); } throw input_error("Invalid option name."); } const char* option_as_string(option_enum opt_enum, unsigned int value) { if (opt_enum < OPTION_START_COMPACT) { option_pair* itr = option_pair_lists[opt_enum]; do { if (itr->value == value) return itr->name; } while ((++itr)->name != NULL); } else if (opt_enum < OPTION_MAX_SIZE) { if (value < option_single_lists[opt_enum - OPTION_START_COMPACT].size) return option_single_lists[opt_enum - OPTION_START_COMPACT].name[value]; } throw input_error("Invalid option value."); } torrent::Object option_list_strings(option_enum opt_enum) { Object::list_type result; if (opt_enum < OPTION_START_COMPACT) { option_pair* itr = option_pair_lists[opt_enum]; while (itr->name != NULL) result.push_back(std::string(itr++->name)); } else if (opt_enum < OPTION_MAX_SIZE) { const char** itr = option_single_lists[opt_enum - OPTION_START_COMPACT].name; while (*itr != NULL) result.push_back(std::string(*itr++)); } return Object::from_list(result); } } libtorrent-0.13.2/src/torrent/utils/option_strings.h000644 000765 000024 00000005115 11705767057 023620 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_OPTION_STRINGS_H #define LIBTORRENT_UTILS_OPTION_STRINGS_H #include #include namespace torrent { class Object; enum option_enum { OPTION_CONNECTION_TYPE, OPTION_CHOKE_HEURISTICS, OPTION_CHOKE_HEURISTICS_DOWNLOAD, OPTION_CHOKE_HEURISTICS_UPLOAD, OPTION_ENCRYPTION, OPTION_IP_FILTER, OPTION_IP_TOS, OPTION_TRACKER_MODE, OPTION_LOG_GROUP, OPTION_TRACKER_EVENT, OPTION_MAX_SIZE, OPTION_START_COMPACT = OPTION_LOG_GROUP, OPTION_SINGLE_SIZE = OPTION_MAX_SIZE - OPTION_START_COMPACT }; int option_find_string(option_enum opt_enum, const char* name) LIBTORRENT_EXPORT; inline int option_find_string_str(option_enum opt_enum, const std::string& name) { return option_find_string(opt_enum, name.c_str()); } const char* option_as_string(option_enum opt_enum, unsigned int value) LIBTORRENT_EXPORT; torrent::Object option_list_strings(option_enum opt_enum) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/utils/ranges.h000644 000765 000024 00000017436 11705767057 022027 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_RANGES_H #define LIBTORRENT_UTILS_RANGES_H #include #include // TODO: Use tr1 functional instead. #include namespace torrent { template class ranges : private std::vector > { public: typedef std::vector > base_type; typedef RangesType bound_type; typedef typename base_type::value_type value_type; typedef typename base_type::reference reference; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::reverse_iterator reverse_iterator; using base_type::clear; using base_type::empty; using base_type::size; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::front; using base_type::back; void insert(bound_type first, bound_type last) { insert(std::make_pair(first, last)); } void erase(bound_type first, bound_type last) { erase(std::make_pair(first, last)); } void insert(value_type r); void erase(value_type r); // Find the first ranges that has an end greater than index. iterator find(bound_type index); const_iterator find(bound_type index) const; // Use find with no closest match. bool has(bound_type index) const; size_t intersect_distance(bound_type first, bound_type last) const; size_t intersect_distance(value_type range) const; static ranges create_union(const ranges& left, const ranges& right); }; template void ranges::insert(value_type r) { if (r.first >= r.second) return; iterator first = std::find_if(begin(), end(), rak::less_equal(r.first, rak::const_mem_ref(&value_type::second))); if (first == end() || r.second < first->first) { // The new range is before the first, after the last or between // two ranges. base_type::insert(first, r); } else { first->first = std::min(r.first, first->first); first->second = std::max(r.second, first->second); iterator last = std::find_if(first, end(), rak::less(first->second, rak::const_mem_ref(&value_type::second))); if (last != end() && first->second >= last->first) first->second = (last++)->second; base_type::erase(first + 1, last); } } template void ranges::erase(value_type r) { if (r.first >= r.second) return; iterator first = std::find_if(begin(), end(), rak::less(r.first, rak::const_mem_ref(&value_type::second))); iterator last = std::find_if(first, end(), rak::less(r.second, rak::const_mem_ref(&value_type::second))); if (first == end()) return; if (first == last) { if (r.first > first->first) { std::swap(first->first, r.second); base_type::insert(first, value_type(r.second, r.first)); } else if (r.second > first->first) { first->first = r.second; } } else { if (r.first > first->first) (first++)->second = r.first; if (last != end() && r.second > last->first) last->first = r.second; base_type::erase(first, last); } } // Find the first ranges that has an end greater than index. template inline typename ranges::iterator ranges::find(bound_type index) { return std::find_if(begin(), end(), rak::less(index, rak::const_mem_ref(&value_type::second))); } template inline typename ranges::const_iterator ranges::find(bound_type index) const { return std::find_if(begin(), end(), rak::less(index, rak::const_mem_ref(&value_type::second))); } // Use find with no closest match. template bool ranges::has(bound_type index) const { const_iterator itr = find(index); return itr != end() && index >= itr->first; } template size_t ranges::intersect_distance(bound_type first, bound_type last) const { return intersect_distance(std::make_pair(first, last)); } // The total length of all the extents within the bounds of 'range'. template size_t ranges::intersect_distance(value_type range) const { const_iterator first = find(range.first); if (first == end() || range.second <= first->first) return 0; size_t dist = std::min(range.second, first->second) - std::max(range.first, first->first); while (++first != end() && range.second > first->first) dist += std::min(range.second, first->second) - first->first; return dist; } template ranges ranges::create_union(const ranges& left, const ranges& right) { if (left.empty()) return right; if (right.empty()) return left; ranges result; typename ranges::const_iterator left_itr = left.begin(); typename ranges::const_iterator left_last = left.end(); typename ranges::const_iterator right_itr = right.begin(); typename ranges::const_iterator right_last = right.end(); if (left_itr->first < right_itr->first) result.base_type::push_back(*left_itr++); else result.base_type::push_back(*right_itr++); while (left_itr != left_last && right_itr != right_last) { value_type next; if (left_itr->first < right_itr->first) next = *left_itr++; else next = *right_itr++; if (next.first <= result.back().second) result.back().second = std::max(next.second, result.back().second); else result.base_type::push_back(next); } // Only one of these while loops will be triggered. for (; left_itr != left_last; left_itr++) { if (left_itr->first <= result.back().second) result.back().second = std::max(left_itr->second, result.back().second); else result.base_type::push_back(*left_itr); } for (; right_itr != right_last; right_itr++) { if (right_itr->first <= result.back().second) result.back().second = std::max(right_itr->second, result.back().second); else result.base_type::push_back(*right_itr); } return result; } } #endif libtorrent-0.13.2/src/torrent/utils/resume.cc000644 000765 000024 00000043460 11716350717 022173 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "peer/peer_info.h" #include "peer/peer_list.h" #include "data/file.h" #include "data/file_list.h" #include "data/transfer_list.h" #include "net/address_list.h" #include "common.h" #include "bitfield.h" #include "download.h" #include "download_info.h" #include "object.h" #include "tracker.h" #include "tracker_list.h" #include "globals.h" #include "resume.h" namespace torrent { void resume_load_progress(Download download, const Object& object) { if (!object.has_key_list("files")) return; const Object::list_type& files = object.get_key_list("files"); if (files.size() != download.file_list()->size_files()) return; if (object.has_key_string("bitfield")) { const Object::string_type& bitfield = object.get_key_string("bitfield"); if (bitfield.size() != download.file_list()->bitfield()->size_bytes()) return; download.set_bitfield((uint8_t*)bitfield.c_str(), (uint8_t*)(bitfield.c_str() + bitfield.size())); } else if (object.has_key_value("bitfield")) { Object::value_type chunksDone = object.get_key_value("bitfield"); if (chunksDone == download.file_list()->bitfield()->size_bits()) download.set_bitfield(true); else if (chunksDone == 0) download.set_bitfield(false); else return; } else { return; } Object::list_const_iterator filesItr = files.begin(); FileList* fileList = download.file_list(); for (FileList::iterator listItr = fileList->begin(), listLast = fileList->end(); listItr != listLast; ++listItr, ++filesItr) { rak::file_stat fs; if (!filesItr->has_key_value("mtime")) { // If 'mtime' is erased, it means we should start hashing and // downloading the file as if it was a new torrent. (*listItr)->set_flags(File::flag_create_queued | File::flag_resize_queued); download.update_range(Download::update_range_recheck | Download::update_range_clear, (*listItr)->range().first, (*listItr)->range().second); continue; } int64_t mtimeValue = filesItr->get_key_value("mtime"); bool fileExists = fs.update(fileList->root_dir() + (*listItr)->path()->as_string()); // The default action when we have 'mtime' is not to create nor // resize the file. (*listItr)->unset_flags(File::flag_create_queued | File::flag_resize_queued); if (mtimeValue == ~int64_t(0) || mtimeValue == ~int64_t(1)) { // If 'mtime' is ~0 it means we haven't gotten around to // creating the file. // // Else if it is ~1 it means the file doesn't exist nor do we // want to create it. // // When 'mtime' is ~2 we need to recheck the hash without // creating the file. It will just fail on the mtime check // later, so we don't need to handle it explicitly. if (mtimeValue == ~int64_t(0)) (*listItr)->set_flags(File::flag_create_queued | File::flag_resize_queued); // Ensure the bitfield range is cleared so that stray resume // data doesn't get counted. download.update_range(Download::update_range_clear | (fileExists ? Download::update_range_recheck : 0), (*listItr)->range().first, (*listItr)->range().second); continue; } // If the file is the wrong size, queue resize and clear resume // data for that file. if ((uint64_t)fs.size() != (*listItr)->size_bytes()) { (*listItr)->set_flags(File::flag_resize_queued); download.update_range(Download::update_range_clear | Download::update_range_recheck, (*listItr)->range().first, (*listItr)->range().second); continue; } // An 'mtime' of ~3 means the resume data was written while the // torrent was actively downloading, and thus we need to recheck // chunks that might not have been completely written to disk. // // This gets handled below, so just skip to the next file. if (mtimeValue == ~int64_t(3)) continue; // An 'mtime' of ~2 indicates that the resume data was made by an // old rtorrent version which does not include 'uncertain_pieces' // field, and thus can't be relied upon. // // If the 'mtime' is an actual mtime we check to see if it matches // the file, else clear the range. This should be set only for // files that have completed and got no indices in // TransferList::completed_list(). if (mtimeValue == ~int64_t(2) || mtimeValue != fs.modified_time()) { download.update_range(Download::update_range_clear | Download::update_range_recheck, (*listItr)->range().first, (*listItr)->range().second); continue; } } resume_load_uncertain_pieces(download, object); } void resume_save_progress(Download download, Object& object) { // We don't remove the old hash data since it might still be valid, // just that the client didn't finish the check this time. if (!download.is_hash_checked()) return; download.sync_chunks(); // If syncing failed, invalidate all resume data and return. if (!download.is_hash_checked()) { if (!object.has_key_list("files")) return; Object::list_type& files = object.get_key_list("files"); for (Object::list_iterator itr = files.begin(), last = files.end(); itr != last; itr++) itr->insert_key("mtime", ~int64_t(2)); return; } const Bitfield* bitfield = download.file_list()->bitfield(); if (bitfield->is_all_set() || bitfield->is_all_unset()) object.insert_key("bitfield", bitfield->size_set()); else object.insert_key("bitfield", std::string((char*)bitfield->begin(), bitfield->size_bytes())); Object::list_type& files = object.insert_preserve_copy("files", Object::create_list()).first->second.as_list(); Object::list_iterator filesItr = files.begin(); FileList* fileList = download.file_list(); for (FileList::iterator listItr = fileList->begin(), listLast = fileList->end(); listItr != listLast; ++listItr, ++filesItr) { if (filesItr == files.end()) filesItr = files.insert(filesItr, Object::create_map()); else if (!filesItr->is_map()) *filesItr = Object::create_map(); filesItr->insert_key("completed", (int64_t)(*listItr)->completed_chunks()); rak::file_stat fs; bool fileExists = fs.update(fileList->root_dir() + (*listItr)->path()->as_string()); if (!fileExists) { if ((*listItr)->is_create_queued()) // ~0 means the file still needs to be created. filesItr->insert_key("mtime", ~int64_t(0)); else // ~1 means the file shouldn't be created. filesItr->insert_key("mtime", ~int64_t(1)); // } else if ((*listItr)->completed_chunks() == (*listItr)->size_chunks()) { } else if (bitfield->is_all_set()) { // Currently only checking if we're finished. This needs to be // smarter when it comes to downloading partial torrents, etc. // This assumes the syncs are properly called before // resume_save_progress gets called after finishing a torrent. filesItr->insert_key("mtime", (int64_t)fs.modified_time()); } else if (!download.info()->is_active()) { // When stopped, all chunks should have received sync, thus the // file's mtime will be correct. (We hope) filesItr->insert_key("mtime", (int64_t)fs.modified_time()); } else { // If the torrent isn't done and we've not shut down, then set // 'mtime' to ~3 so as to indicate that the 'mtime' is not to be // trusted, yet we have a partial bitfield for the file. filesItr->insert_key("mtime", ~int64_t(3)); } } } void resume_clear_progress(Download download, Object& object) { object.erase_key("bitfield"); } void resume_load_uncertain_pieces(Download download, const Object& object) { // Don't rehash when loading resume data within the same session. if (!object.has_key_string("uncertain_pieces") || !object.has_key_value("uncertain_pieces.timestamp") || object.get_key_value("uncertain_pieces.timestamp") >= (int64_t)download.info()->load_date()) return; const Object::string_type& uncertain = object.get_key_string("uncertain_pieces"); for (const char* itr = uncertain.c_str(), *last = uncertain.c_str() + uncertain.size(); itr + sizeof(uint32_t) <= last; itr += sizeof(uint32_t)) { // Fix this so it does full ranges. download.update_range(Download::update_range_recheck | Download::update_range_clear, ntohl(*(uint32_t*)itr), ntohl(*(uint32_t*)itr) + 1); } } void resume_save_uncertain_pieces(Download download, Object& object) { // Add information on what chunks might still not have been properly // written to disk. object.erase_key("uncertain_pieces"); object.insert_key("uncertain_pieces.timestamp", rak::timer::current_seconds()); const TransferList::completed_list_type& completedList = download.transfer_list()->completed_list(); TransferList::completed_list_type::const_iterator itr = std::find_if(completedList.begin(), completedList.end(), rak::less_equal((rak::timer::current() - rak::timer::from_minutes(15)).usec(), rak::const_mem_ref(&TransferList::completed_list_type::value_type::first))); if (itr == completedList.end()) return; std::vector buffer; buffer.reserve(std::distance(itr, completedList.end())); while (itr != completedList.end()) buffer.push_back((itr++)->second); std::sort(buffer.begin(), buffer.end()); for (std::vector::iterator itr2 = buffer.begin(), last = buffer.end(); itr2 != last; itr2++) *itr2 = htonl(*itr2); Object::string_type& completed = object.insert_key("uncertain_pieces", std::string()).as_string(); completed.append((const char*)&buffer.front(), buffer.size() * sizeof(uint32_t)); } bool resume_check_target_files(Download download, __UNUSED const Object& object) { FileList* fileList = download.file_list(); if (!fileList->is_open()) return false; if (!fileList->is_root_dir_created()) return false; if (fileList->is_multi_file()) { // Here we should probably check all/most of the files within the // torrent. But for now just return true, as the root dir is // usually created for each (multi) torrent. // int failed = 0; // int exists = 0; // for (FileList::const_iterator itr = fileList->begin(), last = fileList->end(); itr != last; itr++) { // if (!(*itr)->is_previously_created()) // continue; // if ((*itr)->is_created()) // exists++; // else // failed++; // } // return failed >= exists; return true; } else { // We consider empty file lists as being valid. return fileList->empty() || fileList->front()->is_created(); } } void resume_load_file_priorities(Download download, const Object& object) { if (!object.has_key_list("files")) return; const Object::list_type& files = object.get_key_list("files"); Object::list_const_iterator filesItr = files.begin(); Object::list_const_iterator filesLast = files.end(); FileList* fileList = download.file_list(); for (FileList::iterator listItr = fileList->begin(), listLast = fileList->end(); listItr != listLast; ++listItr, ++filesItr) { if (filesItr == filesLast) return; // Update the priority from the fast resume data. if (filesItr->has_key_value("priority") && filesItr->get_key_value("priority") >= 0 && filesItr->get_key_value("priority") <= PRIORITY_HIGH) (*listItr)->set_priority((priority_t)filesItr->get_key_value("priority")); if (filesItr->has_key_value("completed")) (*listItr)->set_completed_chunks(filesItr->get_key_value("completed")); } } void resume_save_file_priorities(Download download, Object& object) { Object::list_type& files = object.insert_preserve_copy("files", Object::create_list()).first->second.as_list(); Object::list_iterator filesItr = files.begin(); FileList* fileList = download.file_list(); for (FileList::iterator listItr = fileList->begin(), listLast = fileList->end(); listItr != listLast; ++listItr, ++filesItr) { if (filesItr == files.end()) filesItr = files.insert(filesItr, Object::create_map()); else if (!filesItr->is_map()) *filesItr = Object::create_map(); filesItr->insert_key("priority", (int64_t)(*listItr)->priority()); } } void resume_load_addresses(Download download, const Object& object) { if (!object.has_key_list("peers")) return; PeerList* peerList = download.peer_list(); const Object::list_type& src = object.get_key_list("peers"); for (Object::list_const_iterator itr = src.begin(), last = src.end(); itr != last; ++itr) { if (!itr->is_map() || !itr->has_key_string("inet") || itr->get_key_string("inet").size() != sizeof(SocketAddressCompact) || !itr->has_key_value("failed") || !itr->has_key_value("last") || itr->get_key_value("last") > cachedTime.seconds()) continue; int flags = 0; rak::socket_address socketAddress = *reinterpret_cast(itr->get_key_string("inet").c_str()); if (socketAddress.port() != 0) flags |= PeerList::address_available; PeerInfo* peerInfo = peerList->insert_address(socketAddress.c_sockaddr(), flags); if (peerInfo == NULL) continue; peerInfo->set_failed_counter(itr->get_key_value("failed")); peerInfo->set_last_connection(itr->get_key_value("last")); } // Tell rTorrent to harvest addresses. } void resume_save_addresses(Download download, Object& object) { const PeerList* peerList = download.peer_list(); Object& dest = object.insert_key("peers", Object::create_list()); for (PeerList::const_iterator itr = peerList->begin(), last = peerList->end(); itr != last; ++itr) { // Add some checks, like see if there's anything interesting to // save, etc. Or if we can reconnect to it at some later time. // // This should really ensure that if called on a torrent that has // been closed for a while, it won't throw out perfectly good // entries. Object& peer = dest.insert_back(Object::create_map()); const rak::socket_address* sa = rak::socket_address::cast_from(itr->second->socket_address()); if (sa->family() == rak::socket_address::af_inet) peer.insert_key("inet", std::string(SocketAddressCompact(sa->sa_inet()->address_n(), htons(itr->second->listen_port())).c_str(), sizeof(SocketAddressCompact))); peer.insert_key("failed", itr->second->failed_counter()); peer.insert_key("last", itr->second->is_connected() ? cachedTime.seconds() : itr->second->last_connection()); } } void resume_load_tracker_settings(Download download, const Object& object) { if (!object.has_key_map("trackers")) return; const Object& src = object.get_key("trackers"); TrackerList* tracker_list = download.tracker_list(); for (Object::map_const_iterator itr = src.as_map().begin(), last = src.as_map().end(); itr != last; ++itr) { if (!itr->second.has_key("extra_tracker") || itr->second.get_key_value("extra_tracker") == 0 || !itr->second.has_key("group")) continue; if (tracker_list->find_url(itr->first) != tracker_list->end()) continue; download.tracker_list()->insert_url(itr->second.get_key_value("group"), itr->first); } for (TrackerList::iterator itr = tracker_list->begin(), last = tracker_list->end(); itr != last; ++itr) { if (!src.has_key_map((*itr)->url())) continue; const Object& trackerObject = src.get_key((*itr)->url()); if (trackerObject.has_key_value("enabled") && trackerObject.get_key_value("enabled") == 0) (*itr)->disable(); else (*itr)->enable(); } } void resume_save_tracker_settings(Download download, Object& object) { Object& dest = object.insert_preserve_copy("trackers", Object::create_map()).first->second; TrackerList* tracker_list = download.tracker_list(); for (TrackerList::iterator itr = tracker_list->begin(), last = tracker_list->end(); itr != last; ++itr) { Object& trackerObject = dest.insert_key((*itr)->url(), Object::create_map()); trackerObject.insert_key("enabled", Object((int64_t)(*itr)->is_enabled())); if ((*itr)->is_extra_tracker()) { trackerObject.insert_key("extra_tracker", Object((int64_t)1)); trackerObject.insert_key("group", (*itr)->group()); } } } } libtorrent-0.13.2/src/torrent/utils/resume.h000644 000765 000024 00000006406 11705767057 022043 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Various functions for loading and saving various states of a // download to an Object. // // These functions use only the public interface, and thus the client // may choose to replace these with their own resume code. // Should propably move this into a sub-directory. #ifndef LIBTORRENT_UTILS_RESUME_H #define LIBTORRENT_UTILS_RESUME_H #include namespace torrent { // When saving resume data for a torrent that is currently active, set // 'onlyCompleted' to ensure that a crash, etc, will cause incomplete // files to be hashed. void resume_load_progress(Download download, const Object& object) LIBTORRENT_EXPORT; void resume_save_progress(Download download, Object& object) LIBTORRENT_EXPORT; void resume_clear_progress(Download download, Object& object) LIBTORRENT_EXPORT; // Do not call 'resume_load_uncertain_pieces' directly. void resume_load_uncertain_pieces(Download download, const Object& object) LIBTORRENT_EXPORT; void resume_save_uncertain_pieces(Download download, Object& object) LIBTORRENT_EXPORT; bool resume_check_target_files(Download download, const Object& object) LIBTORRENT_EXPORT; void resume_load_file_priorities(Download download, const Object& object) LIBTORRENT_EXPORT; void resume_save_file_priorities(Download download, Object& object) LIBTORRENT_EXPORT; void resume_load_addresses(Download download, const Object& object) LIBTORRENT_EXPORT; void resume_save_addresses(Download download, Object& object) LIBTORRENT_EXPORT; void resume_load_tracker_settings(Download download, const Object& object) LIBTORRENT_EXPORT; void resume_save_tracker_settings(Download download, Object& object) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/utils/signal_bitfield.cc000644 000765 000024 00000004745 11716350717 024015 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/exceptions.h" #include "signal_bitfield.h" namespace torrent { // Only the thread owning this signal bitfield should add signals. unsigned int signal_bitfield::add_signal(slot_type slot) { if (m_size >= max_size) throw internal_error("signal_bitfield::add_signal(...): No more available slots."); if (!slot) throw internal_error("signal_bitfield::add_signal(...): Cannot add empty slot."); unsigned int index = m_size; __sync_add_and_fetch(&m_size, 1); m_slots[index] = slot; return index; } void signal_bitfield::work() { bitfield_type bitfield; while (!__sync_bool_compare_and_swap(&m_bitfield, (bitfield = m_bitfield), 0)) ; // Do nothing. unsigned int i = 0; while (bitfield) { if ((bitfield & (1 << i))) { m_slots[i](); bitfield = bitfield & ~(1 << i); } i++; } } } libtorrent-0.13.2/src/torrent/utils/signal_bitfield.h000644 000765 000024 00000004567 11744202447 023656 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_SIGNAL_BITFIELD_H #define LIBTORRENT_UTILS_SIGNAL_BITFIELD_H #include #include namespace torrent { class LIBTORRENT_EXPORT lt_cacheline_aligned signal_bitfield { public: typedef uint32_t bitfield_type; typedef std::tr1::function slot_type; static const unsigned int max_size = 32; signal_bitfield() : m_bitfield(0), m_size(0) {} // Do the interrupt from the thread? void signal(unsigned int index) { __sync_or_and_fetch(&m_bitfield, 1 << index); } void work(); unsigned int add_signal(slot_type slot); private: bitfield_type m_bitfield; unsigned int m_size; slot_type m_slots[max_size] lt_cacheline_aligned; }; } #endif libtorrent-0.13.2/src/torrent/utils/thread_base.cc000644 000765 000024 00000010533 11736247566 023140 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "exceptions.h" #include "poll.h" #include "thread_base.h" #include "utils/log.h" namespace torrent { thread_base::global_lock_type lt_cacheline_aligned thread_base::m_global = { 0, 0, PTHREAD_MUTEX_INITIALIZER }; thread_base::thread_base() : m_state(STATE_UNKNOWN), m_flags(0), m_poll(NULL) { std::memset(&m_thread, 0, sizeof(pthread_t)); } void thread_base::start_thread() { if (m_poll == NULL) throw internal_error("No poll object for thread defined."); if (m_state != STATE_INITIALIZED || pthread_create(&m_thread, NULL, (pthread_func)&thread_base::event_loop, this)) throw internal_error("Failed to create thread."); } void thread_base::stop_thread() { __sync_fetch_and_or(&m_flags, flag_do_shutdown); interrupt(); } void thread_base::stop_thread_wait() { stop_thread(); release_global_lock(); while (!is_inactive()) { usleep(1000); } acquire_global_lock(); } void thread_base::interrupt() { __sync_fetch_and_or(&m_flags, flag_no_timeout); while (is_polling() && has_no_timeout()) { pthread_kill(m_thread, SIGUSR1); if (!(is_polling() && has_no_timeout())) return; usleep(0); } } void* thread_base::event_loop(thread_base* thread) { __sync_lock_test_and_set(&thread->m_state, STATE_ACTIVE); lt_log_print(torrent::LOG_THREAD_NOTICE, "%s: Starting thread.", thread->name()); try { while (true) { if (thread->m_slot_do_work) thread->m_slot_do_work(); thread->call_events(); thread->signal_bitfield()->work(); __sync_fetch_and_or(&thread->m_flags, flag_polling); // Call again after setting flag_polling to ensure we process // any events set while it was working. if (thread->m_slot_do_work) thread->m_slot_do_work(); thread->call_events(); thread->signal_bitfield()->work(); uint64_t next_timeout = 0; if (!(thread->m_flags & flag_no_timeout)) { next_timeout = thread->next_timeout_usec(); if (thread->m_slot_next_timeout) next_timeout = std::min(next_timeout, thread->m_slot_next_timeout()); } // Add the sleep call when testing interrupts, etc. // usleep(50); int poll_flags = 0; if (!(thread->m_flags & flag_main_thread)) poll_flags = torrent::Poll::poll_worker_thread; thread->m_poll->do_poll(next_timeout, poll_flags); __sync_fetch_and_and(&thread->m_flags, ~(flag_polling | flag_no_timeout)); } } catch (torrent::shutdown_exception& e) { lt_log_print(torrent::LOG_THREAD_NOTICE, "%s: Shutting down thread.", thread->name()); } __sync_lock_test_and_set(&thread->m_state, STATE_INACTIVE); return NULL; } } libtorrent-0.13.2/src/torrent/utils/thread_base.h000644 000765 000024 00000014252 11725127412 022765 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_UTILS_THREAD_BASE_H #define LIBTORRENT_UTILS_THREAD_BASE_H #include #include #include #include #include namespace torrent { class Poll; class LIBTORRENT_EXPORT lt_cacheline_aligned thread_base { public: typedef void* (*pthread_func)(void*); typedef std::tr1::function slot_void; typedef std::tr1::function slot_timer; typedef class signal_bitfield signal_type; enum state_type { STATE_UNKNOWN, STATE_INITIALIZED, STATE_ACTIVE, STATE_INACTIVE }; static const int flag_do_shutdown = 0x1; static const int flag_did_shutdown = 0x2; static const int flag_no_timeout = 0x4; static const int flag_polling = 0x8; static const int flag_main_thread = 0x10; thread_base(); virtual ~thread_base() {} bool is_initialized() const { return m_state == STATE_INITIALIZED; } bool is_active() const { return m_state == STATE_ACTIVE; } bool is_inactive() const { return m_state == STATE_INACTIVE; } bool is_polling() const { return (m_flags & flag_polling); } bool has_no_timeout() const { return (m_flags & flag_no_timeout); } bool has_do_shutdown() const { return (m_flags & flag_do_shutdown); } bool has_did_shutdown() const { return (m_flags & flag_did_shutdown); } state_type state() const { return m_state; } int flags() const { return m_flags; } virtual const char* name() const = 0; Poll* poll() { return m_poll; } signal_type* signal_bitfield() { return &m_signal_bitfield; } pthread_t pthread() { return m_thread; } virtual void init_thread() = 0; virtual void start_thread(); virtual void stop_thread(); void stop_thread_wait(); void interrupt(); void send_event_signal(unsigned int index, bool interrupt = true); slot_void& slot_do_work() { return m_slot_do_work; } slot_timer& slot_next_timeout() { return m_slot_next_timeout; } static inline int global_queue_size() { return m_global.waiting; } static inline void acquire_global_lock(); static inline bool trylock_global_lock(); static inline void release_global_lock(); static inline void waive_global_lock(); static inline bool is_main_polling() { return m_global.main_polling; } static inline void entering_main_polling(); static inline void leaving_main_polling(); static void* event_loop(thread_base* thread); protected: struct global_lock_type { int waiting; int main_polling; pthread_mutex_t lock; }; virtual void call_events() = 0; virtual int64_t next_timeout_usec() = 0; static global_lock_type m_global; pthread_t m_thread; state_type m_state; int m_flags; Poll* m_poll; signal_type m_signal_bitfield; slot_void m_slot_do_work; slot_timer m_slot_next_timeout; }; inline void thread_base::send_event_signal(unsigned int index, bool do_interrupt) { m_signal_bitfield.signal(index); if (do_interrupt) interrupt(); } inline void thread_base::acquire_global_lock() { __sync_add_and_fetch(&thread_base::m_global.waiting, 1); pthread_mutex_lock(&thread_base::m_global.lock); __sync_sub_and_fetch(&thread_base::m_global.waiting, 1); } inline bool thread_base::trylock_global_lock() { return pthread_mutex_trylock(&thread_base::m_global.lock) == 0; } inline void thread_base::release_global_lock() { pthread_mutex_unlock(&thread_base::m_global.lock); } inline void thread_base::waive_global_lock() { pthread_mutex_unlock(&thread_base::m_global.lock); // Do we need to sleep here? Make a CppUnit test for this. acquire_global_lock(); } // 'entering/leaving_main_polling' is used by the main polling thread // to indicate to other threads when it is safe to change the main // thread's event entries. // // A thread should first aquire global lock, then if it needs to // change poll'ed sockets on the main thread it should call // 'interrupt_main_polling' unless 'is_main_polling() == false'. inline void thread_base::entering_main_polling() { __sync_lock_test_and_set(&thread_base::m_global.main_polling, 1); } inline void thread_base::leaving_main_polling() { __sync_lock_test_and_set(&thread_base::m_global.main_polling, 0); } } #endif libtorrent-0.13.2/src/torrent/peer/choke_status.h000644 000765 000024 00000006105 11705767056 023025 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_CHOKE_STATUS_H #define LIBTORRENT_DOWNLOAD_CHOKE_STATUS_H #include namespace torrent { class group_entry; class choke_status { public: choke_status() : m_group_entry(NULL), m_queued(false), m_unchoked(false), m_snubbed(false), m_timeLastChoke(0) {} group_entry* entry() const { return m_group_entry; } void set_entry(group_entry* grp_ent) { m_group_entry = grp_ent; } bool queued() const { return m_queued; } void set_queued(bool s) { m_queued = s; } bool choked() const { return !m_unchoked; } bool unchoked() const { return m_unchoked; } void set_unchoked(bool s) { m_unchoked = s; } bool snubbed() const { return m_snubbed; } void set_snubbed(bool s) { m_snubbed = s; } int64_t time_last_choke() const { return m_timeLastChoke; } void set_time_last_choke(int64_t t) { m_timeLastChoke = t; } private: // TODO: Use flags. group_entry* m_group_entry; bool m_queued; bool m_unchoked; bool m_snubbed; int64_t m_timeLastChoke; }; } #endif libtorrent-0.13.2/src/torrent/peer/client_info.cc000644 000765 000024 00000007614 11705767056 022766 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "client_info.h" namespace torrent { unsigned int ClientInfo::key_size(id_type id) { switch (id) { case TYPE_AZUREUS: return 2; case TYPE_COMPACT: case TYPE_MAINLINE: return 1; default: return 0; } } unsigned int ClientInfo::version_size(id_type id) { switch (id) { case TYPE_AZUREUS: return 4; case TYPE_COMPACT: case TYPE_MAINLINE: return 3; default: return 0; } } bool ClientInfo::less_intersects(const ClientInfo& left, const ClientInfo& right) { if (left.type() > right.type()) return false; else if (left.type() < right.type()) return true; int keyComp = std::memcmp(left.key(), right.key(), ClientInfo::max_key_size); return keyComp < 0 || (keyComp == 0 && std::memcmp(left.upper_version(), right.version(), ClientInfo::max_version_size) < 0); } bool ClientInfo::less_disjoint(const ClientInfo& left, const ClientInfo& right) { if (left.type() > right.type()) return false; else if (left.type() < right.type()) return true; int keyComp = std::memcmp(left.key(), right.key(), ClientInfo::max_key_size); return keyComp < 0 || (keyComp == 0 && std::memcmp(left.version(), right.upper_version(), ClientInfo::max_version_size) < 0); } bool ClientInfo::greater_intersects(const ClientInfo& left, const ClientInfo& right) { return less_intersects(right, left); } bool ClientInfo::greater_disjoint(const ClientInfo& left, const ClientInfo& right) { return less_disjoint(right, left); } bool ClientInfo::intersects(const ClientInfo& left, const ClientInfo& right) { return left.type() == right.type() && std::memcmp(left.key(), right.key(), ClientInfo::max_key_size) == 0 && std::memcmp(left.version(), right.upper_version(), ClientInfo::max_version_size) <= 0 && std::memcmp(left.upper_version(), right.version(), ClientInfo::max_version_size) >= 0; } inline bool ClientInfo::equal_to(const ClientInfo& left, const ClientInfo& right) { return left.type() == right.type() && std::memcmp(left.key(), right.key(), ClientInfo::max_key_size) == 0 && std::memcmp(left.version(), right.version(), ClientInfo::max_version_size) == 0 && std::memcmp(left.upper_version(), right.upper_version(), ClientInfo::max_version_size) == 0; } } libtorrent-0.13.2/src/torrent/peer/client_info.h000644 000765 000024 00000010623 11705767056 022622 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_CLIENT_INFO_H #define LIBTORRENT_PEER_CLIENT_INFO_H #include namespace torrent { class LIBTORRENT_EXPORT ClientInfo { public: friend class ClientList; typedef enum { TYPE_UNKNOWN, TYPE_AZUREUS, TYPE_COMPACT, TYPE_MAINLINE, TYPE_MAX_SIZE } id_type; struct info_type { const char* m_shortDescription; }; static const uint32_t max_key_size = 2; static const uint32_t max_version_size = 4; id_type type() const { return m_type; } const char* key() const { return m_key; } const char* version() const { return m_version; } const char* upper_version() const { return m_upperVersion; } const char* short_description() const { return m_info->m_shortDescription; } void set_short_description(const char* str) { m_info->m_shortDescription = str; } static unsigned int key_size(id_type id); static unsigned int version_size(id_type id); // The intersect/disjoint postfix indicates what kind of equivalence // comparison we get when using !less && !greater. static bool less_intersects(const ClientInfo& left, const ClientInfo& right); static bool less_disjoint(const ClientInfo& left, const ClientInfo& right); static bool greater_intersects(const ClientInfo& left, const ClientInfo& right); static bool greater_disjoint(const ClientInfo& left, const ClientInfo& right); static bool intersects(const ClientInfo& left, const ClientInfo& right); static bool equal_to(const ClientInfo& left, const ClientInfo& right); protected: void set_type(id_type t) { m_type = t; } info_type* info() const { return m_info; } void set_info(info_type* ptr) { m_info = ptr; } char* mutable_key() { return m_key; } char* mutable_version() { return m_version; } char* mutable_upper_version() { return m_upperVersion; } private: id_type m_type; char m_key[max_key_size]; // The client version. The ClientInfo object in ClientList bounds // the versions that this object applies to. When the user searches // the ClientList for a client id, m_version will be set to the // actual client version. char m_version[max_version_size]; char m_upperVersion[max_version_size]; // We don't really care about cleaning up this as deleting an entry // form ClientList shouldn't happen. info_type* m_info; }; } #endif libtorrent-0.13.2/src/torrent/peer/client_list.cc000644 000765 000024 00000024303 11716350717 022772 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "client_list.h" #include "exceptions.h" #include "hash_string.h" namespace torrent { ClientList::ClientList() { insert(ClientInfo::TYPE_UNKNOWN, NULL, NULL, NULL); // Move this to a seperate initialize function in libtorrent. // Sorted by popularity to optimize search. This list is heavily // biased by my own prejudices, and not at all based on facts. // First batch of clients. insert_helper(ClientInfo::TYPE_AZUREUS, "AZ", NULL, NULL, "Azureus"); insert_helper(ClientInfo::TYPE_AZUREUS, "BC", NULL, NULL, "BitComet"); insert_helper(ClientInfo::TYPE_AZUREUS, "CD", NULL, NULL, "Enhanced CTorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "KT", NULL, NULL, "KTorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "LT", NULL, NULL, "libtorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "lt", NULL, NULL, "libTorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "UT", NULL, NULL, "uTorrent"); insert_helper(ClientInfo::TYPE_MAINLINE, "M", NULL, NULL, "Mainline"); insert_helper(ClientInfo::TYPE_COMPACT, "T", NULL, NULL, "BitTornado"); // Second batch of clients. insert_helper(ClientInfo::TYPE_AZUREUS, "AR", NULL, NULL, "Arctic"); insert_helper(ClientInfo::TYPE_AZUREUS, "BB", NULL, NULL, "BitBuddy"); insert_helper(ClientInfo::TYPE_AZUREUS, "BX", NULL, NULL, "Bittorrent X"); insert_helper(ClientInfo::TYPE_AZUREUS, "BS", NULL, NULL, "BTSlave"); insert_helper(ClientInfo::TYPE_AZUREUS, "CT", NULL, NULL, "CTorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "DE", NULL, NULL, "DelugeTorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "ES", NULL, NULL, "Electric Sheep"); insert_helper(ClientInfo::TYPE_AZUREUS, "LP", NULL, NULL, "Lphant"); insert_helper(ClientInfo::TYPE_AZUREUS, "MT", NULL, NULL, "MoonlightTorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "MP", NULL, NULL, "MooPolice"); insert_helper(ClientInfo::TYPE_AZUREUS, "QT", NULL, NULL, "Qt 4 Torrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "RT", NULL, NULL, "Retriever"); insert_helper(ClientInfo::TYPE_AZUREUS, "SZ", NULL, NULL, "Shareaza"); insert_helper(ClientInfo::TYPE_AZUREUS, "SS", NULL, NULL, "SwarmScope"); insert_helper(ClientInfo::TYPE_AZUREUS, "SB", NULL, NULL, "Swiftbit"); insert_helper(ClientInfo::TYPE_AZUREUS, "TN", NULL, NULL, "TorrentDotNET"); insert_helper(ClientInfo::TYPE_AZUREUS, "TS", NULL, NULL, "Torrentstorm"); insert_helper(ClientInfo::TYPE_AZUREUS, "TR", NULL, NULL, "Transmission"); insert_helper(ClientInfo::TYPE_AZUREUS, "XT", NULL, NULL, "XanTorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "ZT", NULL, NULL, "ZipTorrent"); insert_helper(ClientInfo::TYPE_COMPACT, "A", NULL, NULL, "ABC"); insert_helper(ClientInfo::TYPE_COMPACT, "S", NULL, NULL, "Shadow's client"); insert_helper(ClientInfo::TYPE_COMPACT, "U", NULL, NULL, "UPnP NAT BitTorrent"); insert_helper(ClientInfo::TYPE_COMPACT, "O", NULL, NULL, "Osprey Permaseed"); // Third batch of clients. insert_helper(ClientInfo::TYPE_AZUREUS, "AX", NULL, NULL, "BitPump"); insert_helper(ClientInfo::TYPE_AZUREUS, "BF", NULL, NULL, "BitFlu"); insert_helper(ClientInfo::TYPE_AZUREUS, "BG", NULL, NULL, "BTG"); insert_helper(ClientInfo::TYPE_AZUREUS, "BR", NULL, NULL, "BitRocket"); insert_helper(ClientInfo::TYPE_AZUREUS, "EB", NULL, NULL, "EBit"); insert_helper(ClientInfo::TYPE_AZUREUS, "HL", NULL, NULL, "Halite"); insert_helper(ClientInfo::TYPE_AZUREUS, "qB", NULL, NULL, "qBittorrent"); insert_helper(ClientInfo::TYPE_AZUREUS, "UL", NULL, NULL, "uLeecher!"); insert_helper(ClientInfo::TYPE_AZUREUS, "XL", NULL, NULL, "XeiLun"); insert_helper(ClientInfo::TYPE_COMPACT, "R", NULL, NULL, "Tribler"); } ClientList::~ClientList() { for (iterator itr = begin(), last = end(); itr != last; ++itr) delete itr->info(); } ClientList::iterator ClientList::insert(ClientInfo::id_type type, const char* key, const char* version, const char* upperVersion) { if (type >= ClientInfo::TYPE_MAX_SIZE) throw input_error("Invalid client info id type."); ClientInfo clientInfo; clientInfo.set_type(type); clientInfo.set_info(new ClientInfo::info_type); clientInfo.set_short_description("Unknown"); std::memset(clientInfo.mutable_key(), 0, ClientInfo::max_key_size); if (key == NULL) std::memset(clientInfo.mutable_key(), 0, ClientInfo::max_key_size); else std::strncpy(clientInfo.mutable_key(), key, ClientInfo::max_key_size); if (version != NULL) std::memcpy(clientInfo.mutable_version(), version, ClientInfo::max_version_size); else std::memset(clientInfo.mutable_version(), 0, ClientInfo::max_version_size); if (upperVersion != NULL) std::memcpy(clientInfo.mutable_upper_version(), upperVersion, ClientInfo::max_version_size); else std::memset(clientInfo.mutable_upper_version(), -1, ClientInfo::max_version_size); return base_type::insert(end(), clientInfo); } ClientList::iterator ClientList::insert_helper(ClientInfo::id_type type, const char* key, const char* version, const char* upperVersion, const char* shortDescription) { char newKey[ClientInfo::max_key_size]; std::memset(newKey, 0, ClientInfo::max_key_size); std::memcpy(newKey, key, ClientInfo::key_size(type)); iterator itr = insert(type, newKey, version, upperVersion); itr->set_short_description(shortDescription); return itr; } // Make this properly honor const-ness. bool ClientList::retrieve_id(ClientInfo* dest, const HashString& id) const { if (id[0] == '-' && id[7] == '-' && std::isalpha(id[1]) && std::isalpha(id[2]) && std::isxdigit(id[3]) && std::isxdigit(id[4]) && std::isxdigit(id[5]) && std::isxdigit(id[6])) { dest->set_type(ClientInfo::TYPE_AZUREUS); dest->mutable_key()[0] = id[1]; dest->mutable_key()[1] = id[2]; for (int i = 0; i < 4; i++) dest->mutable_version()[i] = dest->mutable_upper_version()[i] = rak::hexchar_to_value(id[3 + i]); } else if (std::isalpha(id[0]) && id[4] == '-' && std::isxdigit(id[1]) && std::isxdigit(id[2]) && std::isxdigit(id[3])) { dest->set_type(ClientInfo::TYPE_COMPACT); dest->mutable_key()[0] = id[0]; dest->mutable_key()[1] = '\0'; dest->mutable_version()[0] = dest->mutable_upper_version()[0] = rak::hexchar_to_value(id[1]); dest->mutable_version()[1] = dest->mutable_upper_version()[1] = rak::hexchar_to_value(id[2]); dest->mutable_version()[2] = dest->mutable_upper_version()[2] = rak::hexchar_to_value(id[3]); dest->mutable_version()[3] = dest->mutable_upper_version()[3] = '\0'; } else if (std::isalpha(id[0]) && std::isdigit(id[1]) && id[2] == '-' && std::isdigit(id[3]) && (id[6] == '-' || id[7] == '-')) { dest->set_type(ClientInfo::TYPE_MAINLINE); dest->mutable_key()[0] = id[0]; dest->mutable_key()[1] = '\0'; dest->mutable_version()[0] = dest->mutable_upper_version()[0] = rak::hexchar_to_value(id[1]); if (id[4] == '-' && std::isdigit(id[5]) && id[6] == '-') { dest->mutable_version()[1] = dest->mutable_upper_version()[1] = rak::hexchar_to_value(id[3]); dest->mutable_version()[2] = dest->mutable_upper_version()[2] = rak::hexchar_to_value(id[5]); dest->mutable_version()[3] = dest->mutable_upper_version()[3] = '\0'; } else if (std::isdigit(id[4]) && id[5] == '-' && std::isdigit(id[6]) && id[7] == '-') { dest->mutable_version()[1] = dest->mutable_upper_version()[1] = rak::hexchar_to_value(id[3]) * 10 + rak::hexchar_to_value(id[4]); dest->mutable_version()[2] = dest->mutable_upper_version()[2] = rak::hexchar_to_value(id[6]); dest->mutable_version()[3] = dest->mutable_upper_version()[3] = '\0'; } else { *dest = *begin(); std::memset(dest->mutable_upper_version(), 0, ClientInfo::max_version_size); return false; } } else { // And then the incompatible idiots that make life difficult for us // others. (There's '3' schemes to choose from already...) // // Or not... // The first entry always contains the default ClientInfo. *dest = *begin(); std::memset(dest->mutable_upper_version(), 0, ClientInfo::max_version_size); return false; } const_iterator itr = std::find_if(begin() + 1, end(), std::tr1::bind(&ClientInfo::intersects, *dest, std::tr1::placeholders::_1)); if (itr == end()) dest->set_info(begin()->info()); else dest->set_info(itr->info()); return true; } void ClientList::retrieve_unknown(ClientInfo* dest) const { *dest = *begin(); std::memset(dest->mutable_upper_version(), 0, ClientInfo::max_version_size); } } libtorrent-0.13.2/src/torrent/peer/client_list.h000644 000765 000024 00000005715 11705767056 022650 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_CLIENT_LIST_H #define LIBTORRENT_PEER_CLIENT_LIST_H #include #include namespace torrent { class LIBTORRENT_EXPORT ClientList : private std::vector { public: typedef std::vector base_type; typedef uint32_t size_type; using base_type::value_type; using base_type::reference; using base_type::difference_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::size; using base_type::empty; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; ClientList(); ~ClientList(); iterator insert(ClientInfo::id_type type, const char* key, const char* version, const char* upperVersion); // Helper functions which only require the key to be as long as the // key for that specific id type. iterator insert_helper(ClientInfo::id_type type, const char* key, const char* version, const char* upperVersion, const char* shortDescription); bool retrieve_id(ClientInfo* dest, const HashString& id) const; void retrieve_unknown(ClientInfo* dest) const; }; } #endif libtorrent-0.13.2/src/torrent/peer/connection_list.cc000644 000765 000024 00000020513 11740502002 023631 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "download/download_main.h" #include "net/address_list.h" #include "protocol/peer_connection_base.h" #include "torrent/exceptions.h" #include "torrent/download_info.h" #include "torrent/download/choke_group.h" #include "torrent/download/choke_queue.h" #include "connection_list.h" #include "peer.h" #include "peer_info.h" // When a peer is connected it should be removed from the list of // available peers. // // When a peer is disconnected the torrent should rebalance the choked // peers and connect to new ones if possible. namespace torrent { ConnectionList::ConnectionList(DownloadMain* download) : m_download(download), m_minSize(50), m_maxSize(100) { } void ConnectionList::clear() { std::for_each(begin(), end(), rak::on(std::mem_fun(&Peer::m_ptr), rak::call_delete())); base_type::clear(); m_disconnectQueue.clear(); } bool ConnectionList::want_connection(PeerInfo* p, Bitfield* bitfield) { if (m_download->file_list()->is_done() || m_download->initial_seeding() != NULL) return !bitfield->is_all_set(); if (!m_download->info()->is_accepting_seeders()) return !bitfield->is_all_set(); return true; } PeerConnectionBase* ConnectionList::insert(PeerInfo* peerInfo, const SocketFd& fd, Bitfield* bitfield, EncryptionInfo* encryptionInfo, ProtocolExtension* extensions) { if (size() >= m_maxSize) return NULL; PeerConnectionBase* peerConnection = m_slotNewConnection(encryptionInfo->is_encrypted()); if (peerConnection == NULL || bitfield == NULL) throw internal_error("ConnectionList::insert(...) received a NULL pointer."); peerInfo->set_connection(peerConnection); peerInfo->set_last_connection(cachedTime.seconds()); peerConnection->initialize(m_download, peerInfo, fd, bitfield, encryptionInfo, extensions); if (!peerConnection->get_fd().is_valid()) { delete peerConnection; return NULL; } base_type::push_back(peerConnection); m_download->info()->change_flags(DownloadInfo::flag_accepting_new_peers, size() < m_maxSize); rak::slot_list_call(m_signalConnected, peerConnection); return peerConnection; } ConnectionList::iterator ConnectionList::erase(iterator pos, int flags) { if (pos < begin() || pos >= end()) throw internal_error("ConnectionList::erase(...) iterator out or range."); if (flags & disconnect_delayed) { m_disconnectQueue.push_back((*pos)->id()); if (!m_download->delay_disconnect_peers().is_queued()) priority_queue_insert(&taskScheduler, &m_download->delay_disconnect_peers(), cachedTime); return pos; } PeerConnectionBase* peerConnection = (*pos)->m_ptr(); // The connection must be erased from the list before the signal is // emited otherwise some listeners might do stuff with the // assumption that the connection will remain in the list. *pos = base_type::back(); base_type::pop_back(); m_download->info()->change_flags(DownloadInfo::flag_accepting_new_peers, size() < m_maxSize); rak::slot_list_call(m_signalDisconnected, peerConnection); // Before of after the signal? peerConnection->cleanup(); peerConnection->mutable_peer_info()->set_connection(NULL); m_download->peer_list()->disconnected(peerConnection->mutable_peer_info(), PeerList::disconnect_set_time); // Delete after the signal to ensure the address of 'v' doesn't get // allocated for a different PCB in the signal. delete peerConnection; return pos; } void ConnectionList::erase(Peer* p, int flags) { erase(std::find(begin(), end(), p), flags); } void ConnectionList::erase(PeerInfo* peerInfo, int flags) { iterator itr = std::find(begin(), end(), peerInfo->connection()); if (itr == end()) return; erase(itr, flags); } void ConnectionList::erase_remaining(iterator pos, int flags) { flags |= disconnect_quick; // Need to do it one connection at the time to ensure that when the // signal is emited everything is in a valid state. while (pos != end()) erase(--end(), flags); m_download->info()->change_flags(DownloadInfo::flag_accepting_new_peers, size() < m_maxSize); } void ConnectionList::erase_seeders() { erase_remaining(std::partition(begin(), end(), rak::on(std::mem_fun(&Peer::c_ptr), std::mem_fun(&PeerConnectionBase::is_not_seeder))), disconnect_unwanted); } void ConnectionList::disconnect_queued() { for (queue_type::const_iterator itr = m_disconnectQueue.begin(), last = m_disconnectQueue.end(); itr != last; itr++) { ConnectionList::iterator conn_itr = find(m_disconnectQueue.back().c_str()); if (conn_itr != end()) erase(conn_itr, 0); } m_disconnectQueue = queue_type(); } struct connection_list_less { bool operator () (const Peer* p1, const Peer* p2) const { return *rak::socket_address::cast_from(p1->peer_info()->socket_address()) < *rak::socket_address::cast_from(p2->peer_info()->socket_address()); } bool operator () (const rak::socket_address& sa1, const Peer* p2) const { return sa1 < *rak::socket_address::cast_from(p2->peer_info()->socket_address()); } bool operator () (const Peer* p1, const rak::socket_address& sa2) const { return *rak::socket_address::cast_from(p1->peer_info()->socket_address()) < sa2; } }; ConnectionList::iterator ConnectionList::find(const char* id) { return std::find_if(begin(), end(), rak::equal(*HashString::cast_from(id), rak::on(std::mem_fun(&Peer::m_ptr), rak::on(std::mem_fun(&PeerConnectionBase::peer_info), std::mem_fun(&PeerInfo::id))))); } ConnectionList::iterator ConnectionList::find(const sockaddr* sa) { return std::find_if(begin(), end(), rak::equal_ptr(rak::socket_address::cast_from(sa), rak::on(std::mem_fun(&Peer::m_ptr), rak::on(std::mem_fun(&PeerConnectionBase::peer_info), std::mem_fun(&PeerInfo::socket_address))))); } void ConnectionList::set_difference(AddressList* l) { std::sort(begin(), end(), connection_list_less()); l->erase(std::set_difference(l->begin(), l->end(), begin(), end(), l->begin(), connection_list_less()), l->end()); } void ConnectionList::set_min_size(size_type v) { if (v > (1 << 16)) throw input_error("Min peer connections must be between 0 and 2^16."); m_minSize = v; } void ConnectionList::set_max_size(size_type v) { if (v > (1 << 16)) throw input_error("Max peer connections must be between 0 and 2^16."); if (v == 0) v = choke_queue::unlimited; m_maxSize = v; m_download->info()->change_flags(DownloadInfo::flag_accepting_new_peers, size() < m_maxSize); //m_download->choke_group()->up_queue()->balance(); } } libtorrent-0.13.2/src/torrent/peer/connection_list.h000644 000765 000024 00000012743 11740502002 023501 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_CONNECTION_LIST_H #define LIBTORRENT_PEER_CONNECTION_LIST_H #include #include #include #include #include namespace torrent { class AddressList; class Bitfield; class DownloadMain; class DownloadWrapper; class Peer; class PeerConnectionBase; class PeerInfo; class ProtocolExtension; class SocketFd; class EncryptionInfo; class HandshakeManager; class LIBTORRENT_EXPORT ConnectionList : private std::vector { public: friend class DownloadMain; friend class DownloadWrapper; friend class HandshakeManager; typedef std::vector base_type; typedef std::vector queue_type; typedef uint32_t size_type; typedef std::tr1::function slot_peer_type; typedef std::list signal_peer_type; typedef PeerConnectionBase* (*slot_new_conn_type)(bool encrypted); using base_type::value_type; using base_type::reference; using base_type::difference_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::const_iterator; using base_type::const_reverse_iterator; // using base_type::size; using base_type::empty; using base_type::front; using base_type::back; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; // Make sure any change here match PeerList's flags. static const int disconnect_available = (1 << 0); static const int disconnect_quick = (1 << 1); static const int disconnect_unwanted = (1 << 2); static const int disconnect_delayed = (1 << 3); ConnectionList(DownloadMain* download); // Make these protected? iterator erase(iterator pos, int flags); void erase(Peer* p, int flags); void erase(PeerInfo* peerInfo, int flags); void erase_remaining(iterator pos, int flags); void erase_seeders(); iterator find(const char* id); iterator find(const sockaddr* sa); size_type min_size() const { return m_minSize; } void set_min_size(size_type v); size_type size() const { return base_type::size(); } size_type max_size() const { return m_maxSize; } void set_max_size(size_type v); // Removes from 'l' addresses that are already connected to. Assumes // 'l' is sorted and unique. void set_difference(AddressList* l); signal_peer_type& signal_connected() { return m_signalConnected; } signal_peer_type& signal_disconnected() { return m_signalDisconnected; } // Move to protected: void slot_new_connection(slot_new_conn_type s) { m_slotNewConnection = s; } protected: // Does not do the usual cleanup done by 'erase'. void clear() LIBTORRENT_NO_EXPORT; bool want_connection(PeerInfo* p, Bitfield* bitfield); // Returns NULL if the connection was not added, the caller is then // responsible for cleaning up 'fd'. // // Clean this up, don't use this many arguments. PeerConnectionBase* insert(PeerInfo* p, const SocketFd& fd, Bitfield* bitfield, EncryptionInfo* encryptionInfo, ProtocolExtension* extensions) LIBTORRENT_NO_EXPORT; void disconnect_queued() LIBTORRENT_NO_EXPORT; private: ConnectionList(const ConnectionList&) LIBTORRENT_NO_EXPORT; void operator = (const ConnectionList&) LIBTORRENT_NO_EXPORT; DownloadMain* m_download; size_type m_minSize; size_type m_maxSize; signal_peer_type m_signalConnected; signal_peer_type m_signalDisconnected; slot_new_conn_type m_slotNewConnection; queue_type m_disconnectQueue; }; } #endif libtorrent-0.13.2/src/torrent/peer/Makefile.am000644 000765 000024 00000001100 11705767056 022202 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_torrentpeer.la libsub_torrentpeer_la_SOURCES = \ choke_status.h \ client_info.cc \ client_info.h \ client_list.cc \ client_list.h \ connection_list.cc \ connection_list.h \ peer.cc \ peer.h \ peer_info.cc \ peer_info.h \ peer_list.cc \ peer_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/peer libtorrentinclude_HEADERS = \ choke_status.h \ client_info.h \ client_list.h \ connection_list.h \ peer.h \ peer_info.h \ peer_list.h libtorrent-0.13.2/src/torrent/peer/Makefile.in000644 000765 000024 00000045623 11744204216 022220 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/torrent/peer DIST_COMMON = $(libtorrentinclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_torrentpeer_la_LIBADD = am_libsub_torrentpeer_la_OBJECTS = client_info.lo client_list.lo \ connection_list.lo peer.lo peer_info.lo peer_list.lo libsub_torrentpeer_la_OBJECTS = $(am_libsub_torrentpeer_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_torrentpeer_la_SOURCES) DIST_SOURCES = $(libsub_torrentpeer_la_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libtorrentincludedir)" HEADERS = $(libtorrentinclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_torrentpeer.la libsub_torrentpeer_la_SOURCES = \ choke_status.h \ client_info.cc \ client_info.h \ client_list.cc \ client_list.h \ connection_list.cc \ connection_list.h \ peer.cc \ peer.h \ peer_info.cc \ peer_info.h \ peer_list.cc \ peer_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/peer libtorrentinclude_HEADERS = \ choke_status.h \ client_info.h \ client_list.h \ connection_list.h \ peer.h \ peer_info.h \ peer_list.h all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/torrent/peer/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/torrent/peer/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_torrentpeer.la: $(libsub_torrentpeer_la_OBJECTS) $(libsub_torrentpeer_la_DEPENDENCIES) $(EXTRA_libsub_torrentpeer_la_DEPENDENCIES) $(CXXLINK) $(libsub_torrentpeer_la_OBJECTS) $(libsub_torrentpeer_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer_list.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-libtorrentincludeHEADERS: $(libtorrentinclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(libtorrentincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libtorrentincludedir)" @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtorrentincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtorrentincludedir)" || exit $$?; \ done uninstall-libtorrentincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libtorrentincludedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libtorrentincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-libtorrentincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libtorrentincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libtorrentincludeHEADERS install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libtorrentincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/torrent/peer/peer.cc000644 000765 000024 00000010056 11705767056 021422 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "data/block.h" #include "data/block_transfer.h" #include "download/download_main.h" #include "protocol/peer_chunks.h" #include "protocol/peer_connection_base.h" #include "torrent/download/choke_queue.h" #include "exceptions.h" #include "connection_list.h" #include "peer.h" #include "peer_info.h" #include "rate.h" namespace torrent { bool Peer::is_encrypted() const { return c_ptr()->is_encrypted(); } bool Peer::is_obfuscated() const { return c_ptr()->is_obfuscated(); } bool Peer::is_up_choked() const { return c_ptr()->is_up_choked(); } bool Peer::is_up_interested() const { return c_ptr()->is_down_interested(); } bool Peer::is_down_choked() const { return !c_ptr()->is_down_remote_unchoked(); } bool Peer::is_down_choked_limited() const { return !c_ptr()->is_down_local_unchoked(); } bool Peer::is_down_queued() const { return c_ptr()->is_down_queued(); } bool Peer::is_down_interested() const { return c_ptr()->is_up_interested(); } bool Peer::is_snubbed() const { return c_ptr()->is_up_snubbed(); } bool Peer::is_banned() const { return m_peerInfo->failed_counter() >= 64; } void Peer::set_snubbed(bool v) { m_ptr()->set_upload_snubbed(v); } void Peer::set_banned(bool v) { m_peerInfo->set_failed_counter(v ? 64 : 0); } const Rate* Peer::down_rate() const { return c_ptr()->c_peer_chunks()->download_throttle()->rate(); } const Rate* Peer::up_rate() const { return c_ptr()->c_peer_chunks()->upload_throttle()->rate(); } const Rate* Peer::peer_rate() const { return c_ptr()->c_peer_chunks()->peer_rate(); } const Bitfield* Peer::bitfield() const { return c_ptr()->c_peer_chunks()->bitfield(); } uint32_t Peer::incoming_queue_size() const { return c_ptr()->download_queue()->queued_size(); } uint32_t Peer::outgoing_queue_size() const { return c_ptr()->c_peer_chunks()->upload_queue()->size(); } uint32_t Peer::chunks_done() const { return c_ptr()->c_peer_chunks()->bitfield()->size_set(); } const BlockTransfer* Peer::transfer() const { if (c_ptr()->download_queue()->transfer() != NULL) return c_ptr()->download_queue()->transfer(); else if (!c_ptr()->download_queue()->queued_empty()) return c_ptr()->download_queue()->queued_transfer(0); else return NULL; } void Peer::disconnect(int flags) { m_ptr()->download()->connection_list()->erase(this, flags); } } libtorrent-0.13.2/src/torrent/peer/peer.h000644 000765 000024 00000010211 11705767056 021255 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_H #define LIBTORRENT_PEER_H #include #include #include namespace torrent { class PeerConnectionBase; // == and = operators works as expected. // The Peer class is a wrapper around the internal peer class. This // peer class may be invalidated during a torrent::work call. So if // you keep a list or single instances in the client, you need to // listen to the appropriate signals from the download to keep up to // date. class LIBTORRENT_EXPORT Peer { public: // Does not check if it has been removed from the download. bool is_incoming() const { return peer_info()->is_incoming(); } bool is_encrypted() const; bool is_obfuscated() const; bool is_up_choked() const; bool is_up_interested() const; bool is_down_choked() const; bool is_down_choked_limited() const; bool is_down_queued() const; bool is_down_interested() const; bool is_snubbed() const; bool is_banned() const; void set_snubbed(bool v); void set_banned(bool v); const HashString& id() const { return peer_info()->id(); } const char* options() const { return peer_info()->options(); } const sockaddr* address() const { return peer_info()->socket_address(); } const Rate* down_rate() const; const Rate* up_rate() const; const Rate* peer_rate() const; const Bitfield* bitfield() const; const BlockTransfer* transfer() const; uint32_t incoming_queue_size() const; uint32_t outgoing_queue_size() const; uint32_t chunks_done() const; uint32_t failed_counter() const { return peer_info()->failed_counter(); } void disconnect(int flags); // // New interface: // const PeerInfo* peer_info() const { return m_peerInfo; } PeerConnectionBase* m_ptr() { return reinterpret_cast(this); } const PeerConnectionBase* c_ptr() const { return reinterpret_cast(this); } protected: Peer() {} virtual ~Peer() {} Peer(const Peer&); void operator = (const Peer&); bool operator == (const Peer& p) const; PeerInfo* m_peerInfo; }; } #endif libtorrent-0.13.2/src/torrent/peer/peer_info.cc000644 000765 000024 00000005144 11705767056 022437 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "protocol/extensions.h" #include "protocol/peer_connection_base.h" #include "exceptions.h" #include "peer_info.h" namespace torrent { // Move this to peer_info.cc when these are made into the public API. PeerInfo::PeerInfo(const sockaddr* address) : m_flags(0), m_failedCounter(0), m_transferCounter(0), m_lastConnection(0), m_lastHandshake(0), m_listenPort(0), m_connection(NULL) { rak::socket_address* sa = new rak::socket_address(); *sa = *rak::socket_address::cast_from(address); m_address = sa->c_sockaddr(); } PeerInfo::~PeerInfo() { if (m_transferCounter != 0) throw internal_error("PeerInfo::~PeerInfo() m_transferCounter != 0."); if (is_blocked()) throw internal_error("PeerInfo::~PeerInfo() peer is blocked."); delete rak::socket_address::cast_from(m_address); } void PeerInfo::set_port(uint16_t port) { rak::socket_address::cast_from(m_address)->set_port(port); } } libtorrent-0.13.2/src/torrent/peer/peer_info.h000644 000765 000024 00000013610 11705767056 022276 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_INFO_H #define LIBTORRENT_PEER_INFO_H #include #include namespace torrent { class LIBTORRENT_EXPORT PeerInfo { public: friend class ConnectionList; friend class Handshake; friend class HandshakeManager; friend class InitialSeeding; friend class PeerList; friend class ProtocolExtension; static const int flag_connected = (1 << 0); static const int flag_incoming = (1 << 1); static const int flag_handshake = (1 << 2); static const int flag_blocked = (1 << 3); // For initial seeding. static const int flag_restart = (1 << 4); static const int flag_unwanted = (1 << 5); static const int flag_preferred = (1 << 6); static const int mask_ip_table = flag_unwanted | flag_preferred; PeerInfo(const sockaddr* address); ~PeerInfo(); bool is_connected() const { return m_flags & flag_connected; } bool is_incoming() const { return m_flags & flag_incoming; } bool is_handshake() const { return m_flags & flag_handshake; } bool is_blocked() const { return m_flags & flag_blocked; } bool is_restart() const { return m_flags & flag_restart; } bool is_unwanted() const { return m_flags & flag_unwanted; } bool is_preferred() const { return m_flags & flag_preferred; } int flags() const { return m_flags; } const HashString& id() const { return m_id; } const ClientInfo& client_info() const { return m_clientInfo; } const char* options() const { return m_options; } const sockaddr* socket_address() const { return m_address; } uint16_t listen_port() const { return m_listenPort; } uint32_t failed_counter() const { return m_failedCounter; } void set_failed_counter(uint32_t c) { m_failedCounter = c; } uint32_t transfer_counter() const { return m_transferCounter; } void set_transfer_counter(uint32_t c) { m_transferCounter = c; } uint32_t last_connection() const { return m_lastConnection; } void set_last_connection(uint32_t tvsec) { m_lastConnection = tvsec; } uint32_t last_handshake() const { return m_lastHandshake; } void set_last_handshake(uint32_t tvsec) { m_lastHandshake = tvsec; } bool supports_dht() const { return m_options[7] & 0x01; } bool supports_extensions() const { return m_options[5] & 0x10; } // Internal to libTorrent: PeerConnectionBase* connection() { return m_connection; } protected: void set_flags(int flags) { m_flags |= flags; } void unset_flags(int flags) { m_flags &= ~flags; } HashString& mutable_id() { return m_id; } ClientInfo& mutable_client_info() { return m_clientInfo; } void set_port(uint16_t port) LIBTORRENT_NO_EXPORT; void set_listen_port(uint16_t port) { m_listenPort = port; } char* set_options() { return m_options; } void set_connection(PeerConnectionBase* c) { m_connection = c; } private: PeerInfo(const PeerInfo&); void operator = (const PeerInfo&); // Replace id with a char buffer, or a cheap struct? int m_flags; HashString m_id; ClientInfo m_clientInfo; char m_options[8]; uint32_t m_failedCounter; uint32_t m_transferCounter; uint32_t m_lastConnection; uint32_t m_lastHandshake; uint16_t m_listenPort; // Replace this with a union. Since the user never copies PeerInfo // it should be safe to not require sockaddr_in6 to be part of it. sockaddr* m_address; PeerConnectionBase* m_connection; }; } #endif libtorrent-0.13.2/src/torrent/peer/peer_list.cc000644 000765 000024 00000026227 11716350717 022456 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include "download/available_list.h" #include "torrent/peer/client_list.h" #include "exceptions.h" #include "globals.h" #include "manager.h" #include "peer_info.h" #include "peer_list.h" namespace torrent { ipv4_table PeerList::m_ipv4_table; bool socket_address_less(const sockaddr* s1, const sockaddr* s2) { const rak::socket_address* sa1 = rak::socket_address::cast_from(s1); const rak::socket_address* sa2 = rak::socket_address::cast_from(s2); if (sa1->family() != sa2->family()) return sa1->family() < sa2->family(); else if (sa1->family() == rak::socket_address::af_inet) // Sort by hardware byte order to ensure proper ordering for // humans. return sa1->sa_inet()->address_h() < sa2->sa_inet()->address_h(); else // When we implement INET6 handling, embed the ipv4 address in // the ipv6 address. throw internal_error("socket_address_key(...) tried to compare an invalid family type."); } inline bool socket_address_key::is_comparable(const sockaddr* sa) { return rak::socket_address::cast_from(sa)->family() == rak::socket_address::af_inet; } struct peer_list_equal_port : public std::binary_function { bool operator () (PeerList::reference p, uint16_t port) { return rak::socket_address::cast_from(p.second->socket_address())->port() == port; } }; PeerList::PeerList() : m_availableList(new AvailableList) { } PeerList::~PeerList() { std::for_each(begin(), end(), rak::on(rak::mem_ref(&value_type::second), rak::call_delete())); base_type::clear(); delete m_availableList; } PeerInfo* PeerList::insert_address(const sockaddr* sa, int flags) { if (!socket_address_key::is_comparable(sa)) return NULL; range_type range = base_type::equal_range(sa); // Do some special handling if we got a new port number but the // address was present. // // What we do depends on the flags, but for now just allow one // PeerInfo per address key and do nothing. if (range.first != range.second) return NULL; const rak::socket_address* address = rak::socket_address::cast_from(sa); PeerInfo* peerInfo = new PeerInfo(sa); peerInfo->set_listen_port(address->port()); peerInfo->set_flags(m_ipv4_table.at(address->sa_inet()->address_h()) & PeerInfo::mask_ip_table); manager->client_list()->retrieve_unknown(&peerInfo->mutable_client_info()); base_type::insert(range.second, value_type(socket_address_key(peerInfo->socket_address()), peerInfo)); if (flags & address_available && peerInfo->listen_port() != 0) m_availableList->push_back(address); return peerInfo; } inline bool socket_address_less_rak(const rak::socket_address& s1, const rak::socket_address& s2) { return socket_address_less(s1.c_sockaddr(), s2.c_sockaddr()); } uint32_t PeerList::insert_available(const void* al) { uint32_t inserted = 0; const AddressList* addressList = static_cast(al); if (m_availableList->size() + addressList->size() > m_availableList->capacity()) m_availableList->reserve(m_availableList->size() + addressList->size() + 128); // Optimize this so that we don't traverse the tree for every // insert, since we know 'al' is sorted. AddressList::const_iterator itr = addressList->begin(); AddressList::const_iterator last = addressList->end(); AvailableList::const_iterator availItr = m_availableList->begin(); AvailableList::const_iterator availLast = m_availableList->end(); for (; itr != last; itr++) { if (!socket_address_key::is_comparable(itr->c_sockaddr()) || itr->port() == 0) continue; availItr = std::find_if(availItr, availLast, rak::bind2nd(std::ptr_fun(&socket_address_less_rak), *itr)); if (availItr != availLast && !socket_address_less(availItr->c_sockaddr(), itr->c_sockaddr())) { // The address is already in m_availableList, so don't bother // going further. continue; } // Check if the peerinfo exists, if it does, check if we would // ever want to connect. Just update the timer for the last // availability notice if the peer isn't really ideal, but might // be used in an emergency. range_type range = base_type::equal_range(itr->c_sockaddr()); if (range.first != range.second) { // Add some logic here to select the best PeerInfo, but for now // just assume the first one is the only one that exists. PeerInfo* peerInfo = range.first->second; if (peerInfo->listen_port() == 0) peerInfo->set_port(itr->port()); if (peerInfo->connection() != NULL || peerInfo->last_handshake() + 600 > (uint32_t)cachedTime.seconds()) continue; // If the peer has sent us bad chunks or we just connected or // tried to do so a few minutes ago, only update its // availability timer. } // Should we perhaps add to available list even though we don't // want the peer, just to ensure we don't need to search for the // PeerInfo every time it gets reported. Though I'd assume it // won't happen often enough to be worth it. inserted++; m_availableList->push_back(&*itr); } return inserted; } uint32_t PeerList::available_list_size() const { return m_availableList->size(); } PeerInfo* PeerList::connected(const sockaddr* sa, int flags) { const rak::socket_address* address = rak::socket_address::cast_from(sa); if (!socket_address_key::is_comparable(sa)) return NULL; int filter_value = m_ipv4_table.at(address->sa_inet()->address_h()); // We should also remove any PeerInfo objects already for this // address. if ((filter_value & PeerInfo::flag_unwanted)) return NULL; PeerInfo* peerInfo; range_type range = base_type::equal_range(sa); if (range.first == range.second) { // Create a new entry. peerInfo = new PeerInfo(sa); peerInfo->set_flags(filter_value & PeerInfo::mask_ip_table); base_type::insert(range.second, value_type(socket_address_key(peerInfo->socket_address()), peerInfo)); } else if (!range.first->second->is_connected()) { // Use an old entry. peerInfo = range.first->second; peerInfo->set_port(address->port()); } else { // Make sure we don't end up throwing away the port the host is // actually listening on, when there may be several simultaneous // connection attempts to/from different ports. // // This also ensure we can connect to peers running on the same // host as the tracker. if (flags & connect_keep_handshakes && range.first->second->is_handshake() && rak::socket_address::cast_from(range.first->second->socket_address())->port() != address->port()) m_availableList->buffer()->push_back(*address); return NULL; } if (flags & connect_filter_recent && peerInfo->last_handshake() + 600 > (uint32_t)cachedTime.seconds()) return NULL; if (!(flags & connect_incoming)) peerInfo->set_listen_port(address->port()); if (flags & connect_incoming) peerInfo->set_flags(PeerInfo::flag_incoming); else peerInfo->unset_flags(PeerInfo::flag_incoming); peerInfo->set_flags(PeerInfo::flag_connected); peerInfo->set_last_handshake(cachedTime.seconds()); return peerInfo; } // Make sure we properly clear port when disconnecting. void PeerList::disconnected(PeerInfo* p, int flags) { range_type range = base_type::equal_range(p->socket_address()); iterator itr = std::find_if(range.first, range.second, rak::equal(p, rak::mem_ref(&value_type::second))); if (itr == range.second) { if (std::find_if(base_type::begin(), base_type::end(), rak::equal(p, rak::mem_ref(&value_type::second))) == base_type::end()) throw internal_error("PeerList::disconnected(...) itr == range.second, doesn't exist."); else throw internal_error("PeerList::disconnected(...) itr == range.second, not in the range."); } disconnected(itr, flags); } PeerList::iterator PeerList::disconnected(iterator itr, int flags) { if (itr == base_type::end()) throw internal_error("PeerList::disconnected(...) itr == end()."); if (!itr->second->is_connected()) throw internal_error("PeerList::disconnected(...) !itr->is_connected()."); itr->second->unset_flags(PeerInfo::flag_connected); // Replace the socket address port with the listening port so that // future outgoing connections will connect to the right port. itr->second->set_port(0); if (flags & disconnect_set_time) itr->second->set_last_connection(cachedTime.seconds()); if (flags & disconnect_available && itr->second->listen_port() != 0) m_availableList->push_back(rak::socket_address::cast_from(itr->second->socket_address())); // Do magic to get rid of unneeded entries. return ++itr; } uint32_t PeerList::cull_peers(int flags) { uint32_t counter = 0; uint32_t timer; if (flags & cull_old) timer = cachedTime.seconds() - 24 * 60 * 60; else timer = 0; for (iterator itr = base_type::begin(); itr != base_type::end(); ) { if (itr->second->is_connected() || itr->second->transfer_counter() != 0 || itr->second->last_connection() >= timer || (flags & cull_keep_interesting && (itr->second->failed_counter() != 0 || itr->second->is_blocked()))) { itr++; continue; } // The key is a pointer to a member in the value, although the key // shouldn't actually be used in erase (I think), just ot be safe // we delete it after erase. iterator tmp = itr++; PeerInfo* peerInfo = tmp->second; base_type::erase(tmp); delete peerInfo; counter++; } return counter; } } libtorrent-0.13.2/src/torrent/peer/peer_list.h000644 000765 000024 00000011421 11705767056 022314 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_LIST_H #define LIBTORRENT_PEER_LIST_H #include #include #include namespace torrent { typedef extents ipv4_table; bool socket_address_less(const sockaddr* s1, const sockaddr* s2); // Unique key for the address, excluding port numbers etc. class LIBTORRENT_EXPORT socket_address_key { public: socket_address_key(const sockaddr* sa) : m_sockaddr(sa) {} inline static bool is_comparable(const sockaddr* sa); bool operator < (const socket_address_key& sa) const { return socket_address_less(m_sockaddr, sa.m_sockaddr); } private: const sockaddr* m_sockaddr; }; class LIBTORRENT_EXPORT PeerList : private std::multimap { public: friend class Handshake; friend class HandshakeManager; friend class ConnectionList; typedef std::multimap base_type; typedef std::pair range_type; using base_type::value_type; using base_type::reference; using base_type::difference_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::const_iterator; using base_type::const_reverse_iterator; using base_type::size; using base_type::empty; static const int address_available = (1 << 0); static const int connect_incoming = (1 << 0); static const int connect_keep_handshakes = (1 << 1); static const int connect_filter_recent = (1 << 2); // Make sure any change here match ConnectionList's flags. static const int disconnect_available = (1 << 0); static const int disconnect_quick = (1 << 1); static const int disconnect_unwanted = (1 << 2); static const int disconnect_set_time = (1 << 3); static const int cull_old = (1 << 0); static const int cull_keep_interesting = (1 << 1); PeerList(); ~PeerList(); PeerInfo* insert_address(const sockaddr* address, int flags); // This will be used internally only for the moment. uint32_t insert_available(const void* al) LIBTORRENT_NO_EXPORT; static ipv4_table* ipv4_filter() { return &m_ipv4_table; } AvailableList* available_list() { return m_availableList; } uint32_t available_list_size() const; uint32_t cull_peers(int flags); const_iterator begin() const { return base_type::begin(); } const_iterator end() const { return base_type::end(); } const_reverse_iterator rbegin() const { return base_type::rbegin(); } const_reverse_iterator rend() const { return base_type::rend(); } protected: // Insert, or find a PeerInfo with socket address 'sa'. Returns end // if no more connections are allowed from that host. PeerInfo* connected(const sockaddr* sa, int flags) LIBTORRENT_NO_EXPORT; void disconnected(PeerInfo* p, int flags) LIBTORRENT_NO_EXPORT; iterator disconnected(iterator itr, int flags) LIBTORRENT_NO_EXPORT; private: PeerList(const PeerList&); void operator = (const PeerList&); static ipv4_table m_ipv4_table; AvailableList* m_availableList; }; } #endif libtorrent-0.13.2/src/torrent/download/choke_group.cc000644 000765 000024 00000005103 11732130527 023630 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "choke_group.h" #include "choke_queue.h" // TODO: Put resource_manager_entry in a separate file. #include "resource_manager.h" #include "torrent/exceptions.h" #include "download/download_main.h" namespace tr1 { using namespace std::tr1; } namespace torrent { choke_group::choke_group() : m_tracker_mode(TRACKER_MODE_NORMAL), m_down_queue(choke_queue::flag_unchoke_all_new), m_first(NULL), m_last(NULL) { } uint64_t choke_group::up_rate() const { return std::for_each(m_first, m_last, rak::accumulate((uint64_t)0, tr1::bind(&Rate::rate, tr1::bind(&resource_manager_entry::up_rate, tr1::placeholders::_1)))).result; } uint64_t choke_group::down_rate() const { return std::for_each(m_first, m_last, rak::accumulate((uint64_t)0, tr1::bind(&Rate::rate, tr1::bind(&resource_manager_entry::down_rate, tr1::placeholders::_1)))).result; } } libtorrent-0.13.2/src/torrent/download/choke_group.h000644 000765 000024 00000007470 11744202446 023506 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_CHOKE_GROUP_H #define LIBTORRENT_DOWNLOAD_CHOKE_GROUP_H #include #include #include #include #include // TODO: Separate out resource_manager_entry. #include namespace torrent { class choke_queue; class resource_manager_entry; class LIBTORRENT_EXPORT choke_group { public: enum tracker_mode_enum { TRACKER_MODE_NORMAL, TRACKER_MODE_AGGRESSIVE }; choke_group(); const std::string& name() const { return m_name; } void set_name(const std::string& name) { m_name = name; } tracker_mode_enum tracker_mode() const { return m_tracker_mode; } void set_tracker_mode(tracker_mode_enum tm) { m_tracker_mode = tm; } choke_queue* up_queue() { return &m_up_queue; } choke_queue* down_queue() { return &m_down_queue; } const choke_queue* c_up_queue() const { return &m_up_queue; } const choke_queue* c_down_queue() const { return &m_down_queue; } uint32_t up_requested() const { return std::min(m_up_queue.size_total(), m_up_queue.max_unchoked()); } uint32_t down_requested() const { return std::min(m_down_queue.size_total(), m_down_queue.max_unchoked()); } bool empty() const { return m_first == m_last; } uint32_t size() const { return std::distance(m_first, m_last); } uint64_t up_rate() const; uint64_t down_rate() const; // Internal: resource_manager_entry* first() { return m_first; } resource_manager_entry* last() { return m_last; } void set_first(resource_manager_entry* first) { m_first = first; } void set_last(resource_manager_entry* last) { m_last = last; } void inc_iterators() { m_first++; m_last++; } void dec_iterators() { m_first--; m_last--; } private: std::string m_name; tracker_mode_enum m_tracker_mode; choke_queue m_up_queue; choke_queue m_down_queue; resource_manager_entry* m_first; resource_manager_entry* m_last; }; } #endif libtorrent-0.13.2/src/torrent/download/choke_queue.cc000644 000765 000024 00000056203 11744202446 023632 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include "protocol/peer_connection_base.h" #include "torrent/download/group_entry.h" #include "torrent/peer/connection_list.h" #include "torrent/peer/choke_status.h" #include "torrent/utils/log.h" #include "torrent/utils/log_files.h" #include "choke_queue.h" namespace torrent { struct choke_manager_less { bool operator () (choke_queue::value_type v1, choke_queue::value_type v2) const { return v1.weight < v2.weight; } }; static inline bool should_connection_unchoke(choke_queue* cq, PeerConnectionBase* pcb) { return pcb->should_connection_unchoke(cq); } choke_queue::~choke_queue() { if (m_currently_unchoked != 0) throw internal_error("choke_queue::~choke_queue() called but m_currentlyUnchoked != 0."); if (m_currently_queued != 0) throw internal_error("choke_queue::~choke_queue() called but m_currentlyQueued != 0."); } // 1 > 1 // 9 > 2 // 17 > 3 < 21 // 25 > 4 < 31 // 33 > 5 < 41 // 65 > 9 < 81 inline uint32_t choke_queue::max_alternate() const { if (m_currently_unchoked < 31) return (m_currently_unchoked + 7) / 8; else return (m_currently_unchoked + 9) / 10; } group_stats choke_queue::prepare_weights(group_stats gs) { // gs.sum_min_needed = 0; // gs.sum_max_needed = 0; // gs.sum_max_leftovers = 0; // Needs to reflect how many we can optimistically unchoke after choking unchoked connections? // // also remember to clear the queue/unchoked thingies. for (group_container_type::iterator itr = m_group_container.begin(), last = m_group_container.end(); itr != last; itr++) { m_heuristics_list[m_heuristics].slot_choke_weight((*itr)->mutable_unchoked()->begin(), (*itr)->mutable_unchoked()->end()); std::sort((*itr)->mutable_unchoked()->begin(), (*itr)->mutable_unchoked()->end(), choke_manager_less()); m_heuristics_list[m_heuristics].slot_unchoke_weight((*itr)->mutable_queued()->begin(), (*itr)->mutable_queued()->end()); std::sort((*itr)->mutable_queued()->begin(), (*itr)->mutable_queued()->end(), choke_manager_less()); // Aggregate the statistics... Remember to update them after // optimistic/pessimistic unchokes. gs.sum_min_needed += std::min((*itr)->size_connections(), std::min((*itr)->min_slots(), (*itr)->max_slots())); uint32_t max_slots = std::min((*itr)->size_connections(), (*itr)->max_slots()); gs.sum_max_needed += max_slots; gs.sum_max_leftovers += (*itr)->size_connections() - max_slots; // Counter for how many can choke/unchoke based on weights? // However one should never have zero weight for any weight group. } return gs; } group_stats choke_queue::retrieve_connections(group_stats gs, container_type* queued, container_type* unchoked) { for (group_container_type::iterator itr = m_group_container.begin(), last = m_group_container.end(); itr != last; itr++) { group_entry* entry = *itr; unsigned int min_slots = std::min(entry->min_slots(), entry->max_slots()); lt_log_print(LOG_PEER_DEBUG, "Choke queue retrieve_connections; queued:%u unchoked:%u min_slots:%u max_slots:%u.", (unsigned)entry->queued()->size(), (unsigned)entry->unchoked()->size(), min_slots, entry->max_slots()); // Disable this after finding the flaw... ? // if (entry->unchoked()->size() > entry->max_slots()) { // unsigned int count = 0; // // Still needing choke/unchoke to fill min_size. // while (entry->unchoked()->size() > entry->max_slots() && !entry->unchoked()->empty()) // count += m_slotConnection(entry->unchoked()->back().connection, true); // // m_slotUnchoke(-count); // Move this? // gs.now_choked += entry->unchoked()->size(); // Need to add this... // } if (entry->unchoked()->size() < min_slots) { // Currently unchoked is less than min_slots, so don't give any // candidates for choking and also check if we can fill the // requirement by unchoking queued connections. unsigned int count = 0; // Still needing choke/unchoke to fill min_size. while (!entry->queued()->empty() && entry->unchoked()->size() < min_slots) count += m_slotConnection(entry->queued()->back().connection, false); gs.changed_unchoked += count; gs.now_unchoked += entry->unchoked()->size(); } else { // TODO: This only handles a single weight group, fixme. group_entry::container_type::const_iterator first = entry->unchoked()->begin() + min_slots; group_entry::container_type::const_iterator last = entry->unchoked()->end(); unchoked->insert(unchoked->end(), first, last); gs.now_unchoked += min_slots; } // TODO: Does not do optimistic unchokes if min_slots >= max_slots. if (entry->unchoked()->size() < entry->max_slots()) { // We can assume that at either we have no queued connections or // 'min_slots' has been reached. queued->insert(queued->end(), entry->queued()->end() - std::min(entry->queued()->size(), entry->max_slots() - entry->unchoked()->size()), entry->queued()->end()); } } return gs; } void choke_queue::rebuild_containers(container_type* queued, container_type* unchoked) { queued->clear(); unchoked->clear(); for (group_container_type::iterator itr = m_group_container.begin(), last = m_group_container.end(); itr != last; itr++) { queued->insert(queued->end(), (*itr)->queued()->begin(), (*itr)->queued()->end()); unchoked->insert(unchoked->end(), (*itr)->unchoked()->begin(), (*itr)->unchoked()->end()); } } void choke_queue::balance() { // Return if no balancing is needed. Don't return if is_unlimited() // as we might have just changed the value and have interested that // can be unchoked. // // TODO: Check if unlimited, in that case we don't need to balance // if we got no queued connections. if (m_currently_unchoked == m_maxUnchoked) return; container_type queued; container_type unchoked; group_stats gs; std::memset(&gs, 0, sizeof(group_stats)); gs = prepare_weights(gs); gs = retrieve_connections(gs, &queued, &unchoked); if (gs.changed_unchoked != 0) m_slotUnchoke(gs.changed_unchoked); // If we have more unchoked than max global slots allow for, // 'can_unchoke' will be negative. int can_unchoke = m_slotCanUnchoke(); int max_unchoked = std::min(m_maxUnchoked, (uint32_t)(1 << 20)); int adjust = max_unchoked - (int)(unchoked.size() + gs.now_unchoked); adjust = std::min(adjust, can_unchoke); if (log_files[LOG_CHOKE_CHANGES].is_open()) log_choke_changes_func_new(this, "balance", m_maxUnchoked, adjust); int result = 0; if (adjust > 0) { result = adjust_choke_range(queued.begin(), queued.end(), &queued, &unchoked, adjust, false); } else if (adjust < 0) { // We can do the choking before the slot is called as this // choke_queue won't be unchoking the same peers due to the // call-back. result = -adjust_choke_range(unchoked.begin(), unchoked.end(), &unchoked, &queued, -adjust, true); } if (result != 0) m_slotUnchoke(result); lt_log_print(LOG_PEER_DEBUG, "Called balance; adjust:%i can_unchoke:%i queued:%u unchoked:%u result:%i.", adjust, can_unchoke, (unsigned)queued.size(), (unsigned)unchoked.size(), result); } void choke_queue::balance_entry(group_entry* entry) { m_heuristics_list[m_heuristics].slot_choke_weight(entry->mutable_unchoked()->begin(), entry->mutable_unchoked()->end()); std::sort(entry->mutable_unchoked()->begin(), entry->mutable_unchoked()->end(), choke_manager_less()); m_heuristics_list[m_heuristics].slot_unchoke_weight(entry->mutable_queued()->begin(), entry->mutable_queued()->end()); std::sort(entry->mutable_queued()->begin(), entry->mutable_queued()->end(), choke_manager_less()); int count = 0; unsigned int min_slots = std::min(entry->min_slots(), entry->max_slots()); while (!entry->unchoked()->empty() && entry->unchoked()->size() > entry->max_slots()) count -= m_slotConnection(entry->unchoked()->back().connection, true); while (!entry->queued()->empty() && entry->unchoked()->size() < min_slots) count += m_slotConnection(entry->queued()->back().connection, false); m_slotUnchoke(count); } int choke_queue::cycle(uint32_t quota) { // TODO: This should not use the old values, but rather the number // of unchoked this round. // HACKKKKKK container_type queued; container_type unchoked; rebuild_containers(&queued, &unchoked); int oldSize = unchoked.size(); uint32_t alternate = max_alternate(); queued.clear(); unchoked.clear(); group_stats gs; std::memset(&gs, 0, sizeof(group_stats)); gs = prepare_weights(gs); gs = retrieve_connections(gs, &queued, &unchoked); quota = std::min(quota, m_maxUnchoked); quota = quota - std::min(quota, gs.now_unchoked); uint32_t adjust = (unchoked.size() < quota) ? (quota - unchoked.size()) : 0; adjust = std::max(adjust, alternate); adjust = std::min(adjust, quota); if (log_files[LOG_CHOKE_CHANGES].is_open()) log_choke_changes_func_new(this, "cycle", quota, adjust); lt_log_print(LOG_PEER_DEBUG, "Called cycle; quota:%u adjust:%i alternate:%i queued:%u unchoked:%u.", quota, adjust, alternate, (unsigned)queued.size(), (unsigned)unchoked.size()); uint32_t unchoked_count = adjust_choke_range(queued.begin(), queued.end(), &queued, &unchoked, adjust, false); if (unchoked.size() > quota) adjust_choke_range(unchoked.begin(), unchoked.end() - unchoked_count, &unchoked, &queued, unchoked.size() - quota, true); if (unchoked.size() > quota) throw internal_error("choke_queue::cycle() unchoked.size() > quota."); rebuild_containers(&queued, &unchoked); // Remove... lt_log_print(LOG_PEER_DEBUG, "After cycle; queued:%u unchoked:%u unchoked_count:%i old_size:%i.", (unsigned)queued.size(), (unsigned)unchoked.size(), unchoked_count, oldSize); return ((int)unchoked.size() - (int)oldSize); // + gs.changed_unchoke } void choke_queue::set_queued(PeerConnectionBase* pc, choke_status* base) { if (base->queued() || base->unchoked()) return; base->set_queued(true); if (base->snubbed()) return; base->entry()->connection_queued(pc); modify_currently_queued(1); if (!is_full() && (m_flags & flag_unchoke_all_new || m_slotCanUnchoke() > 0) && should_connection_unchoke(this, pc) && rak::timer(base->time_last_choke()) + rak::timer::from_seconds(10) < cachedTime) { m_slotConnection(pc, false); m_slotUnchoke(1); } } void choke_queue::set_not_queued(PeerConnectionBase* pc, choke_status* base) { if (!base->queued()) return; base->set_queued(false); if (base->snubbed()) return; if (base->unchoked()) { m_slotConnection(pc, true); m_slotUnchoke(-1); } base->entry()->connection_unqueued(pc); modify_currently_queued(-1); } void choke_queue::set_snubbed(PeerConnectionBase* pc, choke_status* base) { if (base->snubbed()) return; base->set_snubbed(true); if (base->unchoked()) { m_slotConnection(pc, true); m_slotUnchoke(-1); } else if (!base->queued()) { return; } base->entry()->connection_unqueued(pc); modify_currently_queued(-1); base->set_queued(false); } void choke_queue::set_not_snubbed(PeerConnectionBase* pc, choke_status* base) { if (!base->snubbed()) return; base->set_snubbed(false); if (!base->queued()) return; if (base->unchoked()) throw internal_error("choke_queue::set_not_snubbed(...) base->unchoked()."); base->entry()->connection_queued(pc); modify_currently_queued(1); if (!is_full() && (m_flags & flag_unchoke_all_new || m_slotCanUnchoke() > 0) && should_connection_unchoke(this, pc) && rak::timer(base->time_last_choke()) + rak::timer::from_seconds(10) < cachedTime) { m_slotConnection(pc, false); m_slotUnchoke(1); } } // We are no longer in m_connectionList. void choke_queue::disconnected(PeerConnectionBase* pc, choke_status* base) { if (base->snubbed()) { // Do nothing. } else if (base->unchoked()) { m_slotUnchoke(-1); base->entry()->connection_choked(pc); modify_currently_unchoked(-1); } else if (base->queued()) { base->entry()->connection_unqueued(pc); modify_currently_queued(-1); } base->set_queued(false); } // No need to do any choking as the next choke balancing will take // care of things. void choke_queue::move_connections(choke_queue* src, choke_queue* dest, DownloadMain* download, group_entry* base) { if (src != NULL) { group_container_type::iterator itr = std::find(src->m_group_container.begin(), src->m_group_container.end(), base); if (itr == src->m_group_container.end()) throw internal_error("choke_queue::move_connections(...) could not find group."); std::swap(*itr, src->m_group_container.back()); src->m_group_container.pop_back(); } if (dest != NULL) { dest->m_group_container.push_back(base); } if (src == NULL || dest == NULL) return; src->modify_currently_queued(-base->queued()->size()); src->modify_currently_unchoked(-base->unchoked()->size()); dest->modify_currently_queued(base->queued()->size()); dest->modify_currently_unchoked(base->unchoked()->size()); } // // Heuristics: // void choke_manager_allocate_slots(choke_queue::iterator first, choke_queue::iterator last, uint32_t max, uint32_t* weights, choke_queue::target_type* target) { // Sorting the connections from the lowest to highest value. // TODO: std::sort(first, last, choke_manager_less()); // 'weightTotal' only contains the weight of targets that have // connections to unchoke. When all connections are in a group are // to be unchoked, then the group's weight is removed. uint32_t weightTotal = 0; uint32_t unchoke = max; target[0].second = first; for (uint32_t i = 0; i < choke_queue::order_max_size; i++) { target[i].first = 0; target[i + 1].second = std::find_if(target[i].second, last, rak::less(i * choke_queue::order_base + (choke_queue::order_base - 1), rak::mem_ref(&choke_queue::value_type::weight))); if (std::distance(target[i].second, target[i + 1].second) != 0) weightTotal += weights[i]; } // Spread available unchoke slots as long as we can give everyone an // equal share. while (weightTotal != 0 && unchoke / weightTotal > 0) { uint32_t base = unchoke / weightTotal; for (uint32_t itr = 0; itr < choke_queue::order_max_size; itr++) { uint32_t s = std::distance(target[itr].second, target[itr + 1].second); if (weights[itr] == 0 || target[itr].first >= s) continue; uint32_t u = std::min(s - target[itr].first, base * weights[itr]); unchoke -= u; target[itr].first += u; if (target[itr].first >= s) weightTotal -= weights[itr]; } } // Spread the remainder starting from a random position based on the // total weight. This will ensure that aggregated over time we // spread the unchokes equally according to the weight table. if (weightTotal != 0 && unchoke != 0) { uint32_t start = ::random() % weightTotal; unsigned int itr = 0; for ( ; ; itr++) { uint32_t s = std::distance(target[itr].second, target[itr + 1].second); if (weights[itr] == 0 || target[itr].first >= s) continue; if (start < weights[itr]) break; start -= weights[itr]; } for ( ; weightTotal != 0 && unchoke != 0; itr = (itr + 1) % choke_queue::order_max_size) { uint32_t s = std::distance(target[itr].second, target[itr + 1].second); if (weights[itr] == 0 || target[itr].first >= s) continue; uint32_t u = std::min(unchoke, std::min(s - target[itr].first, weights[itr] - start)); start = 0; unchoke -= u; target[itr].first += u; if (target[itr].first >= s) weightTotal -= weights[itr]; } } } template bool range_is_contained(Itr first, Itr last, Itr lower_bound, Itr upper_bound) { return first >= lower_bound && last <= upper_bound && first <= last; } uint32_t choke_queue::adjust_choke_range(iterator first, iterator last, container_type* src_container, container_type* dest_container, uint32_t max, bool is_choke) { target_type target[order_max_size + 1]; if (is_choke) { // TODO: m_heuristics_list[m_heuristics].slot_choke_weight(first, last); choke_manager_allocate_slots(first, last, max, m_heuristics_list[m_heuristics].choke_weight, target); } else { // m_heuristics_list[m_heuristics].slot_unchoke_weight(first, last); choke_manager_allocate_slots(first, last, max, m_heuristics_list[m_heuristics].unchoke_weight, target); } if (log_files[LOG_CHOKE_CHANGES].is_open()) for (uint32_t i = 0; i < choke_queue::order_max_size; i++) log_choke_changes_func_allocate(this, "unchoke" + 2*is_choke, i, target[i].first, std::distance(target[i].second, target[i + 1].second)); // Now do the actual unchoking. uint32_t count = 0; uint32_t skipped = 0; for (target_type* itr = target + order_max_size; itr != target; itr--) { uint32_t order_size = std::distance((itr - 1)->second, itr->second); uint32_t order_remaining = order_size - (itr - 1)->first; if ((itr - 1)->first > order_size) throw internal_error("choke_queue::adjust_choke_range(...) itr->first > std::distance((itr - 1)->second, itr->second)."); (itr - 1)->first += std::min(skipped, order_remaining); skipped -= std::min(skipped, order_remaining); iterator first_adjust = itr->second - (itr - 1)->first; iterator last_adjust = itr->second; if (!range_is_contained(first_adjust, last_adjust, src_container->begin(), src_container->end())) throw internal_error("choke_queue::adjust_choke_range(...) bad iterator range."); // We start by unchoking the highest priority in this group, and // if we find any peers we can't choke/unchoke we'll move them to // the last spot in the container and decrement 'last_adjust'. iterator itr_adjust = last_adjust; while (itr_adjust != first_adjust) { itr_adjust--; // if (!is_choke && !should_connection_unchoke(this, itr_adjust->first)) { // // Swap with end and continue if not done with group. Count how many? // std::iter_swap(itr_adjust, --last_adjust); // if (first_adjust == (itr - 1)->second) // skipped++; // else // first_adjust--; // continue; // } m_slotConnection(itr_adjust->connection, is_choke); count++; if (!log_files[LOG_CHOKE_CHANGES].is_open()) continue; log_choke_changes_func_peer(this, "unchoke" + 2*is_choke, &*itr_adjust); } // The 'target' iterators remain valid after erase since we're // removing them in reverse order. dest_container->insert(dest_container->end(), first_adjust, last_adjust); src_container->erase(first_adjust, last_adjust); } if (count > max) throw internal_error("choke_queue::adjust_choke_range(...) count > max."); return count; } // Note that these algorithms fail if the rate >= 2^30. // Need to add the recently unchoked check here? void calculate_upload_choke(choke_queue::iterator first, choke_queue::iterator last) { while (first != last) { // Very crude version for now. // // This needs to give more weight to peers that haven't had time to unchoke us. uint32_t downloadRate = first->connection->peer_chunks()->download_throttle()->rate()->rate() / 16; first->weight = choke_queue::order_base - 1 - downloadRate; first++; } } void calculate_upload_unchoke(choke_queue::iterator first, choke_queue::iterator last) { while (first != last) { if (first->connection->is_down_local_unchoked()) { uint32_t downloadRate = first->connection->peer_chunks()->download_throttle()->rate()->rate(); // If the peer transmits at less than 1KB, we should consider it // to be a rather stingy peer, and should look for new ones. if (downloadRate < 1000) first->weight = downloadRate; else first->weight = 2 * choke_queue::order_base + downloadRate; } else { // This will be our optimistic unchoke queue, should be // semi-random. Give lower weights to known stingy peers. first->weight = 1 * choke_queue::order_base + ::random() % (1 << 10); } first++; } } // Fix this, but for now just use something simple. void calculate_download_choke(choke_queue::iterator first, choke_queue::iterator last) { while (first != last) { // Very crude version for now. uint32_t downloadRate = first->connection->peer_chunks()->download_throttle()->rate()->rate(); first->weight = choke_queue::order_base - 1 - downloadRate; first++; } } void calculate_download_unchoke(choke_queue::iterator first, choke_queue::iterator last) { while (first != last) { // Very crude version for now. uint32_t downloadRate = first->connection->peer_chunks()->download_throttle()->rate()->rate(); first->weight = downloadRate; first++; } } choke_queue::heuristics_type choke_queue::m_heuristics_list[HEURISTICS_MAX_SIZE] = { { &calculate_upload_choke, &calculate_upload_unchoke, { 1, 1, 1, 1 }, { 1, 3, 9, 0 } }, { &calculate_upload_choke, &calculate_upload_unchoke, { 1, 1, 1, 1 }, { 1, 3, 9, 0 } }, { &calculate_download_choke, &calculate_download_unchoke, { 1, 1, 1, 1 }, { 1, 1, 1, 1 } }, { &calculate_download_choke, &calculate_download_unchoke, { 1, 1, 1, 1 }, { 1, 1, 1, 1 } }, }; } libtorrent-0.13.2/src/torrent/download/choke_queue.h000644 000765 000024 00000016221 11744202446 023470 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_CHOKE_QUEUE_H #define LIBTORRENT_DOWNLOAD_CHOKE_QUEUE_H #include #include #include #include #include #include namespace torrent { class choke_status; class group_entry; class ConnectionList; class PeerConnectionBase; class DownloadMain; struct group_stats { unsigned int sum_min_needed; unsigned int sum_max_needed; unsigned int sum_max_leftovers; unsigned int changed_choked; unsigned int changed_unchoked; unsigned int now_choked; unsigned int now_unchoked; }; class LIBTORRENT_EXPORT choke_queue { public: typedef std::tr1::function slot_unchoke; typedef std::tr1::function slot_can_unchoke; typedef std::tr1::function slot_connection; typedef std::vector container_type; typedef container_type::value_type value_type; typedef container_type::iterator iterator; typedef std::pair target_type; typedef std::vector group_container_type; typedef void (*slot_weight)(iterator first, iterator last); static const int flag_unchoke_all_new = 0x1; static const uint32_t order_base = (1 << 30); static const uint32_t order_max_size = 4; static const uint32_t weight_size_bytes = order_max_size * sizeof(uint32_t); static const uint32_t unlimited = ~uint32_t(); struct heuristics_type { slot_weight slot_choke_weight; slot_weight slot_unchoke_weight; uint32_t choke_weight[order_max_size]; uint32_t unchoke_weight[order_max_size]; }; enum heuristics_enum { HEURISTICS_UPLOAD_LEECH, HEURISTICS_UPLOAD_LEECH_DUMMY, HEURISTICS_DOWNLOAD_LEECH, HEURISTICS_DOWNLOAD_LEECH_DUMMY, HEURISTICS_MAX_SIZE }; choke_queue(int flags = 0) : m_flags(flags), m_heuristics(HEURISTICS_MAX_SIZE), m_maxUnchoked(unlimited), m_currently_queued(0), m_currently_unchoked(0), m_slotConnection(NULL) {} ~choke_queue(); bool is_full() const { return !is_unlimited() && size_unchoked() >= m_maxUnchoked; } bool is_unlimited() const { return m_maxUnchoked == unlimited; } uint32_t size_unchoked() const { return m_currently_unchoked; } uint32_t size_queued() const { return m_currently_queued; } uint32_t size_total() const { return size_unchoked() + size_queued(); } // This must be unsigned. uint32_t max_unchoked() const { return m_maxUnchoked; } int32_t max_unchoked_signed() const { return m_maxUnchoked; } void set_max_unchoked(uint32_t v) { m_maxUnchoked = v; } void balance(); void balance_entry(group_entry* entry); int cycle(uint32_t quota); // Assume interested state is already updated for the PCB and that // this gets called once every time the status changes. void set_queued(PeerConnectionBase* pc, choke_status* base); void set_not_queued(PeerConnectionBase* pc, choke_status* base); void set_snubbed(PeerConnectionBase* pc, choke_status* base); void set_not_snubbed(PeerConnectionBase* pc, choke_status* base); void disconnected(PeerConnectionBase* pc, choke_status* base); static void move_connections(choke_queue* src, choke_queue* dest, DownloadMain* download, group_entry* base); heuristics_enum heuristics() const { return m_heuristics; } void set_heuristics(heuristics_enum hs) { m_heuristics = hs; } void set_slot_unchoke(slot_unchoke s) { m_slotUnchoke = s; } void set_slot_can_unchoke(slot_can_unchoke s) { m_slotCanUnchoke = s; } void set_slot_connection(slot_connection s) { m_slotConnection = s; } // TODO: Consider putting this in queue_group. group_container_type& group_container() { return m_group_container; } void modify_currently_queued(int value) { m_currently_queued += value; } void modify_currently_unchoked(int value) { m_currently_unchoked += value; } private: group_stats prepare_weights(group_stats gs); group_stats retrieve_connections(group_stats gs, container_type* queued, container_type* unchoked); void rebuild_containers(container_type* queued, container_type* unchoked); inline uint32_t max_alternate() const; uint32_t adjust_choke_range(iterator first, iterator last, container_type* src_container, container_type* dest_container, uint32_t max, bool is_choke); static heuristics_type m_heuristics_list[HEURISTICS_MAX_SIZE]; int m_flags; heuristics_enum m_heuristics; uint32_t m_maxUnchoked; uint32_t m_currently_queued; uint32_t m_currently_unchoked; slot_unchoke m_slotUnchoke; slot_can_unchoke m_slotCanUnchoke; slot_connection m_slotConnection; group_container_type m_group_container; }; } #endif libtorrent-0.13.2/src/torrent/download/download_manager.cc000644 000765 000024 00000007713 11705767056 024652 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "torrent/exceptions.h" #include "download/download_wrapper.h" #include "download_manager.h" namespace torrent { DownloadManager::iterator DownloadManager::insert(DownloadWrapper* d) { if (find(d->info()->hash()) != end()) throw internal_error("Could not add torrent as it already exists."); return base_type::insert(end(), d); } DownloadManager::iterator DownloadManager::erase(DownloadWrapper* d) { iterator itr = std::find(begin(), end(), d); if (itr == end()) throw internal_error("Tried to remove a torrent that doesn't exist"); delete *itr; return base_type::erase(itr); } void DownloadManager::clear() { while (!empty()) { delete base_type::back(); base_type::pop_back(); } } DownloadManager::iterator DownloadManager::find(const std::string& hash) { return std::find_if(begin(), end(), rak::equal(*HashString::cast_from(hash), rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash)))); } DownloadManager::iterator DownloadManager::find(const HashString& hash) { return std::find_if(begin(), end(), rak::equal(hash, rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash)))); } DownloadManager::iterator DownloadManager::find(DownloadInfo* info) { return std::find_if(begin(), end(), rak::equal(info, std::mem_fun(&DownloadWrapper::info))); } DownloadManager::iterator DownloadManager::find_chunk_list(ChunkList* cl) { return std::find_if(begin(), end(), rak::equal(cl, std::mem_fun(&DownloadWrapper::chunk_list))); } DownloadMain* DownloadManager::find_main(const char* hash) { iterator itr = std::find_if(begin(), end(), rak::equal(*HashString::cast_from(hash), rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash)))); if (itr == end()) return NULL; else return (*itr)->main(); } DownloadMain* DownloadManager::find_main_obfuscated(const char* hash) { iterator itr = std::find_if(begin(), end(), rak::equal(*HashString::cast_from(hash), rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash_obfuscated)))); if (itr == end()) return NULL; else return (*itr)->main(); } } libtorrent-0.13.2/src/torrent/download/download_manager.h000644 000765 000024 00000006274 11705767056 024515 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_MANAGER_H #define LIBTORRENT_DOWNLOAD_MANAGER_H #include #include namespace torrent { class ChunkList; class DownloadWrapper; class DownloadInfo; class DownloadMain; class LIBTORRENT_EXPORT DownloadManager : private std::vector { public: typedef std::vector base_type; typedef base_type::value_type value_type; typedef base_type::pointer pointer; typedef base_type::const_pointer const_pointer; typedef base_type::reference reference; typedef base_type::const_reference const_reference; typedef base_type::size_type size_type; typedef base_type::iterator iterator; typedef base_type::reverse_iterator reverse_iterator; typedef base_type::const_iterator const_iterator; typedef base_type::const_reverse_iterator const_reverse_iterator; using base_type::empty; using base_type::size; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; ~DownloadManager() { clear(); } iterator find(const std::string& hash); iterator find(const HashString& hash); iterator find(DownloadInfo* info); iterator find_chunk_list(ChunkList* cl); DownloadMain* find_main(const char* hash); DownloadMain* find_main_obfuscated(const char* hash); // // Don't export: // iterator insert(DownloadWrapper* d) LIBTORRENT_NO_EXPORT; iterator erase(DownloadWrapper* d) LIBTORRENT_NO_EXPORT; void clear() LIBTORRENT_NO_EXPORT; }; } #endif libtorrent-0.13.2/src/torrent/download/group_entry.h000644 000765 000024 00000013054 11705767056 023563 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_GROUP_ENTRY_H #define LIBTORRENT_DOWNLOAD_GROUP_ENTRY_H #include #include #include #include #include namespace torrent { class choke_queue; class PeerConnectionBase; struct weighted_connection { weighted_connection(PeerConnectionBase* pcb, uint32_t w) : connection(pcb), weight(w) {} bool operator == (const PeerConnectionBase* pcb) { return pcb == connection; } bool operator != (const PeerConnectionBase* pcb) { return pcb != connection; } PeerConnectionBase* connection; uint32_t weight; }; // TODO: Rename to choke_entry, create an new class called group entry? class group_entry { public: typedef std::vector container_type; static const uint32_t unlimited = ~uint32_t(); group_entry() : m_max_slots(unlimited), m_min_slots(0) {} uint32_t size_connections() const { return m_queued.size() + m_unchoked.size(); } uint32_t max_slots() const { return m_max_slots; } uint32_t min_slots() const { return m_min_slots; } void set_max_slots(uint32_t s) { m_max_slots = s; } void set_min_slots(uint32_t s) { m_min_slots = s; } const container_type* queued() { return &m_queued; } const container_type* unchoked() { return &m_unchoked; } protected: friend class choke_queue; friend class PeerConnectionBase; container_type* mutable_queued() { return &m_queued; } container_type* mutable_unchoked() { return &m_unchoked; } void connection_unchoked(PeerConnectionBase* pcb); void connection_choked(PeerConnectionBase* pcb); void connection_queued(PeerConnectionBase* pcb); void connection_unqueued(PeerConnectionBase* pcb); private: uint32_t m_max_slots; uint32_t m_min_slots; // After a cycle the end of the vector should have the // highest-priority connections, and any new connections get put at // the back so they should always good candidates for unchoking. container_type m_queued; container_type m_unchoked; }; inline void group_entry::connection_unchoked(PeerConnectionBase* pcb) { container_type::iterator itr = std::find_if(m_unchoked.begin(), m_unchoked.end(), std::tr1::bind(&weighted_connection::operator==, std::tr1::placeholders::_1, pcb)); if (itr != m_unchoked.end()) throw internal_error("group_entry::connection_unchoked(pcb) failed."); m_unchoked.push_back(weighted_connection(pcb, uint32_t())); } inline void group_entry::connection_queued(PeerConnectionBase* pcb) { container_type::iterator itr = std::find_if(m_queued.begin(), m_queued.end(), std::tr1::bind(&weighted_connection::operator==, std::tr1::placeholders::_1, pcb)); if (itr != m_queued.end()) throw internal_error("group_entry::connection_queued(pcb) failed."); m_queued.push_back(weighted_connection(pcb, uint32_t())); } inline void group_entry::connection_choked(PeerConnectionBase* pcb) { container_type::iterator itr = std::find_if(m_unchoked.begin(), m_unchoked.end(), std::tr1::bind(&weighted_connection::operator==, std::tr1::placeholders::_1, pcb)); if (itr == m_unchoked.end()) throw internal_error("group_entry::connection_choked(pcb) failed."); std::swap(*itr, m_unchoked.back()); m_unchoked.pop_back(); } inline void group_entry::connection_unqueued(PeerConnectionBase* pcb) { container_type::iterator itr = std::find_if(m_queued.begin(), m_queued.end(), std::tr1::bind(&weighted_connection::operator==, std::tr1::placeholders::_1, pcb)); if (itr == m_queued.end()) throw internal_error("group_entry::connection_unqueued(pcb) failed."); std::swap(*itr, m_queued.back()); m_queued.pop_back(); } } #endif libtorrent-0.13.2/src/torrent/download/Makefile.am000644 000765 000024 00000001000 11705767056 023055 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_torrentdownload.la libsub_torrentdownload_la_SOURCES = \ choke_group.cc \ choke_group.h \ choke_queue.cc \ choke_queue.h \ download_manager.cc \ download_manager.h \ group_entry.h \ resource_manager.cc \ resource_manager.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/download libtorrentinclude_HEADERS = \ choke_group.h \ choke_queue.h \ download_manager.h \ group_entry.h \ resource_manager.h libtorrent-0.13.2/src/torrent/download/Makefile.in000644 000765 000024 00000045377 11744204216 023102 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/torrent/download DIST_COMMON = $(libtorrentinclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_torrentdownload_la_LIBADD = am_libsub_torrentdownload_la_OBJECTS = choke_group.lo choke_queue.lo \ download_manager.lo resource_manager.lo libsub_torrentdownload_la_OBJECTS = \ $(am_libsub_torrentdownload_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_torrentdownload_la_SOURCES) DIST_SOURCES = $(libsub_torrentdownload_la_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libtorrentincludedir)" HEADERS = $(libtorrentinclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_torrentdownload.la libsub_torrentdownload_la_SOURCES = \ choke_group.cc \ choke_group.h \ choke_queue.cc \ choke_queue.h \ download_manager.cc \ download_manager.h \ group_entry.h \ resource_manager.cc \ resource_manager.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/download libtorrentinclude_HEADERS = \ choke_group.h \ choke_queue.h \ download_manager.h \ group_entry.h \ resource_manager.h all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/torrent/download/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/torrent/download/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_torrentdownload.la: $(libsub_torrentdownload_la_OBJECTS) $(libsub_torrentdownload_la_DEPENDENCIES) $(EXTRA_libsub_torrentdownload_la_DEPENDENCIES) $(CXXLINK) $(libsub_torrentdownload_la_OBJECTS) $(libsub_torrentdownload_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/choke_group.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/choke_queue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resource_manager.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-libtorrentincludeHEADERS: $(libtorrentinclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(libtorrentincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libtorrentincludedir)" @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtorrentincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtorrentincludedir)" || exit $$?; \ done uninstall-libtorrentincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libtorrentincludedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libtorrentincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-libtorrentincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libtorrentincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libtorrentincludeHEADERS install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libtorrentincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/torrent/download/resource_manager.cc000644 000765 000024 00000024641 11744202447 024660 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include "torrent/exceptions.h" #include "torrent/download/choke_group.h" #include "torrent/utils/log.h" #include "download/download_main.h" #include "protocol/peer_connection_base.h" #include "choke_queue.h" #include "resource_manager.h" namespace tr1 { using namespace std::tr1; } namespace torrent { const Rate* resource_manager_entry::up_rate() const { return m_download->info()->up_rate(); } const Rate* resource_manager_entry::down_rate() const { return m_download->info()->down_rate(); } ResourceManager::ResourceManager() : m_currentlyUploadUnchoked(0), m_currentlyDownloadUnchoked(0), m_maxUploadUnchoked(0), m_maxDownloadUnchoked(0) { choke_base_type::push_back(new choke_group()); choke_base_type::back()->set_name("default"); choke_base_type::back()->set_first(&*base_type::end()); choke_base_type::back()->set_last(&*base_type::end()); choke_base_type::back()->up_queue()->set_heuristics(choke_queue::HEURISTICS_UPLOAD_LEECH); choke_base_type::back()->down_queue()->set_heuristics(choke_queue::HEURISTICS_DOWNLOAD_LEECH); choke_base_type::back()->up_queue()->set_slot_unchoke(tr1::bind(&ResourceManager::receive_upload_unchoke, this, tr1::placeholders::_1)); choke_base_type::back()->down_queue()->set_slot_unchoke(tr1::bind(&ResourceManager::receive_download_unchoke, this, tr1::placeholders::_1)); choke_base_type::back()->up_queue()->set_slot_can_unchoke(tr1::bind(&ResourceManager::retrieve_upload_can_unchoke, this)); choke_base_type::back()->down_queue()->set_slot_can_unchoke(tr1::bind(&ResourceManager::retrieve_download_can_unchoke, this)); choke_base_type::back()->up_queue()->set_slot_connection(tr1::bind(&PeerConnectionBase::receive_upload_choke, tr1::placeholders::_1, tr1::placeholders::_2)); choke_base_type::back()->down_queue()->set_slot_connection(tr1::bind(&PeerConnectionBase::receive_download_choke, tr1::placeholders::_1, tr1::placeholders::_2)); } ResourceManager::~ResourceManager() { if (m_currentlyUploadUnchoked != 0) throw internal_error("ResourceManager::~ResourceManager() called but m_currentlyUploadUnchoked != 0."); if (m_currentlyDownloadUnchoked != 0) throw internal_error("ResourceManager::~ResourceManager() called but m_currentlyDownloadUnchoked != 0."); std::for_each(choke_base_type::begin(), choke_base_type::end(), rak::call_delete()); } // If called directly ensure a valid group has been selected. ResourceManager::iterator ResourceManager::insert(const resource_manager_entry& entry) { iterator itr = base_type::insert(base_type::end(), entry); DownloadMain* download = itr->download(); download->set_choke_group(choke_base_type::at(entry.group())); update_group_iterators(); choke_queue::move_connections(NULL, download->choke_group()->up_queue(), download, download->up_group_entry()); choke_queue::move_connections(NULL, download->choke_group()->down_queue(), download, download->down_group_entry()); return itr; } void ResourceManager::update_group_iterators() { base_type::iterator entry_itr = base_type::begin(); choke_base_type::iterator group_itr = choke_base_type::begin(); while (group_itr != choke_base_type::end()) { (*group_itr)->set_first(&*entry_itr); entry_itr = std::find_if(entry_itr, end(), rak::less(std::distance(choke_base_type::begin(), group_itr), std::mem_fun_ref(&value_type::group))); (*group_itr)->set_last(&*entry_itr); group_itr++; } } void ResourceManager::validate_group_iterators() { base_type::iterator entry_itr = base_type::begin(); choke_base_type::iterator group_itr = choke_base_type::begin(); while (group_itr != choke_base_type::end()) { if ((*group_itr)->first() != &*entry_itr) throw internal_error("ResourceManager::receive_tick() invalid first iterator."); entry_itr = std::find_if(entry_itr, end(), rak::less(std::distance(choke_base_type::begin(), group_itr), std::mem_fun_ref(&value_type::group))); if ((*group_itr)->last() != &*entry_itr) throw internal_error("ResourceManager::receive_tick() invalid last iterator."); group_itr++; } } void ResourceManager::erase(DownloadMain* d) { iterator itr = std::find_if(begin(), end(), rak::equal(d, std::mem_fun_ref(&value_type::download))); if (itr == end()) throw internal_error("ResourceManager::erase() itr == end()."); choke_queue::move_connections(d->choke_group()->up_queue(), NULL, d, d->up_group_entry()); choke_queue::move_connections(d->choke_group()->down_queue(), NULL, d, d->down_group_entry()); choke_base_type::iterator group_itr = choke_base_type::begin() + itr->group(); (*group_itr)->set_last((*group_itr)->last() - 1); base_type::erase(itr); } ResourceManager::iterator ResourceManager::find(DownloadMain* d) { return std::find_if(begin(), end(), rak::equal(d, std::mem_fun_ref(&value_type::download))); } ResourceManager::iterator ResourceManager::find_throw(DownloadMain* d) { iterator itr = std::find_if(begin(), end(), rak::equal(d, std::mem_fun_ref(&value_type::download))); if (itr == end()) throw input_error("Could not find download in resource manager."); return itr; } void ResourceManager::set_priority(iterator itr, uint16_t pri) { itr->set_priority(pri); } void ResourceManager::set_group(iterator itr, uint16_t grp) { if (itr->group() == grp) return; // if (grp >= choke_base_type::size()) throw input_error("Choke group not found."); } void ResourceManager::set_max_upload_unchoked(unsigned int m) { if (m > (1 << 16)) throw input_error("Max unchoked must be between 0 and 2^16."); m_maxUploadUnchoked = m; } void ResourceManager::set_max_download_unchoked(unsigned int m) { if (m > (1 << 16)) throw input_error("Max unchoked must be between 0 and 2^16."); m_maxDownloadUnchoked = m; } // The choking choke manager won't updated it's count until after // possibly multiple calls of this function. void ResourceManager::receive_upload_unchoke(int num) { lt_log_print(LOG_PEER_DEBUG, "Upload unchoked slots adjust; currently:%u adjust:%i", m_currentlyUploadUnchoked, num); if ((int)m_currentlyUploadUnchoked + num < 0) throw internal_error("ResourceManager::receive_upload_unchoke(...) received an invalid value."); m_currentlyUploadUnchoked += num; } void ResourceManager::receive_download_unchoke(int num) { lt_log_print(LOG_PEER_DEBUG, "Download unchoked slots adjust; currently:%u adjust:%i", m_currentlyDownloadUnchoked, num); if ((int)m_currentlyDownloadUnchoked + num < 0) throw internal_error("ResourceManager::receive_download_unchoke(...) received an invalid value."); m_currentlyDownloadUnchoked += num; } int ResourceManager::retrieve_upload_can_unchoke() { if (m_maxUploadUnchoked == 0) return std::numeric_limits::max(); return (int)m_maxUploadUnchoked - (int)m_currentlyUploadUnchoked; } int ResourceManager::retrieve_download_can_unchoke() { if (m_maxDownloadUnchoked == 0) return std::numeric_limits::max(); return (int)m_maxDownloadUnchoked - (int)m_currentlyDownloadUnchoked; } void ResourceManager::receive_tick() { validate_group_iterators(); m_currentlyUploadUnchoked += balance_unchoked(choke_base_type::size(), m_maxUploadUnchoked, true); m_currentlyDownloadUnchoked += balance_unchoked(choke_base_type::size(), m_maxDownloadUnchoked, false); if (m_currentlyUploadUnchoked != choke_base_type::back()->up_queue()->size_unchoked()) throw torrent::internal_error("m_currentlyUploadUnchoked != choke_base_type::back()->up_queue()->size_unchoked()"); if (m_currentlyDownloadUnchoked != choke_base_type::back()->down_queue()->size_unchoked()) throw torrent::internal_error("m_currentlyDownloadUnchoked != choke_base_type::back()->down_queue()->size_unchoked()"); } unsigned int ResourceManager::total_weight() const { // TODO: This doesn't take into account inactive downloads. return std::for_each(begin(), end(), rak::accumulate((unsigned int)0, std::mem_fun_ref(&value_type::priority))).result; } int ResourceManager::balance_unchoked(unsigned int weight, unsigned int max_unchoked, bool is_up) { int change = 0; if (max_unchoked == 0) max_unchoked = std::numeric_limits::max(); if (is_up) { change += choke_base_type::back()->up_queue()->cycle(max_unchoked); lt_log_print(LOG_PEER_DEBUG, "Upload unchoked slots cycle; currently:%u adjusted:%i max_unchoked:%u", m_currentlyUploadUnchoked, change, max_unchoked); } else { change += choke_base_type::back()->down_queue()->cycle(max_unchoked); lt_log_print(LOG_PEER_DEBUG, "Download unchoked slots cycle; currently:%u adjusted:%i max_unchoked:%u", m_currentlyDownloadUnchoked, change, max_unchoked); } return change; } } libtorrent-0.13.2/src/torrent/download/resource_manager.h000644 000765 000024 00000012742 11744202447 024521 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_RESOURCE_MANAGER_H #define LIBTORRENT_PEER_RESOURCE_MANAGER_H #include #include #include #include namespace torrent { // This class will handle the division of various resources like // uploads. For now the weight is equal to the value of the priority. // // Although the ConnectionManager class keeps a tally of open sockets, // we still need to balance them across the different downloads so // ResourceManager will also keep track of those. // // Add unlimited handling later. class choke_group; class DownloadMain; class Rate; class ResourceManager; class LIBTORRENT_EXPORT resource_manager_entry { public: friend class ResourceManager; resource_manager_entry(DownloadMain* d = NULL, uint16_t pri = 0, uint16_t grp = 0) : m_download(d), m_priority(pri), m_group(grp) {} DownloadMain* download() { return m_download; } const DownloadMain* c_download() const { return m_download; } uint16_t priority() const { return m_priority; } uint16_t group() const { return m_group; } const Rate* up_rate() const; const Rate* down_rate() const; protected: void set_priority(uint16_t pri) { m_priority = pri; } void set_group(uint16_t grp) { m_group = grp; } private: DownloadMain* m_download; uint16_t m_priority; uint16_t m_group; }; class LIBTORRENT_EXPORT ResourceManager : private std::vector, private std::vector { public: typedef std::vector base_type; typedef std::vector choke_base_type; typedef base_type::value_type value_type; typedef base_type::iterator iterator; using base_type::begin; using base_type::end; using base_type::size; using base_type::capacity; ResourceManager(); ~ResourceManager(); void insert(DownloadMain* d, uint16_t priority) { insert(value_type(d, priority)); } void erase(DownloadMain* d); iterator find(DownloadMain* d); iterator find_throw(DownloadMain* d); iterator find_group_end(uint16_t group); choke_group* group_at(uint16_t grp); resource_manager_entry& entry_at(DownloadMain* d) { return *find_throw(d); } void set_priority(iterator itr, uint16_t pri); void set_group(iterator itr, uint16_t grp); // When setting this, make sure you choke peers, else change // receive_can_unchoke. unsigned int currently_upload_unchoked() const { return m_currentlyUploadUnchoked; } unsigned int currently_download_unchoked() const { return m_currentlyDownloadUnchoked; } unsigned int max_upload_unchoked() const { return m_maxUploadUnchoked; } unsigned int max_download_unchoked() const { return m_maxDownloadUnchoked; } void set_max_upload_unchoked(unsigned int m); void set_max_download_unchoked(unsigned int m); void receive_upload_unchoke(int num); void receive_download_unchoke(int num); int retrieve_upload_can_unchoke(); int retrieve_download_can_unchoke(); void receive_tick(); private: iterator insert(const resource_manager_entry& entry); void update_group_iterators(); void validate_group_iterators(); unsigned int total_weight() const; int balance_unchoked(unsigned int weight, unsigned int max_unchoked, bool is_up); unsigned int m_currentlyUploadUnchoked; unsigned int m_currentlyDownloadUnchoked; unsigned int m_maxUploadUnchoked; unsigned int m_maxDownloadUnchoked; }; } #endif libtorrent-0.13.2/src/torrent/data/block.cc000644 000765 000024 00000031356 11705767056 021545 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "peer/peer_info.h" #include "protocol/peer_connection_base.h" #include "block.h" #include "block_failed.h" #include "block_list.h" #include "block_transfer.h" #include "exceptions.h" namespace torrent { Block::~Block() { m_leader = NULL; std::for_each(m_queued.begin(), m_queued.end(), std::bind1st(std::mem_fun(&Block::invalidate_transfer), this)); m_queued.clear(); std::for_each(m_transfers.begin(), m_transfers.end(), std::bind1st(std::mem_fun(&Block::invalidate_transfer), this)); m_transfers.clear(); if (m_notStalled != 0) throw internal_error("Block::clear() m_stalled != 0."); delete m_failedList; } BlockTransfer* Block::insert(PeerInfo* peerInfo) { if (find_queued(peerInfo) || find_transfer(peerInfo)) throw internal_error("Block::insert(...) find_queued(peerInfo) || find_transfer(peerInfo)."); m_notStalled++; transfer_list_type::iterator itr = m_queued.insert(m_queued.end(), new BlockTransfer()); (*itr)->set_peer_info(peerInfo); (*itr)->set_block(this); (*itr)->set_piece(m_piece); (*itr)->set_state(BlockTransfer::STATE_QUEUED); (*itr)->set_position(0); (*itr)->set_stall(0); (*itr)->set_failed_index(BlockFailed::invalid_index); peerInfo->set_transfer_counter(peerInfo->transfer_counter() + 1); return (*itr); } void Block::erase(BlockTransfer* transfer) { if (transfer->is_erased()) throw internal_error("Block::erase(...) transfer already erased."); m_notStalled -= transfer->stall() == 0; if (transfer->is_queued()) { transfer_list_type::iterator itr = std::find(m_queued.begin(), m_queued.end(), transfer); if (itr == m_queued.end()) throw internal_error("Block::erase(...) Could not find transfer."); m_queued.erase(itr); } else if (!transfer->is_finished()) { transfer_list_type::iterator itr = std::find(m_transfers.begin(), m_transfers.end(), transfer); if (itr == m_transfers.end()) throw internal_error("Block::erase(...) Could not find transfer."); // Need to do something different here for now, i think. m_transfers.erase(itr); if (transfer == m_leader) { // When the leader is erased then any non-leading transfer must // be promoted. These non-leading transfers are guaranteed to // have the same data up to their position. PeerConnectionBase // assumes that a Block with non-leaders have a leader. // Create a range containing transfers with // is_not_leader(). Erased transfer will end up in the back. transfer_list_type::iterator first = std::find_if(m_transfers.begin(), m_transfers.end(), std::not1(std::mem_fun(&BlockTransfer::is_leader))); transfer_list_type::iterator last = std::stable_partition(first, m_transfers.end(), std::mem_fun(&BlockTransfer::is_not_leader)); transfer_list_type::iterator newLeader = std::max_element(first, last, rak::less2(std::mem_fun(&BlockTransfer::position), std::mem_fun(&BlockTransfer::position))); if (newLeader != last) { m_leader = *newLeader; m_leader->set_state(BlockTransfer::STATE_LEADER); } else { m_leader = NULL; // If we have no new leader, remove the erased (dissimilar) // transfers so they can get another shot. They cannot be // removed when found dissimilar as that would result in them // being queued immediately. remove_erased_transfers(); } } } else { throw internal_error("Block::erase(...) Transfer is finished."); } if (transfer->peer_info() != NULL) transfer->peer_info()->set_transfer_counter(transfer->peer_info()->transfer_counter() - 1); transfer->set_block(NULL); delete transfer; } bool Block::transfering(BlockTransfer* transfer) { if (!transfer->is_valid()) throw internal_error("Block::transfering(...) transfer->block() == NULL."); transfer_list_type::iterator itr = std::find(m_queued.begin(), m_queued.end(), transfer); if (itr == m_queued.end()) throw internal_error("Block::transfering(...) not queued."); m_queued.erase(itr); m_transfers.insert(m_transfers.end(), transfer); // If this block already has an active transfer, make this transfer // skip the piece. If this transfer gets ahead of the currently // transfering, it will (a) take over as the leader if the data is // the same or (b) erase itself from this block if the data does not // match. if (m_leader != NULL) { transfer->set_state(BlockTransfer::STATE_NOT_LEADER); return false; } else { m_leader = transfer; transfer->set_state(BlockTransfer::STATE_LEADER); return true; } } bool Block::completed(BlockTransfer* transfer) { if (!transfer->is_valid()) throw internal_error("Block::completed(...) transfer->block() == NULL."); if (!transfer->is_leader()) throw internal_error("Block::completed(...) transfer is not the leader."); // Special case where another ignored transfer finished before the // leader? // // Perhaps do magic to the transfer, erase it or something. if (!is_finished()) throw internal_error("Block::completed(...) !is_finished()."); if (transfer != m_leader) throw internal_error("Block::completed(...) transfer != m_leader."); m_parent->inc_finished(); if ((Block::size_type)std::count_if(m_parent->begin(), m_parent->end(), std::mem_fun_ref(&Block::is_finished)) < m_parent->finished()) throw internal_error("Block::completed(...) Finished blocks too large."); m_notStalled -= transfer->stall() == 0; transfer->set_block(NULL); transfer->set_stall(~uint32_t()); // Currently just throw out the queued transfers. In case the hash // check fails, we might consider telling pcb during the call to // Block::transfering(...). But that would propably not be correct // as we want to trigger cancel messages from here, as hash fail is // a rare occurrence. std::for_each(m_queued.begin(), m_queued.end(), std::bind1st(std::mem_fun(&Block::invalidate_transfer), this)); m_queued.clear(); // We need to invalidate those unfinished and keep the one that // finished for later reference. remove_non_leader_transfers(); if (m_transfers.empty() || m_transfers.back() != transfer) throw internal_error("Block::completed(...) m_transfers.empty() || m_transfers.back() != transfer."); return m_parent->is_all_finished(); } // Mark a non-leading transfer as having received dissimilar data to // the leader. It is then marked as erased so that we know its data // was not used, yet keep it in m_transfers so as not to cause a // re-download. void Block::transfer_dissimilar(BlockTransfer* transfer) { if (!transfer->is_not_leader() || m_leader == transfer) throw internal_error("Block::transfer_dissimilar(...) transfer is the leader."); m_notStalled -= transfer->stall() == 0; // Why not just delete? Gets done by completed(), though when // erasing the leader we need to remove dissimilar unless we have // another leader. transfer->set_state(BlockTransfer::STATE_ERASED); transfer->set_position(0); transfer->set_block(NULL); } void Block::stalled_transfer(BlockTransfer* transfer) { if (transfer->stall() == 0) { if (m_notStalled == 0) throw internal_error("Block::stalled(...) m_notStalled == 0."); m_notStalled--; // Do magic here. } transfer->set_stall(transfer->stall() + 1); } void Block::change_leader(BlockTransfer* transfer) { if (m_leader == transfer) throw internal_error("Block::change_leader(...) m_leader == transfer."); if (is_finished()) throw internal_error("Block::change_leader(...) is_finished()."); if (m_leader != NULL) m_leader->set_state(BlockTransfer::STATE_NOT_LEADER); m_leader = transfer; m_leader->set_state(BlockTransfer::STATE_LEADER); } void Block::failed_leader() { if (!is_finished()) throw internal_error("Block::failed_leader(...) !is_finished()."); m_leader = NULL; if (m_failedList != NULL) m_failedList->set_current(BlockFailed::invalid_index); } void Block::create_dummy(BlockTransfer* transfer, PeerInfo* peerInfo, const Piece& piece) { transfer->set_peer_info(peerInfo); if (peerInfo != NULL) peerInfo->set_transfer_counter(peerInfo->transfer_counter() + 1); transfer->set_block(NULL); transfer->set_piece(piece); transfer->set_state(BlockTransfer::STATE_ERASED); transfer->set_position(0); transfer->set_stall(0); transfer->set_failed_index(BlockTransfer::invalid_index); } void Block::release(BlockTransfer* transfer) { if (!transfer->is_valid()) { if (transfer->peer_info() != NULL) transfer->peer_info()->set_transfer_counter(transfer->peer_info()->transfer_counter() - 1); delete transfer; } else { transfer->block()->erase(transfer); } } void Block::invalidate_transfer(BlockTransfer* transfer) { if (transfer == m_leader) throw internal_error("Block::invalidate_transfer(...) transfer == m_leader."); // FIXME: Various other accounting like position and counters. if (!transfer->is_valid()) { if (transfer->peer_info() != NULL) transfer->peer_info()->set_transfer_counter(transfer->peer_info()->transfer_counter() - 1); delete transfer; } else { m_notStalled -= transfer->stall() == 0; transfer->set_block(NULL); // Do the canceling magic here. if (transfer->peer_info()->connection() != NULL) transfer->peer_info()->connection()->cancel_transfer(transfer); } } void Block::remove_erased_transfers() { transfer_list_type::iterator split = std::stable_partition(m_transfers.begin(), m_transfers.end(), std::not1(std::mem_fun(&BlockTransfer::is_erased))); std::for_each(split, m_transfers.end(), std::bind1st(std::mem_fun(&Block::invalidate_transfer), this)); m_transfers.erase(split, m_transfers.end()); } void Block::remove_non_leader_transfers() { transfer_list_type::iterator split = std::stable_partition(m_transfers.begin(), m_transfers.end(), std::mem_fun(&BlockTransfer::is_leader)); std::for_each(split, m_transfers.end(), std::bind1st(std::mem_fun(&Block::invalidate_transfer), this)); m_transfers.erase(split, m_transfers.end()); } BlockTransfer* Block::find_queued(const PeerInfo* p) { transfer_list_type::iterator itr = std::find_if(m_queued.begin(), m_queued.end(), rak::equal(p, std::mem_fun(&BlockTransfer::peer_info))); if (itr == m_queued.end()) return NULL; else return *itr; } const BlockTransfer* Block::find_queued(const PeerInfo* p) const { transfer_list_type::const_iterator itr = std::find_if(m_queued.begin(), m_queued.end(), rak::equal(p, std::mem_fun(&BlockTransfer::peer_info))); if (itr == m_queued.end()) return NULL; else return *itr; } BlockTransfer* Block::find_transfer(const PeerInfo* p) { transfer_list_type::iterator itr = std::find_if(m_transfers.begin(), m_transfers.end(), rak::equal(p, std::mem_fun(&BlockTransfer::peer_info))); if (itr == m_transfers.end()) return NULL; else return *itr; } const BlockTransfer* Block::find_transfer(const PeerInfo* p) const { transfer_list_type::const_iterator itr = std::find_if(m_transfers.begin(), m_transfers.end(), rak::equal(p, std::mem_fun(&BlockTransfer::peer_info))); if (itr == m_transfers.end()) return NULL; else return *itr; } } libtorrent-0.13.2/src/torrent/data/block.h000644 000765 000024 00000015320 11705767056 021400 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_BLOCK_H #define LIBTORRENT_BLOCK_H #include #include #include #include namespace torrent { // If you start adding slots, make sure the rest of the code creates // copies and clears the original variables before calls to erase etc. class LIBTORRENT_EXPORT Block { public: // Using vectors as they will remain small, thus the cost of erase // should be small. Later we can do faster erase by ignoring the // ordering. typedef std::vector transfer_list_type; typedef uint32_t size_type; Block() : m_notStalled(0), m_leader(NULL), m_failedList(NULL) { } ~Block(); bool is_stalled() const { return m_notStalled == 0; } bool is_finished() const { return m_leader != NULL && m_leader->is_finished(); } bool is_transfering() const { return m_leader != NULL && !m_leader->is_finished(); } bool is_peer_queued(const PeerInfo* p) const { return find_queued(p) != NULL; } bool is_peer_transfering(const PeerInfo* p) const { return find_transfer(p) != NULL; } size_type size_all() const { return m_queued.size() + m_transfers.size(); } size_type size_not_stalled() const { return m_notStalled; } BlockList* parent() { return m_parent; } const BlockList* parent() const { return m_parent; } void set_parent(BlockList* p) { m_parent = p; } const Piece& piece() const { return m_piece; } void set_piece(const Piece& p) { m_piece = p; } uint32_t index() const { return m_piece.index(); } const transfer_list_type* queued() const { return &m_queued; } const transfer_list_type* transfers() const { return &m_transfers; } // The leading transfer, whom's data we're currently using. BlockTransfer* leader() { return m_leader; } const BlockTransfer* leader() const { return m_leader; } BlockTransfer* find(const PeerInfo* p); const BlockTransfer* find(const PeerInfo* p) const; BlockTransfer* find_queued(const PeerInfo* p); const BlockTransfer* find_queued(const PeerInfo* p) const; BlockTransfer* find_transfer(const PeerInfo* p); const BlockTransfer* find_transfer(const PeerInfo* p) const; // Internal to libTorrent: BlockTransfer* insert(PeerInfo* peerInfo); void erase(BlockTransfer* transfer); bool transfering(BlockTransfer* transfer); // Return true if all blocks in the chunk are finished. bool completed(BlockTransfer* transfer); void transfer_dissimilar(BlockTransfer* transfer); static void stalled(BlockTransfer* transfer) { if (!transfer->is_valid()) return; transfer->block()->stalled_transfer(transfer); } void stalled_transfer(BlockTransfer* transfer); void change_leader(BlockTransfer* transfer); void failed_leader(); BlockFailed* failed_list() { return m_failedList; } void set_failed_list(BlockFailed* f) { m_failedList = f; } static void create_dummy(BlockTransfer* transfer, PeerInfo* peerInfo, const Piece& piece); // If the queued or transfering is already removed from the block it // will just delete the object. Made static so it can be called when // block == NULL. static void release(BlockTransfer* transfer); private: // Block(const Block&); // void operator = (const Block&); void invalidate_transfer(BlockTransfer* transfer) LIBTORRENT_NO_EXPORT; void remove_erased_transfers() LIBTORRENT_NO_EXPORT; void remove_non_leader_transfers() LIBTORRENT_NO_EXPORT; BlockList* m_parent; Piece m_piece; uint32_t m_notStalled; transfer_list_type m_queued; transfer_list_type m_transfers; BlockTransfer* m_leader; BlockFailed* m_failedList; }; inline BlockTransfer* Block::find(const PeerInfo* p) { BlockTransfer* transfer; if ((transfer = find_queued(p)) != NULL) return transfer; else return find_transfer(p); } inline const BlockTransfer* Block::find(const PeerInfo* p) const { const BlockTransfer* transfer; if ((transfer = find_queued(p)) != NULL) return transfer; else return find_transfer(p); } } #endif libtorrent-0.13.2/src/torrent/data/block_failed.h000644 000765 000024 00000007442 11705767056 022712 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_BLOCK_FAILED_H #define LIBTORRENT_BLOCK_FAILED_H #include #include #include #include namespace torrent { class BlockFailed : public std::vector > { public: typedef std::vector > base_type; using base_type::value_type; using base_type::reference; using base_type::size_type; using base_type::difference_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::size; using base_type::empty; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::operator[]; static const uint32_t invalid_index = ~uint32_t(); BlockFailed() : m_current(invalid_index) {} ~BlockFailed(); size_type current() const { return m_current; } iterator current_iterator() { return begin() + m_current; } reverse_iterator current_reverse_iterator() { return reverse_iterator(begin() + m_current + 1); } void set_current(size_type idx) { m_current = idx; } void set_current(iterator itr) { m_current = itr - begin(); } void set_current(reverse_iterator itr) { m_current = itr.base() - begin() - 1; } iterator max_element(); reverse_iterator reverse_max_element(); private: BlockFailed(const BlockFailed&); void operator = (const BlockFailed&); static void delete_entry(const reference e) { delete [] e.first; } static bool compare_entries(const reference e1, const reference e2) { return e1.second < e2.second; } size_type m_current; }; inline BlockFailed::~BlockFailed() { std::for_each(begin(), end(), std::ptr_fun(&BlockFailed::delete_entry)); } inline BlockFailed::iterator BlockFailed::max_element() { return std::max_element(begin(), end(), std::ptr_fun(&BlockFailed::compare_entries)); } inline BlockFailed::reverse_iterator BlockFailed::reverse_max_element() { return std::max_element(rbegin(), rend(), std::ptr_fun(&BlockFailed::compare_entries)); } } #endif libtorrent-0.13.2/src/torrent/data/block_list.cc000644 000765 000024 00000005305 11705767056 022573 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "block_transfer.h" #include "block_list.h" #include "exceptions.h" namespace torrent { BlockList::BlockList(const Piece& piece, uint32_t blockLength) : m_piece(piece), m_priority(PRIORITY_OFF), m_finished(0), m_failed(0), m_attempt(0), m_bySeeder(false) { if (piece.length() == 0) throw internal_error("BlockList::BlockList(...) received zero length piece."); // Look into optimizing this by using input iterators in the ctor. base_type::resize((m_piece.length() + blockLength - 1) / blockLength); // ATM assume offset of 0. // uint32_t offset = m_piece.offset(); uint32_t offset = 0; for (iterator itr = begin(), last = end() - 1; itr != last; ++itr, offset += blockLength) { itr->set_parent(this); itr->set_piece(Piece(m_piece.index(), offset, blockLength)); } base_type::back().set_parent(this); base_type::back().set_piece(Piece(m_piece.index(), offset, (m_piece.length() % blockLength) ? m_piece.length() % blockLength : blockLength)); } BlockList::~BlockList() { } } libtorrent-0.13.2/src/torrent/data/block_list.h000644 000765 000024 00000007667 11705767056 022452 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_BLOCK_LIST_H #define LIBTORRENT_BLOCK_LIST_H #include #include #include #include namespace torrent { class LIBTORRENT_EXPORT BlockList : public std::vector { public: typedef std::vector base_type; typedef uint32_t size_type; using base_type::value_type; using base_type::reference; using base_type::difference_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::size; using base_type::empty; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::operator[]; BlockList(const Piece& piece, uint32_t blockLength); ~BlockList(); bool is_all_finished() const { return m_finished == size(); } const Piece& piece() const { return m_piece; } uint32_t index() const { return m_piece.index(); } priority_t priority() const { return m_priority; } void set_priority(priority_t p) { m_priority = p; } size_type finished() const { return m_finished; } void inc_finished() { m_finished++; } void clear_finished() { m_finished = 0; } uint32_t failed() const { return m_failed; } // Temporary, just increment for now. void inc_failed() { m_failed++; } uint32_t attempt() const { return m_attempt; } void set_attempt(uint32_t a) { m_attempt = a; } // Set when the chunk was initially requested from a seeder. This // allows us to quickly determine if it is a suitable chunk to // request from another seeder, e.g by already knowing it is a rare // piece. bool by_seeder() const { return m_bySeeder; } void set_by_seeder(bool state) { m_bySeeder = state; } private: BlockList(const BlockList&); void operator = (const BlockList&); Piece m_piece; priority_t m_priority; size_type m_finished; uint32_t m_failed; uint32_t m_attempt; bool m_bySeeder; }; } #endif libtorrent-0.13.2/src/torrent/data/block_transfer.h000644 000765 000024 00000010436 11705767056 023307 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_BLOCK_TRANSFER_H #define LIBTORRENT_BLOCK_TRANSFER_H #include #include #include namespace torrent { class LIBTORRENT_EXPORT BlockTransfer { public: static const uint32_t invalid_index = ~uint32_t(); typedef PeerInfo* key_type; typedef enum { STATE_ERASED, STATE_QUEUED, STATE_LEADER, STATE_NOT_LEADER } state_type; BlockTransfer() {} bool is_valid() const { return m_block != NULL; } bool is_erased() const { return m_state == STATE_ERASED; } bool is_queued() const { return m_state == STATE_QUEUED; } bool is_leader() const { return m_state == STATE_LEADER; } bool is_not_leader() const { return m_state == STATE_NOT_LEADER; } bool is_finished() const { return m_position == m_piece.length(); } key_type peer_info() { return m_peerInfo; } const key_type const_peer_info() const { return m_peerInfo; } Block* block() { return m_block; } const Block* const_block() const { return m_block; } const Piece& piece() const { return m_piece; } uint32_t index() const { return m_piece.index(); } state_type state() const { return m_state; } // Adjust the position after any actions like erasing it from a // Block, but before if finishing. uint32_t position() const { return m_position; } uint32_t stall() const { return m_stall; } uint32_t failed_index() const { return m_failedIndex; } void set_peer_info(key_type p) { m_peerInfo = p; } void set_block(Block* b) { m_block = b; } void set_piece(const Piece& p) { m_piece = p; } void set_state(state_type s) { m_state = s; } void set_position(uint32_t p) { m_position = p; } void adjust_position(uint32_t p) { m_position += p; } void set_stall(uint32_t s) { m_stall = s; } void set_failed_index(uint32_t i) { m_failedIndex = i; } private: BlockTransfer(const BlockTransfer&); void operator = (const BlockTransfer&); key_type m_peerInfo; Block* m_block; Piece m_piece; state_type m_state; uint32_t m_position; uint32_t m_stall; uint32_t m_failedIndex; }; } #endif libtorrent-0.13.2/src/torrent/data/chunk_utils.cc000644 000765 000024 00000007100 11705767056 022771 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "chunk_utils.h" #include "download.h" #include "exceptions.h" #include "manager.h" #include "chunk_manager.h" #include "download/download_wrapper.h" #include "torrent/download/download_manager.h" #include "data/chunk.h" #include "data/chunk_list.h" namespace torrent { std::vector chunk_list_mapping(Download* download) { ChunkList* chunk_list = download->ptr()->main()->chunk_list(); std::vector mappings; for (ChunkList::const_iterator itr = chunk_list->begin(), last = chunk_list->end(); itr != last; itr++) { if (!itr->is_valid()) continue; for (Chunk::const_iterator itr2 = itr->chunk()->begin(), last2 = itr->chunk()->end(); itr2 != last2; itr2++) { if (itr2->mapped() != ChunkPart::MAPPED_MMAP) continue; vm_mapping val = { itr2->chunk().ptr(), itr2->chunk().size_aligned() }; mappings.push_back(val); } } return mappings; } chunk_info_result chunk_list_address_info(void* address) { ChunkManager::iterator first = manager->chunk_manager()->begin(); ChunkManager::iterator last = manager->chunk_manager()->begin(); while (first != last) { ChunkList::chunk_address_result result = (*first)->find_address(address); if (result.first != (*first)->end()) { DownloadManager::iterator d_itr = manager->download_manager()->find_chunk_list(*first); if (d_itr == manager->download_manager()->end()) return chunk_info_result(); chunk_info_result ci; ci.download = Download(*d_itr); ci.chunk_index = result.first->index(); ci.chunk_offset = result.second->position() + std::distance(result.second->chunk().begin(), (char*)address); ci.file_path = result.second->file()->frozen_path().c_str(); ci.file_offset = result.second->file_offset() + std::distance(result.second->chunk().begin(), (char*)address); return ci; } first++; } return chunk_info_result(); } } libtorrent-0.13.2/src/torrent/data/chunk_utils.h000644 000765 000024 00000004453 11705767056 022643 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_CHUNK_UTILS_H #define LIBTORRENT_CHUNK_UTILS_H #include #include #include namespace torrent { class ChunkList; struct vm_mapping { void* ptr; uint64_t length; }; // Change to ChunkList* when that becomes part of the public API. std::vector chunk_list_mapping(Download* download) LIBTORRENT_EXPORT; struct chunk_info_result { Download download; uint32_t chunk_index; uint32_t chunk_offset; const char* file_path; uint64_t file_offset; // void* chunk_begin; // void* chunk_end; // int prot; }; chunk_info_result chunk_list_address_info(void* address) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/data/download_data.cc000644 000765 000024 00000005600 11705767056 023244 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/exceptions.h" #include "download_data.h" namespace torrent { // Calculate the number of chunks remaining to be downloaded. // // Doing it the slow and safe way, optimize this at some point. uint32_t download_data::calc_wanted_chunks() const { if (m_completed_bitfield.is_all_set()) return 0; priority_ranges wanted_ranges = priority_ranges::create_union(m_normal_priority, m_high_priority); if (m_completed_bitfield.is_all_unset()) return wanted_ranges.intersect_distance(0, m_completed_bitfield.size_bits()); if (m_completed_bitfield.empty()) throw internal_error("download_data::update_wanted_chunks() m_completed_bitfield.empty()."); uint32_t result = 0; for (download_data::priority_ranges::const_iterator itr = wanted_ranges.begin(), last = wanted_ranges.end(); itr != last; itr++) { //remaining = completed->count_range(itr->first, itr->second); uint32_t idx = itr->first; while (idx != itr->second) result += !m_completed_bitfield.get(idx++); } return result; } void download_data::verify_wanted_chunks(const char* where) const { if (m_wanted_chunks != calc_wanted_chunks()) throw internal_error("Invalid download_data::wanted_chunks() value in " + std::string(where) + "."); } } libtorrent-0.13.2/src/torrent/data/download_data.h000644 000765 000024 00000011575 11720140327 023075 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_DOWNLOAD_DATA_H #define LIBTORRENT_DATA_DOWNLOAD_DATA_H #include #include #include #include #include namespace torrent { class ChunkSelector; class Download; class DownloadWrapper; class FileList; class download_data { public: typedef ranges priority_ranges; typedef void (function_void)(void); typedef std::tr1::function slot_void; download_data() : m_wanted_chunks(0) {} const HashString& hash() const { return m_hash; } bool is_partially_done() const { return m_wanted_chunks == 0; } bool is_not_partially_done() const { return m_wanted_chunks != 0; } const Bitfield* completed_bitfield() const { return &m_completed_bitfield; } const Bitfield* untouched_bitfield() const { return &m_untouched_bitfield; } const priority_ranges* high_priority() const { return &m_high_priority; } const priority_ranges* normal_priority() const { return &m_normal_priority; } uint32_t wanted_chunks() const { return m_wanted_chunks; } uint32_t calc_wanted_chunks() const; void verify_wanted_chunks(const char* where) const; slot_void& slot_initial_hash() const { return m_slot_initial_hash; } slot_void& slot_download_done() const { return m_slot_download_done; } slot_void& slot_partially_done() const { return m_slot_partially_done; } slot_void& slot_partially_restarted() const { return m_slot_partially_restarted; } protected: friend class ChunkList; friend class ChunkSelector; friend class Download; friend class DownloadWrapper; friend class FileList; HashString& mutable_hash() { return m_hash; } Bitfield* mutable_completed_bitfield() { return &m_completed_bitfield; } Bitfield* mutable_untouched_bitfield() { return &m_untouched_bitfield; } priority_ranges* mutable_high_priority() { return &m_high_priority; } priority_ranges* mutable_normal_priority() { return &m_normal_priority; } void update_wanted_chunks() { m_wanted_chunks = calc_wanted_chunks(); } void set_wanted_chunks(uint32_t n) { m_wanted_chunks = n; } void call_download_done() { if (m_slot_download_done) m_slot_download_done(); } void call_partially_done() { if (m_slot_partially_done) m_slot_partially_done(); } void call_partially_restarted() { if (m_slot_partially_restarted) m_slot_partially_restarted(); } private: HashString m_hash; Bitfield m_completed_bitfield; Bitfield m_untouched_bitfield; priority_ranges m_high_priority; priority_ranges m_normal_priority; uint32_t m_wanted_chunks; mutable slot_void m_slot_initial_hash; mutable slot_void m_slot_download_done; mutable slot_void m_slot_partially_done; mutable slot_void m_slot_partially_restarted; }; } #endif // LIBTORRENT_DATA_DOWNLOAD_DATA_H libtorrent-0.13.2/src/torrent/data/file.cc000644 000765 000024 00000011751 11705767056 021367 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "data/memory_chunk.h" #include "data/socket_file.h" #include "torrent/exceptions.h" #include "file.h" #include "file_manager.h" #include "globals.h" #include "manager.h" namespace torrent { File::File() : m_fd(-1), m_protection(0), m_flags(0), m_offset(0), m_size(0), m_lastTouched(cachedTime.usec()), m_completed(0), m_priority(PRIORITY_NORMAL), m_matchDepthPrev(0), m_matchDepthNext(0) { } File::~File() { if (is_open()) throw internal_error("File::~File() called on an open file."); } bool File::is_created() const { rak::file_stat fs; // If we can't even get permission to do fstat, we might as well // consider the file as not created. This function is to be used by // the client to check that the torrent files are present and ok, // rather than as a way to find out if it is starting on a blank // slate. if (!fs.update(frozen_path())) // return rak::error_number::current() == rak::error_number::e_access; return false; return fs.is_regular(); } bool File::is_correct_size() const { rak::file_stat fs; if (!fs.update(frozen_path())) return false; return fs.is_regular() && (uint64_t)fs.size() == m_size; } // At some point we should pass flags for deciding if the correct size // is necessary, etc. bool File::prepare(int prot, int flags) { m_lastTouched = cachedTime.usec(); // Check if we got write protection and flag_resize_queued is // set. If so don't quit as we need to try re-sizing, instead call // resize_file. if (is_open() && has_permissions(prot)) return true; // For now don't allow overridding this check in prepare. if (m_flags & flag_create_queued) flags |= SocketFile::o_create; else flags &= ~SocketFile::o_create; if (!manager->file_manager()->open(this, prot, flags)) return false; m_flags |= flag_previously_created; m_flags &= ~flag_create_queued; // Replace PROT_WRITE with something prettier. if ((m_flags & flag_resize_queued) && has_permissions(PROT_WRITE)) { m_flags &= ~flag_resize_queued; return resize_file(); } return true; } void File::set_range(uint32_t chunkSize) { if (chunkSize == 0) m_range = range_type(0, 0); else if (m_size == 0) m_range = File::range_type(m_offset / chunkSize, m_offset / chunkSize); else m_range = File::range_type(m_offset / chunkSize, (m_offset + m_size + chunkSize - 1) / chunkSize); } void File::set_match_depth(File* left, File* right) { uint32_t level = 0; Path::const_iterator itrLeft = left->path()->begin(); Path::const_iterator itrRight = right->path()->begin(); while (itrLeft != left->path()->end() && itrRight != right->path()->end() && *itrLeft == *itrRight) { itrLeft++; itrRight++; level++; } left->m_matchDepthNext = level; right->m_matchDepthPrev = level; } bool File::resize_file() { if (!is_open()) return false; // This doesn't try to re-open it as rw. if (m_size == SocketFile(m_fd).size()) return true; // For now make it so that the fallocate flag indicates if we want // to do potentially blocking allocation, while FS supported // non-blocking allocation is done always. int flags = SocketFile::flag_fallocate; if (m_flags & flag_fallocate) flags |= SocketFile::flag_fallocate_blocking; return SocketFile(m_fd).set_size(m_size, flags); } } libtorrent-0.13.2/src/torrent/data/file.h000644 000765 000024 00000016154 11705767056 021233 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_FILE_H #define LIBTORRENT_FILE_H #include #include namespace torrent { class LIBTORRENT_EXPORT File { public: friend class FileList; typedef std::pair range_type; static const int flag_active = (1 << 0); static const int flag_create_queued = (1 << 1); static const int flag_resize_queued = (1 << 2); static const int flag_fallocate = (1 << 3); static const int flag_previously_created = (1 << 4); static const int flag_prioritize_first = (1 << 5); static const int flag_prioritize_last = (1 << 6); File(); ~File(); bool is_created() const; bool is_open() const { return m_fd != -1; } bool is_correct_size() const; bool is_valid_position(uint64_t p) const; bool is_create_queued() const { return m_flags & flag_create_queued; } bool is_resize_queued() const { return m_flags & flag_resize_queued; } bool is_previously_created() const { return m_flags & flag_previously_created; } bool has_flags(int flags) { return m_flags & flags; } void set_flags(int flags); void unset_flags(int flags); bool has_permissions(int prot) const { return !(prot & ~m_protection); } uint64_t offset() const { return m_offset; } uint64_t size_bytes() const { return m_size; } uint32_t size_chunks() const { return m_range.second - m_range.first; } uint32_t completed_chunks() const { return m_completed; } void set_completed_chunks(uint32_t v); const range_type& range() const { return m_range; } uint32_t range_first() const { return m_range.first; } uint32_t range_second() const { return m_range.second; } priority_t priority() const { return m_priority; } void set_priority(priority_t t) { m_priority = t; } const Path* path() const { return &m_path; } Path* mutable_path() { return &m_path; } const std::string& frozen_path() const { return m_frozenPath; } uint32_t match_depth_prev() const { return m_matchDepthPrev; } uint32_t match_depth_next() const { return m_matchDepthNext; } // This should only be changed by libtorrent. int file_descriptor() const { return m_fd; } void set_file_descriptor(int fd) { m_fd = fd; } // This might actually be wanted, as it would be nice to allow the // File to decide if it needs to try creating the underlying file or // not. bool prepare(int prot, int flags = 0); int protection() const { return m_protection; } void set_protection(int prot) { m_protection = prot; } uint64_t last_touched() const { return m_lastTouched; } void set_last_touched(uint64_t t) { m_lastTouched = t; } protected: void set_flags_protected(int flags) { m_flags |= flags; } void unset_flags_protected(int flags) { m_flags &= ~flags; } void set_frozen_path(const std::string& path) { m_frozenPath = path; } void set_offset(uint64_t off) { m_offset = off; } void set_size_bytes(uint64_t size) { m_size = size; } void set_range(uint32_t chunkSize); void set_completed_protected(uint32_t v) { m_completed = v; } void inc_completed_protected() { m_completed++; } static void set_match_depth(File* left, File* right); void set_match_depth_prev(uint32_t l) { m_matchDepthPrev = l; } void set_match_depth_next(uint32_t l) { m_matchDepthNext = l; } private: File(const File&); void operator = (const File&); bool resize_file(); int m_fd; int m_protection; int m_flags; Path m_path; std::string m_frozenPath; uint64_t m_offset; uint64_t m_size; uint64_t m_lastTouched; range_type m_range; uint32_t m_completed; priority_t m_priority; uint32_t m_matchDepthPrev; uint32_t m_matchDepthNext; }; inline bool File::is_valid_position(uint64_t p) const { return p >= m_offset && p < m_offset + m_size; } inline void File::set_flags(int flags) { set_flags_protected(flags & (flag_create_queued | flag_resize_queued | flag_fallocate | flag_prioritize_first | flag_prioritize_last)); } inline void File::unset_flags(int flags) { unset_flags_protected(flags & (flag_create_queued | flag_resize_queued | flag_fallocate | flag_prioritize_first | flag_prioritize_last)); } inline void File::set_completed_chunks(uint32_t v) { if (!has_flags(flag_active) && v <= size_chunks()) m_completed = v; } } #endif libtorrent-0.13.2/src/torrent/data/file_list.cc000644 000765 000024 00000051665 11735056603 022422 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #define __STDC_FORMAT_MACROS #include #include #include #include #include #include #include #include #include #include #include "data/chunk.h" #include "data/memory_chunk.h" #include "data/socket_file.h" #include "torrent/exceptions.h" #include "torrent/path.h" #include "torrent/utils/log.h" #include "file.h" #include "file_list.h" #include "file_manager.h" #include "manager.h" #include "piece.h" #define LT_LOG_FL(log_level, log_fmt, ...) \ lt_log_print_data(LOG_STORAGE_##log_level, (&m_data), "file_list", log_fmt, __VA_ARGS__); namespace torrent { void verify_file_list(const FileList* fl) { if (fl->empty()) throw internal_error("verify_file_list() 1."); if ((*fl->begin())->match_depth_prev() != 0 || (*fl->rbegin())->match_depth_next() != 0) throw internal_error("verify_file_list() 2."); for (FileList::const_iterator itr = fl->begin(), last = fl->end() - 1; itr != last; itr++) if ((*itr)->match_depth_next() != (*(itr + 1))->match_depth_prev() || (*itr)->match_depth_next() >= (*itr)->path()->size()) throw internal_error("verify_file_list() 3."); } FileList::FileList() : m_isOpen(false), m_torrentSize(0), m_chunkSize(0), m_maxFileSize(~uint64_t()) { } FileList::~FileList() { // Can we skip close()? close(); std::for_each(begin(), end(), rak::call_delete()); base_type::clear(); m_torrentSize = 0; } bool FileList::is_valid_piece(const Piece& piece) const { return piece.index() < size_chunks() && piece.length() != 0 && // Make sure offset does not overflow 32 bits. piece.offset() + piece.length() >= piece.offset() && piece.offset() + piece.length() <= chunk_index_size(piece.index()); } bool FileList::is_root_dir_created() const { rak::file_stat fs; if (!fs.update(m_rootDir)) // return rak::error_number::current() == rak::error_number::e_access; return false; return fs.is_directory(); } bool FileList::is_multi_file() const { // Currently only check if we got just one file. In the future this // should be a bool, which will be set based on what flags are // passed when the torrent was loaded. return m_isMultiFile; } uint64_t FileList::completed_bytes() const { // Chunk size needs to be cast to a uint64_t for the below to work. uint64_t cs = chunk_size(); if (bitfield()->empty()) return bitfield()->is_all_set() ? size_bytes() : (completed_chunks() * cs); if (!bitfield()->get(size_chunks() - 1) || size_bytes() % cs == 0) { // The last chunk is not done, or the last chunk is the same size // as the others. return completed_chunks() * cs; } else { if (completed_chunks() == 0) throw internal_error("FileList::bytes_completed() completed_chunks() == 0."); return (completed_chunks() - 1) * cs + size_bytes() % cs; } } uint64_t FileList::left_bytes() const { uint64_t left = size_bytes() - completed_bytes(); if (left > ((uint64_t)1 << 60)) throw internal_error("FileList::bytes_left() is too large."); if (completed_chunks() == size_chunks() && left != 0) throw internal_error("FileList::bytes_left() has an invalid size."); return left; } uint32_t FileList::chunk_index_size(uint32_t index) const { if (index + 1 != size_chunks() || size_bytes() % chunk_size() == 0) return chunk_size(); else return size_bytes() % chunk_size(); } void FileList::set_root_dir(const std::string& path) { if (is_open()) throw input_error("Tried to change the root directory on an open download."); std::string::size_type last = path.find_last_not_of('/'); if (last == std::string::npos) m_rootDir = "."; else m_rootDir = path.substr(0, last + 1); } void FileList::set_max_file_size(uint64_t size) { if (is_open()) throw input_error("Tried to change the max file size for an open download."); m_maxFileSize = size; } // This function should really ensure that we arn't dealing files // spread over multiple mount-points. uint64_t FileList::free_diskspace() const { uint64_t freeDiskspace = std::numeric_limits::max(); for (path_list::const_iterator itr = m_indirectLinks.begin(), last = m_indirectLinks.end(); itr != last; ++itr) { rak::fs_stat stat; if (!stat.update(*itr)) continue; freeDiskspace = std::min(freeDiskspace, stat.bytes_avail()); } return freeDiskspace != std::numeric_limits::max() ? freeDiskspace : 0; } FileList::iterator_range FileList::split(iterator position, split_type* first, split_type* last) { if (is_open()) throw internal_error("FileList::split(...) is_open()."); if (first == last || position == end()) throw internal_error("FileList::split(...) invalid arguments."); if (position != begin()) (*(position - 1))->set_match_depth_next(0); if (position + 1 != end()) (*(position + 1))->set_match_depth_prev(0); File* oldFile = *position; uint64_t offset = oldFile->offset(); size_type index = std::distance(begin(), position); size_type length = std::distance(first, last); base_type::insert(position, length - 1, NULL); position = begin() + index; iterator itr = position; while (first != last) { File* newFile = new File(); newFile->set_offset(offset); newFile->set_size_bytes(first->first); newFile->set_range(m_chunkSize); *newFile->mutable_path() = first->second; offset += first->first; *itr = newFile; itr++; first++; } if (offset != oldFile->offset() + oldFile->size_bytes()) throw internal_error("FileList::split(...) split size does not match the old size."); delete oldFile; return iterator_range(position, itr); } FileList::iterator FileList::merge(iterator first, iterator last, const Path& path) { File* newFile = new File; // Set the path before deleting any iterators in case it refers to // one of the objects getting deleted. *newFile->mutable_path() = path; if (first == last) { if (first == end()) newFile->set_offset(m_torrentSize); else newFile->set_offset((*first)->offset()); first = base_type::insert(first, newFile); } else { newFile->set_offset((*first)->offset()); for (iterator itr = first; itr != last; ++itr) { newFile->set_size_bytes(newFile->size_bytes() + (*itr)->size_bytes()); delete *itr; } first = base_type::erase(first + 1, last) - 1; *first = newFile; } newFile->set_range(m_chunkSize); if (first == begin()) newFile->set_match_depth_prev(0); else File::set_match_depth(*(first - 1), newFile); if (first + 1 == end()) newFile->set_match_depth_next(0); else File::set_match_depth(newFile, *(first + 1)); return first; } // If the user supplies an invalid range, it will bork in weird ways. void FileList::update_paths(iterator first, iterator last) { // Check if we're open? if (first == last) return; if (first != begin()) File::set_match_depth(*(first - 1), *first); while (first != last && ++first != end()) File::set_match_depth(*(first - 1), *first); verify_file_list(this); } bool FileList::make_root_path() { if (!is_open()) return false; return ::mkdir(m_rootDir.c_str(), 0777) == 0 || errno == EEXIST; } bool FileList::make_all_paths() { if (!is_open()) return false; Path dummyPath; const Path* lastPath = &dummyPath; for (iterator itr = begin(), last = end(); itr != last; ++itr) { File* entry = *itr; // No need to create directories if the entry has already been // opened. if (entry->is_open()) continue; if (entry->path()->empty()) throw storage_error("Found an empty filename."); Path::const_iterator lastPathItr = lastPath->begin(); Path::const_iterator firstMismatch = entry->path()->begin(); // Couldn't find a suitable stl algo, need to write my own. while (firstMismatch != entry->path()->end() && lastPathItr != lastPath->end() && *firstMismatch == *lastPathItr) { lastPathItr++; firstMismatch++; } rak::error_number::clear_global(); make_directory(entry->path()->begin(), entry->path()->end(), firstMismatch); lastPath = entry->path(); } return true; } // Initialize FileList and add a dummy file that may be split into // multiple files. void FileList::initialize(uint64_t torrentSize, uint32_t chunkSize) { if (sizeof(off_t) != 8) throw internal_error("Last minute panic; sizeof(off_t) != 8."); if (chunkSize == 0) throw internal_error("FileList::initialize() chunk_size() == 0."); m_chunkSize = chunkSize; m_torrentSize = torrentSize; m_rootDir = "."; m_data.mutable_completed_bitfield()->set_size_bits((size_bytes() + chunk_size() - 1) / chunk_size()); m_data.mutable_normal_priority()->insert(0, size_chunks()); m_data.set_wanted_chunks(size_chunks()); File* newFile = new File(); newFile->set_offset(0); newFile->set_size_bytes(torrentSize); newFile->set_range(m_chunkSize); base_type::push_back(newFile); } struct file_list_cstr_less { bool operator () (const char* c1, const char* c2) const { return std::strcmp(c1, c2) < 0; } }; void FileList::open(int flags) { typedef std::set path_set; LT_LOG_FL(INFO, "Opening.", 0); if (m_rootDir.empty()) throw internal_error("FileList::open() m_rootDir.empty()."); m_indirectLinks.push_back(m_rootDir); Path lastPath; path_set pathSet; iterator itr = end(); try { if (!(flags & open_no_create) && !make_root_path()) throw storage_error("Could not create directory '" + m_rootDir + "': " + std::strerror(errno)); for (itr = begin(); itr != end(); ++itr) { File* entry = *itr; // We no longer consider it an error to open a previously opened // FileList as we now use the same function to create // non-existent files. // // Since m_isOpen is set, we know root dir wasn't changed, thus // we can keep the previously opened file. if (entry->is_open()) continue; // Update the path during open so that any changes to root dir // and file paths are properly handled. if (entry->path()->back().empty()) entry->set_frozen_path(std::string()); else entry->set_frozen_path(m_rootDir + entry->path()->as_string()); if (!pathSet.insert(entry->frozen_path().c_str()).second) throw storage_error("Duplicate filename found."); if (entry->size_bytes() > m_maxFileSize) throw storage_error("File exceedes the configured max file size."); if (entry->path()->empty()) throw storage_error("Empty filename is not allowed."); // Handle directory creation outside of open_file, so we can do // it here if necessary. entry->set_flags_protected(File::flag_active); if (!open_file(&*entry, lastPath, flags)) { // This needs to check if the error was due to open_no_create // being set or not. if (!(flags & open_no_create)) // Also check if open_require_all_open is set. throw storage_error("Could not open file: " + std::string(rak::error_number::current().c_str())); // Don't set the lastPath as we haven't created the directory. continue; } lastPath = *entry->path(); } } catch (local_error& e) { for (iterator itr2 = begin(), last = end(); itr2 != last; ++itr2) { (*itr2)->unset_flags_protected(File::flag_active); manager->file_manager()->close(*itr2); } if (itr == end()) { LT_LOG_FL(ERROR, "Failed to prepare file list: %s", e.what()); } else { LT_LOG_FL(ERROR, "Failed to prepare file '%s': %s", (*itr)->path()->as_string().c_str(), e.what()); } // Set to false here in case we tried to open the FileList for the // second time. m_isOpen = false; throw; } m_isOpen = true; m_frozenRootDir = m_rootDir; // For meta-downloads, if the file exists, we have to assume that // it is either 0 or 1 length or the correct size. If the size // turns out wrong later, a storage_error will be thrown elsewhere // to alert the user in this (unlikely) case. // // DEBUG: Make this depend on a flag... if (size_bytes() < 2) { rak::file_stat stat; // This probably recurses into open() once, but that is harmless. if (stat.update((*begin())->frozen_path()) && stat.size() > 1) return reset_filesize(stat.size()); } } void FileList::close() { if (!is_open()) return; LT_LOG_FL(INFO, "Closing.", 0); for (iterator itr = begin(), last = end(); itr != last; ++itr) { (*itr)->unset_flags_protected(File::flag_active); manager->file_manager()->close(*itr); } m_isOpen = false; m_indirectLinks.clear(); m_data.mutable_completed_bitfield()->unallocate(); } void FileList::make_directory(Path::const_iterator pathBegin, Path::const_iterator pathEnd, Path::const_iterator startItr) { std::string path = m_rootDir; while (pathBegin != pathEnd) { path += "/" + *pathBegin; if (pathBegin++ != startItr) continue; startItr++; rak::file_stat fileStat; if (fileStat.update_link(path) && fileStat.is_link() && std::find(m_indirectLinks.begin(), m_indirectLinks.end(), path) == m_indirectLinks.end()) m_indirectLinks.push_back(path); if (pathBegin == pathEnd) break; if (::mkdir(path.c_str(), 0777) != 0 && errno != EEXIST) throw storage_error("Could not create directory '" + path + "': " + std::strerror(errno)); } } bool FileList::open_file(File* node, const Path& lastPath, int flags) { rak::error_number::clear_global(); if (!(flags & open_no_create)) { const Path* path = node->path(); Path::const_iterator lastItr = lastPath.begin(); Path::const_iterator firstMismatch = path->begin(); // Couldn't find a suitable stl algo, need to write my own. while (firstMismatch != path->end() && lastItr != lastPath.end() && *firstMismatch == *lastItr) { lastItr++; firstMismatch++; } make_directory(path->begin(), path->end(), firstMismatch); } // Some torrents indicate an empty directory by having a path with // an empty last element. This entry must be zero length. if (node->path()->back().empty()) return node->size_bytes() == 0; rak::file_stat fileStat; if (fileStat.update(node->frozen_path()) && !fileStat.is_regular() && !fileStat.is_link()) { // Might also bork on other kinds of file types, but there's no // suitable errno for all cases. rak::error_number::set_global(rak::error_number::e_isdir); return false; } return node->prepare(MemoryChunk::prot_read, 0); } MemoryChunk FileList::create_chunk_part(FileList::iterator itr, uint64_t offset, uint32_t length, int prot) { offset -= (*itr)->offset(); length = std::min(length, (*itr)->size_bytes() - offset); if ((int64_t)offset < 0) throw internal_error("FileList::chunk_part(...) caught a negative offset"); // Check that offset != length of file. if (!(*itr)->prepare(prot)) return MemoryChunk(); return SocketFile((*itr)->file_descriptor()).create_chunk(offset, length, prot, MemoryChunk::map_shared); } Chunk* FileList::create_chunk(uint64_t offset, uint32_t length, int prot) { if (offset + length > m_torrentSize) throw internal_error("Tried to access chunk out of range in FileList"); std::auto_ptr chunk(new Chunk); for (iterator itr = std::find_if(begin(), end(), std::bind2nd(std::mem_fun(&File::is_valid_position), offset)); length != 0; ++itr) { if (itr == end()) throw internal_error("FileList could not find a valid file for chunk"); if ((*itr)->size_bytes() == 0) continue; MemoryChunk mc = create_chunk_part(itr, offset, length, prot); if (!mc.is_valid()) return NULL; if (mc.size() == 0) throw internal_error("FileList::create_chunk(...) mc.size() == 0."); if (mc.size() > length) throw internal_error("FileList::create_chunk(...) mc.size() > length."); chunk->push_back(ChunkPart::MAPPED_MMAP, mc); chunk->back().set_file(*itr, offset - (*itr)->offset()); offset += mc.size(); length -= mc.size(); } if (chunk->empty()) return NULL; return chunk.release(); } Chunk* FileList::create_chunk_index(uint32_t index, int prot) { return create_chunk((uint64_t)index * chunk_size(), chunk_index_size(index), prot); } void FileList::mark_completed(uint32_t index) { if (index >= size_chunks() || completed_chunks() >= size_chunks()) throw internal_error("FileList::mark_completed(...) received an invalid index."); if (bitfield()->empty()) throw internal_error("FileList::mark_completed(...) bitfield is empty."); if (bitfield()->size_bits() != size_chunks()) throw internal_error("FileList::mark_completed(...) bitfield is not the right size."); if (bitfield()->get(index)) throw internal_error("FileList::mark_completed(...) received a chunk that has already been finished."); if (bitfield()->size_set() >= bitfield()->size_bits()) throw internal_error("FileList::mark_completed(...) bitfield()->size_set() >= bitfield()->size_bits()."); LT_LOG_FL(DEBUG, "Done chunk: index:%" PRIu32 ".", index); m_data.mutable_completed_bitfield()->set(index); inc_completed(begin(), index); // TODO: Remember to validate 'wanted_chunks'. if (m_data.normal_priority()->has(index) || m_data.high_priority()->has(index)) { if (m_data.wanted_chunks() == 0) throw internal_error("FileList::mark_completed(...) m_data.wanted_chunks() == 0."); m_data.set_wanted_chunks(m_data.wanted_chunks() - 1); } } FileList::iterator FileList::inc_completed(iterator firstItr, uint32_t index) { firstItr = std::find_if(firstItr, end(), rak::less(index, std::mem_fun(&File::range_second))); iterator lastItr = std::find_if(firstItr, end(), rak::less(index + 1, std::mem_fun(&File::range_second))); if (firstItr == end()) throw internal_error("FileList::inc_completed() first == m_entryList->end()."); // TODO: Check if this works right for zero-length files. std::for_each(firstItr, lastItr == end() ? end() : (lastItr + 1), std::mem_fun(&File::inc_completed_protected)); return lastItr; } void FileList::update_completed() { if (!bitfield()->is_tail_cleared()) throw internal_error("Content::update_done() called but m_bitfield's tail isn't cleared."); m_data.update_wanted_chunks(); if (bitfield()->is_all_set()) { for (iterator itr = begin(), last = end(); itr != last; ++itr) (*itr)->set_completed_protected((*itr)->size_chunks()); } else { // Clear any old progress data from the entries as we don't clear // this on close, etc. for (iterator itr = begin(), last = end(); itr != last; ++itr) (*itr)->set_completed_protected(0); if (bitfield()->is_all_unset()) return; iterator entryItr = begin(); for (Bitfield::size_type index = 0; index < bitfield()->size_bits(); ++index) if (bitfield()->get(index)) entryItr = inc_completed(entryItr, index); } } void FileList::reset_filesize(int64_t size) { LT_LOG_FL(INFO, "Resetting torrent size: size:%" PRIi64 ".", size); close(); m_chunkSize = size; m_torrentSize = size; (*begin())->set_size_bytes(size); (*begin())->set_range(m_chunkSize); m_data.mutable_completed_bitfield()->allocate(); m_data.mutable_completed_bitfield()->unset_all(); open(open_no_create); } } libtorrent-0.13.2/src/torrent/data/file_list.h000644 000765 000024 00000020405 11705767056 022260 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_FILE_LIST_H #define LIBTORRENT_FILE_LIST_H #include #include #include #include #include #include #include namespace torrent { class Content; class Download; class DownloadConstructor; class DownloadMain; class DownloadWrapper; class Handshake; class LIBTORRENT_EXPORT FileList : private std::vector { public: friend class Content; friend class Download; friend class DownloadConstructor; friend class DownloadMain; friend class DownloadWrapper; friend class Handshake; typedef std::vector base_type; typedef std::vector path_list; typedef std::pair split_type; // The below are using-directives that make visible functions and // typedefs in the parent std::vector, only those listed below are // accessible. If you don't understand how this works, use google, // don't ask me. using base_type::value_type; using base_type::iterator; using base_type::const_iterator; using base_type::reverse_iterator; using base_type::const_reverse_iterator; typedef std::pair iterator_range; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::front; using base_type::back; using base_type::empty; using base_type::reserve; using base_type::at; using base_type::operator[]; FileList() LIBTORRENT_NO_EXPORT; ~FileList() LIBTORRENT_NO_EXPORT; bool is_open() const { return m_isOpen; } bool is_done() const { return completed_chunks() == size_chunks(); } bool is_valid_piece(const Piece& piece) const; bool is_root_dir_created() const; // Check if the torrent is loaded as a multi-file torrent. This may // return true even for a torrent with just one file. bool is_multi_file() const; void set_multi_file(bool state) { m_isMultiFile = state; } size_t size_files() const { return base_type::size(); } uint64_t size_bytes() const { return m_torrentSize; } uint32_t size_chunks() const { return bitfield()->size_bits(); } uint32_t completed_chunks() const { return bitfield()->size_set(); } uint64_t completed_bytes() const; uint64_t left_bytes() const; uint32_t chunk_size() const { return m_chunkSize; } uint32_t chunk_index_size(uint32_t index) const; uint64_t chunk_index_position(uint32_t index) const { return index * chunk_size(); } const download_data* data() const { return &m_data; } const Bitfield* bitfield() const { return m_data.completed_bitfield(); } // You may only call set_root_dir after all nodes have been added. const std::string& root_dir() const { return m_rootDir; } const std::string& frozen_root_dir() const { return m_frozenRootDir; } void set_root_dir(const std::string& path); uint64_t max_file_size() const { return m_maxFileSize; } void set_max_file_size(uint64_t size); // If the files span multiple disks, the one with the least amount // of free diskspace will be returned. uint64_t free_diskspace() const; // List of directories in the torrent that might be on different // volumes as they are links, including the root directory. Used by // 'free_diskspace()'. const path_list* indirect_links() const { return &m_indirectLinks; } // The sum of the sizes in the range [first,last> must be equal to // the size of 'position'. Do not use the old pointer in 'position' // after this call. iterator_range split(iterator position, split_type* first, split_type* last); // Use an empty range to insert a zero length file. iterator merge(iterator first, iterator last, const Path& path); iterator merge(iterator_range range, const Path& path) { return merge(range.first, range.second, path); } void update_paths(iterator first, iterator last); bool make_root_path(); bool make_all_paths(); protected: static const int open_no_create = (1 << 0); static const int open_require_all_open = (1 << 1); void initialize(uint64_t torrentSize, uint32_t chunkSize) LIBTORRENT_NO_EXPORT; void open(int flags) LIBTORRENT_NO_EXPORT; void close() LIBTORRENT_NO_EXPORT; download_data* mutable_data() { return &m_data; } // Before calling this function, make sure you clear errno. If // creating the chunk failed, NULL is returned and errno is set. Chunk* create_chunk(uint64_t offset, uint32_t length, int prot) LIBTORRENT_NO_EXPORT; Chunk* create_chunk_index(uint32_t index, int prot) LIBTORRENT_NO_EXPORT; void mark_completed(uint32_t index) LIBTORRENT_NO_EXPORT; iterator inc_completed(iterator firstItr, uint32_t index) LIBTORRENT_NO_EXPORT; void update_completed() LIBTORRENT_NO_EXPORT; // Used for meta downloads; we only know the // size after the first extension handshake. void reset_filesize(int64_t) LIBTORRENT_NO_EXPORT; private: bool open_file(File* node, const Path& lastPath, int flags) LIBTORRENT_NO_EXPORT; void make_directory(Path::const_iterator pathBegin, Path::const_iterator pathEnd, Path::const_iterator startItr) LIBTORRENT_NO_EXPORT; MemoryChunk create_chunk_part(FileList::iterator itr, uint64_t offset, uint32_t length, int prot) LIBTORRENT_NO_EXPORT; download_data m_data; bool m_isOpen; uint64_t m_torrentSize; uint32_t m_chunkSize; uint64_t m_maxFileSize; std::string m_rootDir; path_list m_indirectLinks; // Reorder next minor version bump: bool m_isMultiFile; std::string m_frozenRootDir; }; inline FileList::iterator file_list_contains_position(FileList* file_list, uint64_t pos) { return std::find_if(file_list->begin(), file_list->end(), std::bind2nd(std::mem_fun(&File::is_valid_position), pos)); } } #endif libtorrent-0.13.2/src/torrent/data/file_list_iterator.cc000644 000765 000024 00000010342 11705767056 024326 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/exceptions.h" #include "file.h" #include "file_list_iterator.h" namespace torrent { bool FileListIterator::is_file() const { return m_depth >= 0 && m_depth + 1 == (int32_t)(*m_position)->path()->size(); } bool FileListIterator::is_empty() const { return (*m_position)->path()->size() == 0; } bool FileListIterator::is_entering() const { return m_depth >= 0 && m_depth + 1 != (int32_t)(*m_position)->path()->size(); } FileListIterator& FileListIterator::operator ++() { int32_t size = (*m_position)->path()->size(); if (size == 0) { m_position++; return *this; } m_depth++; if (m_depth > size) throw internal_error("FileListIterator::operator ++() m_depth > size."); if (m_depth == size) m_depth = -(size - 1); if (m_depth == -(int32_t)(*m_position)->match_depth_next()) { m_depth = (*m_position)->match_depth_next(); m_position++; } return *this; } FileListIterator& FileListIterator::operator --() { // We're guaranteed that if m_depth != 0 then so is the path size, // so there's no need to check for it. if (m_depth == 0) { m_position--; // This ensures we properly start iterating the paths in a tree // without failing badly when size == 0. if ((*m_position)->path()->size() > 1) m_depth = -1; } else if (m_depth == (int32_t)(*m_position)->match_depth_prev()) { m_position--; // If only the last element differs, then we don't switch to // negative depth. Also make sure we skip the negative of the // current depth, as we index by the depth we're exiting from. if (m_depth + 1 != (int32_t)(*m_position)->path()->size()) m_depth = -(m_depth + 1); } else { int32_t size = (int32_t)(*m_position)->path()->size(); m_depth--; if (m_depth < -size) throw internal_error("FileListIterator::operator --() m_depth < -size."); if (m_depth == -size) m_depth = size - 1; } return *this; } FileListIterator& FileListIterator::forward_current_depth() { uint32_t baseDepth = depth(); if (!is_entering()) return ++(*this); // If the above test was false then we know there must be a // 'leaving' at baseDepth before the end of the list. do { ++(*this); } while (depth() > baseDepth); return *this; } FileListIterator& FileListIterator::backward_current_depth() { --(*this); if (is_entering() || is_file() || is_empty()) return *this; if (depth() == 0) throw internal_error("FileListIterator::backward_current_depth() depth() == 0."); uint32_t baseDepth = depth(); while (depth() >= baseDepth) --(*this); return *this; } } libtorrent-0.13.2/src/torrent/data/file_list_iterator.h000644 000765 000024 00000013452 11705767056 024175 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_FILE_LIST_ITERATOR_H #define LIBTORRENT_FILE_LIST_ITERATOR_H #include #include #include namespace torrent { class File; // A special purpose iterator class for iterating through FileList as // a dired structure. class LIBTORRENT_EXPORT FileListIterator { public: typedef FileList::iterator iterator; typedef File* reference; typedef File** pointer; FileListIterator() {} explicit FileListIterator(iterator pos, uint32_t depth = 0) : m_position(pos), m_depth(depth) {} bool is_file() const; bool is_empty() const; bool is_entering() const; bool is_leaving() const { return m_depth < 0; } uint32_t depth() const { return std::abs(m_depth); } iterator base() const { return m_position; } reference file() const { return *m_position; } reference operator *() const { return *m_position; } pointer operator ->() const { return &*m_position; } FileListIterator& operator ++(); FileListIterator& operator --(); FileListIterator operator ++(int); FileListIterator operator --(int); FileListIterator& forward_current_depth(); FileListIterator& backward_current_depth(); friend bool operator ==(const FileListIterator& left, const FileListIterator& right); friend bool operator !=(const FileListIterator& left, const FileListIterator& right); private: iterator m_position; int32_t m_depth; }; inline FileListIterator FileListIterator::operator ++(int) { FileListIterator tmp = *this; ++(*this); return tmp; } inline FileListIterator FileListIterator::operator --(int) { FileListIterator tmp = *this; --(*this); return tmp; } inline bool operator ==(const FileListIterator& left, const FileListIterator& right) { return left.m_position == right.m_position && left.m_depth == right.m_depth; } inline bool operator !=(const FileListIterator& left, const FileListIterator& right) { return left.m_position != right.m_position || left.m_depth != right.m_depth; } // Take a range as input and return the next entry at the same // directory depth as first. If the returned iterator equals 'last' or // is_leaving() == true then the search failed. class LIBTORRENT_EXPORT file_list_collapsed_iterator : private FileListIterator { public: typedef FileListIterator base_type; typedef file_list_collapsed_iterator this_type; using base_type::iterator; using base_type::reference; using base_type::pointer; using base_type::is_file; using base_type::is_empty; using base_type::is_entering; using base_type::is_leaving; using base_type::depth; using base_type::file; file_list_collapsed_iterator() {} file_list_collapsed_iterator(const FileListIterator& src) : FileListIterator(src) {} explicit file_list_collapsed_iterator(iterator pos, uint32_t depth = 0) : FileListIterator(pos, depth) {} base_type base() const { return *static_cast(this); } this_type& operator ++() { base_type::forward_current_depth(); return *this; } this_type& operator --() { base_type::backward_current_depth(); return *this; } this_type operator ++(int); this_type operator --(int); friend bool operator ==(const file_list_collapsed_iterator& left, const file_list_collapsed_iterator& right); friend bool operator !=(const file_list_collapsed_iterator& left, const file_list_collapsed_iterator& right); }; inline bool operator ==(const file_list_collapsed_iterator& left, const file_list_collapsed_iterator& right) { return left.base() == right.base(); } inline bool operator !=(const file_list_collapsed_iterator& left, const file_list_collapsed_iterator& right) { return left.base() != right.base(); } inline file_list_collapsed_iterator file_list_collapsed_iterator::operator ++(int) { this_type tmp = *this; ++(*this); return tmp; } inline file_list_collapsed_iterator file_list_collapsed_iterator::operator --(int) { this_type tmp = *this; --(*this); return tmp; } } #endif libtorrent-0.13.2/src/torrent/data/file_manager.cc000644 000765 000024 00000007276 11705767056 023070 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "data/socket_file.h" #include "torrent/exceptions.h" #include "file.h" #include "file_manager.h" #include "manager.h" namespace torrent { FileManager::FileManager() : m_maxOpenFiles(0), m_filesOpenedCounter(0), m_filesClosedCounter(0), m_filesFailedCounter(0) {} FileManager::~FileManager() { if (!empty()) throw internal_error("FileManager::~FileManager() called but empty() != true."); } void FileManager::set_max_open_files(size_type s) { if (s < 4 || s > (1 << 16)) throw input_error("Max open files must be between 4 and 2^16."); m_maxOpenFiles = s; while (size() > m_maxOpenFiles) close_least_active(); } bool FileManager::open(value_type file, int prot, int flags) { if (file->is_open()) close(file); if (size() > m_maxOpenFiles) throw internal_error("FileManager::open_file(...) m_openSize > m_maxOpenFiles."); if (size() == m_maxOpenFiles) close_least_active(); SocketFile fd; if (!fd.open(file->frozen_path(), prot, flags)) { m_filesFailedCounter++; return false; } file->set_protection(prot); file->set_file_descriptor(fd.fd()); base_type::push_back(file); // Consider storing the position of the file here. m_filesOpenedCounter++; return true; } void FileManager::close(value_type file) { if (!file->is_open()) return; SocketFile(file->file_descriptor()).close(); file->set_protection(0); file->set_file_descriptor(-1); iterator itr = std::find(begin(), end(), file); if (itr == end()) throw internal_error("FileManager::close_file(...) itr == end()."); *itr = back(); base_type::pop_back(); m_filesClosedCounter++; } struct FileManagerActivity { FileManagerActivity() : m_last(rak::timer::max().usec()), m_file(NULL) {} void operator ()(File* f) { if (f->is_open() && f->last_touched() <= m_last) { m_last = f->last_touched(); m_file = f; } } uint64_t m_last; File* m_file; }; void FileManager::close_least_active() { close(std::for_each(begin(), end(), FileManagerActivity()).m_file); } } libtorrent-0.13.2/src/torrent/data/file_manager.h000644 000765 000024 00000006140 11705767056 022717 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_FILE_MANAGER_H #define LIBTORRENT_DATA_FILE_MANAGER_H #include #include namespace torrent { class File; class LIBTORRENT_EXPORT FileManager : private std::vector { public: typedef std::vector base_type; typedef uint32_t size_type; using base_type::value_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; FileManager(); ~FileManager(); size_type open_files() const { return base_type::size(); } size_type max_open_files() const { return m_maxOpenFiles; } void set_max_open_files(size_type s); bool open(value_type file, int prot, int flags); void close(value_type file); void close_least_active(); // Statistics: uint64_t files_opened_counter() const { return m_filesOpenedCounter; } uint64_t files_closed_counter() const { return m_filesClosedCounter; } uint64_t files_failed_counter() const { return m_filesFailedCounter; } private: FileManager(const FileManager&) LIBTORRENT_NO_EXPORT; void operator = (const FileManager&) LIBTORRENT_NO_EXPORT; size_type m_maxOpenFiles; uint64_t m_filesOpenedCounter; uint64_t m_filesClosedCounter; uint64_t m_filesFailedCounter; }; } #endif libtorrent-0.13.2/src/torrent/data/file_utils.cc000644 000765 000024 00000007107 11705767056 022607 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "exceptions.h" #include "file.h" #include "file_utils.h" namespace torrent { FileList::iterator file_split(FileList* fileList, FileList::iterator position, uint64_t maxSize, const std::string& suffix) { const Path* srcPath = (*position)->path(); uint64_t splitSize = ((*position)->size_bytes() + maxSize - 1) / maxSize; if (srcPath->empty() || (*position)->size_bytes() == 0) throw input_error("Tried to split a file with an empty path or zero length file."); if (splitSize > 1000) throw input_error("Tried to split a file into more than 1000 parts."); // Also replace dwnlctor's vector. FileList::split_type* splitList = new FileList::split_type[splitSize]; FileList::split_type* splitItr = splitList; unsigned int nameSize = srcPath->back().size() + suffix.size(); char name[nameSize + 4]; std::memcpy(name, srcPath->back().c_str(), srcPath->back().size()); std::memcpy(name + srcPath->back().size(), suffix.c_str(), suffix.size()); for (unsigned int i = 0; i != splitSize; ++i, ++splitItr) { if (i == splitSize - 1 && (*position)->size_bytes() % maxSize != 0) splitItr->first = (*position)->size_bytes() % maxSize; else splitItr->first = maxSize; name[nameSize + 0] = '0' + (i / 100) % 10; name[nameSize + 1] = '0' + (i / 10) % 10; name[nameSize + 2] = '0' + (i / 1) % 10; name[nameSize + 3] = '\0'; splitItr->second = *srcPath; splitItr->second.back() = name; } return fileList->split(position, splitList, splitItr).second; } void file_split_all(FileList* fileList, uint64_t maxSize, const std::string& suffix) { if (maxSize == 0) throw input_error("Tried to split torrent files into zero sized chunks."); FileList::iterator itr = fileList->begin(); while (itr != fileList->end()) if ((*itr)->size_bytes() > maxSize && !(*itr)->path()->empty()) itr = file_split(fileList, itr, maxSize, suffix); else itr++; } } libtorrent-0.13.2/src/torrent/data/file_utils.h000644 000765 000024 00000004163 11705767056 022450 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_FILE_UTILS_H #define LIBTORRENT_FILE_UTILS_H #include #include namespace torrent { // Split 'position' into 'maxSize' sized files and return the iterator // after the last new entry. FileList::iterator file_split(FileList* fileList, FileList::iterator position, uint64_t maxSize, const std::string& suffix) LIBTORRENT_EXPORT; void file_split_all(FileList* fileList, uint64_t maxSize, const std::string& suffix) LIBTORRENT_EXPORT; } #endif libtorrent-0.13.2/src/torrent/data/Makefile.am000644 000765 000024 00000001455 11705767056 022175 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_torrentdata.la libsub_torrentdata_la_SOURCES = \ block.cc \ block.h \ block_failed.h \ block_list.cc \ block_list.h \ block_transfer.h \ chunk_utils.cc \ chunk_utils.h \ download_data.cc \ download_data.h \ file.cc \ file.h \ file_list.cc \ file_list.h \ file_list_iterator.cc \ file_list_iterator.h \ file_manager.cc \ file_manager.h \ file_utils.cc \ file_utils.h \ piece.h \ transfer_list.cc \ transfer_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/data libtorrentinclude_HEADERS = \ block.h \ block_list.h \ block_transfer.h \ chunk_utils.h \ download_data.h \ file.h \ file_list.h \ file_list_iterator.h \ file_manager.h \ file_utils.h \ piece.h \ transfer_list.h libtorrent-0.13.2/src/torrent/data/Makefile.in000644 000765 000024 00000046766 11744204216 022207 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/torrent/data DIST_COMMON = $(libtorrentinclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_torrentdata_la_LIBADD = am_libsub_torrentdata_la_OBJECTS = block.lo block_list.lo \ chunk_utils.lo download_data.lo file.lo file_list.lo \ file_list_iterator.lo file_manager.lo file_utils.lo \ transfer_list.lo libsub_torrentdata_la_OBJECTS = $(am_libsub_torrentdata_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_torrentdata_la_SOURCES) DIST_SOURCES = $(libsub_torrentdata_la_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libtorrentincludedir)" HEADERS = $(libtorrentinclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_torrentdata.la libsub_torrentdata_la_SOURCES = \ block.cc \ block.h \ block_failed.h \ block_list.cc \ block_list.h \ block_transfer.h \ chunk_utils.cc \ chunk_utils.h \ download_data.cc \ download_data.h \ file.cc \ file.h \ file_list.cc \ file_list.h \ file_list_iterator.cc \ file_list_iterator.h \ file_manager.cc \ file_manager.h \ file_utils.cc \ file_utils.h \ piece.h \ transfer_list.cc \ transfer_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir) libtorrentincludedir = $(includedir)/torrent/data libtorrentinclude_HEADERS = \ block.h \ block_list.h \ block_transfer.h \ chunk_utils.h \ download_data.h \ file.h \ file_list.h \ file_list_iterator.h \ file_manager.h \ file_utils.h \ piece.h \ transfer_list.h all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/torrent/data/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/torrent/data/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_torrentdata.la: $(libsub_torrentdata_la_OBJECTS) $(libsub_torrentdata_la_DEPENDENCIES) $(EXTRA_libsub_torrentdata_la_DEPENDENCIES) $(CXXLINK) $(libsub_torrentdata_la_OBJECTS) $(libsub_torrentdata_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/block.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/block_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk_utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_data.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_list_iterator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transfer_list.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-libtorrentincludeHEADERS: $(libtorrentinclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(libtorrentincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libtorrentincludedir)" @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtorrentincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(libtorrentincludedir)" || exit $$?; \ done uninstall-libtorrentincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(libtorrentinclude_HEADERS)'; test -n "$(libtorrentincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libtorrentincludedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libtorrentincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-libtorrentincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libtorrentincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libtorrentincludeHEADERS install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libtorrentincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/torrent/data/piece.h000644 000765 000024 00000005561 11705767056 021401 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PIECE_H #define LIBTORRENT_PIECE_H #include namespace torrent { class LIBTORRENT_EXPORT Piece { public: static const uint32_t invalid_index = ~uint32_t(); Piece() : m_index(invalid_index), m_offset(0), m_length(0) {} Piece(uint32_t index, uint32_t offset, uint32_t length) : m_index(index), m_offset(offset), m_length(length) {} bool is_valid() const { return m_index != invalid_index; } uint32_t index() const { return m_index; } void set_index(uint32_t v) { m_index = v; } uint32_t offset() const { return m_offset; } void set_offset(uint32_t v) { m_offset = v; } uint32_t length() const { return m_length; } void set_length(uint32_t v) { m_length = v; } bool operator == (const Piece& p) const { return m_index == p.m_index && m_offset == p.m_offset && m_length == p.m_length; } bool operator != (const Piece& p) const { return m_index != p.m_index || m_offset != p.m_offset || m_length != p.m_length; } private: uint32_t m_index; uint32_t m_offset; uint32_t m_length; }; } #endif libtorrent-0.13.2/src/torrent/data/transfer_list.cc000644 000765 000024 00000024602 11705767056 023326 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include "data/chunk.h" #include "peer/peer_info.h" #include "block_failed.h" #include "block_transfer.h" #include "block_list.h" #include "exceptions.h" #include "piece.h" #include "transfer_list.h" namespace torrent { TransferList::TransferList() : m_slotCanceled(slot_canceled_type(slot_canceled_op(NULL), NULL)), m_slotCompleted(slot_completed_type(slot_completed_op(NULL), NULL)), m_slotQueued(slot_queued_type(slot_queued_op(NULL), NULL)), m_slotCorrupt(slot_corrupt_type(slot_corrupt_op(NULL), NULL)), m_succeededCount(0), m_failedCount(0) { } TransferList::iterator TransferList::find(uint32_t index) { return std::find_if(begin(), end(), rak::equal(index, std::mem_fun(&BlockList::index))); } TransferList::const_iterator TransferList::find(uint32_t index) const { return std::find_if(begin(), end(), rak::equal(index, std::mem_fun(&BlockList::index))); } void TransferList::clear() { std::for_each(begin(), end(), rak::on(std::mem_fun(&BlockList::index), m_slotCanceled)); std::for_each(begin(), end(), rak::call_delete()); base_type::clear(); } TransferList::iterator TransferList::insert(const Piece& piece, uint32_t blockSize) { if (find(piece.index()) != end()) throw internal_error("Delegator::new_chunk(...) received an index that is already delegated."); BlockList* blockList = new BlockList(piece, blockSize); m_slotQueued(piece.index()); return base_type::insert(end(), blockList); } TransferList::iterator TransferList::erase(iterator itr) { if (itr == end()) throw internal_error("TransferList::erase(...) itr == m_chunks.end()."); delete *itr; return base_type::erase(itr); } void TransferList::finished(BlockTransfer* transfer) { if (!transfer->is_valid()) throw internal_error("TransferList::finished(...) got transfer with wrong state."); uint32_t index = transfer->block()->index(); // Marks the transfer as complete and erases it. if (transfer->block()->completed(transfer)) m_slotCompleted(index); } void TransferList::hash_succeeded(uint32_t index, Chunk* chunk) { iterator blockListItr = find(index); if ((Block::size_type)std::count_if((*blockListItr)->begin(), (*blockListItr)->end(), std::mem_fun_ref(&Block::is_finished)) != (*blockListItr)->size()) throw internal_error("TransferList::hash_succeeded(...) Finished blocks does not match size."); // The chunk should also be marked here or by the caller so that it // gets priority for syncing back to disk. if ((*blockListItr)->failed() != 0) mark_failed_peers(*blockListItr, chunk); // Add to a list of finished chunks indices with timestamps. This is // mainly used for torrent resume data on which chunks need to be // rehashed on crashes. // // We assume the chunk gets sync'ed within 10 minutes, so minimum // retention time of 30 minutes should be enough. The list only gets // pruned every 60 minutes, so any timer that reads values once // every 30 minutes is guaranteed to get them all as long as it is // ordered properly. m_completedList.push_back(std::make_pair(rak::timer::current().usec(), index)); if (rak::timer(m_completedList.front().first) + rak::timer::from_minutes(60) < rak::timer::current()) { completed_list_type::iterator itr = std::find_if(m_completedList.begin(), m_completedList.end(), rak::less_equal(rak::timer::current() - rak::timer::from_minutes(30), rak::mem_ref(&completed_list_type::value_type::first))); m_completedList.erase(m_completedList.begin(), itr); } m_succeededCount++; erase(blockListItr); } struct transfer_list_compare_data { transfer_list_compare_data(Chunk* chunk, const Piece& p) : m_chunk(chunk), m_piece(p) { } bool operator () (const BlockFailed::reference failed) { return m_chunk->compare_buffer(failed.first, m_piece.offset(), m_piece.length()); } Chunk* m_chunk; Piece m_piece; }; void TransferList::hash_failed(uint32_t index, Chunk* chunk) { iterator blockListItr = find(index); if (blockListItr == end()) throw internal_error("TransferList::hash_failed(...) Could not find index."); if ((Block::size_type)std::count_if((*blockListItr)->begin(), (*blockListItr)->end(), std::mem_fun_ref(&Block::is_finished)) != (*blockListItr)->size()) throw internal_error("TransferList::hash_failed(...) Finished blocks does not match size."); m_failedCount++; // Could propably also check promoted against size of the block // list. if ((*blockListItr)->attempt() == 0) { unsigned int promoted = update_failed(*blockListItr, chunk); if (promoted > 0 || promoted < (*blockListItr)->size()) { // Retry with the most popular blocks. (*blockListItr)->set_attempt(1); retry_most_popular(*blockListItr, chunk); // Also consider various other schemes, like using blocks from // only/mainly one peer. return; } } // Should we check if there's any peers whom have sent us bad data // before, and just clear those first? // Re-download the blocks. (*blockListItr)->clear_finished(); (*blockListItr)->set_attempt(0); // Clear leaders when we want to redownload the chunk. std::for_each((*blockListItr)->begin(), (*blockListItr)->end(), std::mem_fun_ref(&Block::failed_leader)); } // update_failed(...) either increments the reference count of a // failed entry, or creates a new one if the data differs. unsigned int TransferList::update_failed(BlockList* blockList, Chunk* chunk) { unsigned int promoted = 0; blockList->inc_failed(); for (BlockList::iterator itr = blockList->begin(), last = blockList->end(); itr != last; ++itr) { if (itr->failed_list() == NULL) itr->set_failed_list(new BlockFailed()); BlockFailed::iterator failedItr = std::find_if(itr->failed_list()->begin(), itr->failed_list()->end(), transfer_list_compare_data(chunk, itr->piece())); if (failedItr == itr->failed_list()->end()) { // We've never encountered this data before, make a new entry. char* buffer = new char[itr->piece().length()]; chunk->to_buffer(buffer, itr->piece().offset(), itr->piece().length()); itr->failed_list()->push_back(BlockFailed::value_type(buffer, 1)); failedItr = itr->failed_list()->end() - 1; // Count how many new data sets? } else { // Increment promoted when the entry's reference count becomes // larger than others, but not if it previously was the largest. BlockFailed::iterator maxItr = itr->failed_list()->max_element(); if (maxItr->second == failedItr->second && maxItr != (itr->failed_list()->reverse_max_element().base() - 1)) promoted++; failedItr->second++; } itr->failed_list()->set_current(failedItr); itr->leader()->set_failed_index(failedItr - itr->failed_list()->begin()); } return promoted; } void TransferList::mark_failed_peers(BlockList* blockList, Chunk* chunk) { std::set badPeers; for (BlockList::iterator itr = blockList->begin(), last = blockList->end(); itr != last; ++itr) { // This chunk data is good, set it as current and // everyone who sent something else is a bad peer. itr->failed_list()->set_current(std::find_if(itr->failed_list()->begin(), itr->failed_list()->end(), transfer_list_compare_data(chunk, itr->piece()))); for (Block::transfer_list_type::const_iterator itr2 = itr->transfers()->begin(), last2 = itr->transfers()->end(); itr2 != last2; ++itr2) if ((*itr2)->failed_index() != itr->failed_list()->current() && (*itr2)->failed_index() != ~uint32_t()) badPeers.insert((*itr2)->peer_info()); } std::for_each(badPeers.begin(), badPeers.end(), m_slotCorrupt); } // Copy the stored data to the chunk from the failed entries with // largest reference counts. void TransferList::retry_most_popular(BlockList* blockList, Chunk* chunk) { for (BlockList::iterator itr = blockList->begin(), last = blockList->end(); itr != last; ++itr) { BlockFailed::reverse_iterator failedItr = itr->failed_list()->reverse_max_element(); if (failedItr == itr->failed_list()->rend()) throw internal_error("TransferList::retry_most_popular(...) No failed list entry found."); // The data is the same, so no need to copy. if (failedItr == itr->failed_list()->current_reverse_iterator()) continue; // Change the leader to the currently held buffer? chunk->from_buffer(failedItr->first, itr->piece().offset(), itr->piece().length()); itr->failed_list()->set_current(failedItr); } m_slotCompleted(blockList->index()); } } libtorrent-0.13.2/src/torrent/data/transfer_list.h000644 000765 000024 00000011102 11705767056 023157 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_TRANSFER_LIST_H #define LIBTORRENT_TRANSFER_LIST_H #include #include #include namespace torrent { class TransferList : public std::vector { public: typedef std::vector base_type; typedef std::vector > completed_list_type; using base_type::value_type; using base_type::reference; using base_type::difference_type; using base_type::iterator; using base_type::const_iterator; using base_type::reverse_iterator; using base_type::const_reverse_iterator; using base_type::size; using base_type::empty; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; TransferList(); iterator find(uint32_t index); const_iterator find(uint32_t index) const; const completed_list_type& completed_list() const { return m_completedList; } uint32_t succeeded_count() const { return m_succeededCount; } uint32_t failed_count() const { return m_failedCount; } // // Internal to libTorrent: // void clear(); iterator insert(const Piece& piece, uint32_t blockSize); iterator erase(iterator itr); void finished(BlockTransfer* transfer); void hash_succeeded(uint32_t index, Chunk* chunk); void hash_failed(uint32_t index, Chunk* chunk); typedef std::mem_fun1_t slot_canceled_op; typedef std::binder1st slot_canceled_type; typedef std::mem_fun1_t slot_completed_op; typedef std::binder1st slot_completed_type; typedef std::mem_fun1_t slot_queued_op; typedef std::binder1st slot_queued_type; typedef std::mem_fun1_t slot_corrupt_op; typedef std::binder1st slot_corrupt_type; void slot_canceled(slot_canceled_type s) { m_slotCanceled = s; } void slot_completed(slot_completed_type s) { m_slotCompleted = s; } void slot_queued(slot_queued_type s) { m_slotQueued = s; } void slot_corrupt(slot_corrupt_type s) { m_slotCorrupt = s; } private: TransferList(const TransferList&); void operator = (const TransferList&); unsigned int update_failed(BlockList* blockList, Chunk* chunk); void mark_failed_peers(BlockList* blockList, Chunk* chunk); void retry_most_popular(BlockList* blockList, Chunk* chunk); slot_canceled_type m_slotCanceled; slot_completed_type m_slotCompleted; slot_queued_type m_slotQueued; slot_corrupt_type m_slotCorrupt; completed_list_type m_completedList; uint32_t m_succeededCount; uint32_t m_failedCount; }; } #endif libtorrent-0.13.2/src/protocol/encryption_info.h000644 000765 000024 00000006170 11705767056 022751 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_ENCRYPTION_H #define LIBTORRENT_PROTOCOL_ENCRYPTION_H #include "utils/rc4.h" namespace torrent { class EncryptionInfo { public: EncryptionInfo() : m_encrypted(false), m_obfuscated(false), m_decryptValid(false) {}; void encrypt(const void *indata, void *outdata, unsigned int length) { m_encrypt.crypt(indata, outdata, length); } void encrypt(void *data, unsigned int length) { m_encrypt.crypt(data, length); } void decrypt(const void *indata, void *outdata, unsigned int length) { m_decrypt.crypt(indata, outdata, length); } void decrypt(void *data, unsigned int length) { m_decrypt.crypt(data, length); } bool is_encrypted() const { return m_encrypted; } bool is_obfuscated() const { return m_obfuscated; } bool decrypt_valid() const { return m_decryptValid; } void set_obfuscated() { m_obfuscated = true; m_encrypted = m_decryptValid = false; } void set_encrypt(const RC4& encrypt) { m_encrypt = encrypt; m_encrypted = m_obfuscated = true; } void set_decrypt(const RC4& decrypt) { m_decrypt = decrypt; m_decryptValid = true; } private: bool m_encrypted; bool m_obfuscated; bool m_decryptValid; RC4 m_encrypt; RC4 m_decrypt; }; } #endif libtorrent-0.13.2/src/protocol/extensions.cc000644 000765 000024 00000031052 11716350717 022070 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "download/available_list.h" #include "download/download_main.h" #include "download/download_wrapper.h" #include "protocol/peer_connection_base.h" #include "torrent/connection_manager.h" #include "torrent/object_stream.h" #include "torrent/download/download_manager.h" #include "torrent/peer/connection_list.h" #include "torrent/peer/peer_info.h" #include "manager.h" #include "extensions.h" namespace torrent { template <> const ExtHandshakeMessage::key_list_type ExtHandshakeMessage::keys = { { key_e, "e" }, { key_m_utMetadata, "m::ut_metadata" }, { key_m_utPex, "m::ut_pex" }, { key_metadataSize, "metadata_size" }, { key_p, "p" }, { key_reqq, "reqq" }, { key_v, "v" }, }; template <> const ExtPEXMessage::key_list_type ExtPEXMessage::keys = { { key_pex_added, "added*S" }, }; // DEBUG: Add type info. template <> const ExtMetadataMessage::key_list_type ExtMetadataMessage::keys = { { key_msgType, "msg_type" }, { key_piece, "piece" }, { key_totalSize, "total_size" }, }; struct message_type { const char* key; ext_handshake_keys index; }; const message_type message_keys[] = { { "HANDSHAKE", key_handshake_LAST }, { "ut_pex", key_m_utPex }, { "metadata_size", key_m_utMetadata } }; void ProtocolExtension::cleanup() { // if (is_default()) // return; for (int t = HANDSHAKE + 1; t < FIRST_INVALID; t++) if (is_local_enabled(t)) unset_local_enabled(t); } void ProtocolExtension::set_local_enabled(int t) { if (is_local_enabled(t)) return; m_flags |= flag_local_enabled_base << t; switch (t) { case UT_PEX: m_download->info()->set_size_pex(m_download->info()->size_pex() + 1); break; default: break; } } void ProtocolExtension::unset_local_enabled(int t) { if (!is_local_enabled(t)) return; m_flags &= ~(flag_local_enabled_base << t); switch (t) { case UT_PEX: m_download->info()->set_size_pex(m_download->info()->size_pex() - 1); break; default: break; } } DataBuffer ProtocolExtension::generate_handshake_message() { ExtHandshakeMessage message; // Add "e" key if encryption is enabled, set it to 1 if we require // encryption for incoming connections, or 0 otherwise. if ((manager->connection_manager()->encryption_options() & ConnectionManager::encryption_allow_incoming) != 0) message[key_e] = (manager->connection_manager()->encryption_options() & ConnectionManager::encryption_require) != 0; message[key_p] = manager->connection_manager()->listen_port(); message[key_v] = raw_string::from_c_str("libTorrent " VERSION); message[key_reqq] = 2048; // maximum request queue size if (!m_download->info()->is_meta_download()) message[key_metadataSize] = m_download->info()->metadata_size(); message[key_m_utPex] = is_local_enabled(UT_PEX) ? UT_PEX : 0; message[key_m_utMetadata] = UT_METADATA; char buffer[1024]; object_buffer_t result = static_map_write_bencode_c(object_write_to_buffer, NULL, std::make_pair(buffer, buffer + sizeof(buffer)), message); int length = result.second - buffer; char* copy = new char[length]; memcpy(copy, buffer, length); return DataBuffer(copy, copy + length); } inline DataBuffer ProtocolExtension::build_bencode(size_t maxLength, const char* format, ...) { char* b = new char[maxLength]; va_list args; va_start(args, format); unsigned int length = vsnprintf(b, maxLength, format, args); va_end(args); if (length > maxLength) throw internal_error("ProtocolExtension::build_bencode wrote past buffer."); return DataBuffer(b, b + length); } DataBuffer ProtocolExtension::generate_toggle_message(MessageType t, bool on) { // TODO: Check if we're accepting this message type? // Manually create bencoded map { "m" => { message_keys[t] => on ? t : 0 } } return build_bencode(32, "d1:md%zu:%si%deee", strlen(message_keys[t].key), message_keys[t].key, on ? t : 0); } DataBuffer ProtocolExtension::generate_ut_pex_message(const PEXList& added, const PEXList& removed) { if (added.empty() && removed.empty()) return DataBuffer(); int added_len = added.size() * 6; int removed_len = removed.size() * 6; // Manually create bencoded map { "added" => added, "dropped" => dropped } char* buffer = new char[32 + added_len + removed_len]; char* end = buffer; end += sprintf(end, "d5:added%d:", added_len); memcpy(end, added.begin()->c_str(), added_len); end += added_len; end += sprintf(end, "7:dropped%d:", removed_len); memcpy(end, removed.begin()->c_str(), removed_len); end += removed_len; *end++ = 'e'; if (end - buffer > 32 + added_len + removed_len) throw internal_error("ProtocolExtension::ut_pex_message wrote beyond buffer."); return DataBuffer(buffer, end); } void ProtocolExtension::read_start(int type, uint32_t length, bool skip) { if (is_default() || (type >= FIRST_INVALID) || length > (1 << 15)) throw communication_error("Received invalid extension message."); if (m_read != NULL || (int32_t)length < 0) throw internal_error("ProtocolExtension::read_start called in inconsistent state."); m_readLeft = length; if (skip || !is_local_enabled(type)) { m_readType = SKIP_EXTENSION; } else { m_readType = type; } // Allocate the buffer even for SKIP_EXTENSION, just to make things // simpler. m_readPos = m_read = new char[length]; } bool ProtocolExtension::read_done() { bool result = true; try { switch(m_readType) { case SKIP_EXTENSION: break; case HANDSHAKE: result = parse_handshake(); break; case UT_PEX: result = parse_ut_pex(); break; case UT_METADATA: result = parse_ut_metadata(); break; default: throw internal_error("ProtocolExtension::read_done called with invalid extension type."); } } catch (bencode_error& e) { // Ignore malformed messages. // DEBUG: // throw internal_error("ProtocolExtension::read_done '" + std::string(m_read, std::distance(m_read, m_readPos)) + "'"); } delete [] m_read; m_read = NULL; m_readType = FIRST_INVALID; m_flags |= flag_received_ext; return result; } // Called whenever peer enables or disables an extension. void ProtocolExtension::peer_toggle_remote(int type, bool active) { if (type == UT_PEX) { // When ut_pex is enabled, the first peer exchange afterwards needs // to be a full message, not delta. if (active) m_flags |= flag_initial_pex; } } bool ProtocolExtension::parse_handshake() { ExtHandshakeMessage message; static_map_read_bencode(m_read, m_readPos, message); for (int t = HANDSHAKE + 1; t < FIRST_INVALID; t++) { if (!message[message_keys[t].index].is_value()) continue; uint8_t id = message[message_keys[t].index].as_value(); set_remote_supported(t); if (id != m_idMap[t - 1]) { peer_toggle_remote(t, id != 0); m_idMap[t - 1] = id; } } // If this is the first handshake, then disable any local extensions // not supported by remote. if (is_initial_handshake()) { for (int t = HANDSHAKE + 1; t < FIRST_INVALID; t++) if (!is_remote_supported(t)) unset_local_enabled(t); } if (message[key_p].is_value()) { uint16_t port = message[key_p].as_value(); if (port > 0) m_peerInfo->set_listen_port(port); } if (message[key_reqq].is_value()) m_maxQueueLength = message[key_reqq].as_value(); if (message[key_metadataSize].is_value()) m_download->set_metadata_size(message[key_metadataSize].as_value()); m_flags &= ~flag_initial_handshake; return true; } bool ProtocolExtension::parse_ut_pex() { // Ignore message if we're still in the handshake (no connection // yet), or no peers are present. ExtPEXMessage message; static_map_read_bencode(m_read, m_readPos, message); // TODO: Check if pex is enabled? if (!message[key_pex_added].is_raw_string()) return true; raw_string peers = message[key_pex_added].as_raw_string(); if (peers.empty()) return true; // TODO: Sort the list before adding it. AddressList l; l.parse_address_compact(peers); l.sort(); l.erase(std::unique(l.begin(), l.end()), l.end()); m_download->peer_list()->insert_available(&l); return true; } bool ProtocolExtension::parse_ut_metadata() { ExtMetadataMessage message; // Piece data comes after bencoded extension message. const char* dataStart = static_map_read_bencode(m_read, m_readPos, message); switch(message[key_msgType].as_value()) { case 0: // Can't process new request while still having data to send. if (has_pending_message()) return false; send_metadata_piece(message[key_piece].as_value()); break; case 1: if (m_connection == NULL) break; m_connection->receive_metadata_piece(message[key_piece].as_value(), dataStart, m_readPos - dataStart); break; case 2: if (m_connection == NULL) break; m_connection->receive_metadata_piece(message[key_piece].as_value(), NULL, 0); break; }; return true; } void ProtocolExtension::send_metadata_piece(size_t piece) { // Reject out-of-range piece, or if we don't have the complete metadata yet. size_t metadataSize = m_download->info()->metadata_size(); size_t pieceEnd = (metadataSize + metadata_piece_size - 1) >> metadata_piece_shift; if (m_download->info()->is_meta_download() || piece >= pieceEnd) { // reject: { "msg_type" => 2, "piece" => ... } m_pendingType = UT_METADATA; m_pending = build_bencode(40, "d8:msg_typei2e5:piecei%zuee", piece); return; } // These messages will be rare, so we'll just build the // metadata here instead of caching it uselessly. char* buffer = new char[metadataSize]; object_write_bencode_c(object_write_to_buffer, NULL, object_buffer_t(buffer, buffer + metadataSize), &(*manager->download_manager()->find(m_download->info()))->bencode()->get_key("info")); // data: { "msg_type" => 1, "piece" => ..., "total_size" => ... } followed by piece data (outside of dictionary) size_t length = piece == pieceEnd - 1 ? m_download->info()->metadata_size() % metadata_piece_size : metadata_piece_size; m_pendingType = UT_METADATA; m_pending = build_bencode(length + 128, "d8:msg_typei1e5:piecei%zue10:total_sizei%zuee", piece, metadataSize); memcpy(m_pending.end(), buffer + (piece << metadata_piece_shift), length); m_pending.set(m_pending.data(), m_pending.end() + length, m_pending.owned()); delete [] buffer; } bool ProtocolExtension::request_metadata_piece(const Piece* p) { if (p->offset() % metadata_piece_size) throw internal_error("ProtocolExtension::request_metadata_piece got misaligned piece offset."); if (has_pending_message()) return false; m_pendingType = UT_METADATA; m_pending = build_bencode(40, "d8:msg_typei0e5:piecei%uee", (unsigned)(p->offset() >> metadata_piece_shift)); return true; } } libtorrent-0.13.2/src/protocol/extensions.h000644 000765 000024 00000020707 11705767056 021745 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_EXTENSIONS_H #define LIBTORRENT_PROTOCOL_EXTENSIONS_H #include #include #include "torrent/exceptions.h" #include "torrent/object.h" #include "torrent/object_static_map.h" #include "torrent/download_info.h" #include "net/address_list.h" #include "net/data_buffer.h" // Not really important, so no need to make this a configure check. #ifdef __GNUC__ #define ATTRIBUTE_PRINTF(num) __attribute__ ((format (printf, num, num+1))) #else #define ATTRIBUTE_PRINTF(num) #endif namespace torrent { class ProtocolExtension { public: typedef enum { HANDSHAKE = 0, UT_PEX, UT_METADATA, FIRST_INVALID, // first invalid message ID SKIP_EXTENSION, } MessageType; typedef std::vector PEXList; static const int flag_default = 1<<0; static const int flag_initial_handshake = 1<<1; static const int flag_initial_pex = 1<<2; static const int flag_received_ext = 1<<3; // The base bit to shift by MessageType to check if the extension is // enabled locally or supported by the peer. static const int flag_local_enabled_base = 1<<8; static const int flag_remote_supported_base = 1<<16; // Number of extensions we support, not counting handshake. static const int extension_count = FIRST_INVALID - HANDSHAKE - 1; // Fixed size of a metadata piece (16 KB). static const size_t metadata_piece_shift = 14; static const size_t metadata_piece_size = 1 << metadata_piece_shift; ProtocolExtension(); ~ProtocolExtension() { delete [] m_read; } void cleanup(); // Create default extension object, with all extensions disabled. // Useful for eliminating checks whether peer supports extensions at all. static ProtocolExtension make_default(); void set_info(PeerInfo* peerInfo, DownloadMain* download) { m_peerInfo = peerInfo; m_download = download; } void set_connection(PeerConnectionBase* c) { m_connection = c; } DataBuffer generate_handshake_message(); static DataBuffer generate_toggle_message(MessageType t, bool on); static DataBuffer generate_ut_pex_message(const PEXList& added, const PEXList& removed); // Return peer's extension ID for the given extension type, or 0 if // disabled by peer. uint8_t id(int t) const; bool is_local_enabled(int t) const { return m_flags & flag_local_enabled_base << t; } bool is_remote_supported(int t) const { return m_flags & flag_remote_supported_base << t; } void set_local_enabled(int t); void unset_local_enabled(int t); void set_remote_supported(int t) { m_flags |= flag_remote_supported_base << t; } // General information about peer from extension handshake. uint32_t max_queue_length() const { return m_maxQueueLength; } // Handle reading extension data from peer. void read_start(int type, uint32_t length, bool skip); bool read_done(); char* read_position() { return m_readPos; } bool read_move(uint32_t v) { m_readPos += v; return (m_readLeft -= v) == 0; } uint32_t read_need() const { return m_readLeft; } bool is_complete() const { return m_readLeft == 0; } bool is_invalid() const { return m_readType == FIRST_INVALID; } bool is_default() const { return m_flags & flag_default; } // Initial PEX message after peer enables PEX needs to send full list // of peers instead of the delta list, so keep track of that. bool is_initial_handshake() const { return m_flags & flag_initial_handshake; } bool is_initial_pex() const { return m_flags & flag_initial_pex; } bool is_received_ext() const { return m_flags & flag_received_ext; } void clear_initial_pex() { m_flags &= ~flag_initial_pex; } void reset() { std::memset(&m_idMap, 0, sizeof(m_idMap)); } bool request_metadata_piece(const Piece* p); // To handle cases where the extension protocol needs to send a reply. bool has_pending_message() const { return m_pendingType != HANDSHAKE; } MessageType pending_message_type() const { return m_pendingType; } DataBuffer pending_message_data() { return m_pending.release(); } void clear_pending_message() { if (m_pending.empty()) m_pendingType = HANDSHAKE; } private: bool parse_handshake(); bool parse_ut_pex(); bool parse_ut_metadata(); static DataBuffer build_bencode(size_t maxLength, const char* format, ...) ATTRIBUTE_PRINTF(2); void peer_toggle_remote(int type, bool active); void send_metadata_piece(size_t piece); // Map of IDs peer uses for each extension message type, excluding // HANDSHAKE. uint8_t m_idMap[extension_count]; uint32_t m_maxQueueLength; int m_flags; PeerInfo* m_peerInfo; DownloadMain* m_download; PeerConnectionBase* m_connection; uint8_t m_readType; uint32_t m_readLeft; char* m_read; char* m_readPos; MessageType m_pendingType; DataBuffer m_pending; }; // // // enum ext_handshake_keys { key_e, key_m_utMetadata, key_m_utPex, key_metadataSize, key_p, key_reqq, key_v, key_handshake_LAST }; enum ext_pex_keys { key_pex_added, key_pex_LAST }; enum ext_metadata_keys { key_msgType, key_piece, key_totalSize, key_metadata_LAST }; typedef static_map_type ExtHandshakeMessage; typedef static_map_type ExtPEXMessage; typedef static_map_type ExtMetadataMessage; // // // inline ProtocolExtension::ProtocolExtension() : // Set HANDSHAKE as enabled and supported. Those bits should not be // touched. m_flags(flag_local_enabled_base | flag_remote_supported_base | flag_initial_handshake), m_peerInfo(NULL), m_download(NULL), m_connection(NULL), m_readType(FIRST_INVALID), m_read(NULL), m_pendingType(HANDSHAKE) { reset(); set_local_enabled(UT_METADATA); } inline ProtocolExtension ProtocolExtension::make_default() { ProtocolExtension extension; extension.m_flags |= flag_default; return extension; } inline uint8_t ProtocolExtension::id(int t) const { if (t == HANDSHAKE) return 0; if (t - 1 >= extension_count) throw internal_error("ProtocolExtension::id message type out of range."); return m_idMap[t - 1]; } } #endif libtorrent-0.13.2/src/protocol/handshake.cc000644 000765 000024 00000115007 11716350717 021622 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "download/download_main.h" #include "net/throttle_list.h" #include "torrent/dht_manager.h" #include "torrent/download_info.h" #include "torrent/exceptions.h" #include "torrent/error.h" #include "torrent/poll.h" #include "torrent/throttle.h" #include "utils/diffie_hellman.h" #include "globals.h" #include "manager.h" #include "extensions.h" #include "handshake.h" #include "handshake_manager.h" namespace torrent { const char* Handshake::m_protocol = "BitTorrent protocol"; class handshake_error : public network_error { public: handshake_error(int type, int error) : m_type(type), m_error(error) {} virtual const char* what() const throw() { return "Handshake error"; } virtual int type() const throw() { return m_type; } virtual int error() const throw() { return m_error; } private: int m_type; int m_error; }; class handshake_succeeded : public network_error { public: handshake_succeeded() {} }; Handshake::Handshake(SocketFd fd, HandshakeManager* m, int encryptionOptions) : m_state(INACTIVE), m_manager(m), m_peerInfo(NULL), m_download(NULL), // Use global throttles until we know which download it is. m_uploadThrottle(manager->upload_throttle()->throttle_list()), m_downloadThrottle(manager->download_throttle()->throttle_list()), m_readDone(false), m_writeDone(false), m_encryption(encryptionOptions), m_extensions(m->default_extensions()) { set_fd(fd); m_readBuffer.reset(); m_writeBuffer.reset(); m_taskTimeout.clear_time(); m_taskTimeout.slot() = std::tr1::bind(&HandshakeManager::receive_timeout, m, this); } Handshake::~Handshake() { if (m_taskTimeout.is_queued()) throw internal_error("Handshake m_taskTimeout bork bork bork."); if (get_fd().is_valid()) throw internal_error("Handshake dtor called but m_fd is still open."); m_encryption.cleanup(); } void Handshake::initialize_incoming(const rak::socket_address& sa) { m_incoming = true; m_address = sa; if (m_encryption.options() & (ConnectionManager::encryption_allow_incoming | ConnectionManager::encryption_require)) m_state = READ_ENC_KEY; else m_state = READ_INFO; manager->poll()->open(this); manager->poll()->insert_read(this); manager->poll()->insert_error(this); // Use lower timeout here. priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(60)).round_seconds()); } void Handshake::initialize_outgoing(const rak::socket_address& sa, DownloadMain* d, PeerInfo* peerInfo) { m_download = d; m_peerInfo = peerInfo; m_peerInfo->set_flags(PeerInfo::flag_handshake); m_incoming = false; m_address = sa; std::make_pair(m_uploadThrottle, m_downloadThrottle) = m_download->throttles(m_address.c_sockaddr()); m_state = CONNECTING; manager->poll()->open(this); manager->poll()->insert_write(this); manager->poll()->insert_error(this); priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(60)).round_seconds()); } void Handshake::deactivate_connection() { m_state = INACTIVE; priority_queue_erase(&taskScheduler, &m_taskTimeout); manager->poll()->remove_read(this); manager->poll()->remove_write(this); manager->poll()->remove_error(this); manager->poll()->close(this); } void Handshake::release_connection() { m_peerInfo->unset_flags(PeerInfo::flag_handshake); m_peerInfo = NULL; get_fd().clear(); } void Handshake::destroy_connection() { manager->connection_manager()->dec_socket_count(); get_fd().close(); get_fd().clear(); if (m_peerInfo == NULL) return; m_download->peer_list()->disconnected(m_peerInfo, 0); m_peerInfo->unset_flags(PeerInfo::flag_handshake); m_peerInfo = NULL; if (!m_extensions->is_default()) { m_extensions->cleanup(); delete m_extensions; } } int Handshake::retry_options() { uint32_t options = m_encryption.options() & ~ConnectionManager::encryption_enable_retry; if (m_encryption.retry() == HandshakeEncryption::RETRY_PLAIN) options &= ~ConnectionManager::encryption_try_outgoing; else if (m_encryption.retry() == HandshakeEncryption::RETRY_ENCRYPTED) options |= ConnectionManager::encryption_try_outgoing; else throw internal_error("Invalid retry type."); return options; } inline uint32_t Handshake::read_unthrottled(void* buf, uint32_t length) { return m_downloadThrottle->node_used_unthrottled(read_stream_throws(buf, length)); } inline uint32_t Handshake::write_unthrottled(const void* buf, uint32_t length) { return m_uploadThrottle->node_used_unthrottled(write_stream_throws(buf, length)); } // Handshake::read_proxy_connect() // Entry: 0, 0 // * 0, [0, 508> bool Handshake::read_proxy_connect() { // Being greedy for now. m_readBuffer.move_end(read_unthrottled(m_readBuffer.end(), 512)); const char* pattern = "\r\n\r\n"; const unsigned int patternLength = 4; if (m_readBuffer.remaining() < patternLength) return false; Buffer::iterator itr = std::search(m_readBuffer.begin(), m_readBuffer.end(), (uint8_t*)pattern, (uint8_t*)pattern + patternLength); m_readBuffer.set_position_itr(itr != m_readBuffer.end() ? (itr + patternLength) : (itr - patternLength)); m_readBuffer.move_unused(); return itr != m_readBuffer.end(); } // Handshake::read_encryption_key() // Entry: * 0, [0, 508> // IU 20, [20, enc_pad_read_size> // *E 96, [96, enc_pad_read_size> bool Handshake::read_encryption_key() { if (m_incoming) { if (m_readBuffer.remaining() < 20) m_readBuffer.move_end(read_unthrottled(m_readBuffer.end(), 20 - m_readBuffer.remaining())); if (m_readBuffer.remaining() < 20) return false; if (m_readBuffer.peek_8() == 19 && std::memcmp(m_readBuffer.position() + 1, m_protocol, 19) == 0) { // got unencrypted BT handshake if (m_encryption.options() & ConnectionManager::encryption_require) throw handshake_error(ConnectionManager::handshake_dropped, e_handshake_unencrypted_rejected); m_state = READ_INFO; return true; } } // Read as much of key, pad and sync string as we can; this is safe // because peer can't send anything beyond the initial BT handshake // because it doesn't know our encryption choice yet. if (m_readBuffer.remaining() < enc_pad_read_size) m_readBuffer.move_end(read_unthrottled(m_readBuffer.end(), enc_pad_read_size - m_readBuffer.remaining())); // but we need at least the key at this point if (m_readBuffer.size_end() < 96) return false; // If the handshake fails after this, it wasn't because the peer // doesn't like encrypted connections, so don't retry unencrypted. m_encryption.set_retry(HandshakeEncryption::RETRY_NONE); if (m_incoming) prepare_key_plus_pad(); m_encryption.key()->compute_secret(m_readBuffer.position(), 96); m_readBuffer.consume(96); // Determine the synchronisation string. if (m_incoming) m_encryption.hash_req1_to_sync(); else m_encryption.encrypt_vc_to_sync(m_download->info()->hash().c_str()); // also put as much as we can write so far in the buffer if (!m_incoming) prepare_enc_negotiation(); m_state = READ_ENC_SYNC; return true; } // Handshake::read_encryption_sync() // *E 96, [96, enc_pad_read_size> bool Handshake::read_encryption_sync() { // Check if we've read the sync string already in the previous // state. This is very likely and avoids an unneeded read. Buffer::iterator itr = std::search(m_readBuffer.position(), m_readBuffer.end(), (uint8_t*)m_encryption.sync(), (uint8_t*)m_encryption.sync() + m_encryption.sync_length()); if (itr == m_readBuffer.end()) { // Otherwise read as many bytes as possible until we find the sync // string. int toRead = enc_pad_size + m_encryption.sync_length() - m_readBuffer.remaining(); if (toRead <= 0) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_encryption_sync_failed); m_readBuffer.move_end(read_unthrottled(m_readBuffer.end(), toRead)); itr = std::search(m_readBuffer.position(), m_readBuffer.end(), (uint8_t*)m_encryption.sync(), (uint8_t*)m_encryption.sync() + m_encryption.sync_length()); if (itr == m_readBuffer.end()) return false; } if (m_incoming) { // We've found HASH('req1' + S), skip that and go on reading the // SKEY hash. m_readBuffer.consume(std::distance(m_readBuffer.position(), itr) + 20); m_state = READ_ENC_SKEY; } else { m_readBuffer.consume(std::distance(m_readBuffer.position(), itr)); m_state = READ_ENC_NEGOT; } return true; } bool Handshake::read_encryption_skey() { if (!fill_read_buffer(20)) return false; m_encryption.deobfuscate_hash((char*)m_readBuffer.position()); m_download = m_manager->download_info_obfuscated((char*)m_readBuffer.position()); m_readBuffer.consume(20); validate_download(); std::make_pair(m_uploadThrottle, m_downloadThrottle) = m_download->throttles(m_address.c_sockaddr()); m_encryption.initialize_encrypt(m_download->info()->hash().c_str(), m_incoming); m_encryption.initialize_decrypt(m_download->info()->hash().c_str(), m_incoming); m_encryption.info()->decrypt(m_readBuffer.position(), m_readBuffer.remaining()); HandshakeEncryption::copy_vc(m_writeBuffer.end()); m_encryption.info()->encrypt(m_writeBuffer.end(), HandshakeEncryption::vc_length); m_writeBuffer.move_end(HandshakeEncryption::vc_length); m_state = READ_ENC_NEGOT; return true; } bool Handshake::read_encryption_negotiation() { if (!fill_read_buffer(enc_negotiation_size)) return false; if (!m_incoming) { // Start decrypting, but don't decrypt beyond the initial // encrypted handshake and later the pad because we may have read // too much data which may be unencrypted if the peer chose that // option. m_encryption.initialize_decrypt(m_download->info()->hash().c_str(), m_incoming); m_encryption.info()->decrypt(m_readBuffer.position(), enc_negotiation_size); } if (!HandshakeEncryption::compare_vc(m_readBuffer.position())) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); m_readBuffer.consume(HandshakeEncryption::vc_length); m_encryption.set_crypto(m_readBuffer.read_32()); m_readPos = m_readBuffer.read_16(); // length of padC/padD if (m_readPos > enc_pad_size) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); // choose one of the offered encryptions, or check the chosen one is valid if (m_incoming) { if ((m_encryption.options() & ConnectionManager::encryption_prefer_plaintext) && m_encryption.has_crypto_plain()) { m_encryption.set_crypto(HandshakeEncryption::crypto_plain); } else if ((m_encryption.options() & ConnectionManager::encryption_require_RC4) && !m_encryption.has_crypto_rc4()) { throw handshake_error(ConnectionManager::handshake_dropped, e_handshake_unencrypted_rejected); } else if (m_encryption.has_crypto_rc4()) { m_encryption.set_crypto(HandshakeEncryption::crypto_rc4); } else if (m_encryption.has_crypto_plain()) { m_encryption.set_crypto(HandshakeEncryption::crypto_plain); } else { throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_encryption); } // at this point we can also write the rest of our negotiation reply m_writeBuffer.write_32(m_encryption.crypto()); m_writeBuffer.write_16(0); m_encryption.info()->encrypt(m_writeBuffer.end() - 4 - 2, 4 + 2); } else { if (m_encryption.crypto() != HandshakeEncryption::crypto_rc4 && m_encryption.crypto() != HandshakeEncryption::crypto_plain) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_encryption); if ((m_encryption.options() & ConnectionManager::encryption_require_RC4) && (m_encryption.crypto() != HandshakeEncryption::crypto_rc4)) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_encryption); } if (!m_incoming) { // decrypt appropriate part of buffer: only pad or all if (m_encryption.crypto() == HandshakeEncryption::crypto_plain) m_encryption.info()->decrypt(m_readBuffer.position(), std::min(m_readPos, m_readBuffer.remaining())); else m_encryption.info()->decrypt(m_readBuffer.position(), m_readBuffer.remaining()); } // next, skip padC/padD m_state = READ_ENC_PAD; return true; } bool Handshake::read_negotiation_reply() { if (!m_incoming) { if (m_encryption.crypto() != HandshakeEncryption::crypto_rc4) m_encryption.info()->set_obfuscated(); m_state = READ_INFO; return true; } if (!fill_read_buffer(2)) return false; // The peer may send initial payload that is RC4 encrypted even if // we have selected plaintext encryption, so read it ahead of BT // handshake. m_encryption.set_length_ia(m_readBuffer.read_16()); if (m_encryption.length_ia() > handshake_size) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); m_state = READ_ENC_IA; return true; } bool Handshake::read_info() { fill_read_buffer(handshake_size); // Check the first byte as early as possible so we can // disconnect non-BT connections if they send less than 20 bytes. if ((m_readBuffer.remaining() >= 1 && m_readBuffer.peek_8() != 19) || (m_readBuffer.remaining() >= 20 && (std::memcmp(m_readBuffer.position() + 1, m_protocol, 19) != 0))) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_not_bittorrent); if (m_readBuffer.remaining() < part1_size) return false; // If the handshake fails after this, it isn't being rejected because // it is unencrypted, so don't retry. m_encryption.set_retry(HandshakeEncryption::RETRY_NONE); m_readBuffer.consume(20); // Should do some option field stuff here, for now just copy. m_readBuffer.read_range(m_options, m_options + 8); // Check the info hash. if (m_incoming) { if (m_download != NULL) { // Have the download from the encrypted handshake, make sure it // matches the BT handshake. if (m_download->info()->hash().not_equal_to((char*)m_readBuffer.position())) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); } else { m_download = m_manager->download_info((char*)m_readBuffer.position()); } validate_download(); std::make_pair(m_uploadThrottle, m_downloadThrottle) = m_download->throttles(m_address.c_sockaddr()); prepare_handshake(); } else { if (m_download->info()->hash().not_equal_to((char*)m_readBuffer.position())) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); } m_readBuffer.consume(20); m_state = READ_PEER; return true; } bool Handshake::read_peer() { if (!fill_read_buffer(20)) return false; prepare_peer_info(); // Send EXTENSION_PROTOCOL handshake message if peer supports it. if (m_peerInfo->supports_extensions()) write_extension_handshake(); // Replay HAVE messages we receive after starting to send the bitfield. // This avoids replaying HAVEs for pieces received between starting the // handshake and now (e.g. when connecting takes longer). Ideally we // should make a snapshot of the bitfield here in case it changes while // we're sending it (if it can't be sent in one write() call). m_initializedTime = cachedTime; // The download is just starting so we're not sending any // bitfield. Pretend we wrote it already. if (m_download->file_list()->bitfield()->is_all_unset() || m_download->initial_seeding() != NULL) { m_writePos = m_download->file_list()->bitfield()->size_bytes(); m_writeBuffer.write_32(0); if (m_encryption.info()->is_encrypted()) m_encryption.info()->encrypt(m_writeBuffer.end() - 4, 4); } else { prepare_bitfield(); } m_state = READ_MESSAGE; manager->poll()->insert_write(this); // Give some extra time for reading/writing the bitfield. priority_queue_erase(&taskScheduler, &m_taskTimeout); priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(120)).round_seconds()); return true; } bool Handshake::read_bitfield() { if (m_readPos < m_bitfield.size_bytes()) { uint32_t length = read_unthrottled(m_bitfield.begin() + m_readPos, m_bitfield.size_bytes() - m_readPos); if (m_encryption.info()->decrypt_valid()) m_encryption.info()->decrypt(m_bitfield.begin() + m_readPos, length); m_readPos += length; } return m_readPos == m_bitfield.size_bytes(); } bool Handshake::read_extension() { if (m_readBuffer.peek_32() > m_readBuffer.reserved()) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); int32_t need = m_readBuffer.peek_32() + 4 - m_readBuffer.remaining(); // We currently can't handle an extension handshake that doesn't // completely fit in the buffer. However these messages are usually // ~100 bytes large and the buffer holds over 1000 bytes so it // should be ok. Else maybe figure out how to disable extensions for // when peer connects next time. // // In addition, make sure there's at least 5 bytes available after // the PEX message has been read, so that we can fit the preamble of // the BITFIELD message. if (need + 5 > m_readBuffer.reserved_left()) { m_readBuffer.move_unused(); if (need + 5 > m_readBuffer.reserved_left()) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); } if (!fill_read_buffer(m_readBuffer.peek_32() + 4)) return false; uint32_t length = m_readBuffer.read_32() - 2; m_readBuffer.read_8(); m_extensions->read_start(m_readBuffer.read_8(), length, false); std::memcpy(m_extensions->read_position(), m_readBuffer.position(), length); m_extensions->read_move(length); // Does this check need to check if it is a handshake we read? if (!m_extensions->is_complete()) throw internal_error("Could not read extension handshake even though it should be in the read buffer."); m_extensions->read_done(); m_readBuffer.consume(length); return true; } bool Handshake::read_port() { if (m_readBuffer.peek_32() > m_readBuffer.reserved()) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); int32_t need = m_readBuffer.peek_32() + 4 - m_readBuffer.remaining(); if (need + 5 > m_readBuffer.reserved_left()) { m_readBuffer.move_unused(); if (need + 5 > m_readBuffer.reserved_left()) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); } if (!fill_read_buffer(m_readBuffer.peek_32() + 4)) return false; uint32_t length = m_readBuffer.read_32() - 1; m_readBuffer.read_8(); if (length == 2) manager->dht_manager()->add_node(m_address.c_sockaddr(), m_readBuffer.peek_16()); m_readBuffer.consume(length); return true; } void Handshake::read_done() { if (m_readDone != false) throw internal_error("Handshake::read_done() m_readDone != false."); // if (m_peerInfo->supports_extensions() && m_extensions->is_initial_handshake()) // throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_order); m_readDone = true; manager->poll()->remove_read(this); if (m_bitfield.empty()) { m_bitfield.set_size_bits(m_download->file_list()->bitfield()->size_bits()); m_bitfield.allocate(); m_bitfield.unset_all(); } else { m_bitfield.update(); } // Should've started to write post handshake data already, but we were // still reading the bitfield/extension and postponed it. If we had no // bitfield to send, we need to send a keep-alive now. if (m_writePos == m_download->file_list()->bitfield()->size_bytes()) prepare_post_handshake(m_download->file_list()->bitfield()->is_all_unset() || m_download->initial_seeding() != NULL); if (m_writeDone) throw handshake_succeeded(); } void Handshake::event_read() { try { restart: switch (m_state) { case PROXY_CONNECT: if (!read_proxy_connect()) break; m_state = PROXY_DONE; manager->poll()->insert_write(this); return event_write(); case READ_ENC_KEY: if (!read_encryption_key()) break; if (m_state != READ_ENC_SYNC) goto restart; case READ_ENC_SYNC: if (!read_encryption_sync()) break; if (m_state != READ_ENC_SKEY) goto restart; case READ_ENC_SKEY: if (!read_encryption_skey()) break; case READ_ENC_NEGOT: if (!read_encryption_negotiation()) break; if (m_state != READ_ENC_PAD) goto restart; case READ_ENC_PAD: if (m_readPos) { // Read padC + lenIA or padD; pad length in m_readPos. if (!fill_read_buffer(m_readPos + (m_incoming ? 2 : 0))) // This can be improved (consume as much as was read) break; m_readBuffer.consume(m_readPos); m_readPos = 0; } if (!read_negotiation_reply()) break; if (m_state != READ_ENC_IA) goto restart; case READ_ENC_IA: // Just read (and automatically decrypt) the initial payload // and leave it in the buffer for READ_INFO later. if (m_encryption.length_ia() > 0 && !fill_read_buffer(m_encryption.length_ia())) break; if (m_readBuffer.remaining() > m_encryption.length_ia()) throw internal_error("Read past initial payload after incoming encrypted handshake."); if (m_encryption.crypto() != HandshakeEncryption::crypto_rc4) m_encryption.info()->set_obfuscated(); m_state = READ_INFO; case READ_INFO: if (!read_info()) break; if (m_state != READ_PEER) goto restart; case READ_PEER: if (!read_peer()) break; // Is this correct? if (m_state != READ_MESSAGE) goto restart; case READ_MESSAGE: case POST_HANDSHAKE: // For meta-downloads, we aren't interested in the bitfield or // extension messages here, PCMetadata handles all that. The // bitfield only refers to the single-chunk meta-data, so fake that. if (m_download->info()->is_meta_download()) { m_bitfield.set_size_bits(1); m_bitfield.allocate(); m_bitfield.set(0); read_done(); break; } fill_read_buffer(5); // Received a keep-alive message which means we won't be // getting any bitfield. if (m_readBuffer.remaining() >= 4 && m_readBuffer.peek_32() == 0) { m_readBuffer.read_32(); read_done(); break; } if (m_readBuffer.remaining() < 5) break; m_readPos = 0; // Extension handshake was sent after BT handshake but before // bitfield, so handle that. If we've already received a message // of this type then we will assume the peer won't be sending a // bitfield, as the second extension message will be part of the // normal traffic, not the handshake. if (m_readBuffer.peek_8_at(4) == protocol_bitfield) { const Bitfield* bitfield = m_download->file_list()->bitfield(); if (!m_bitfield.empty() || m_readBuffer.read_32() != bitfield->size_bytes() + 1) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value); m_readBuffer.read_8(); m_bitfield.set_size_bits(bitfield->size_bits()); m_bitfield.allocate(); m_readPos = std::min(m_bitfield.size_bytes(), m_readBuffer.remaining()); std::memcpy(m_bitfield.begin(), m_readBuffer.position(), m_readPos); m_readBuffer.consume(m_readPos); m_state = READ_BITFIELD; } else if (m_readBuffer.peek_8_at(4) == protocol_extension && m_extensions->is_initial_handshake()) { m_readPos = 0; m_state = READ_EXT; } else if (m_readBuffer.peek_8_at(4) == protocol_port) { // Some peers seem to send the port message before handshake, // so handle it here. m_readPos = 0; m_state = READ_PORT; } else { read_done(); break; } case READ_BITFIELD: case READ_EXT: case READ_PORT: // Gather the different command types into the same case group // so that we don't need 'goto restart' above. if ((m_state == READ_BITFIELD && !read_bitfield()) || (m_state == READ_EXT && !read_extension()) || (m_state == READ_PORT && !read_port())) break; m_state = READ_MESSAGE; if (!m_bitfield.empty() && (!m_peerInfo->supports_extensions() || !m_extensions->is_initial_handshake())) { read_done(); break; } goto restart; default: throw internal_error("Handshake::event_read() called in invalid state."); } // Call event_write if we have any data to write. Make sure // event_write() doesn't get called twice in this function. if (m_writeBuffer.remaining() && !manager->poll()->in_write(this)) { manager->poll()->insert_write(this); return event_write(); } } catch (handshake_succeeded& e) { m_manager->receive_succeeded(this); } catch (handshake_error& e) { m_manager->receive_failed(this, e.type(), e.error()); } catch (network_error& e) { m_manager->receive_failed(this, ConnectionManager::handshake_failed, e_handshake_network_error); } } bool Handshake::fill_read_buffer(int size) { if (m_readBuffer.remaining() < size) { if (size - m_readBuffer.remaining() > m_readBuffer.reserved_left()) throw internal_error("Handshake::fill_read_buffer(...) Buffer overflow."); int read = m_readBuffer.move_end(read_unthrottled(m_readBuffer.end(), size - m_readBuffer.remaining())); if (m_encryption.info()->decrypt_valid()) m_encryption.info()->decrypt(m_readBuffer.end() - read, read); } return m_readBuffer.remaining() >= size; } inline void Handshake::validate_download() { if (m_download == NULL) throw handshake_error(ConnectionManager::handshake_dropped, e_handshake_unknown_download); if (!m_download->info()->is_active()) throw handshake_error(ConnectionManager::handshake_dropped, e_handshake_inactive_download); if (!m_download->info()->is_accepting_new_peers()) throw handshake_error(ConnectionManager::handshake_dropped, e_handshake_not_accepting_connections); } void Handshake::event_write() { try { switch (m_state) { case CONNECTING: if (get_fd().get_error()) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_network_unreachable); manager->poll()->insert_read(this); if (m_encryption.options() & ConnectionManager::encryption_use_proxy) { prepare_proxy_connect(); m_state = PROXY_CONNECT; break; } case PROXY_DONE: // If there's any bytes remaining, it means we got a reply from // the other side before our proxy connect command was finished // written. This probably means the other side isn't a proxy. if (m_writeBuffer.remaining()) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_not_bittorrent); m_writeBuffer.reset(); if (m_encryption.options() & (ConnectionManager::encryption_try_outgoing | ConnectionManager::encryption_require)) { prepare_key_plus_pad(); // if connection fails, peer probably closed it because it was encrypted, so retry encrypted if enabled if (!(m_encryption.options() & ConnectionManager::encryption_require)) m_encryption.set_retry(HandshakeEncryption::RETRY_PLAIN); m_state = READ_ENC_KEY; } else { // if connection is closed before we read the handshake, it might // be rejected because it is unencrypted, in that case retry encrypted m_encryption.set_retry(HandshakeEncryption::RETRY_ENCRYPTED); prepare_handshake(); if (m_incoming) m_state = READ_PEER; else m_state = READ_INFO; } break; case READ_MESSAGE: case READ_BITFIELD: case READ_EXT: write_bitfield(); return; default: break; } if (!m_writeBuffer.remaining()) throw internal_error("event_write called with empty write buffer."); if (m_writeBuffer.consume(write_unthrottled(m_writeBuffer.position(), m_writeBuffer.remaining()))) { if (m_state == POST_HANDSHAKE) write_done(); else manager->poll()->remove_write(this); } } catch (handshake_succeeded& e) { m_manager->receive_succeeded(this); } catch (handshake_error& e) { m_manager->receive_failed(this, e.type(), e.error()); } catch (network_error& e) { m_manager->receive_failed(this, ConnectionManager::handshake_failed, e_handshake_network_error); } } void Handshake::prepare_proxy_connect() { char buf[256]; m_address.address_c_str(buf, 256); int advance = snprintf((char*)m_writeBuffer.position(), m_writeBuffer.reserved_left(), "CONNECT %s:%hu HTTP/1.0\r\n\r\n", buf, m_address.port()); if (advance == -1 || advance > m_writeBuffer.reserved_left()) throw internal_error("Handshake::prepare_proxy_connect() snprintf failed."); m_writeBuffer.move_end(advance); } void Handshake::prepare_key_plus_pad() { m_encryption.initialize(); m_encryption.key()->store_pub_key(m_writeBuffer.end(), 96); m_writeBuffer.move_end(96); int length = random() % enc_pad_size; char pad[length]; std::generate_n(pad, length, &::random); m_writeBuffer.write_len(pad, length); } void Handshake::prepare_enc_negotiation() { char hash[20]; // first piece, HASH('req1' + S) sha1_salt("req1", 4, m_encryption.key()->c_str(), m_encryption.key()->size(), m_writeBuffer.end()); m_writeBuffer.move_end(20); // second piece, HASH('req2' + SKEY) ^ HASH('req3' + S) m_writeBuffer.write_len(m_download->info()->hash_obfuscated().c_str(), 20); sha1_salt("req3", 4, m_encryption.key()->c_str(), m_encryption.key()->size(), hash); for (int i = 0; i < 20; i++) m_writeBuffer.end()[i - 20] ^= hash[i]; // last piece, ENCRYPT(VC, crypto_provide, len(PadC), PadC, len(IA)) m_encryption.initialize_encrypt(m_download->info()->hash().c_str(), m_incoming); Buffer::iterator old_end = m_writeBuffer.end(); HandshakeEncryption::copy_vc(m_writeBuffer.end()); m_writeBuffer.move_end(HandshakeEncryption::vc_length); if (m_encryption.options() & ConnectionManager::encryption_require_RC4) m_writeBuffer.write_32(HandshakeEncryption::crypto_rc4); else m_writeBuffer.write_32(HandshakeEncryption::crypto_plain | HandshakeEncryption::crypto_rc4); m_writeBuffer.write_16(0); m_writeBuffer.write_16(handshake_size); m_encryption.info()->encrypt(old_end, m_writeBuffer.end() - old_end); // write and encrypt BT handshake as initial payload IA prepare_handshake(); } void Handshake::prepare_handshake() { m_writeBuffer.write_8(19); m_writeBuffer.write_range(m_protocol, m_protocol + 19); std::memset(m_writeBuffer.end(), 0, 8); *(m_writeBuffer.end()+5) |= 0x10; // support extension protocol if (manager->dht_manager()->is_active()) *(m_writeBuffer.end()+7) |= 0x01; // DHT support, enable PORT message m_writeBuffer.move_end(8); m_writeBuffer.write_range(m_download->info()->hash().c_str(), m_download->info()->hash().c_str() + 20); m_writeBuffer.write_range(m_download->info()->local_id().c_str(), m_download->info()->local_id().c_str() + 20); if (m_encryption.info()->is_encrypted()) m_encryption.info()->encrypt(m_writeBuffer.end() - handshake_size, handshake_size); } void Handshake::prepare_peer_info() { if (std::memcmp(m_readBuffer.position(), m_download->info()->local_id().c_str(), 20) == 0) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_is_self); // PeerInfo handling for outgoing connections needs to be moved to // HandshakeManager. if (m_peerInfo == NULL) { if (!m_incoming) throw internal_error("Handshake::prepare_peer_info() !m_incoming."); m_peerInfo = m_download->peer_list()->connected(m_address.c_sockaddr(), PeerList::connect_incoming); if (m_peerInfo == NULL) throw handshake_error(ConnectionManager::handshake_failed, e_handshake_network_error); if (m_peerInfo->failed_counter() > m_manager->max_failed) throw handshake_error(ConnectionManager::handshake_dropped, e_handshake_toomanyfailed); m_peerInfo->set_flags(PeerInfo::flag_handshake); } std::memcpy(m_peerInfo->set_options(), m_options, 8); m_peerInfo->mutable_id().assign((const char*)m_readBuffer.position()); m_readBuffer.consume(20); // For meta downloads, we require support of the extension protocol. if (m_download->info()->is_meta_download() && !m_peerInfo->supports_extensions()) throw handshake_error(ConnectionManager::handshake_dropped, e_handshake_unwanted_connection); } void Handshake::prepare_bitfield() { m_writeBuffer.write_32(m_download->file_list()->bitfield()->size_bytes() + 1); m_writeBuffer.write_8(protocol_bitfield); if (m_encryption.info()->is_encrypted()) m_encryption.info()->encrypt(m_writeBuffer.end() - 5, 5); m_writePos = 0; } void Handshake::prepare_post_handshake(bool must_write) { if (m_writePos != m_download->file_list()->bitfield()->size_bytes()) throw internal_error("Handshake::prepare_post_handshake called while bitfield not written completely."); m_state = POST_HANDSHAKE; Buffer::iterator old_end = m_writeBuffer.end(); // Send PORT message for DHT if enabled and peer supports it. if (m_peerInfo->supports_dht() && manager->dht_manager()->is_active() && manager->dht_manager()->can_receive_queries()) { m_writeBuffer.write_32(3); m_writeBuffer.write_8(protocol_port); m_writeBuffer.write_16(manager->dht_manager()->port()); manager->dht_manager()->port_sent(); } // Send a keep-alive if we still must send something. if (must_write && old_end == m_writeBuffer.end()) m_writeBuffer.write_32(0); if (m_encryption.info()->is_encrypted()) m_encryption.info()->encrypt(old_end, m_writeBuffer.end() - old_end); if (!m_writeBuffer.remaining()) write_done(); } void Handshake::write_done() { m_writeDone = true; manager->poll()->remove_write(this); // Ok to just check m_readDone as the call in event_read() won't // set it before the call. if (m_readDone) throw handshake_succeeded(); } void Handshake::write_extension_handshake() { DownloadInfo* info = m_download->info(); if (m_extensions->is_default()) { m_extensions = new ProtocolExtension; m_extensions->set_info(m_peerInfo, m_download); } // PEX may be disabled but still active if disabled since last download tick. if (info->is_pex_enabled() && info->is_pex_active() && info->size_pex() < info->max_size_pex()) m_extensions->set_local_enabled(ProtocolExtension::UT_PEX); DataBuffer message = m_extensions->generate_handshake_message(); m_writeBuffer.write_32(message.length() + 2); m_writeBuffer.write_8(protocol_extension); m_writeBuffer.write_8(ProtocolExtension::HANDSHAKE); m_writeBuffer.write_range(message.data(), message.end()); if (m_encryption.info()->is_encrypted()) m_encryption.info()->encrypt(m_writeBuffer.end() - message.length() - 2 - 4, message.length() + 2 + 4); message.clear(); } void Handshake::write_bitfield() { const Bitfield* bitfield = m_download->file_list()->bitfield(); if (m_writeDone != false) throw internal_error("Handshake::event_write() m_writeDone != false."); if (m_writeBuffer.remaining()) if (!m_writeBuffer.consume(write_unthrottled(m_writeBuffer.position(), m_writeBuffer.remaining()))) return; if (m_writePos != bitfield->size_bytes()) { if (m_encryption.info()->is_encrypted()) { if (m_writePos == 0) m_writeBuffer.reset(); // this should be unnecessary now uint32_t length = std::min(bitfield->size_bytes() - m_writePos, m_writeBuffer.reserved()) - m_writeBuffer.size_end(); if (length > 0) { std::memcpy(m_writeBuffer.end(), bitfield->begin() + m_writePos + m_writeBuffer.size_end(), length); m_encryption.info()->encrypt(m_writeBuffer.end(), length); m_writeBuffer.move_end(length); } length = write_unthrottled(m_writeBuffer.begin(), m_writeBuffer.size_end()); m_writePos += length; if (length != m_writeBuffer.size_end() && length > 0) std::memmove(m_writeBuffer.begin(), m_writeBuffer.begin() + length, m_writeBuffer.size_end() - length); m_writeBuffer.move_end(-length); } else { m_writePos += write_unthrottled(bitfield->begin() + m_writePos, bitfield->size_bytes() - m_writePos); } } // We can't call prepare_post_handshake until the read code is done reading // the bitfield, so if we get here before then, postpone the post handshake // data until reading is done. Since we're done writing, remove us from the // poll in that case. if (m_writePos == bitfield->size_bytes()) { if (!m_readDone) manager->poll()->remove_write(this); else prepare_post_handshake(false); } } void Handshake::event_error() { if (m_state == INACTIVE) throw internal_error("Handshake::event_error() called on an inactive handshake."); m_manager->receive_failed(this, ConnectionManager::handshake_failed, e_handshake_network_error); } } libtorrent-0.13.2/src/protocol/handshake.h000644 000765 000024 00000015300 11716630446 021457 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_HANDSHAKE_H #define LIBTORRENT_HANDSHAKE_H #include #include "net/protocol_buffer.h" #include "net/socket_stream.h" #include "torrent/bitfield.h" #include "torrent/peer/peer_info.h" #include "utils/sha1.h" #include "handshake_encryption.h" namespace torrent { class HandshakeManager; class DownloadMain; class Handshake : public SocketStream { public: static const uint32_t part1_size = 20 + 28; static const uint32_t part2_size = 20; static const uint32_t handshake_size = part1_size + part2_size; static const uint32_t protocol_bitfield = 5; static const uint32_t protocol_port = 9; static const uint32_t protocol_extension = 20; static const uint32_t enc_negotiation_size = 8 + 4 + 2; static const uint32_t enc_pad_size = 512; static const uint32_t enc_pad_read_size = 96 + enc_pad_size + 20; static const uint32_t buffer_size = enc_pad_read_size + 20 + enc_negotiation_size + enc_pad_size + 2 + handshake_size + 5; typedef ProtocolBuffer Buffer; typedef enum { INACTIVE, CONNECTING, POST_HANDSHAKE, PROXY_CONNECT, PROXY_DONE, READ_ENC_KEY, READ_ENC_SYNC, READ_ENC_SKEY, READ_ENC_NEGOT, READ_ENC_PAD, READ_ENC_IA, READ_INFO, READ_PEER, READ_MESSAGE, READ_BITFIELD, READ_EXT, READ_PORT } State; Handshake(SocketFd fd, HandshakeManager* m, int encryption_options); ~Handshake(); const char* type_name() const { return "handshake"; } bool is_active() const { return m_state != INACTIVE; } State state() const { return m_state; } void initialize_incoming(const rak::socket_address& sa); void initialize_outgoing(const rak::socket_address& sa, DownloadMain* d, PeerInfo* peerInfo); PeerInfo* peer_info() { return m_peerInfo; } const PeerInfo* peer_info() const { return m_peerInfo; } void set_peer_info(PeerInfo* p) { m_peerInfo = p; } const rak::socket_address* socket_address() const { return &m_address; } DownloadMain* download() { return m_download; } Bitfield* bitfield() { return &m_bitfield; } void deactivate_connection(); void release_connection(); void destroy_connection(); const void* unread_data() { return m_readBuffer.position(); } uint32_t unread_size() const { return m_readBuffer.remaining(); } rak::timer initialized_time() const { return m_initializedTime; } virtual void event_read(); virtual void event_write(); virtual void event_error(); HandshakeEncryption* encryption() { return &m_encryption; } ProtocolExtension* extensions() { return m_extensions; } int retry_options(); protected: Handshake(const Handshake&); void operator = (const Handshake&); void read_done(); void write_done(); bool fill_read_buffer(int size); // Check what is unnessesary. bool read_proxy_connect(); bool read_encryption_key(); bool read_encryption_sync(); bool read_encryption_skey(); bool read_encryption_negotiation(); bool read_negotiation_reply(); bool read_info(); bool read_peer(); bool read_bitfield(); bool read_extension(); bool read_port(); void prepare_proxy_connect(); void prepare_key_plus_pad(); void prepare_enc_negotiation(); void prepare_handshake(); void prepare_peer_info(); void prepare_bitfield(); void prepare_post_handshake(bool must_write); void write_extension_handshake(); void write_bitfield(); inline void validate_download(); uint32_t read_unthrottled(void* buf, uint32_t length); uint32_t write_unthrottled(const void* buf, uint32_t length); static const char* m_protocol; State m_state; HandshakeManager* m_manager; PeerInfo* m_peerInfo; DownloadMain* m_download; Bitfield m_bitfield; ThrottleList* m_uploadThrottle; ThrottleList* m_downloadThrottle; rak::priority_item m_taskTimeout; rak::timer m_initializedTime; uint32_t m_readPos; uint32_t m_writePos; bool m_readDone; bool m_writeDone; bool m_incoming; rak::socket_address m_address; char m_options[8]; HandshakeEncryption m_encryption; ProtocolExtension* m_extensions; // Put these last to keep variables closer to *this. Buffer m_readBuffer; Buffer m_writeBuffer; }; } #endif libtorrent-0.13.2/src/protocol/handshake_encryption.cc000644 000765 000024 00000011142 11705767056 024075 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "torrent/connection_manager.h" #include "torrent/exceptions.h" #include "utils/diffie_hellman.h" #include "utils/sha1.h" #include "handshake_encryption.h" namespace torrent { const unsigned char HandshakeEncryption::dh_prime[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x3A, 0x36, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x05, 0x63, }; const unsigned char HandshakeEncryption::dh_generator[] = { 2 }; const unsigned char HandshakeEncryption::vc_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; bool HandshakeEncryption::should_retry() const { return (m_options & ConnectionManager::encryption_enable_retry) != 0 && m_retry != HandshakeEncryption::RETRY_NONE; } void HandshakeEncryption::initialize() { m_key = new DiffieHellman(dh_prime, dh_prime_length, dh_generator, dh_generator_length); } void HandshakeEncryption::cleanup() { delete m_key; m_key = NULL; } bool HandshakeEncryption::compare_vc(const void* buf) { return std::memcmp(buf, vc_data, vc_length) == 0; } void HandshakeEncryption::initialize_decrypt(const char* origHash, bool incoming) { char hash[20]; unsigned char discard[1024]; sha1_salt(incoming ? "keyA" : "keyB", 4, m_key->c_str(), 96, origHash, 20, hash); m_info.set_decrypt(RC4((const unsigned char*)hash, 20)); m_info.decrypt(discard, 1024); } void HandshakeEncryption::initialize_encrypt(const char* origHash, bool incoming) { char hash[20]; unsigned char discard[1024]; sha1_salt(incoming ? "keyB" : "keyA", 4, m_key->c_str(), 96, origHash, 20, hash); m_info.set_encrypt(RC4((const unsigned char*)hash, 20)); m_info.encrypt(discard, 1024); } // Obfuscated hash is HASH('req2', download_hash), extract that from // HASH('req2', download_hash) ^ HASH('req3', S). void HandshakeEncryption::deobfuscate_hash(char* src) const { char tmp[20]; sha1_salt("req3", 4, m_key->c_str(), m_key->size(), tmp); for (int i = 0; i < 20; i++) src[i] ^= tmp[i]; } void HandshakeEncryption::hash_req1_to_sync() { sha1_salt("req1", 4, m_key->c_str(), m_key->size(), modify_sync(20)); } void HandshakeEncryption::encrypt_vc_to_sync(const char* origHash) { m_syncLength = vc_length; std::memcpy(m_sync, vc_data, vc_length); char hash[20]; char discard[1024]; sha1_salt("keyB", 4, m_key->c_str(), 96, origHash, 20, hash); RC4 peerEncrypt((const unsigned char*)hash, 20); peerEncrypt.crypt(discard, 1024); peerEncrypt.crypt(m_sync, HandshakeEncryption::vc_length); } } libtorrent-0.13.2/src/protocol/handshake_encryption.h000644 000765 000024 00000011316 11705767056 023742 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_HANDSHAKE_ENCRYPTION_H #define LIBTORRENT_PROTOCOL_HANDSHAKE_ENCRYPTION_H #include #include "encryption_info.h" namespace torrent { class DiffieHellman; class HandshakeEncryption { public: typedef enum { RETRY_NONE, RETRY_PLAIN, RETRY_ENCRYPTED, } Retry; static const int crypto_plain = 1; static const int crypto_rc4 = 2; static const unsigned char dh_prime[]; static const unsigned int dh_prime_length = 96; static const unsigned char dh_generator[]; static const unsigned int dh_generator_length = 1; static const unsigned char vc_data[]; static const unsigned int vc_length = 8; HandshakeEncryption(int options) : m_key(NULL), m_options(options), m_crypto(0), m_retry(RETRY_NONE), m_syncLength(0), m_lengthIA(0) {} bool has_crypto_plain() const { return m_crypto & crypto_plain; } bool has_crypto_rc4() const { return m_crypto & crypto_rc4; } DiffieHellman* key() { return m_key; } EncryptionInfo* info() { return &m_info; } int options() const { return m_options; } int crypto() const { return m_crypto; } void set_crypto(int val) { m_crypto = val; } Retry retry() const { return m_retry; } void set_retry(Retry val) { m_retry = val; } bool should_retry() const; const char* sync() const { return m_sync; } unsigned int sync_length() const { return m_syncLength; } void set_sync(const char* src, unsigned int len) { std::memcpy(m_sync, src, (m_syncLength = len)); } char* modify_sync(unsigned int len) { m_syncLength = len; return m_sync; } unsigned int length_ia() const { return m_lengthIA; } void set_length_ia(unsigned int len) { m_lengthIA = len; } void initialize(); void cleanup(); void initialize_decrypt(const char* origHash, bool incoming); void initialize_encrypt(const char* origHash, bool incoming); void deobfuscate_hash(char* src) const; void hash_req1_to_sync(); void encrypt_vc_to_sync(const char* origHash); static void copy_vc(void* dest) { std::memset(dest, 0, vc_length); } static bool compare_vc(const void* buf); private: DiffieHellman* m_key; // A pointer instead? EncryptionInfo m_info; int m_options; int m_crypto; Retry m_retry; char m_sync[20]; unsigned int m_syncLength; unsigned int m_lengthIA; }; } #endif libtorrent-0.13.2/src/protocol/handshake_manager.cc000644 000765 000024 00000026445 11744202530 023311 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "torrent/exceptions.h" #include "torrent/error.h" #include "download/download_main.h" #include "torrent/connection_manager.h" #include "torrent/download_info.h" #include "torrent/peer/peer_info.h" #include "torrent/peer/client_list.h" #include "torrent/peer/connection_list.h" #include "peer_connection_base.h" #include "handshake.h" #include "handshake_manager.h" #include "manager.h" namespace torrent { ProtocolExtension HandshakeManager::DefaultExtensions = ProtocolExtension::make_default(); inline void handshake_manager_delete_handshake(Handshake* h) { h->deactivate_connection(); h->destroy_connection(); delete h; } HandshakeManager::size_type HandshakeManager::size_info(DownloadMain* info) const { return std::count_if(base_type::begin(), base_type::end(), rak::equal(info, std::mem_fun(&Handshake::download))); } void HandshakeManager::clear() { std::for_each(base_type::begin(), base_type::end(), std::ptr_fun(&handshake_manager_delete_handshake)); base_type::clear(); } void HandshakeManager::erase(Handshake* handshake) { iterator itr = std::find(base_type::begin(), base_type::end(), handshake); if (itr == base_type::end()) throw internal_error("HandshakeManager::erase(...) could not find handshake."); base_type::erase(itr); } struct handshake_manager_equal : std::binary_function { bool operator () (const rak::socket_address* sa1, const Handshake* p2) const { return p2->peer_info() != NULL && *sa1 == *rak::socket_address::cast_from(p2->peer_info()->socket_address()); } }; bool HandshakeManager::find(const rak::socket_address& sa) { return std::find_if(base_type::begin(), base_type::end(), std::bind1st(handshake_manager_equal(), &sa)) != base_type::end(); } void HandshakeManager::erase_download(DownloadMain* info) { iterator split = std::partition(base_type::begin(), base_type::end(), rak::not_equal(info, std::mem_fun(&Handshake::download))); std::for_each(split, base_type::end(), std::ptr_fun(&handshake_manager_delete_handshake)); base_type::erase(split, base_type::end()); } void HandshakeManager::add_incoming(SocketFd fd, const rak::socket_address& sa) { if (!manager->connection_manager()->can_connect() || !manager->connection_manager()->filter(sa.c_sockaddr()) || !setup_socket(fd)) { fd.close(); return; } manager->connection_manager()->signal_handshake_log().emit(sa.c_sockaddr(), ConnectionManager::handshake_incoming, e_none, NULL); manager->connection_manager()->inc_socket_count(); Handshake* h = new Handshake(fd, this, manager->connection_manager()->encryption_options()); h->initialize_incoming(sa); base_type::push_back(h); } void HandshakeManager::add_outgoing(const rak::socket_address& sa, DownloadMain* download) { if (!manager->connection_manager()->can_connect() || !manager->connection_manager()->filter(sa.c_sockaddr())) return; create_outgoing(sa, download, manager->connection_manager()->encryption_options()); } void HandshakeManager::create_outgoing(const rak::socket_address& sa, DownloadMain* download, int encryptionOptions) { int connection_options = PeerList::connect_keep_handshakes; if (!(encryptionOptions & ConnectionManager::encryption_retrying)) connection_options |= PeerList::connect_filter_recent; PeerInfo* peerInfo = download->peer_list()->connected(sa.c_sockaddr(), connection_options); if (peerInfo == NULL || peerInfo->failed_counter() > max_failed) return; SocketFd fd; const rak::socket_address* bindAddress = rak::socket_address::cast_from(manager->connection_manager()->bind_address()); const rak::socket_address* connectAddress = &sa; if (rak::socket_address::cast_from(manager->connection_manager()->proxy_address())->is_valid()) { connectAddress = rak::socket_address::cast_from(manager->connection_manager()->proxy_address()); encryptionOptions |= ConnectionManager::encryption_use_proxy; } if (!fd.open_stream() || !setup_socket(fd) || (bindAddress->is_bindable() && !fd.bind(*bindAddress)) || !fd.connect(*connectAddress)) { if (fd.is_valid()) fd.close(); download->peer_list()->disconnected(peerInfo, 0); return; } int message; if (encryptionOptions & ConnectionManager::encryption_use_proxy) message = ConnectionManager::handshake_outgoing_proxy; else if (encryptionOptions & (ConnectionManager::encryption_try_outgoing | ConnectionManager::encryption_require)) message = ConnectionManager::handshake_outgoing_encrypted; else message = ConnectionManager::handshake_outgoing; manager->connection_manager()->signal_handshake_log().emit(sa.c_sockaddr(), message, e_none, &download->info()->hash()); manager->connection_manager()->inc_socket_count(); Handshake* handshake = new Handshake(fd, this, encryptionOptions); handshake->initialize_outgoing(sa, download, peerInfo); base_type::push_back(handshake); } void HandshakeManager::receive_succeeded(Handshake* handshake) { if (!handshake->is_active()) throw internal_error("HandshakeManager::receive_succeeded(...) called on an inactive handshake."); erase(handshake); handshake->deactivate_connection(); DownloadMain* download = handshake->download(); PeerConnectionBase* pcb; if (download->info()->is_active() && download->connection_list()->want_connection(handshake->peer_info(), handshake->bitfield()) && (pcb = download->connection_list()->insert(handshake->peer_info(), handshake->get_fd(), handshake->bitfield(), handshake->encryption()->info(), handshake->extensions())) != NULL) { manager->client_list()->retrieve_id(&handshake->peer_info()->mutable_client_info(), handshake->peer_info()->id()); manager->connection_manager()->signal_handshake_log().emit(handshake->peer_info()->socket_address(), ConnectionManager::handshake_success, e_none, &download->info()->hash()); pcb->peer_chunks()->set_have_timer(handshake->initialized_time()); if (handshake->unread_size() != 0) { if (handshake->unread_size() > PeerConnectionBase::ProtocolRead::buffer_size) throw internal_error("HandshakeManager::receive_succeeded(...) Unread data won't fit PCB's read buffer."); pcb->push_unread(handshake->unread_data(), handshake->unread_size()); pcb->event_read(); } handshake->release_connection(); } else { uint32_t reason; if (!download->info()->is_active()) reason = e_handshake_inactive_download; else if (download->file_list()->is_done() && handshake->bitfield()->is_all_set()) reason = e_handshake_unwanted_connection; else reason = e_handshake_duplicate; manager->connection_manager()->signal_handshake_log().emit(handshake->peer_info()->socket_address(), ConnectionManager::handshake_dropped, reason, &download->info()->hash()); handshake->destroy_connection(); } delete handshake; } void HandshakeManager::receive_failed(Handshake* handshake, int message, int error) { if (!handshake->is_active()) throw internal_error("HandshakeManager::receive_failed(...) called on an inactive handshake."); const rak::socket_address* sa = handshake->socket_address(); erase(handshake); handshake->deactivate_connection(); handshake->destroy_connection(); manager->connection_manager()->signal_handshake_log().emit(sa->c_sockaddr(), message, error, handshake->download() != NULL ? &handshake->download()->info()->hash() : NULL); if (handshake->encryption()->should_retry()) { int retry_options = handshake->retry_options() | ConnectionManager::encryption_retrying; DownloadMain* download = handshake->download(); manager->connection_manager()->signal_handshake_log().emit(sa->c_sockaddr(), retry_options & ConnectionManager::encryption_try_outgoing ? ConnectionManager::handshake_retry_encrypted : ConnectionManager::handshake_retry_plaintext, e_none, &download->info()->hash()); create_outgoing(*sa, download, retry_options); } delete handshake; } void HandshakeManager::receive_timeout(Handshake* h) { receive_failed(h, ConnectionManager::handshake_failed, h->state() == Handshake::CONNECTING ? e_handshake_network_unreachable : e_handshake_network_timeout); } bool HandshakeManager::setup_socket(SocketFd fd) { if (!fd.set_nonblock()) return false; ConnectionManager* m = manager->connection_manager(); if (m->priority() != ConnectionManager::iptos_default && !fd.set_priority(m->priority())) return false; if (m->send_buffer_size() != 0 && !fd.set_send_buffer_size(m->send_buffer_size())) return false; if (m->receive_buffer_size() != 0 && !fd.set_receive_buffer_size(m->receive_buffer_size())) return false; return true; } } libtorrent-0.13.2/src/protocol/handshake_manager.h000644 000765 000024 00000010026 11705767056 023157 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_HANDSHAKE_MANAGER_H #define LIBTORRENT_NET_HANDSHAKE_MANAGER_H #include #include #include #include #include #include #include "net/socket_fd.h" namespace torrent { class Handshake; class DownloadManager; class DownloadMain; class PeerConnectionBase; class HandshakeManager : private rak::unordered_vector { public: typedef rak::unordered_vector base_type; typedef uint32_t size_type; typedef rak::mem_fun1 SlotDownloadId; // Do not connect to peers with this many or more failed chunks. static const unsigned int max_failed = 3; using base_type::empty; HandshakeManager() { } ~HandshakeManager() { clear(); } size_type size() const { return base_type::size(); } size_type size_info(DownloadMain* info) const; void clear(); bool find(const rak::socket_address& sa); void erase_download(DownloadMain* info); // Cleanup. void add_incoming(SocketFd fd, const rak::socket_address& sa); void add_outgoing(const rak::socket_address& sa, DownloadMain* info); void slot_download_id(SlotDownloadId s) { m_slotDownloadId = s; } void slot_download_id_obfuscated(SlotDownloadId s) { m_slotDownloadIdObfuscated = s; } void receive_succeeded(Handshake* h); void receive_failed(Handshake* h, int message, int error); void receive_timeout(Handshake* h); // This needs to be filterable slot. DownloadMain* download_info(const char* hash) { return m_slotDownloadId(hash); } DownloadMain* download_info_obfuscated(const char* hash) { return m_slotDownloadIdObfuscated(hash); } ProtocolExtension* default_extensions() const { return &DefaultExtensions; } private: void create_outgoing(const rak::socket_address& sa, DownloadMain* info, int encryptionOptions); void erase(Handshake* handshake); bool setup_socket(SocketFd fd); static ProtocolExtension DefaultExtensions; SlotDownloadId m_slotDownloadId; SlotDownloadId m_slotDownloadIdObfuscated; }; } #endif libtorrent-0.13.2/src/protocol/initial_seed.cc000644 000765 000024 00000024071 11705767056 022333 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include "torrent/download/choke_group.h" #include "torrent/download/choke_queue.h" #include "download/chunk_statistics.h" #include "initial_seed.h" #include "peer_connection_leech.h" namespace torrent { PeerInfo* const InitialSeeding::chunk_unsent = (PeerInfo*) 0; PeerInfo* const InitialSeeding::chunk_unknown = (PeerInfo*) 1; PeerInfo* const InitialSeeding::chunk_done = (PeerInfo*) 2; InitialSeeding::InitialSeeding(DownloadMain* download) : m_nextChunk(0), m_chunksLeft(download->file_list()->size_chunks()), m_download(download), m_peerChunks(new PeerInfo*[m_chunksLeft]) { memset(m_peerChunks, 0, m_chunksLeft * sizeof(m_peerChunks[0])); } InitialSeeding::~InitialSeeding() { unblock_all(); delete[] m_peerChunks; } inline bool InitialSeeding::valid_peer(PeerInfo* peer) { return peer > chunk_done; } void InitialSeeding::clear_peer(PeerInfo* peer) { if (!valid_peer(peer)) return; peer->unset_flags(PeerInfo::flag_blocked); // If peer is still connected, offer new piece right away. if (peer->connection() != NULL) peer->connection()->write_insert_poll_safe(); } void InitialSeeding::chunk_seen(uint32_t index, PeerConnectionBase* pcb) { // When we have two other seeds, trust that the download will // be sufficiently seeded and switch to normal seeding. This is // mainly for when the user accidentally enables initial seeding. if (m_download->chunk_statistics()->complete() > 1) complete(pcb); PeerInfo* peer = pcb->mutable_peer_info(); PeerInfo* old = m_peerChunks[index]; // We didn't send this chunk. Is someone else initial seeding too? // Or maybe we restarted and the peer got this chunk from someone // we did send it to. Either way, we don't know who it belongs to. // Don't mark it done until we see it from someone else, though. if (old == chunk_unsent) { m_peerChunks[index] = chunk_unknown; return; } if (old == peer || old == chunk_done) return; // We've seen two peers on the swarm receive this chunk. m_peerChunks[index] = chunk_done; if (--m_chunksLeft == 0) complete(pcb); // The peer we sent it to originally may now receive another chunk. clear_peer(old); } void InitialSeeding::chunk_complete(uint32_t index, PeerConnectionBase* pcb) { clear_peer(m_peerChunks[index]); m_peerChunks[index] = chunk_unknown; chunk_seen(index, pcb); } void InitialSeeding::new_peer(PeerConnectionBase* pcb) { PeerInfo* peer = pcb->mutable_peer_info(); if (peer->is_blocked()) peer->set_flags(PeerInfo::flag_restart); // We don't go through the peer's entire bitfield here. This eliminates // cheating by sending a bogus bitfield if it figures out we are initial // seeding, to drop us out of it. We should see HAVE messages for pieces // it has that we were waiting for anyway. We will check individual chunks // as we are about to offer them, to avoid the overhead of checking each // peer's bitfield as well. If it really was cheating, the pieces it isn't // sharing will be sent during the second round of initial seeding. // If we're on the second round, don't check // it until we're about to offer a chunk. if (m_peerChunks[m_nextChunk] != chunk_unsent) return; // But during primary initial seeding (some chunks not sent at all), // check that nobody already has the next chunk we were going to send. while (m_peerChunks[m_nextChunk] == chunk_unsent && (*m_download->chunk_statistics())[m_nextChunk]) { // Could set to chunk_done if enough peers have it, but if that was the // last one it could cause initial seeding to end and all connections to // be closed, and now is a bad time for that (still being set up). Plus // this gives us the opportunity to wait for HAVE messages and resend // the chunk if it's not being shared. m_peerChunks[m_nextChunk] = chunk_unknown; find_next(false, pcb); } } uint32_t InitialSeeding::chunk_offer(PeerConnectionBase* pcb, uint32_t chunkDone) { PeerInfo* peer = pcb->mutable_peer_info(); // If this peer completely downloaded the chunk we offered and we have too // many unused upload slots, give it another chunk to download for free. if (peer->is_blocked() && chunkDone != no_offer && m_peerChunks[chunkDone] == peer && m_download->choke_group()->up_queue()->size_total() * 10 < 9 * m_download->choke_group()->up_queue()->max_unchoked()) { m_peerChunks[chunkDone] = chunk_unknown; peer->unset_flags(PeerInfo::flag_blocked); // Otherwise check if we can offer a chunk normally. } else if (peer->is_blocked()) { if (!peer->is_restart()) return no_offer; peer->unset_flags(PeerInfo::flag_restart); // Re-connection of a peer we already sent a chunk. // Offer the same chunk again. PeerInfo** peerChunksEnd = m_peerChunks + m_download->file_list()->size_chunks(); PeerInfo** itr = std::find_if(m_peerChunks, peerChunksEnd, std::bind2nd(std::equal_to(), peer)); if (itr != peerChunksEnd) return itr - m_peerChunks; // Couldn't find the chunk, we probably sent it to someone // else since the disconnection. So offer a new one. } uint32_t index = m_nextChunk; bool secondary = false; // If we already sent this chunk to someone else, we're on the second // (or more) round. We might have already found this chunk elsewhere on // the swarm since then and need to find a different one if so. if (m_peerChunks[index] != chunk_unsent) { secondary = true; // Accounting for peers whose bitfield we didn't check when connecting. // If the chunk stats say there are enough peers who have it, believe that. if (m_peerChunks[index] != chunk_done && (*m_download->chunk_statistics())[index] > 1) chunk_complete(index, pcb); if (m_peerChunks[index] == chunk_done) index = find_next(true, pcb); } // When we only have one chunk left and we already offered it // to someone who hasn't shared it yet, offer it to everyone // else. We do not override the peer we sent it to, so they // cannot be unblocked, but when initial seeding completes // everyone is unblocked anyway. if (m_chunksLeft == 1 && valid_peer(m_peerChunks[index])) { peer->set_flags(PeerInfo::flag_blocked); return index; } // Make sure we don't accidentally offer a chunk it has // already, or it would never even request it from us. // We'll just offer it to the next peer instead. if (pcb->bitfield()->get(index)) return no_offer; m_peerChunks[index] = peer; peer->set_flags(PeerInfo::flag_blocked); find_next(secondary, pcb); return index; } bool InitialSeeding::should_upload(uint32_t index) { return m_peerChunks[index] != chunk_done; } uint32_t InitialSeeding::find_next(bool secondary, PeerConnectionBase* pcb) { if (!secondary) { // Primary seeding: find next chunk not sent yet. while (++m_nextChunk < m_download->file_list()->size_chunks()) { if (m_peerChunks[m_nextChunk] == chunk_unsent) { if (!(*m_download->chunk_statistics())[m_nextChunk]) return m_nextChunk; // Someone has this one already. We don't know if we sent it or not. m_peerChunks[m_nextChunk] = chunk_unknown; } } // Went through all chunks. Continue with secondary seeding. m_nextChunk--; } // Secondary seeding: find next chunk that's not done yet. do { if (++m_nextChunk == m_download->file_list()->size_chunks()) m_nextChunk = 0; if (m_peerChunks[m_nextChunk] != chunk_done && (*m_download->chunk_statistics())[m_nextChunk] > 1) chunk_complete(m_nextChunk, pcb); } while (m_peerChunks[m_nextChunk] == chunk_done); return m_nextChunk; } void InitialSeeding::complete(PeerConnectionBase* pcb) { unblock_all(); m_chunksLeft = 0; m_nextChunk = no_offer; // We think all chunks should be well seeded now. Check to make sure. for (uint32_t i = 0; i < m_download->file_list()->size_chunks(); i++) { if (m_download->chunk_statistics()->complete() + (*m_download->chunk_statistics())[i] < 2) { // Chunk too rare, send it again before switching to normal seeding. m_chunksLeft++; m_peerChunks[i] = chunk_unsent; if (m_nextChunk == no_offer) m_nextChunk = i; } } if (m_chunksLeft) return; m_download->initial_seeding_done(pcb); } void InitialSeeding::unblock_all() { for (PeerList::const_iterator itr = m_download->peer_list()->begin(); itr != m_download->peer_list()->end(); ++itr) itr->second->unset_flags(PeerInfo::flag_blocked); } } libtorrent-0.13.2/src/protocol/initial_seed.h000644 000765 000024 00000006217 11705767056 022177 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_INITIAL_SEED_H #define LIBTORRENT_PROTOCOL_INITIAL_SEED_H #include "download/download_main.h" namespace torrent { class InitialSeeding { public: InitialSeeding(DownloadMain* download); ~InitialSeeding(); static const uint32_t no_offer = ~uint32_t(); void new_peer(PeerConnectionBase* pcb); // Chunk was seen distributed to a peer in the swarm. void chunk_seen(uint32_t index, PeerConnectionBase* pcb); // Returns chunk we may offer the peer or no_offer if none. uint32_t chunk_offer(PeerConnectionBase* pcb, uint32_t indexDone); // During the second stage (seeding rare chunks), return // false if given chunk is already well-seeded now. True otherwise. bool should_upload(uint32_t index); private: static PeerInfo* const chunk_unsent; // Chunk never sent to anyone. static PeerInfo* const chunk_unknown; // Peer has chunk, we don't know who we sent it to. static PeerInfo* const chunk_done; // Chunk properly distributed by peer. uint32_t find_next(bool secondary, PeerConnectionBase* pcb); bool valid_peer(PeerInfo* peer); void clear_peer(PeerInfo* peer); void chunk_complete(uint32_t index, PeerConnectionBase* pcb); void complete(PeerConnectionBase* pcb); void unblock_all(); uint32_t m_nextChunk; uint32_t m_chunksLeft; DownloadMain* m_download; PeerInfo** m_peerChunks; }; } #endif libtorrent-0.13.2/src/protocol/Makefile.am000644 000765 000024 00000001243 11705767056 021423 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_protocol.la libsub_protocol_la_SOURCES = \ encryption_info.h \ extensions.cc \ extensions.h \ handshake.cc \ handshake.h \ handshake_encryption.cc \ handshake_encryption.h \ handshake_manager.cc \ handshake_manager.h \ initial_seed.cc \ initial_seed.h \ peer_chunks.h \ peer_connection_base.cc \ peer_connection_base.h \ peer_connection_leech.cc \ peer_connection_leech.h \ peer_connection_metadata.cc \ peer_connection_metadata.h \ peer_factory.cc \ peer_factory.h \ protocol_base.h \ request_list.cc \ request_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrent-0.13.2/src/protocol/Makefile.in000644 000765 000024 00000042047 11744204216 021426 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/protocol DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_protocol_la_LIBADD = am_libsub_protocol_la_OBJECTS = extensions.lo handshake.lo \ handshake_encryption.lo handshake_manager.lo initial_seed.lo \ peer_connection_base.lo peer_connection_leech.lo \ peer_connection_metadata.lo peer_factory.lo request_list.lo libsub_protocol_la_OBJECTS = $(am_libsub_protocol_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_protocol_la_SOURCES) DIST_SOURCES = $(libsub_protocol_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_protocol.la libsub_protocol_la_SOURCES = \ encryption_info.h \ extensions.cc \ extensions.h \ handshake.cc \ handshake.h \ handshake_encryption.cc \ handshake_encryption.h \ handshake_manager.cc \ handshake_manager.h \ initial_seed.cc \ initial_seed.h \ peer_chunks.h \ peer_connection_base.cc \ peer_connection_base.h \ peer_connection_leech.cc \ peer_connection_leech.h \ peer_connection_metadata.cc \ peer_connection_metadata.h \ peer_factory.cc \ peer_factory.h \ protocol_base.h \ request_list.cc \ request_list.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/protocol/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/protocol/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_protocol.la: $(libsub_protocol_la_OBJECTS) $(libsub_protocol_la_DEPENDENCIES) $(EXTRA_libsub_protocol_la_DEPENDENCIES) $(CXXLINK) $(libsub_protocol_la_OBJECTS) $(libsub_protocol_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extensions.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handshake.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handshake_encryption.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handshake_manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initial_seed.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer_connection_base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer_connection_leech.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer_connection_metadata.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer_factory.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/request_list.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/protocol/peer_chunks.h000644 000765 000024 00000010263 11705767056 022050 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_PEER_CHUNKS_H #define LIBTORRENT_PROTOCOL_PEER_CHUNKS_H #include #include #include #include "net/throttle_node.h" #include "torrent/bitfield.h" #include "torrent/data/piece.h" #include "torrent/rate.h" namespace torrent { class PeerInfo; class PeerChunks { public: typedef std::list piece_list_type; PeerChunks(); bool is_seeder() const { return m_bitfield.is_all_set(); } PeerInfo* peer_info() { return m_peerInfo; } const PeerInfo* peer_info() const { return m_peerInfo; } void set_peer_info(PeerInfo* p) { m_peerInfo = p; } bool using_counter() const { return m_usingCounter; } void set_using_counter(bool state) { m_usingCounter = state; } Bitfield* bitfield() { return &m_bitfield; } const Bitfield* bitfield() const { return &m_bitfield; } rak::partial_queue* download_cache() { return &m_downloadCache; } piece_list_type* upload_queue() { return &m_uploadQueue; } const piece_list_type* upload_queue() const { return &m_uploadQueue; } piece_list_type* cancel_queue() { return &m_cancelQueue; } // Timer used to figure out what HAVE_PIECE messages have not been // sent. rak::timer have_timer() const { return m_haveTimer; } void set_have_timer(rak::timer t) { m_haveTimer = t; } Rate* peer_rate() { return &m_peerRate; } const Rate* peer_rate() const { return &m_peerRate; } ThrottleNode* download_throttle() { return &m_downloadThrottle; } const ThrottleNode* download_throttle() const { return &m_downloadThrottle; } ThrottleNode* upload_throttle() { return &m_uploadThrottle; } const ThrottleNode* upload_throttle() const { return &m_uploadThrottle; } private: PeerInfo* m_peerInfo; bool m_usingCounter; Bitfield m_bitfield; rak::partial_queue m_downloadCache; piece_list_type m_uploadQueue; piece_list_type m_cancelQueue; rak::timer m_haveTimer; Rate m_peerRate; ThrottleNode m_downloadThrottle; ThrottleNode m_uploadThrottle; }; inline PeerChunks::PeerChunks() : m_peerInfo(NULL), m_usingCounter(false), m_peerRate(600), m_downloadThrottle(30), m_uploadThrottle(30) { } } #endif libtorrent-0.13.2/src/protocol/peer_connection_base.cc000644 000765 000024 00000100300 11740502002 024005 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include "data/chunk_iterator.h" #include "data/chunk_list.h" #include "download/chunk_selector.h" #include "download/chunk_statistics.h" #include "download/download_main.h" #include "net/socket_base.h" #include "torrent/exceptions.h" #include "torrent/data/block.h" #include "torrent/chunk_manager.h" #include "torrent/connection_manager.h" #include "torrent/download_info.h" #include "torrent/throttle.h" #include "torrent/download/choke_group.h" #include "torrent/download/choke_queue.h" #include "torrent/peer/peer_info.h" #include "torrent/peer/connection_list.h" #include "torrent/utils/log_files.h" #include "extensions.h" #include "peer_connection_base.h" #include "manager.h" namespace torrent { PeerConnectionBase::PeerConnectionBase() : m_download(NULL), m_down(new ProtocolRead()), m_up(new ProtocolWrite()), m_downStall(0), m_downInterested(false), m_downUnchoked(false), m_sendChoked(false), m_sendInterested(false), m_tryRequest(true), m_sendPEXMask(0), m_encryptBuffer(NULL), m_extensions(NULL), m_incoreContinous(false) { m_peerInfo = NULL; } PeerConnectionBase::~PeerConnectionBase() { delete m_up; delete m_down; delete m_encryptBuffer; if (m_extensions != NULL && !m_extensions->is_default()) delete m_extensions; m_extensionMessage.clear(); } void PeerConnectionBase::initialize(DownloadMain* download, PeerInfo* peerInfo, SocketFd fd, Bitfield* bitfield, EncryptionInfo* encryptionInfo, ProtocolExtension* extensions) { if (get_fd().is_valid()) throw internal_error("Tried to re-set PeerConnection."); if (!fd.is_valid()) throw internal_error("PeerConnectionBase::set(...) received bad input."); if (encryptionInfo->is_encrypted() != encryptionInfo->decrypt_valid()) throw internal_error("Encryption and decryption inconsistent."); set_fd(fd); m_peerInfo = peerInfo; m_download = download; m_encryption = *encryptionInfo; m_extensions = extensions; m_extensions->set_connection(this); m_upChoke.set_entry(m_download->up_group_entry()); m_downChoke.set_entry(m_download->down_group_entry()); m_peerChunks.set_peer_info(m_peerInfo); m_peerChunks.bitfield()->swap(*bitfield); std::pair throttles = m_download->throttles(m_peerInfo->socket_address()); m_up->set_throttle(throttles.first); m_down->set_throttle(throttles.second); m_peerChunks.upload_throttle()->set_list_iterator(m_up->throttle()->end()); m_peerChunks.upload_throttle()->slot_activate(rak::make_mem_fun(static_cast(this), &SocketBase::receive_throttle_up_activate)); m_peerChunks.download_throttle()->set_list_iterator(m_down->throttle()->end()); m_peerChunks.download_throttle()->slot_activate(rak::make_mem_fun(static_cast(this), &SocketBase::receive_throttle_down_activate)); download_queue()->set_delegator(m_download->delegator()); download_queue()->set_peer_chunks(&m_peerChunks); try { initialize_custom(); } catch (close_connection& e) { // The handshake manager closes the socket for us. m_peerInfo = NULL; m_download = NULL; m_extensions = NULL; get_fd().clear(); return; } manager->poll()->open(this); manager->poll()->insert_read(this); manager->poll()->insert_write(this); manager->poll()->insert_error(this); m_timeLastRead = cachedTime; m_download->chunk_statistics()->received_connect(&m_peerChunks); // Hmm... cleanup? // update_interested(); m_peerChunks.download_cache()->clear(); if (!m_download->file_list()->is_done()) { m_sendInterested = true; m_downInterested = true; } } void PeerConnectionBase::cleanup() { if (!get_fd().is_valid()) return; if (m_download == NULL) throw internal_error("PeerConnection::~PeerConnection() m_fd is valid but m_state and/or m_net is NULL"); m_downloadQueue.clear(); up_chunk_release(); down_chunk_release(); m_download->info()->set_upload_unchoked(m_download->info()->upload_unchoked() - m_upChoke.unchoked()); m_download->info()->set_download_unchoked(m_download->info()->download_unchoked() - m_downChoke.unchoked()); m_download->choke_group()->up_queue()->disconnected(this, &m_upChoke); m_download->choke_group()->down_queue()->disconnected(this, &m_downChoke); m_download->chunk_statistics()->received_disconnect(&m_peerChunks); if (!m_extensions->is_default()) m_extensions->cleanup(); manager->poll()->remove_read(this); manager->poll()->remove_write(this); manager->poll()->remove_error(this); manager->poll()->close(this); manager->connection_manager()->dec_socket_count(); get_fd().close(); get_fd().clear(); m_up->throttle()->erase(m_peerChunks.upload_throttle()); m_down->throttle()->erase(m_peerChunks.download_throttle()); m_up->set_state(ProtocolWrite::INTERNAL_ERROR); m_down->set_state(ProtocolRead::INTERNAL_ERROR); m_download = NULL; } void PeerConnectionBase::set_upload_snubbed(bool v) { if (v) m_download->choke_group()->up_queue()->set_snubbed(this, &m_upChoke); else m_download->choke_group()->up_queue()->set_not_snubbed(this, &m_upChoke); } bool PeerConnectionBase::receive_upload_choke(bool choke) { if (choke == m_upChoke.choked()) throw internal_error("PeerConnectionBase::receive_upload_choke(...) already set to the same state."); write_insert_poll_safe(); m_sendChoked = true; m_upChoke.set_unchoked(!choke); m_upChoke.set_time_last_choke(cachedTime.usec()); if (choke) { m_download->info()->set_upload_unchoked(m_download->info()->upload_unchoked() - 1); m_upChoke.entry()->connection_choked(this); m_upChoke.entry()->connection_queued(this); m_download->choke_group()->up_queue()->modify_currently_unchoked(-1); m_download->choke_group()->up_queue()->modify_currently_queued(1); } else { m_download->info()->set_upload_unchoked(m_download->info()->upload_unchoked() + 1); m_upChoke.entry()->connection_unqueued(this); m_upChoke.entry()->connection_unchoked(this); m_download->choke_group()->up_queue()->modify_currently_unchoked(1); m_download->choke_group()->up_queue()->modify_currently_queued(-1); } return true; } bool PeerConnectionBase::receive_download_choke(bool choke) { if (choke == m_downChoke.choked()) throw internal_error("PeerConnectionBase::receive_download_choke(...) already set to the same state."); write_insert_poll_safe(); m_downChoke.set_unchoked(!choke); m_downChoke.set_time_last_choke(cachedTime.usec()); if (choke) { m_download->info()->set_download_unchoked(m_download->info()->download_unchoked() - 1); m_downChoke.entry()->connection_choked(this); m_downChoke.entry()->connection_queued(this); m_download->choke_group()->down_queue()->modify_currently_unchoked(-1); m_download->choke_group()->down_queue()->modify_currently_queued(1); } else { m_download->info()->set_download_unchoked(m_download->info()->download_unchoked() + 1); m_downChoke.entry()->connection_unqueued(this); m_downChoke.entry()->connection_unchoked(this); m_download->choke_group()->down_queue()->modify_currently_unchoked(1); m_download->choke_group()->down_queue()->modify_currently_queued(-1); } if (choke) { m_peerChunks.download_cache()->disable(); // If the queue isn't empty, then we might still receive some // pieces, so don't remove us from throttle or release the chunk. if (!download_queue()->is_downloading() && download_queue()->queued_empty()) { m_down->throttle()->erase(m_peerChunks.download_throttle()); down_chunk_release(); } // Send uninterested if unchoked, but only _after_ receiving our // chunks? if (m_downUnchoked) { // Tell the peer we're no longer interested to avoid // disconnects. We keep the connection in the queue so that // ChokeManager::cycle(...) can attempt to get us unchoked // again. m_sendInterested = m_downInterested; m_downInterested = false; } else { // Remove from queue so that an unchoke from the remote peer // will cause the connection to be unchoked immediately by the // choke manager. // // TODO: This doesn't seem safe... m_download->choke_group()->down_queue()->set_not_queued(this, &m_downChoke); return false; } } else { m_tryRequest = true; if (!m_downInterested) { // We were marked as not interested by the cycling choke and // kept in the queue, thus the peer should have some pieces of // interest. // // We have now been 'unchoked' by the choke manager, so tell the // peer that we're again interested. If the peer doesn't unchoke // us within a cycle or two we're likely to be choked and left // out of the queue. So if the peer unchokes us at a later time, // we skip the queue and unchoke immediately. m_sendInterested = !m_downInterested; m_downInterested = true; } } return true; } void PeerConnectionBase::load_up_chunk() { if (m_upChunk.is_valid() && m_upChunk.index() == m_upPiece.index()) { // Better checking needed. // m_upChunk.chunk()->preload(m_upPiece.offset(), m_upChunk.chunk()->size()); if (log_files[LOG_MINCORE_STATS].is_open()) log_mincore_stats_func(m_upChunk.chunk()->is_incore(m_upPiece.offset(), m_upPiece.length()), false, m_incoreContinous); return; } up_chunk_release(); m_upChunk = m_download->chunk_list()->get(m_upPiece.index()); if (!m_upChunk.is_valid()) throw storage_error("File chunk read error: " + std::string(m_upChunk.error_number().c_str())); if (is_encrypted() && m_encryptBuffer == NULL) { m_encryptBuffer = new EncryptBuffer(); m_encryptBuffer->reset(); } m_incoreContinous = false; if (log_files[LOG_MINCORE_STATS].is_open()) log_mincore_stats_func(m_upChunk.chunk()->is_incore(m_upPiece.offset(), m_upPiece.length()), true, m_incoreContinous); m_incoreContinous = true; // Also check if we've already preloaded in the recent past, even // past unmaps. ChunkManager* cm = manager->chunk_manager(); uint32_t preloadSize = m_upChunk.chunk()->chunk_size() - m_upPiece.offset(); if (cm->preload_type() == 0 || m_upChunk.object()->time_preloaded() >= cachedTime - rak::timer::from_seconds(60) || preloadSize < cm->preload_min_size() || m_peerChunks.upload_throttle()->rate()->rate() < cm->preload_required_rate() * ((preloadSize + (2 << 20) - 1) / (2 << 20))) { cm->inc_stats_not_preloaded(); return; } cm->inc_stats_preloaded(); m_upChunk.object()->set_time_preloaded(cachedTime); m_upChunk.chunk()->preload(m_upPiece.offset(), m_upChunk.chunk()->chunk_size(), cm->preload_type() == 1); } void PeerConnectionBase::cancel_transfer(BlockTransfer* transfer) { if (!get_fd().is_valid()) throw internal_error("PeerConnectionBase::cancel_transfer(...) !get_fd().is_valid()."); // We don't send cancel messages if the transfer has already // started. if (transfer == m_downloadQueue.transfer()) return; write_insert_poll_safe(); m_peerChunks.cancel_queue()->push_back(transfer->piece()); // m_downloadQueue.cancel_transfer(transfer); } void PeerConnectionBase::event_error() { m_download->connection_list()->erase(this, 0); } bool PeerConnectionBase::should_connection_unchoke(choke_queue* cq) const { if (cq == m_download->choke_group()->up_queue()) return m_download->info()->upload_unchoked() < m_download->up_group_entry()->max_slots(); if (cq == m_download->choke_group()->down_queue()) return m_download->info()->download_unchoked() < m_download->down_group_entry()->max_slots(); return true; } bool PeerConnectionBase::down_chunk_start(const Piece& piece) { if (!download_queue()->downloading(piece)) { if (piece.length() == 0) rak::slot_list_call(m_download->info()->signal_network_log(), "Received piece with length zero."); return false; } if (!m_download->file_list()->is_valid_piece(piece)) throw internal_error("Incoming pieces list contains a bad piece."); if (!m_downChunk.is_valid() || piece.index() != m_downChunk.index()) { down_chunk_release(); m_downChunk = m_download->chunk_list()->get(piece.index(), ChunkList::get_writable); if (!m_downChunk.is_valid()) throw storage_error("File chunk write error: " + std::string(m_downChunk.error_number().c_str()) + "."); } return m_downloadQueue.transfer()->is_leader(); } void PeerConnectionBase::down_chunk_finished() { if (!download_queue()->transfer()->is_finished()) throw internal_error("PeerConnectionBase::down_chunk_finished() Transfer not finished."); if (download_queue()->transfer()->is_leader()) { if (!m_downChunk.is_valid()) throw internal_error("PeerConnectionBase::down_chunk_finished() Transfer is the leader, but no chunk allocated."); download_queue()->finished(); m_downChunk.object()->set_time_modified(cachedTime); } else { download_queue()->skipped(); } if (m_downStall > 0) m_downStall--; // We need to release chunks when we're not sure if they will be // used in the near future so as to avoid hitting the address space // limit in high-bandwidth situations. // // Some tweaking of the pipe size might be necessary if the queue // empties too often. if (m_downChunk.is_valid() && (download_queue()->queued_empty() || m_downChunk.index() != download_queue()->next_queued_piece().index())) down_chunk_release(); // If we were choked by choke_manager but still had queued pieces, // then we might still be in the throttle. if (m_downChoke.choked() && download_queue()->queued_empty()) m_down->throttle()->erase(m_peerChunks.download_throttle()); write_insert_poll_safe(); } bool PeerConnectionBase::down_chunk() { if (!m_down->throttle()->is_throttled(m_peerChunks.download_throttle())) throw internal_error("PeerConnectionBase::down_chunk() tried to read a piece but is not in throttle list"); if (!m_downChunk.chunk()->is_writable()) throw internal_error("PeerConnectionBase::down_part() chunk not writable, permission denided"); uint32_t quota = m_down->throttle()->node_quota(m_peerChunks.download_throttle()); if (quota == 0) { manager->poll()->remove_read(this); m_down->throttle()->node_deactivate(m_peerChunks.download_throttle()); return false; } uint32_t bytesTransfered = 0; BlockTransfer* transfer = m_downloadQueue.transfer(); Chunk::data_type data; ChunkIterator itr(m_downChunk.chunk(), transfer->piece().offset() + transfer->position(), transfer->piece().offset() + std::min(transfer->position() + quota, transfer->piece().length())); do { data = itr.data(); data.second = read_stream_throws(data.first, data.second); if (is_encrypted()) m_encryption.decrypt(data.first, data.second); bytesTransfered += data.second; } while (data.second != 0 && itr.forward(data.second)); transfer->adjust_position(bytesTransfered); m_down->throttle()->node_used(m_peerChunks.download_throttle(), bytesTransfered); m_download->info()->mutable_down_rate()->insert(bytesTransfered); return transfer->is_finished(); } bool PeerConnectionBase::down_chunk_from_buffer() { m_down->buffer()->consume(down_chunk_process(m_down->buffer()->position(), m_down->buffer()->remaining())); if (!m_downloadQueue.transfer()->is_finished() && m_down->buffer()->remaining() != 0) throw internal_error("PeerConnectionBase::down_chunk_from_buffer() !transfer->is_finished() && m_down->buffer()->remaining() != 0."); return m_downloadQueue.transfer()->is_finished(); } // When this transfer again becomes the leader, we just return false // and wait for the next polling. It is an exceptional case so we // don't really care that much about performance. bool PeerConnectionBase::down_chunk_skip() { ThrottleList* throttle = m_down->throttle(); if (!throttle->is_throttled(m_peerChunks.download_throttle())) throw internal_error("PeerConnectionBase::down_chunk_skip() tried to read a piece but is not in throttle list"); uint32_t quota = throttle->node_quota(m_peerChunks.download_throttle()); if (quota == 0) { manager->poll()->remove_read(this); throttle->node_deactivate(m_peerChunks.download_throttle()); return false; } uint32_t length = read_stream_throws(m_nullBuffer, std::min(quota, m_downloadQueue.transfer()->piece().length() - m_downloadQueue.transfer()->position())); throttle->node_used(m_peerChunks.download_throttle(), length); if (is_encrypted()) m_encryption.decrypt(m_nullBuffer, length); if (down_chunk_skip_process(m_nullBuffer, length) != length) throw internal_error("PeerConnectionBase::down_chunk_skip() down_chunk_skip_process(m_nullBuffer, length) != length."); return m_downloadQueue.transfer()->is_finished(); } bool PeerConnectionBase::down_chunk_skip_from_buffer() { m_down->buffer()->consume(down_chunk_skip_process(m_down->buffer()->position(), m_down->buffer()->remaining())); return m_downloadQueue.transfer()->is_finished(); } // Process data from a leading transfer. uint32_t PeerConnectionBase::down_chunk_process(const void* buffer, uint32_t length) { if (!m_downChunk.is_valid() || m_downChunk.index() != m_downloadQueue.transfer()->index()) throw internal_error("PeerConnectionBase::down_chunk_process(...) !m_downChunk.is_valid() || m_downChunk.index() != m_downloadQueue.transfer()->index()."); if (length == 0) return length; BlockTransfer* transfer = m_downloadQueue.transfer(); length = std::min(transfer->piece().length() - transfer->position(), length); m_downChunk.chunk()->from_buffer(buffer, transfer->piece().offset() + transfer->position(), length); transfer->adjust_position(length); m_down->throttle()->node_used(m_peerChunks.download_throttle(), length); m_download->info()->mutable_down_rate()->insert(length); return length; } // Process data from non-leading transfer. If this transfer encounters // mismatching data with the leader then bork this transfer. If we get // ahead of the leader, we switch the leader. uint32_t PeerConnectionBase::down_chunk_skip_process(const void* buffer, uint32_t length) { BlockTransfer* transfer = m_downloadQueue.transfer(); // Adjust 'length' to be less than or equal to what is remaining of // the block to simplify the rest of the function. length = std::min(length, transfer->piece().length() - transfer->position()); // Hmm, this might result in more bytes than nessesary being // counted. m_down->throttle()->node_used(m_peerChunks.download_throttle(), length); m_download->info()->mutable_down_rate()->insert(length); m_download->info()->mutable_skip_rate()->insert(length); if (!transfer->is_valid()) { transfer->adjust_position(length); return length; } if (!transfer->block()->is_transfering()) throw internal_error("PeerConnectionBase::down_chunk_skip_process(...) block is not transferring, yet we have non-leaders."); // Temporary test. if (transfer->position() > transfer->block()->leader()->position()) throw internal_error("PeerConnectionBase::down_chunk_skip_process(...) transfer is past the Block's position."); // If the transfer is valid, compare the downloaded data to the // leader. uint32_t compareLength = std::min(length, transfer->block()->leader()->position() - transfer->position()); // The data doesn't match with what has previously been downloaded, // bork this transfer. if (!m_downChunk.chunk()->compare_buffer(buffer, transfer->piece().offset() + transfer->position(), compareLength)) { rak::slot_list_call(m_download->info()->signal_network_log(), "Data does not match what was previously downloaded."); m_downloadQueue.transfer_dissimilar(); m_downloadQueue.transfer()->adjust_position(length); return length; } transfer->adjust_position(compareLength); if (compareLength == length) return length; // Add another check here to see if we really want to be the new // leader. transfer->block()->change_leader(transfer); if (down_chunk_process(static_cast(buffer) + compareLength, length - compareLength) != length - compareLength) throw internal_error("PeerConnectionBase::down_chunk_skip_process(...) down_chunk_process(...) returned wrong value."); return length; } bool PeerConnectionBase::down_extension() { if (m_down->buffer()->remaining()) { uint32_t need = std::min(m_extensions->read_need(), (uint32_t)m_down->buffer()->remaining()); std::memcpy(m_extensions->read_position(), m_down->buffer()->position(), need); m_extensions->read_move(need); m_down->buffer()->consume(need); } if (!m_extensions->is_complete()) { uint32_t bytes = read_stream_throws(m_extensions->read_position(), m_extensions->read_need()); m_down->throttle()->node_used_unthrottled(bytes); if (is_encrypted()) m_encryption.decrypt(m_extensions->read_position(), bytes); m_extensions->read_move(bytes); } // If extension can't be processed yet (due to a pending write), // disable reads until the pending message is completely sent. if (m_extensions->is_complete() && !m_extensions->is_invalid() && !m_extensions->read_done()) { manager->poll()->remove_read(this); return false; } return m_extensions->is_complete(); } inline uint32_t PeerConnectionBase::up_chunk_encrypt(uint32_t quota) { if (m_encryptBuffer == NULL) throw internal_error("PeerConnectionBase::up_chunk: m_encryptBuffer is NULL."); if (quota <= m_encryptBuffer->remaining()) return quota; // Also, consider checking here if the number of bytes remaining in // the buffer is small enought that the cost of moving them would // outweigh the extra context switches, etc. if (m_encryptBuffer->remaining() == 0) { // This handles reset also for new chunk transfers. m_encryptBuffer->reset(); quota = std::min(quota, m_encryptBuffer->reserved()); } else { quota = std::min(quota - m_encryptBuffer->remaining(), m_encryptBuffer->reserved_left()); } m_upChunk.chunk()->to_buffer(m_encryptBuffer->end(), m_upPiece.offset() + m_encryptBuffer->remaining(), quota); m_encryption.encrypt(m_encryptBuffer->end(), quota); m_encryptBuffer->move_end(quota); return m_encryptBuffer->remaining(); } bool PeerConnectionBase::up_chunk() { if (!m_up->throttle()->is_throttled(m_peerChunks.upload_throttle())) throw internal_error("PeerConnectionBase::up_chunk() tried to write a piece but is not in throttle list"); if (!m_upChunk.chunk()->is_readable()) throw internal_error("ProtocolChunk::write_part() chunk not readable, permission denided"); uint32_t quota = m_up->throttle()->node_quota(m_peerChunks.upload_throttle()); if (quota == 0) { manager->poll()->remove_write(this); m_up->throttle()->node_deactivate(m_peerChunks.upload_throttle()); return false; } uint32_t bytesTransfered = 0; if (is_encrypted()) { // Prepare as many bytes as quota specifies, up to end of piece or // buffer. Only bytes beyond remaining() are new and will be // encrypted. quota = up_chunk_encrypt(std::min(quota, m_upPiece.length())); bytesTransfered = write_stream_throws(m_encryptBuffer->position(), quota); m_encryptBuffer->consume(bytesTransfered); } else { Chunk::data_type data; ChunkIterator itr(m_upChunk.chunk(), m_upPiece.offset(), m_upPiece.offset() + std::min(quota, m_upPiece.length())); do { data = itr.data(); data.second = write_stream_throws(data.first, data.second); bytesTransfered += data.second; } while (data.second != 0 && itr.forward(data.second)); } m_up->throttle()->node_used(m_peerChunks.upload_throttle(), bytesTransfered); m_download->info()->mutable_up_rate()->insert(bytesTransfered); // Just modifying the piece to cover the remaining data ends up // being much cleaner and we avoid an unnessesary position variable. m_upPiece.set_offset(m_upPiece.offset() + bytesTransfered); m_upPiece.set_length(m_upPiece.length() - bytesTransfered); return m_upPiece.length() == 0; } bool PeerConnectionBase::up_extension() { if (m_extensionOffset == extension_must_encrypt) { if (m_extensionMessage.owned()) { m_encryption.encrypt(m_extensionMessage.data(), m_extensionMessage.length()); } else { char* buffer = new char[m_extensionMessage.length()]; m_encryption.encrypt(m_extensionMessage.data(), buffer, m_extensionMessage.length()); m_extensionMessage.set(buffer, buffer + m_extensionMessage.length(), true); } m_extensionOffset = 0; } if (m_extensionOffset >= m_extensionMessage.length()) throw internal_error("PeerConnectionBase::up_extension bad offset."); uint32_t written = write_stream_throws(m_extensionMessage.data() + m_extensionOffset, m_extensionMessage.length() - m_extensionOffset); m_up->throttle()->node_used_unthrottled(written); m_extensionOffset += written; if (m_extensionOffset < m_extensionMessage.length()) return false; m_extensionMessage.clear(); // If we have an unprocessed message, process it now and enable reads again. if (m_extensions->is_complete() && !m_extensions->is_invalid()) { // DEBUG: What, this should fail when we block, no? if (!m_extensions->read_done()) throw internal_error("PeerConnectionBase::up_extension could not process complete extension message."); manager->poll()->insert_read(this); } return true; } void PeerConnectionBase::down_chunk_release() { if (m_downChunk.is_valid()) m_download->chunk_list()->release(&m_downChunk); } void PeerConnectionBase::up_chunk_release() { if (m_upChunk.is_valid()) m_download->chunk_list()->release(&m_upChunk); } void PeerConnectionBase::read_request_piece(const Piece& p) { PeerChunks::piece_list_type::iterator itr = std::find(m_peerChunks.upload_queue()->begin(), m_peerChunks.upload_queue()->end(), p); if (m_upChoke.choked() || itr != m_peerChunks.upload_queue()->end() || p.length() > (1 << 17)) return; m_peerChunks.upload_queue()->push_back(p); write_insert_poll_safe(); } void PeerConnectionBase::read_cancel_piece(const Piece& p) { PeerChunks::piece_list_type::iterator itr = std::find(m_peerChunks.upload_queue()->begin(), m_peerChunks.upload_queue()->end(), p); if (itr != m_peerChunks.upload_queue()->end()) m_peerChunks.upload_queue()->erase(itr); } void PeerConnectionBase::write_prepare_piece() { m_upPiece = m_peerChunks.upload_queue()->front(); m_peerChunks.upload_queue()->pop_front(); // Move these checks somewhere else? if (!m_download->file_list()->is_valid_piece(m_upPiece) || !m_download->file_list()->bitfield()->get(m_upPiece.index())) { char buffer[128]; snprintf(buffer, 128, "Peer requested an invalid piece: %u %u %u", m_upPiece.index(), m_upPiece.length(), m_upPiece.offset()); throw communication_error(buffer); } m_up->write_piece(m_upPiece); } void PeerConnectionBase::write_prepare_extension(int type, const DataBuffer& message) { m_up->write_extension(m_extensions->id(type), message.length()); m_extensionOffset = 0; m_extensionMessage = message; // Need to encrypt the buffer, but not until the m_up // write buffer has been flushed, so flag it for now. if (is_encrypted()) m_extensionOffset = extension_must_encrypt; } // High stall count peers should request if we're *not* in endgame, or // if we're in endgame and the download is too slow. Prefere not to request // from high stall counts when we are doing decent speeds. bool PeerConnectionBase::should_request() { if (m_downChoke.choked() || !m_downInterested || !m_downUnchoked) // || m_down->get_state() == ProtocolRead::READ_SKIP_PIECE) return false; else if (!m_download->delegator()->get_aggressive()) return true; else // We check if the peer is stalled, if it is not then we should // request. If the peer is stalled then we only request if the // download rate is below a certain value. return m_downStall <= 1 || m_download->info()->down_rate()->rate() < (10 << 10); } bool PeerConnectionBase::try_request_pieces() { if (download_queue()->queued_empty()) m_downStall = 0; uint32_t pipeSize = download_queue()->calculate_pipe_size(m_peerChunks.download_throttle()->rate()->rate()); // Don't start requesting if we can't do it in large enough chunks. if (download_queue()->queued_size() >= (pipeSize + 10) / 2) return false; bool success = false; while (download_queue()->queued_size() < pipeSize && m_up->can_write_request()) { // Delegator should return a vector of pieces, and it should be // passed the number of pieces it should delegate. Try to ensure // it receives large enough request to fill a whole chunk if the // peer is fast enough. const Piece* p = download_queue()->delegate(); if (p == NULL) break; if (!m_download->file_list()->is_valid_piece(*p) || !m_peerChunks.bitfield()->get(p->index())) throw internal_error("PeerConnectionBase::try_request_pieces() tried to use an invalid piece."); m_up->write_request(*p); success = true; } return success; } // Send one peer exchange message according to bits set in m_sendPEXMask. // We can only send one message at a time, because the derived class // needs to flush the buffer and call up_extension before the next one. bool PeerConnectionBase::send_pex_message() { if (!m_extensions->is_remote_supported(ProtocolExtension::UT_PEX)) { m_sendPEXMask = 0; return false; } // Message to tell peer to stop/start doing PEX is small so send it first. if (m_sendPEXMask & (PEX_ENABLE | PEX_DISABLE)) { if (!m_extensions->is_remote_supported(ProtocolExtension::UT_PEX)) throw internal_error("PeerConnectionBase::send_pex_message() Not supported by peer."); write_prepare_extension(ProtocolExtension::HANDSHAKE, ProtocolExtension::generate_toggle_message(ProtocolExtension::UT_PEX, (m_sendPEXMask & PEX_ENABLE) != 0)); m_sendPEXMask &= ~(PEX_ENABLE | PEX_DISABLE); } else if (m_sendPEXMask & PEX_DO && m_extensions->id(ProtocolExtension::UT_PEX)) { const DataBuffer& pexMessage = m_download->get_ut_pex(m_extensions->is_initial_pex()); m_extensions->clear_initial_pex(); m_sendPEXMask &= ~PEX_DO; if (pexMessage.empty()) return false; write_prepare_extension(ProtocolExtension::UT_PEX, pexMessage); } else { m_sendPEXMask = 0; } return true; } // Extension protocol needs to send a reply. bool PeerConnectionBase::send_ext_message() { write_prepare_extension(m_extensions->pending_message_type(), m_extensions->pending_message_data()); m_extensions->clear_pending_message(); return true; } void PeerConnectionBase::receive_metadata_piece(uint32_t piece, const char* data, uint32_t length) { } } libtorrent-0.13.2/src/protocol/peer_connection_base.h000644 000765 000024 00000023120 11716630446 023674 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_PEER_CONNECTION_BASE_H #define LIBTORRENT_PROTOCOL_PEER_CONNECTION_BASE_H #include "data/chunk_handle.h" #include "net/socket_stream.h" #include "torrent/poll.h" #include "torrent/peer/peer.h" #include "torrent/peer/choke_status.h" #include "encryption_info.h" #include "extensions.h" #include "peer_chunks.h" #include "protocol_base.h" #include "request_list.h" #include "globals.h" #include "manager.h" namespace torrent { // Base class for peer connection classes. Rename to PeerConnection // when the migration is complete? // // This should really be modularized abit, there's too much stuff in // PeerConnectionBase and its children. Do we use additional layers of // inheritance or member instances? class choke_queue; class DownloadMain; class PeerConnectionBase : public Peer, public SocketStream { public: typedef ProtocolBase ProtocolRead; typedef ProtocolBase ProtocolWrite; #if USE_EXTRA_DEBUG == 666 // For testing, use a really small buffer. typedef ProtocolBuffer<256> EncryptBuffer; #else typedef ProtocolBuffer<16384> EncryptBuffer; #endif // Find an optimal number for this. static const uint32_t read_size = 64; // Bitmasks for peer exchange messages to send. static const int PEX_DO = (1 << 0); static const int PEX_ENABLE = (1 << 1); static const int PEX_DISABLE = (1 << 2); PeerConnectionBase(); virtual ~PeerConnectionBase(); const char* type_name() const { return "pcb"; } void initialize(DownloadMain* download, PeerInfo* p, SocketFd fd, Bitfield* bitfield, EncryptionInfo* encryptionInfo, ProtocolExtension* extensions); void cleanup(); bool is_up_choked() const { return m_upChoke.choked(); } bool is_up_interested() const { return m_upChoke.queued(); } bool is_up_snubbed() const { return m_upChoke.snubbed(); } bool is_down_queued() const { return m_downChoke.queued(); } bool is_down_local_unchoked() const { return m_downChoke.unchoked(); } bool is_down_remote_unchoked() const { return m_downUnchoked; } bool is_down_interested() const { return m_downInterested; } void set_upload_snubbed(bool v); bool is_seeder() const { return m_peerChunks.is_seeder(); } bool is_not_seeder() const { return !m_peerChunks.is_seeder(); } bool is_encrypted() const { return m_encryption.is_encrypted(); } bool is_obfuscated() const { return m_encryption.is_obfuscated(); } PeerInfo* mutable_peer_info() { return m_peerInfo; } PeerChunks* peer_chunks() { return &m_peerChunks; } const PeerChunks* c_peer_chunks() const { return &m_peerChunks; } choke_status* up_choke() { return &m_upChoke; } choke_status* down_choke() { return &m_downChoke; } DownloadMain* download() { return m_download; } RequestList* download_queue() { return &m_downloadQueue; } const RequestList* download_queue() const { return &m_downloadQueue; } ProtocolExtension* extensions() { return m_extensions; } DataBuffer* extension_message() { return &m_extensionMessage; } void do_peer_exchange() { m_sendPEXMask |= PEX_DO; } inline void set_peer_exchange(bool state); // These must be implemented by the child class. virtual void initialize_custom() = 0; virtual void update_interested() = 0; virtual bool receive_keepalive() = 0; bool receive_upload_choke(bool choke); bool receive_download_choke(bool choke); virtual void event_error(); void push_unread(const void* data, uint32_t size); void cancel_transfer(BlockTransfer* transfer); // Insert into the poll unless we're blocking for throttling etc. void read_insert_poll_safe(); void write_insert_poll_safe(); // Communication with the protocol extensions virtual void receive_metadata_piece(uint32_t piece, const char* data, uint32_t length); bool should_connection_unchoke(choke_queue* cq) const; protected: static const uint32_t extension_must_encrypt = ~uint32_t(); inline bool read_remaining(); inline bool write_remaining(); void load_up_chunk(); void read_request_piece(const Piece& p); void read_cancel_piece(const Piece& p); void write_prepare_piece(); void write_prepare_extension(int type, const DataBuffer& message); bool down_chunk_start(const Piece& p); void down_chunk_finished(); bool down_chunk(); bool down_chunk_from_buffer(); bool down_chunk_skip(); bool down_chunk_skip_from_buffer(); uint32_t down_chunk_process(const void* buffer, uint32_t length); uint32_t down_chunk_skip_process(const void* buffer, uint32_t length); bool down_extension(); bool up_chunk(); inline uint32_t up_chunk_encrypt(uint32_t quota); bool up_extension(); void down_chunk_release(); void up_chunk_release(); bool should_request(); bool try_request_pieces(); bool send_pex_message(); bool send_ext_message(); DownloadMain* m_download; ProtocolRead* m_down; ProtocolWrite* m_up; PeerChunks m_peerChunks; RequestList m_downloadQueue; ChunkHandle m_downChunk; uint32_t m_downStall; Piece m_upPiece; ChunkHandle m_upChunk; // The interested state no longer follows the spec's wording as it // has been swapped. // // Thus the same ProtocolBase object now groups the same choke and // interested states togheter, thus for m_up 'interested' means the // remote peer wants upload and 'choke' means we've choked upload to // that peer. // // In the downlod object, 'queued' now means the same as the spec's // 'unchoked', while 'unchoked' means we start requesting pieces. choke_status m_upChoke; choke_status m_downChoke; bool m_downInterested; bool m_downUnchoked; bool m_sendChoked; bool m_sendInterested; bool m_tryRequest; int m_sendPEXMask; rak::timer m_timeLastRead; DataBuffer m_extensionMessage; uint32_t m_extensionOffset; EncryptBuffer* m_encryptBuffer; EncryptionInfo m_encryption; ProtocolExtension* m_extensions; bool m_incoreContinous; }; inline void PeerConnectionBase::set_peer_exchange(bool state) { if (m_extensions->is_default() || !m_extensions->is_remote_supported(ProtocolExtension::UT_PEX)) return; if (state) { m_sendPEXMask = PEX_ENABLE | (m_sendPEXMask & ~PEX_DISABLE); m_extensions->set_local_enabled(ProtocolExtension::UT_PEX); } else { m_sendPEXMask = PEX_DISABLE | (m_sendPEXMask & ~PEX_ENABLE); m_extensions->unset_local_enabled(ProtocolExtension::UT_PEX); } } inline void PeerConnectionBase::push_unread(const void* data, uint32_t size) { std::memcpy(m_down->buffer()->end(), data, size); m_down->buffer()->move_end(size); } inline void PeerConnectionBase::read_insert_poll_safe() { if (m_down->get_state() != ProtocolRead::IDLE) return; manager->poll()->insert_read(this); } inline void PeerConnectionBase::write_insert_poll_safe() { if (m_up->get_state() != ProtocolWrite::IDLE) return; manager->poll()->insert_write(this); } } #endif libtorrent-0.13.2/src/protocol/peer_connection_leech.cc000644 000765 000024 00000060117 11740502002 024166 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include "data/chunk_list_node.h" #include "download/chunk_selector.h" #include "download/chunk_statistics.h" #include "download/download_main.h" #include "torrent/dht_manager.h" #include "torrent/download_info.h" #include "torrent/download/choke_group.h" #include "torrent/download/choke_queue.h" #include "torrent/peer/connection_list.h" #include "torrent/peer/peer_info.h" #include "extensions.h" #include "initial_seed.h" #include "peer_connection_leech.h" namespace torrent { template PeerConnection::~PeerConnection() { // if (m_download != NULL && m_down->get_state() != ProtocolRead::READ_BITFIELD) // m_download->bitfield_counter().dec(m_peerChunks.bitfield()->bitfield()); // priority_queue_erase(&taskScheduler, &m_taskSendChoke); } template void PeerConnection::initialize_custom() { if (type == Download::CONNECTION_INITIAL_SEED) { if (m_download->initial_seeding() == NULL) throw close_connection(); m_download->initial_seeding()->new_peer(this); } // if (m_download->content()->chunks_completed() != 0) { // m_up->write_bitfield(m_download->file_list()->bitfield()->size_bytes()); // m_up->buffer()->prepare_end(); // m_up->set_position(0); // m_up->set_state(ProtocolWrite::WRITE_BITFIELD_HEADER); // } } template void PeerConnection::update_interested() { if (type != Download::CONNECTION_LEECH) return; m_peerChunks.download_cache()->clear(); if (m_downInterested) return; // Consider just setting to interested without checking the // bitfield. The status might change by the time we get unchoked // anyway. m_sendInterested = !m_downInterested; m_downInterested = true; // Hmm... does this belong here, or should we insert ourselves into // the queue when we receive the unchoke? // m_download->choke_group()->down_queue()->set_queued(this, &m_downChoke); } template bool PeerConnection::receive_keepalive() { if (cachedTime - m_timeLastRead > rak::timer::from_seconds(240)) return false; // There's no point in adding ourselves to the write poll if the // buffer is full, as that will already have been taken care of. if (m_up->get_state() == ProtocolWrite::IDLE && m_up->can_write_keepalive()) { write_insert_poll_safe(); ProtocolBuffer<512>::iterator old_end = m_up->buffer()->end(); m_up->write_keepalive(); if (is_encrypted()) m_encryption.encrypt(old_end, m_up->buffer()->end() - old_end); } if (type != Download::CONNECTION_LEECH) return true; m_tryRequest = true; // Stall pieces when more than one receive_keepalive() has been // called while a single piece is downloading. // // m_downStall is decremented for every successfull download, so it // should stay at zero or one when downloading at an acceptable // speed. Thus only when m_downStall >= 2 is the download actually // stalling. // // If more than 6 ticks have gone by, assume the peer forgot about // our requests or tried to cheat with empty piece messages, and try // again. // TODO: Do we need to remove from download throttle here? // // Do we also need to remove from download throttle? Check how it // worked again. if (!download_queue()->canceled_empty() && m_downStall >= 6) download_queue()->cancel(); else if (!download_queue()->queued_empty() && m_downStall++ != 0) download_queue()->stall(); return true; } // We keep the message in the buffer if it is incomplete instead of // keeping the state and remembering the read information. This // shouldn't happen very often compared to full reads. template inline bool PeerConnection::read_message() { ProtocolBuffer<512>* buf = m_down->buffer(); if (buf->remaining() < 4) return false; // Remember the start of the message so we may reset it if we don't // have the whole message. ProtocolBuffer<512>::iterator beginning = buf->position(); uint32_t length = buf->read_32(); if (length == 0) { // Keepalive message. m_down->set_last_command(ProtocolBase::KEEP_ALIVE); return true; } else if (buf->remaining() < 1) { buf->set_position_itr(beginning); return false; } else if (length > (1 << 20)) { throw communication_error("PeerConnection::read_message() got an invalid message length."); } // We do not verify the message length of those with static // length. A bug in the remote client causing the message start to // be unsyncronized would in practically all cases be caught with // the above test. // // Those that do in some weird way manage to produce a valid // command, will not be able to do any more damage than a malicious // peer. Those cases should be caught elsewhere in the code. // Temporary. m_down->set_last_command((ProtocolBase::Protocol)buf->peek_8()); switch (buf->read_8()) { case ProtocolBase::CHOKE: if (type != Download::CONNECTION_LEECH) return true; // Cancel before dequeueing so receive_download_choke knows if it // should remove us from throttle. // // Hmm... that won't work, as we arn't necessarily unchoked when // in throttle. // Which needs to be done before, and which after calling choke // manager? m_downUnchoked = false; down_chunk_release(); download_queue()->cancel(); m_download->choke_group()->down_queue()->set_not_queued(this, &m_downChoke); m_down->throttle()->erase(m_peerChunks.download_throttle()); return true; case ProtocolBase::UNCHOKE: if (type != Download::CONNECTION_LEECH) return true; m_downUnchoked = true; // Some peers unchoke us even though we're not interested, so we // need to ensure it doesn't get added to the queue. if (!m_downInterested) return true; m_download->choke_group()->down_queue()->set_queued(this, &m_downChoke); return true; case ProtocolBase::INTERESTED: if (type == Download::CONNECTION_LEECH && m_peerChunks.bitfield()->is_all_set()) return true; m_download->choke_group()->up_queue()->set_queued(this, &m_upChoke); return true; case ProtocolBase::NOT_INTERESTED: m_download->choke_group()->up_queue()->set_not_queued(this, &m_upChoke); return true; case ProtocolBase::HAVE: if (!m_down->can_read_have_body()) break; read_have_chunk(buf->read_32()); return true; case ProtocolBase::REQUEST: if (!m_down->can_read_request_body()) break; if (!m_upChoke.choked()) { write_insert_poll_safe(); read_request_piece(m_down->read_request()); } else { m_down->read_request(); } return true; case ProtocolBase::PIECE: if (type != Download::CONNECTION_LEECH) throw communication_error("Received a piece but the connection is strictly for seeding."); if (!m_down->can_read_piece_body()) break; if (!down_chunk_start(m_down->read_piece(length - 9))) { // We don't want this chunk. if (down_chunk_skip_from_buffer()) { m_tryRequest = true; down_chunk_finished(); return true; } else { m_down->set_state(ProtocolRead::READ_SKIP_PIECE); m_down->throttle()->insert(m_peerChunks.download_throttle()); return false; } } else { if (down_chunk_from_buffer()) { m_tryRequest = true; down_chunk_finished(); return true; } else { m_down->set_state(ProtocolRead::READ_PIECE); m_down->throttle()->insert(m_peerChunks.download_throttle()); return false; } } case ProtocolBase::CANCEL: if (!m_down->can_read_cancel_body()) break; read_cancel_piece(m_down->read_request()); return true; case ProtocolBase::PORT: if (!m_down->can_read_port_body()) break; manager->dht_manager()->add_node(m_peerInfo->socket_address(), m_down->buffer()->read_16()); return true; case ProtocolBase::EXTENSION_PROTOCOL: if (!m_down->can_read_extension_body()) break; if (m_extensions->is_default()) { m_extensions = new ProtocolExtension(); m_extensions->set_info(m_peerInfo, m_download); } { int extension = m_down->buffer()->read_8(); m_extensions->read_start(extension, length - 2, (extension == ProtocolExtension::UT_PEX) && !m_download->want_pex_msg()); m_down->set_state(ProtocolRead::READ_EXTENSION); } if (!down_extension()) return false; if (m_extensions->has_pending_message()) write_insert_poll_safe(); m_down->set_state(ProtocolRead::IDLE); return true; default: throw communication_error("Received unsupported message type."); } // We were unsuccessfull in reading the message, need more data. buf->set_position_itr(beginning); return false; } template void PeerConnection::event_read() { m_timeLastRead = cachedTime; // Need to make sure ProtocolBuffer::end() is pointing to the end of // the unread data, and that the unread data starts from the // beginning of the buffer. Or do we use position? Propably best, // therefor ProtocolBuffer::position() points to the beginning of // the unused data. try { // Normal read. // // We rarely will read zero bytes as the read of 64 bytes will // almost always either not fill up or it will require additional // reads. // // Only loop when end hits 64. do { switch (m_down->get_state()) { case ProtocolRead::IDLE: if (m_down->buffer()->size_end() < read_size) { unsigned int length = read_stream_throws(m_down->buffer()->end(), read_size - m_down->buffer()->size_end()); m_down->throttle()->node_used_unthrottled(length); if (is_encrypted()) m_encryption.decrypt(m_down->buffer()->end(), length); m_down->buffer()->move_end(length); } while (read_message()); if (m_down->buffer()->size_end() == read_size) { m_down->buffer()->move_unused(); break; } else { m_down->buffer()->move_unused(); return; } case ProtocolRead::READ_PIECE: if (type != Download::CONNECTION_LEECH) return; if (!download_queue()->is_downloading()) throw internal_error("ProtocolRead::READ_PIECE state but RequestList is not downloading."); if (!m_downloadQueue.transfer()->is_valid() || !m_downloadQueue.transfer()->is_leader()) { m_down->set_state(ProtocolRead::READ_SKIP_PIECE); break; } if (!down_chunk()) return; m_tryRequest = true; m_down->set_state(ProtocolRead::IDLE); down_chunk_finished(); break; case ProtocolRead::READ_SKIP_PIECE: if (type != Download::CONNECTION_LEECH) return; if (download_queue()->transfer()->is_leader()) { m_down->set_state(ProtocolRead::READ_PIECE); break; } if (!down_chunk_skip()) return; m_tryRequest = true; m_down->set_state(ProtocolRead::IDLE); down_chunk_finished(); break; case ProtocolRead::READ_EXTENSION: if (!down_extension()) return; if (m_extensions->has_pending_message()) write_insert_poll_safe(); m_down->set_state(ProtocolRead::IDLE); break; default: throw internal_error("PeerConnection::event_read() wrong state."); } // Figure out how to get rid of the shouldLoop boolean. } while (true); // Exception handlers: } catch (close_connection& e) { m_download->connection_list()->erase(this, 0); } catch (blocked_connection& e) { rak::slot_list_call(m_download->info()->signal_network_log(), "Momentarily blocked read connection."); m_download->connection_list()->erase(this, 0); } catch (network_error& e) { rak::slot_list_call(m_download->info()->signal_network_log(), (rak::socket_address::cast_from(m_peerInfo->socket_address())->address_str() + " " + rak::copy_escape_html(std::string(m_peerInfo->id().c_str(), 8)) + ": " + e.what()).c_str()); m_download->connection_list()->erase(this, 0); } catch (storage_error& e) { rak::slot_list_call(m_download->info()->signal_storage_error(), e.what()); m_download->connection_list()->erase(this, 0); } catch (base_error& e) { std::stringstream s; s << "Connection read fd(" << get_fd().get_fd() << ',' << m_down->get_state() << ',' << m_down->last_command() << ") \"" << e.what() << '"'; s << " '" << rak::copy_escape_html((char*)m_down->buffer()->begin(), (char*)m_down->buffer()->position()) << "'"; throw internal_error(s.str()); } } template inline void PeerConnection::fill_write_buffer() { ProtocolBuffer<512>::iterator old_end = m_up->buffer()->end(); // No need to use delayed choke ever. if (m_sendChoked && m_up->can_write_choke()) { m_sendChoked = false; m_up->write_choke(m_upChoke.choked()); if (m_upChoke.choked()) { m_up->throttle()->erase(m_peerChunks.upload_throttle()); up_chunk_release(); m_peerChunks.upload_queue()->clear(); if (m_encryptBuffer != NULL) { if (m_encryptBuffer->remaining()) throw internal_error("Deleting encryptBuffer with encrypted data remaining."); delete m_encryptBuffer; m_encryptBuffer = NULL; } } else { m_up->throttle()->insert(m_peerChunks.upload_throttle()); } } // Send the interested state before any requests as some clients, // e.g. BitTornado 0.7.14 and uTorrent 0.3.0, disconnect if a // request has been received while uninterested. The problem arises // as they send unchoke before receiving interested. if (type == Download::CONNECTION_LEECH && m_sendInterested && m_up->can_write_interested()) { m_up->write_interested(m_downInterested); m_sendInterested = false; } if (type == Download::CONNECTION_LEECH && m_tryRequest) { if (!(m_tryRequest = !should_request()) && !(m_tryRequest = try_request_pieces()) && !download_queue()->is_interested_in_active()) { m_sendInterested = true; m_downInterested = false; m_download->choke_group()->down_queue()->set_not_queued(this, &m_downChoke); } } DownloadMain::have_queue_type* haveQueue = m_download->have_queue(); if (type == Download::CONNECTION_LEECH && !haveQueue->empty() && m_peerChunks.have_timer() <= haveQueue->front().first && m_up->can_write_have()) { DownloadMain::have_queue_type::iterator last = std::find_if(haveQueue->begin(), haveQueue->end(), rak::greater(m_peerChunks.have_timer(), rak::mem_ref(&DownloadMain::have_queue_type::value_type::first))); do { m_up->write_have((--last)->second); } while (last != haveQueue->begin() && m_up->can_write_have()); m_peerChunks.set_have_timer(last->first + 1); } if (type == Download::CONNECTION_INITIAL_SEED && m_up->can_write_have()) offer_chunk(); while (type == Download::CONNECTION_LEECH && !m_peerChunks.cancel_queue()->empty() && m_up->can_write_cancel()) { m_up->write_cancel(m_peerChunks.cancel_queue()->front()); m_peerChunks.cancel_queue()->pop_front(); } if (m_sendPEXMask && m_up->can_write_extension() && send_pex_message()) { // Don't do anything else if send_pex_message() succeeded. } else if (m_extensions->has_pending_message() && m_up->can_write_extension() && send_ext_message()) { // Same. } else if (!m_upChoke.choked() && !m_peerChunks.upload_queue()->empty() && m_up->can_write_piece() && (type != Download::CONNECTION_INITIAL_SEED || should_upload())) { write_prepare_piece(); } if (is_encrypted()) m_encryption.encrypt(old_end, m_up->buffer()->end() - old_end); } template void PeerConnection::event_write() { try { do { switch (m_up->get_state()) { case ProtocolWrite::IDLE: fill_write_buffer(); if (m_up->buffer()->remaining() == 0) { manager->poll()->remove_write(this); return; } m_up->set_state(ProtocolWrite::MSG); case ProtocolWrite::MSG: if (!m_up->buffer()->consume(m_up->throttle()->node_used_unthrottled(write_stream_throws(m_up->buffer()->position(), m_up->buffer()->remaining())))) return; m_up->buffer()->reset(); if (m_up->last_command() == ProtocolBase::PIECE) { // We're uploading a piece. load_up_chunk(); m_up->set_state(ProtocolWrite::WRITE_PIECE); // fall through to WRITE_PIECE case below } else if (m_up->last_command() == ProtocolBase::EXTENSION_PROTOCOL) { m_up->set_state(ProtocolWrite::WRITE_EXTENSION); break; } else { // Break or loop? Might do an ifelse based on size of the // write buffer. Also the write buffer is relatively large. m_up->set_state(ProtocolWrite::IDLE); break; } case ProtocolWrite::WRITE_PIECE: if (!up_chunk()) return; m_up->set_state(ProtocolWrite::IDLE); break; case ProtocolWrite::WRITE_EXTENSION: if (!up_extension()) return; m_up->set_state(ProtocolWrite::IDLE); break; default: throw internal_error("PeerConnection::event_write() wrong state."); } } while (true); } catch (close_connection& e) { m_download->connection_list()->erase(this, 0); } catch (blocked_connection& e) { rak::slot_list_call(m_download->info()->signal_network_log(), "Momentarily blocked write connection."); m_download->connection_list()->erase(this, 0); } catch (network_error& e) { rak::slot_list_call(m_download->info()->signal_network_log(), e.what()); m_download->connection_list()->erase(this, 0); } catch (storage_error& e) { rak::slot_list_call(m_download->info()->signal_storage_error(), e.what()); m_download->connection_list()->erase(this, 0); } catch (base_error& e) { std::stringstream s; s << "Connection write fd(" << get_fd().get_fd() << ',' << m_up->get_state() << ',' << m_up->last_command() << ") \"" << e.what() << '"'; throw internal_error(s.str()); } } template void PeerConnection::read_have_chunk(uint32_t index) { if (index >= m_peerChunks.bitfield()->size_bits()) throw communication_error("Peer sent HAVE message with out-of-range index."); if (m_peerChunks.bitfield()->get(index)) return; m_download->chunk_statistics()->received_have_chunk(&m_peerChunks, index, m_download->file_list()->chunk_size()); if (type == Download::CONNECTION_INITIAL_SEED) m_download->initial_seeding()->chunk_seen(index, this); // Disconnect seeds when we are seeding (but not for initial seeding // so that we keep accurate chunk statistics until that is done). if (m_peerChunks.bitfield()->is_all_set()) { if (type == Download::CONNECTION_SEED || (type != Download::CONNECTION_INITIAL_SEED && m_download->file_list()->is_done())) throw close_connection(); m_download->choke_group()->up_queue()->set_not_queued(this, &m_upChoke); } if (type != Download::CONNECTION_LEECH || m_download->file_list()->is_done()) return; if (is_down_interested()) { if (!m_tryRequest && m_download->chunk_selector()->received_have_chunk(&m_peerChunks, index)) { m_tryRequest = true; write_insert_poll_safe(); } } else { if (m_download->chunk_selector()->received_have_chunk(&m_peerChunks, index)) { m_sendInterested = !m_downInterested; m_downInterested = true; // Ensure we get inserted into the choke manager queue in case // the peer keeps us unchoked even though we've said we're not // interested. if (m_downUnchoked) m_download->choke_group()->down_queue()->set_queued(this, &m_downChoke); // Is it enough to insert into write here? Make the interested // check branch to include insert_write, even when not sending // interested. m_tryRequest = true; write_insert_poll_safe(); } } } template<> void PeerConnection::offer_chunk() { // If bytes left to send in this chunk minus bytes about to be sent is zero, // assume the peer will have got the chunk completely. In that case we may // get another one to offer if not enough other peers are interested even // if the peer would otherwise still be blocked. uint32_t bytesLeft = m_data.bytesLeft; if (!m_peerChunks.upload_queue()->empty() && m_peerChunks.upload_queue()->front().index() == m_data.lastIndex) bytesLeft -= m_peerChunks.upload_queue()->front().length(); uint32_t index = m_download->initial_seeding()->chunk_offer(this, bytesLeft == 0 ? m_data.lastIndex : InitialSeeding::no_offer); if (index == InitialSeeding::no_offer || index == m_data.lastIndex) return; m_up->write_have(index); m_data.lastIndex = index; m_data.bytesLeft = m_download->file_list()->chunk_index_size(index); } template<> bool PeerConnection::should_upload() { // For initial seeding, check if chunk is well seeded now, and if so // remove it from the queue to better use our bandwidth on rare chunks. while (!m_peerChunks.upload_queue()->empty() && !m_download->initial_seeding()->should_upload(m_peerChunks.upload_queue()->front().index())) m_peerChunks.upload_queue()->pop_front(); // If queue ends up empty, choke peer to let it know that it // shouldn't wait for the cancelled pieces to be sent. if (m_peerChunks.upload_queue()->empty()) { m_download->choke_group()->up_queue()->set_not_queued(this, &m_upChoke); m_download->choke_group()->up_queue()->set_queued(this, &m_upChoke); // If we're sending the chunk we last offered, adjust bytes left in it. } else if (m_peerChunks.upload_queue()->front().index() == m_data.lastIndex) { m_data.bytesLeft -= m_peerChunks.upload_queue()->front().length(); if (!m_data.bytesLeft) m_data.lastIndex = InitialSeeding::no_offer; } return !m_peerChunks.upload_queue()->empty(); } // Explicit instantiation of the member functions and vtable. template class PeerConnection; template class PeerConnection; template class PeerConnection; } libtorrent-0.13.2/src/protocol/peer_connection_leech.h000644 000765 000024 00000005441 11705767056 024056 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_PEER_CONNECTION_LEECH_H #define LIBTORRENT_PROTOCOL_PEER_CONNECTION_LEECH_H #include "peer_connection_base.h" #include "torrent/download.h" namespace torrent { // Type-specific data. template struct PeerConnectionData; template<> struct PeerConnectionData { }; template<> struct PeerConnectionData { }; template<> struct PeerConnectionData { PeerConnectionData() : lastIndex(~uint32_t()) { } uint32_t lastIndex; uint32_t bytesLeft; }; template class PeerConnection : public PeerConnectionBase { public: ~PeerConnection(); virtual void initialize_custom(); virtual void update_interested(); virtual bool receive_keepalive(); virtual void event_read(); virtual void event_write(); private: inline bool read_message(); void read_have_chunk(uint32_t index); void offer_chunk(); bool should_upload(); inline void fill_write_buffer(); PeerConnectionData m_data; }; } #endif libtorrent-0.13.2/src/protocol/peer_connection_metadata.cc000644 000765 000024 00000035773 11740502002 024700 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "data/chunk_list_node.h" #include "download/chunk_selector.h" #include "download/chunk_statistics.h" #include "download/download_main.h" #include "torrent/dht_manager.h" #include "torrent/download_info.h" #include "torrent/download/choke_queue.h" #include "torrent/peer/connection_list.h" #include "torrent/peer/peer_info.h" #include "rak/functional.h" #include "extensions.h" #include "peer_connection_metadata.h" namespace torrent { PeerConnectionMetadata::~PeerConnectionMetadata() { } void PeerConnectionMetadata::initialize_custom() { } void PeerConnectionMetadata::update_interested() { } bool PeerConnectionMetadata::receive_keepalive() { if (cachedTime - m_timeLastRead > rak::timer::from_seconds(240)) return false; m_tryRequest = true; // There's no point in adding ourselves to the write poll if the // buffer is full, as that will already have been taken care of. if (m_up->get_state() == ProtocolWrite::IDLE && m_up->can_write_keepalive()) { write_insert_poll_safe(); ProtocolBuffer<512>::iterator old_end = m_up->buffer()->end(); m_up->write_keepalive(); if (is_encrypted()) m_encryption.encrypt(old_end, m_up->buffer()->end() - old_end); } return true; } // We keep the message in the buffer if it is incomplete instead of // keeping the state and remembering the read information. This // shouldn't happen very often compared to full reads. inline bool PeerConnectionMetadata::read_message() { ProtocolBuffer<512>* buf = m_down->buffer(); if (buf->remaining() < 4) return false; // Remember the start of the message so we may reset it if we don't // have the whole message. ProtocolBuffer<512>::iterator beginning = buf->position(); uint32_t length = buf->read_32(); if (length == 0) { // Keepalive message. m_down->set_last_command(ProtocolBase::KEEP_ALIVE); return true; } else if (buf->remaining() < 1) { buf->set_position_itr(beginning); return false; } else if (length > (1 << 20)) { throw communication_error("PeerConnection::read_message() got an invalid message length."); } m_down->set_last_command((ProtocolBase::Protocol)buf->peek_8()); // Ignore most messages, they aren't relevant for a metadata download. switch (buf->read_8()) { case ProtocolBase::CHOKE: case ProtocolBase::UNCHOKE: case ProtocolBase::INTERESTED: case ProtocolBase::NOT_INTERESTED: return true; case ProtocolBase::HAVE: if (!m_down->can_read_have_body()) break; buf->read_32(); return true; case ProtocolBase::REQUEST: if (!m_down->can_read_request_body()) break; m_down->read_request(); return true; case ProtocolBase::PIECE: throw communication_error("Received a piece but the connection is strictly for meta data."); case ProtocolBase::CANCEL: if (!m_down->can_read_cancel_body()) break; m_down->read_request(); return true; case ProtocolBase::PORT: if (!m_down->can_read_port_body()) break; manager->dht_manager()->add_node(m_peerInfo->socket_address(), m_down->buffer()->read_16()); return true; case ProtocolBase::EXTENSION_PROTOCOL: rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::read_message() case ProtocolBase::EXTENSION_PROTOCOL:"); if (!m_down->can_read_extension_body()) break; if (m_extensions->is_default()) { m_extensions = new ProtocolExtension(); m_extensions->set_info(m_peerInfo, m_download); } { int extension = m_down->buffer()->read_8(); m_extensions->read_start(extension, length - 2, (extension == ProtocolExtension::UT_PEX) && !m_download->want_pex_msg()); m_down->set_state(ProtocolRead::READ_EXTENSION); } if (!down_extension()) return false; rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::read_message() case ProtocolBase::EXTENSION_PROTOCOL: finished"); // Drop peer if it disabled the metadata extension. if (!m_extensions->is_remote_supported(ProtocolExtension::UT_METADATA)) throw close_connection(); m_down->set_state(ProtocolRead::IDLE); m_tryRequest = true; write_insert_poll_safe(); return true; case ProtocolBase::BITFIELD: // Discard the bitfield sent by the peer. m_skipLength = length - 1; m_down->set_state(ProtocolRead::READ_SKIP_PIECE); return false; default: throw communication_error("Received unsupported message type."); } // We were unsuccessfull in reading the message, need more data. buf->set_position_itr(beginning); return false; } void PeerConnectionMetadata::event_read() { m_timeLastRead = cachedTime; // Need to make sure ProtocolBuffer::end() is pointing to the end of // the unread data, and that the unread data starts from the // beginning of the buffer. Or do we use position? Propably best, // therefor ProtocolBuffer::position() points to the beginning of // the unused data. try { // Normal read. // // We rarely will read zero bytes as the read of 64 bytes will // almost always either not fill up or it will require additional // reads. // // Only loop when end hits 64. do { switch (m_down->get_state()) { case ProtocolRead::IDLE: if (m_down->buffer()->size_end() < read_size) { unsigned int length = read_stream_throws(m_down->buffer()->end(), read_size - m_down->buffer()->size_end()); m_down->throttle()->node_used_unthrottled(length); if (is_encrypted()) m_encryption.decrypt(m_down->buffer()->end(), length); m_down->buffer()->move_end(length); } while (read_message()); if (m_down->buffer()->size_end() == read_size) { m_down->buffer()->move_unused(); break; } else { m_down->buffer()->move_unused(); return; } case ProtocolRead::READ_EXTENSION: if (!down_extension()) return; // Drop peer if it disabled the metadata extension. if (!m_extensions->is_remote_supported(ProtocolExtension::UT_METADATA)) throw close_connection(); rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::event_read() case ProtocolRead::READ_EXTENSION:"); m_down->set_state(ProtocolRead::IDLE); m_tryRequest = true; write_insert_poll_safe(); break; // Actually skipping the bitfield. // We never receive normal piece messages anyway. case ProtocolRead::READ_SKIP_PIECE: if (!read_skip_bitfield()) return; m_down->set_state(ProtocolRead::IDLE); break; default: throw internal_error("PeerConnection::event_read() wrong state."); } // Figure out how to get rid of the shouldLoop boolean. } while (true); // Exception handlers: } catch (close_connection& e) { m_download->connection_list()->erase(this, 0); } catch (blocked_connection& e) { rak::slot_list_call(m_download->info()->signal_network_log(), "Momentarily blocked read connection."); m_download->connection_list()->erase(this, 0); } catch (network_error& e) { m_download->connection_list()->erase(this, 0); } catch (storage_error& e) { rak::slot_list_call(m_download->info()->signal_storage_error(), e.what()); m_download->connection_list()->erase(this, 0); } catch (base_error& e) { std::stringstream s; s << "Connection read fd(" << get_fd().get_fd() << ',' << m_down->get_state() << ',' << m_down->last_command() << ") \"" << e.what() << '"'; throw internal_error(s.str()); } } inline void PeerConnectionMetadata::fill_write_buffer() { ProtocolBuffer<512>::iterator old_end = m_up->buffer()->end(); if (m_tryRequest) m_tryRequest = try_request_metadata_pieces(); if (m_sendPEXMask && m_up->can_write_extension() && send_pex_message()) { // Don't do anything else if send_pex_message() succeeded. } else if (m_extensions->has_pending_message() && m_up->can_write_extension() && send_ext_message()) { // Same. } if (is_encrypted()) m_encryption.encrypt(old_end, m_up->buffer()->end() - old_end); } void PeerConnectionMetadata::event_write() { try { do { switch (m_up->get_state()) { case ProtocolWrite::IDLE: fill_write_buffer(); if (m_up->buffer()->remaining() == 0) { manager->poll()->remove_write(this); return; } m_up->set_state(ProtocolWrite::MSG); case ProtocolWrite::MSG: if (!m_up->buffer()->consume(m_up->throttle()->node_used_unthrottled(write_stream_throws(m_up->buffer()->position(), m_up->buffer()->remaining())))) return; m_up->buffer()->reset(); if (m_up->last_command() != ProtocolBase::EXTENSION_PROTOCOL) { m_up->set_state(ProtocolWrite::IDLE); break; } m_up->set_state(ProtocolWrite::WRITE_EXTENSION); case ProtocolWrite::WRITE_EXTENSION: if (!up_extension()) return; m_up->set_state(ProtocolWrite::IDLE); break; default: throw internal_error("PeerConnection::event_write() wrong state."); } } while (true); } catch (close_connection& e) { m_download->connection_list()->erase(this, 0); } catch (blocked_connection& e) { rak::slot_list_call(m_download->info()->signal_network_log(), "Momentarily blocked write connection."); m_download->connection_list()->erase(this, 0); } catch (network_error& e) { m_download->connection_list()->erase(this, 0); } catch (storage_error& e) { rak::slot_list_call(m_download->info()->signal_storage_error(), e.what()); m_download->connection_list()->erase(this, 0); } catch (base_error& e) { std::stringstream s; s << "Connection write fd(" << get_fd().get_fd() << ',' << m_up->get_state() << ',' << m_up->last_command() << ") \"" << e.what() << '"'; throw internal_error(s.str()); } } bool PeerConnectionMetadata::read_skip_bitfield() { if (m_down->buffer()->remaining()) { uint32_t length = std::min(m_skipLength, (uint32_t)m_down->buffer()->remaining()); m_down->buffer()->consume(length); m_skipLength -= length; } if (m_skipLength) { uint32_t length = std::min(m_skipLength, (uint32_t)null_buffer_size); length = read_stream_throws(m_nullBuffer, length); if (!length) return false; m_skipLength -= length; } return !m_skipLength; } // Same as the PCB code, but only one at a time and with the extension protocol. bool PeerConnectionMetadata::try_request_metadata_pieces() { if (m_download->file_list()->chunk_size() == 1 || !m_extensions->is_remote_supported(ProtocolExtension::UT_METADATA)) return false; if (download_queue()->queued_empty()) m_downStall = 0; uint32_t pipeSize = download_queue()->calculate_pipe_size(m_peerChunks.download_throttle()->rate()->rate()); // Don't start requesting if we can't do it in large enough chunks. if (download_queue()->queued_size() >= (pipeSize + 10) / 2) return false; // DEBUG: // if (!download_queue()->queued_size() < pipeSize || !m_up->can_write_extension() || if (!m_up->can_write_extension() || m_extensions->has_pending_message()) return false; const Piece* p = download_queue()->delegate(); if (p == NULL) return false; if (!m_download->file_list()->is_valid_piece(*p) || !m_peerChunks.bitfield()->get(p->index())) throw internal_error("PeerConnectionMetadata::try_request_metadata_pieces() tried to use an invalid piece."); // return m_extensions->request_metadata_piece(p); // DEBUG: if (m_extensions->request_metadata_piece(p)) { rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::try_request_metadata_pieces() succeded."); return true; } else { rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::try_request_metadata_pieces() failed."); return false; } } void PeerConnectionMetadata::receive_metadata_piece(uint32_t piece, const char* data, uint32_t length) { if (data == NULL) { // Length is not set in a reject message. length = ProtocolExtension::metadata_piece_size; if ((piece << ProtocolExtension::metadata_piece_shift) + ProtocolExtension::metadata_piece_size >= m_download->file_list()->size_bytes()) length = m_download->file_list()->chunk_size() % ProtocolExtension::metadata_piece_size; m_tryRequest = false; read_cancel_piece(Piece(0, piece << ProtocolExtension::metadata_piece_shift, length)); rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::receive_metadata_piece reject."); return; } if (!down_chunk_start(Piece(0, piece << ProtocolExtension::metadata_piece_shift, length))) { rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::receive_metadata_piece skip."); down_chunk_skip_process(data, length); } else { rak::slot_list_call(m_download->info()->signal_network_log(), "PeerConnectionMetadata::receive_metadata_piece process."); down_chunk_process(data, length); } if (!m_downloadQueue.transfer()->is_finished()) throw internal_error("PeerConnectionMetadata::receive_metadata_piece did not have complete piece."); m_tryRequest = true; down_chunk_finished(); } } libtorrent-0.13.2/src/protocol/peer_connection_metadata.h000644 000765 000024 00000004662 11705767056 024562 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PROTOCOL_PEER_CONNECTION_METADATA_H #define LIBTORRENT_PROTOCOL_PEER_CONNECTION_METADATA_H #include "peer_connection_base.h" #include "torrent/download.h" namespace torrent { class PeerConnectionMetadata : public PeerConnectionBase { public: ~PeerConnectionMetadata(); virtual void initialize_custom(); virtual void update_interested(); virtual bool receive_keepalive(); virtual void event_read(); virtual void event_write(); virtual void receive_metadata_piece(uint32_t piece, const char* data, uint32_t length); private: inline bool read_message(); bool read_skip_bitfield(); bool try_request_metadata_pieces(); inline void fill_write_buffer(); uint32_t m_skipLength; }; } #endif libtorrent-0.13.2/src/protocol/peer_factory.cc000644 000765 000024 00000004561 11705767056 022366 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "peer_factory.h" #include "peer_connection_leech.h" #include "peer_connection_metadata.h" namespace torrent { PeerConnectionBase* createPeerConnectionDefault(bool encrypted) { PeerConnectionBase* pc = new PeerConnection; return pc; } PeerConnectionBase* createPeerConnectionSeed(bool encrypted) { PeerConnectionBase* pc = new PeerConnection; return pc; } PeerConnectionBase* createPeerConnectionInitialSeed(bool encrypted) { PeerConnectionBase* pc = new PeerConnection; return pc; } PeerConnectionBase* createPeerConnectionMetadata(bool encrypted) { PeerConnectionBase* pc = new PeerConnectionMetadata; return pc; } } libtorrent-0.13.2/src/protocol/peer_factory.h000644 000765 000024 00000004005 11705767056 022221 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PEER_PEER_FACTORY_H #define LIBTORRENT_PEER_PEER_FACTORY_H namespace torrent { class PeerConnectionBase; PeerConnectionBase* createPeerConnectionDefault(bool encrypted); PeerConnectionBase* createPeerConnectionSeed(bool encrypted); PeerConnectionBase* createPeerConnectionInitialSeed(bool encrypted); PeerConnectionBase* createPeerConnectionMetadata(bool encrypted); } #endif libtorrent-0.13.2/src/protocol/protocol_base.h000644 000765 000024 00000020626 11705767056 022401 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_PROTOCOL_BASE_H #define LIBTORRENT_NET_PROTOCOL_BASE_H #include #include "net/protocol_buffer.h" namespace torrent { class Piece; class ProtocolBase { public: typedef ProtocolBuffer<512> Buffer; typedef uint32_t size_type; static const size_type buffer_size = 512; typedef enum { CHOKE = 0, UNCHOKE, INTERESTED, NOT_INTERESTED, HAVE, BITFIELD, REQUEST, PIECE, CANCEL, PORT, // = 9 EXTENSION_PROTOCOL = 20, NONE, // These are not part of the protocol KEEP_ALIVE // Last command was a keep alive } Protocol; typedef enum { IDLE, MSG, READ_PIECE, READ_SKIP_PIECE, READ_EXTENSION, WRITE_PIECE, WRITE_EXTENSION, INTERNAL_ERROR } State; ProtocolBase() : m_state(IDLE), m_lastCommand(NONE), m_throttle(NULL) { m_buffer.reset(); } Protocol last_command() const { return m_lastCommand; } void set_last_command(Protocol p) { m_lastCommand = p; } Buffer* buffer() { return &m_buffer; } ThrottleList* throttle() { return m_throttle; } void set_throttle(ThrottleList* t) { m_throttle = t; } State get_state() const { return m_state; } void set_state(State s) { m_state = s; } Piece read_request(); Piece read_piece(size_type length); void write_command(Protocol c) { m_buffer.write_8(m_lastCommand = c); } void write_keepalive(); void write_choke(bool s); void write_interested(bool s); void write_have(uint32_t index); void write_bitfield(size_type length); void write_request(const Piece& p); void write_cancel(const Piece& p); void write_piece(const Piece& p); void write_port(uint16_t port); void write_extension(uint8_t id, uint32_t length); static const size_type sizeof_keepalive = 4; static const size_type sizeof_choke = 5; static const size_type sizeof_interested = 5; static const size_type sizeof_have = 9; static const size_type sizeof_have_body = 4; static const size_type sizeof_bitfield = 5; static const size_type sizeof_request = 17; static const size_type sizeof_request_body = 12; static const size_type sizeof_cancel = 17; static const size_type sizeof_cancel_body = 12; static const size_type sizeof_piece = 13; static const size_type sizeof_piece_body = 8; static const size_type sizeof_port = 7; static const size_type sizeof_port_body = 2; static const size_type sizeof_extension = 6; static const size_type sizeof_extension_body=1; bool can_write_keepalive() const { return m_buffer.reserved_left() >= sizeof_keepalive; } bool can_write_choke() const { return m_buffer.reserved_left() >= sizeof_choke; } bool can_write_interested() const { return m_buffer.reserved_left() >= sizeof_interested; } bool can_write_have() const { return m_buffer.reserved_left() >= sizeof_have; } bool can_write_bitfield() const { return m_buffer.reserved_left() >= sizeof_bitfield; } bool can_write_request() const { return m_buffer.reserved_left() >= sizeof_request; } bool can_write_cancel() const { return m_buffer.reserved_left() >= sizeof_cancel; } bool can_write_piece() const { return m_buffer.reserved_left() >= sizeof_piece; } bool can_write_port() const { return m_buffer.reserved_left() >= sizeof_port; } bool can_write_extension() const { return m_buffer.reserved_left() >= sizeof_extension; } bool can_read_have_body() const { return m_buffer.remaining() >= sizeof_have_body; } bool can_read_request_body() const { return m_buffer.remaining() >= sizeof_request_body; } bool can_read_cancel_body() const { return m_buffer.remaining() >= sizeof_request_body; } bool can_read_piece_body() const { return m_buffer.remaining() >= sizeof_piece_body; } bool can_read_port_body() const { return m_buffer.remaining() >= sizeof_port_body; } bool can_read_extension_body() const { return m_buffer.remaining() >= sizeof_extension_body; } protected: State m_state; Protocol m_lastCommand; ThrottleList* m_throttle; Buffer m_buffer; }; inline Piece ProtocolBase::read_request() { uint32_t index = m_buffer.read_32(); uint32_t offset = m_buffer.read_32(); uint32_t length = m_buffer.read_32(); return Piece(index, offset, length); } inline Piece ProtocolBase::read_piece(size_type length) { uint32_t index = m_buffer.read_32(); uint32_t offset = m_buffer.read_32(); return Piece(index, offset, length); } inline void ProtocolBase::write_keepalive() { m_buffer.write_32(0); m_lastCommand = KEEP_ALIVE; } inline void ProtocolBase::write_choke(bool s) { m_buffer.write_32(1); write_command(s ? CHOKE : UNCHOKE); } inline void ProtocolBase::write_interested(bool s) { m_buffer.write_32(1); write_command(s ? INTERESTED : NOT_INTERESTED); } inline void ProtocolBase::write_have(uint32_t index) { m_buffer.write_32(5); write_command(HAVE); m_buffer.write_32(index); } inline void ProtocolBase::write_bitfield(size_type length) { m_buffer.write_32(1 + length); write_command(BITFIELD); } inline void ProtocolBase::write_request(const Piece& p) { m_buffer.write_32(13); write_command(REQUEST); m_buffer.write_32(p.index()); m_buffer.write_32(p.offset()); m_buffer.write_32(p.length()); } inline void ProtocolBase::write_cancel(const Piece& p) { m_buffer.write_32(13); write_command(CANCEL); m_buffer.write_32(p.index()); m_buffer.write_32(p.offset()); m_buffer.write_32(p.length()); } inline void ProtocolBase::write_piece(const Piece& p) { m_buffer.write_32(9 + p.length()); write_command(PIECE); m_buffer.write_32(p.index()); m_buffer.write_32(p.offset()); } inline void ProtocolBase::write_port(uint16_t port) { m_buffer.write_32(3); write_command(PORT); m_buffer.write_16(port); } inline void ProtocolBase::write_extension(uint8_t id, uint32_t length) { m_buffer.write_32(2 + length); write_command(EXTENSION_PROTOCOL); m_buffer.write_8(id); } } #endif libtorrent-0.13.2/src/protocol/request_list.cc000644 000765 000024 00000020057 11705767056 022425 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include "torrent/data/block.h" #include "torrent/data/block_list.h" #include "torrent/exceptions.h" #include "download/delegator.h" #include "peer_chunks.h" #include "request_list.h" namespace torrent { // It is assumed invalid transfers have been removed. struct request_list_same_piece { request_list_same_piece(const Piece& p) : m_piece(p) {} bool operator () (const BlockTransfer* d) { return m_piece.index() == d->piece().index() && m_piece.offset() == d->piece().offset(); } Piece m_piece; }; const Piece* RequestList::delegate() { BlockTransfer* r = m_delegator->delegate(m_peerChunks, m_affinity); if (r) { m_affinity = r->index(); m_queued.push_back(r); return &r->piece(); } else { return NULL; } } // Replace m_canceled with m_queued and set them to stalled. // // This doesn't seem entirely correct... Perhaps canceled requests // should be kept around until we hit a safe state where we may throw // them out? void RequestList::cancel() { std::for_each(m_canceled.begin(), m_canceled.end(), std::ptr_fun(&Block::release)); m_canceled.clear(); std::for_each(m_queued.begin(), m_queued.end(), std::ptr_fun(&Block::stalled)); m_canceled.swap(m_queued); } void RequestList::stall() { if (m_transfer != NULL) Block::stalled(m_transfer); std::for_each(m_queued.begin(), m_queued.end(), std::ptr_fun(&Block::stalled)); } void RequestList::clear() { if (is_downloading()) skipped(); std::for_each(m_queued.begin(), m_queued.end(), std::ptr_fun(&Block::release)); m_queued.clear(); std::for_each(m_canceled.begin(), m_canceled.end(), std::ptr_fun(&Block::release)); m_canceled.clear(); } bool RequestList::downloading(const Piece& piece) { if (m_transfer != NULL) throw internal_error("RequestList::downloading(...) m_transfer != NULL."); ReserveeList::iterator itr = std::find_if(m_queued.begin(), m_queued.end(), request_list_same_piece(piece)); if (itr == m_queued.end()) { itr = std::find_if(m_canceled.begin(), m_canceled.end(), request_list_same_piece(piece)); if (itr == m_canceled.end()) { // Consider counting these pieces as spam. goto downloading_error; } m_transfer = *itr; m_canceled.erase(itr); } else { m_transfer = *itr; cancel_range(itr); m_queued.pop_front(); } // We received an invalid piece length, propably zero length due to // the peer not being able to transfer the requested piece. // // We need to replace the current BlockTransfer so Block can keep // the unmodified BlockTransfer. if (piece.length() != m_transfer->piece().length()) { if (piece.length() != 0) throw communication_error("Peer sent a piece with wrong, non-zero, length."); Block::release(m_transfer); goto downloading_error; } // Check if piece isn't wanted anymore. Do this after the length // check to ensure we return a correct BlockTransfer. if (!m_transfer->is_valid()) return false; m_transfer->block()->transfering(m_transfer); return true; downloading_error: // Create a dummy BlockTransfer object to hold the piece // information. m_transfer = new BlockTransfer(); Block::create_dummy(m_transfer, m_peerChunks->peer_info(), piece); return false; } // Must clear the downloading piece. void RequestList::finished() { if (!is_downloading()) throw internal_error("RequestList::finished() called but no transfer is in progress."); if (!m_transfer->is_valid()) throw internal_error("RequestList::finished() called but transfer is invalid."); BlockTransfer* transfer = m_transfer; m_transfer = NULL; m_delegator->transfer_list()->finished(transfer); } void RequestList::skipped() { if (!is_downloading()) throw internal_error("RequestList::skip() called but no transfer is in progress."); Block::release(m_transfer); m_transfer = NULL; } // Data downloaded by this non-leading transfer does not match what we // already have. void RequestList::transfer_dissimilar() { if (!is_downloading()) throw internal_error("RequestList::transfer_dissimilar() called but no transfer is in progress."); BlockTransfer* dummy = new BlockTransfer(); Block::create_dummy(dummy, m_peerChunks->peer_info(), m_transfer->piece()); dummy->set_position(m_transfer->position()); m_transfer->block()->transfer_dissimilar(m_transfer); m_transfer = dummy; } // void // RequestList::cancel_transfer(BlockTransfer* transfer) { // // ReserveeList itr = std::find_if(m_canceled.begin(), m_canceled.end(), request_list_same_piece(piece)); // // ReserveeList itr = std::find_if(m_canceled.begin(), m_canceled.end(), request_list_same_piece(piece)); // } struct equals_reservee : public std::binary_function { bool operator () (BlockTransfer* r, uint32_t index) const { return r->is_valid() && index == r->index(); } }; bool RequestList::is_interested_in_active() const { for (TransferList::const_iterator itr = m_delegator->transfer_list()->begin(), last = m_delegator->transfer_list()->end(); itr != last; ++itr) if (m_peerChunks->bitfield()->get((*itr)->index())) return true; return false; } bool RequestList::has_index(uint32_t index) { return std::find_if(m_queued.begin(), m_queued.end(), std::bind2nd(equals_reservee(), index)) != m_queued.end(); } void RequestList::cancel_range(ReserveeList::iterator end) { // This only gets called when it's downloading a non-canceled piece, // so to avoid a backlog of canceled pieces we need to empty it // here. // // This may cause us to skip pieces if the peer does some strange // reordering. // // Add some extra checks here to avoid clearing too often. if (!m_canceled.empty()) { std::for_each(m_canceled.begin(), m_canceled.end(), std::ptr_fun(&Block::release)); m_canceled.clear(); } while (m_queued.begin() != end) { BlockTransfer* transfer = m_queued.front(); m_queued.pop_front(); if (transfer->is_valid()) { Block::stalled(transfer); m_canceled.push_back(transfer); } else { Block::release(transfer); } } } uint32_t RequestList::calculate_pipe_size(uint32_t rate) { // Change into KB. rate /= 1024; if (!m_delegator->get_aggressive()) { if (rate < 20) return rate + 2; else return rate / 5 + 18; } else { if (rate < 10) return rate / 5 + 1; else return rate / 10 + 2; } } } libtorrent-0.13.2/src/protocol/request_list.h000644 000765 000024 00000007753 11705767056 022277 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_REQUEST_LIST_H #define LIBTORRENT_REQUEST_LIST_H #include #include "torrent/data/block_transfer.h" namespace torrent { class PeerChunks; class Delegator; class RequestList { public: typedef std::deque ReserveeList; RequestList() : m_delegator(NULL), m_peerChunks(NULL), m_transfer(NULL), m_affinity(-1) {} // Some parameters here, like how fast we are downloading and stuff // when we start considering those. const Piece* delegate(); // If is downloading, call skip before cancel. void cancel(); void stall(); void clear(); // The returned transfer must still be valid. bool downloading(const Piece& piece); void finished(); void skipped(); void transfer_dissimilar(); // void cancel_transfer(BlockTransfer* transfer); bool is_downloading() { return m_transfer != NULL; } bool is_interested_in_active() const; bool has_index(uint32_t i); bool queued_empty() const { return m_queued.empty(); } size_t queued_size() const { return m_queued.size(); } const Piece& next_queued_piece() const { return m_queued.front()->piece(); } bool canceled_empty() const { return m_canceled.empty(); } size_t canceled_size() const { return m_queued.size(); } uint32_t calculate_pipe_size(uint32_t rate); void set_delegator(Delegator* d) { m_delegator = d; } void set_peer_chunks(PeerChunks* b) { m_peerChunks = b; } BlockTransfer* transfer() { return m_transfer; } const BlockTransfer* transfer() const { return m_transfer; } const BlockTransfer* queued_transfer(uint32_t i) const { return m_queued[i]; } private: void cancel_range(ReserveeList::iterator end); Delegator* m_delegator; PeerChunks* m_peerChunks; BlockTransfer* m_transfer; // Replace m_downloading with a pointer to BlockTransfer. int32_t m_affinity; ReserveeList m_queued; ReserveeList m_canceled; }; } #endif libtorrent-0.13.2/src/net/address_list.cc000644 000765 000024 00000006334 11705767056 021311 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "address_list.h" namespace torrent { inline rak::socket_address AddressList::parse_address(const Object& b) { rak::socket_address sa; sa.clear(); if (!b.is_map()) return sa; if (!b.has_key_string("ip") || !sa.set_address_str(b.get_key_string("ip"))) return sa; if (!b.has_key_value("port") || b.get_key_value("port") <= 0 || b.get_key_value("port") >= (1 << 16)) return sa; sa.set_port(b.get_key_value("port")); return sa; } void AddressList::parse_address_normal(const Object::list_type& b) { std::for_each(b.begin(), b.end(), rak::on(std::ptr_fun(&AddressList::parse_address), AddressList::add_address(this))); } void AddressList::parse_address_compact(raw_string s) { if (sizeof(const SocketAddressCompact) != 6) throw internal_error("ConnectionList::AddressList::parse_address_compact(...) bad struct size."); std::copy(reinterpret_cast(s.data()), reinterpret_cast(s.data() + s.size() - s.size() % sizeof(SocketAddressCompact)), std::back_inserter(*this)); } void AddressList::parse_address_bencode(raw_list s) { if (sizeof(const SocketAddressCompact) != 6) throw internal_error("AddressList::parse_address_bencode(...) bad struct size."); for (raw_list::const_iterator itr = s.begin(); itr + 2 + sizeof(SocketAddressCompact) <= s.end(); itr += sizeof(SocketAddressCompact)) { if (*itr++ != '6' || *itr++ != ':') break; insert(end(), *reinterpret_cast(s.data())); } } } libtorrent-0.13.2/src/net/address_list.h000644 000765 000024 00000006566 11705767056 021162 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_ADDRESS_LIST_H #define LIBTORRENT_DOWNLOAD_ADDRESS_LIST_H #include #include #include #include #include namespace torrent { class AddressList : public std::list { public: // Parse normal or compact list of addresses and add to AddressList void parse_address_normal(const Object::list_type& b); void parse_address_bencode(raw_list s); void parse_address_compact(raw_string s); void parse_address_compact(const std::string& s); private: static rak::socket_address parse_address(const Object& b); struct add_address : public std::unary_function { add_address(AddressList* l) : m_list(l) {} void operator () (const rak::socket_address& sa) const { if (!sa.is_valid()) return; m_list->push_back(sa); } AddressList* m_list; }; }; inline void AddressList::parse_address_compact(const std::string& s) { return parse_address_compact(raw_string(s.data(), s.size())); } // Move somewhere else. struct SocketAddressCompact { SocketAddressCompact() {} SocketAddressCompact(uint32_t a, uint16_t p) : addr(a), port(p) {} SocketAddressCompact(const rak::socket_address_inet* sa) : addr(sa->address_n()), port(sa->port_n()) {} operator rak::socket_address () const { rak::socket_address sa; sa.sa_inet()->clear(); sa.sa_inet()->set_port_n(port); sa.sa_inet()->set_address_n(addr); return sa; } uint32_t addr; uint16_t port; const char* c_str() const { return reinterpret_cast(this); } } __attribute__ ((packed)); } #endif libtorrent-0.13.2/src/net/data_buffer.h000644 000765 000024 00000006141 11705767056 020731 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_DATA_BUFFER_H #define LIBTORRENT_NET_DATA_BUFFER_H #include #include namespace torrent { // Recipient must call clear() when done with the buffer. struct DataBuffer { DataBuffer() : m_data(NULL), m_end(NULL), m_owned(true) {} DataBuffer(char* data, char* end) : m_data(data), m_end(end), m_owned(true) {} DataBuffer clone() const { DataBuffer d = *this; d.m_owned = false; return d; } DataBuffer release() { DataBuffer d = *this; set(NULL, NULL, false); return d; } char* data() const { return m_data; } char* end() const { return m_end; } bool owned() const { return m_owned; } bool empty() const { return m_data == NULL; } size_t length() const { return m_end - m_data; } void clear(); void set(char* data, char* end, bool owned); private: char* m_data; char* m_end; // Used to indicate if buffer held by PCB is its own and needs to be // deleted after transmission (false if shared with other connections). bool m_owned; }; inline void DataBuffer::clear() { if (!empty() && m_owned) delete[] m_data; m_data = m_end = NULL; m_owned = false; } inline void DataBuffer::set(char* data, char* end, bool owned) { m_data = data; m_end = end; m_owned = owned; } } #endif libtorrent-0.13.2/src/net/listen.cc000644 000765 000024 00000007252 11705767056 020127 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include "torrent/exceptions.h" #include "torrent/connection_manager.h" #include "torrent/poll.h" #include "listen.h" #include "manager.h" namespace torrent { bool Listen::open(uint16_t first, uint16_t last, const rak::socket_address* bindAddress) { close(); if (first == 0 || last == 0 || first > last) throw input_error("Tried to open listening port with an invalid range."); if (bindAddress->family() != rak::socket_address::af_inet && bindAddress->family() != rak::socket_address::af_inet6) throw input_error("Listening socket must be bound to an inet or inet6 address."); if (!get_fd().open_stream() || !get_fd().set_nonblock() || !get_fd().set_reuse_address(true)) throw resource_error("Could not allocate socket for listening."); rak::socket_address sa; sa.copy(*bindAddress, bindAddress->length()); for (uint16_t i = first; i <= last; ++i) { sa.set_port(i); if (get_fd().bind(sa) && get_fd().listen(50)) { m_port = i; manager->connection_manager()->inc_socket_count(); manager->poll()->open(this); manager->poll()->insert_read(this); manager->poll()->insert_error(this); return true; } } // This needs to be done if local_error is thrown too... get_fd().close(); get_fd().clear(); return false; } void Listen::close() { if (!get_fd().is_valid()) return; manager->poll()->remove_read(this); manager->poll()->remove_error(this); manager->poll()->close(this); manager->connection_manager()->dec_socket_count(); get_fd().close(); get_fd().clear(); m_port = 0; } void Listen::event_read() { rak::socket_address sa; SocketFd fd; while ((fd = get_fd().accept(&sa)).is_valid()) m_slotIncoming(fd, sa); } void Listen::event_write() { throw internal_error("Listener does not support write()."); } void Listen::event_error() { throw internal_error("Listener port received an error event."); } } libtorrent-0.13.2/src/net/listen.h000644 000765 000024 00000005235 11705767056 017770 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_LISTEN_H #define LIBTORRENT_LISTEN_H #include #include #include #include "socket_base.h" #include "socket_fd.h" namespace torrent { class HandshakeManager; class Listen : public SocketBase { public: typedef rak::mem_fun2 SlotIncoming; Listen() : m_port(0) {} ~Listen() { close(); } bool open(uint16_t first, uint16_t last, const rak::socket_address* bindAddress); void close(); bool is_open() { return get_fd().is_valid(); } uint16_t port() const { return m_port; } void slot_incoming(const SlotIncoming& s) { m_slotIncoming = s; } virtual void event_read(); virtual void event_write(); virtual void event_error(); private: uint64_t m_port; SlotIncoming m_slotIncoming; }; } // namespace torrent #endif // LIBTORRENT_TORRENT_H libtorrent-0.13.2/src/net/Makefile.am000644 000765 000024 00000000774 11705767056 020360 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_net.la libsub_net_la_SOURCES = \ address_list.cc \ address_list.h \ data_buffer.h \ listen.cc \ listen.h \ protocol_buffer.h \ socket_base.cc \ socket_base.h \ socket_datagram.cc \ socket_datagram.h \ socket_fd.cc \ socket_fd.h \ socket_set.cc \ socket_set.h \ socket_stream.cc \ socket_stream.h \ throttle_internal.cc \ throttle_internal.h \ throttle_list.cc \ throttle_list.h \ throttle_node.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrent-0.13.2/src/net/Makefile.in000644 000765 000024 00000041207 11744204216 020350 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/net DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_net_la_LIBADD = am_libsub_net_la_OBJECTS = address_list.lo listen.lo socket_base.lo \ socket_datagram.lo socket_fd.lo socket_set.lo socket_stream.lo \ throttle_internal.lo throttle_list.lo libsub_net_la_OBJECTS = $(am_libsub_net_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_net_la_SOURCES) DIST_SOURCES = $(libsub_net_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_net.la libsub_net_la_SOURCES = \ address_list.cc \ address_list.h \ data_buffer.h \ listen.cc \ listen.h \ protocol_buffer.h \ socket_base.cc \ socket_base.h \ socket_datagram.cc \ socket_datagram.h \ socket_fd.cc \ socket_fd.h \ socket_set.cc \ socket_set.h \ socket_stream.cc \ socket_stream.h \ throttle_internal.cc \ throttle_internal.h \ throttle_list.cc \ throttle_list.h \ throttle_node.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/net/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/net/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_net.la: $(libsub_net_la_OBJECTS) $(libsub_net_la_DEPENDENCIES) $(EXTRA_libsub_net_la_DEPENDENCIES) $(CXXLINK) $(libsub_net_la_OBJECTS) $(libsub_net_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/address_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_datagram.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_fd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_set.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_stream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/throttle_internal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/throttle_list.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/net/protocol_buffer.h000644 000765 000024 00000021213 11705767056 021656 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_PROTOCOL_BUFFER_H #define LIBTORRENT_NET_PROTOCOL_BUFFER_H #include #include #include #include "torrent/exceptions.h" namespace torrent { template class ProtocolBuffer { public: typedef uint8_t value_type; typedef value_type* iterator; typedef uint16_t size_type; typedef int16_t difference_type; void reset() { m_position = m_end = begin(); } void reset_position() { m_position = m_buffer; } bool consume(difference_type v); void set_position_itr(iterator itr) { m_position = itr; } void set_end(size_type v) { m_end = m_buffer + v; } void set_end_itr(iterator itr) { m_end = itr; } difference_type move_end(difference_type v) { m_end += v; return v; } uint8_t read_8() { return *m_position++; } uint8_t peek_8() { return *m_position; } uint16_t read_16(); uint16_t peek_16(); uint32_t read_32(); uint32_t peek_32(); uint64_t read_64() { return read_int(); } uint64_t peek_64() { return peek_int(); } uint8_t peek_8_at(size_type pos) { return *(m_position + pos); } template void read_range(Out first, Out last); template void read_len(Out start, unsigned int len); template inline T read_int(); template inline T peek_int(); void write_8(uint8_t v) { *m_end++ = v; validate_end(); } void write_16(uint16_t v); void write_32(uint32_t v); void write_32_n(uint32_t v); void write_64(uint64_t v) { write_int(v); } template inline void write_int(T t); template void write_range(In first, In last); template void write_len(In start, unsigned int len); iterator begin() { return m_buffer; } iterator position() { return m_position; } iterator end() { return m_end; } size_type size_position() const { return m_position - m_buffer; } size_type size_end() const { return m_end - m_buffer; } size_type remaining() const { return m_end - m_position; } size_type reserved() const { return tmpl_size; } size_type reserved_left() const { return reserved() - size_end(); } void move_unused(); void validate_position() const { #ifdef USE_EXTRA_DEBUG if (m_position > m_buffer + tmpl_size) throw internal_error("ProtocolBuffer tried to read beyond scope of the buffer."); if (m_position > m_end) throw internal_error("ProtocolBuffer tried to read beyond end of the buffer."); #endif } void validate_end() const { #ifdef USE_EXTRA_DEBUG if (m_end > m_buffer + tmpl_size) throw internal_error("ProtocolBuffer tried to write beyond scope of the buffer."); #endif } private: iterator m_position; iterator m_end; value_type m_buffer[tmpl_size]; }; template inline bool ProtocolBuffer::consume(difference_type v) { m_position += v; if (remaining()) return false; return true; } template inline uint16_t ProtocolBuffer::read_16() { #ifndef USE_ALIGNED uint16_t t = ntohs(*reinterpret_cast(m_position)); m_position += sizeof(uint16_t); return t; #else return read_int(); #endif } template inline uint16_t ProtocolBuffer::peek_16() { #ifndef USE_ALIGNED return ntohs(*reinterpret_cast(m_position)); #else return peek_int(); #endif } template inline uint32_t ProtocolBuffer::read_32() { #ifndef USE_ALIGNED uint32_t t = ntohl(*reinterpret_cast(m_position)); m_position += sizeof(uint32_t); return t; #else return read_int(); #endif } template inline uint32_t ProtocolBuffer::peek_32() { #ifndef USE_ALIGNED return ntohl(*reinterpret_cast(m_position)); #else return peek_int(); #endif } template template inline T ProtocolBuffer::read_int() { T t = T(); for (iterator last = m_position + sizeof(T); m_position != last; ++m_position) t = (t << 8) + *m_position; return t; } template template inline T ProtocolBuffer::peek_int() { T t = T(); for (iterator itr = m_position, last = m_position + sizeof(T); itr != last; ++itr) t = (t << 8) + *itr; return t; } template inline void ProtocolBuffer::write_16(uint16_t v) { #ifndef USE_ALIGNED *reinterpret_cast(m_end) = htons(v); m_end += sizeof(uint16_t); validate_end(); #else write_int(v); #endif } template inline void ProtocolBuffer::write_32(uint32_t v) { #ifndef USE_ALIGNED *reinterpret_cast(m_end) = htonl(v); m_end += sizeof(uint32_t); validate_end(); #else write_int(v); #endif } template inline void ProtocolBuffer::write_32_n(uint32_t v) { *reinterpret_cast(m_end) = v; m_end += sizeof(uint32_t); validate_end(); } template template void ProtocolBuffer::read_range(Out first, Out last) { for ( ; first != last; ++m_position, ++first) *first = *m_position; validate_position(); } template template void ProtocolBuffer::read_len(Out start, unsigned int len) { for ( ; len > 0; ++m_position, ++start, --len) *start = *m_position; validate_position(); } template template inline void ProtocolBuffer::write_int(T v) { for (iterator itr = m_end + sizeof(T); itr != m_end; v >>= 8) *(--itr) = v; m_end += sizeof(T); validate_end(); } template template void ProtocolBuffer::write_range(In first, In last) { for ( ; first != last; ++m_end, ++first) *m_end = *first; validate_end(); } template template void ProtocolBuffer::write_len(In start, unsigned int len) { for ( ; len > 0; ++m_end, ++start, --len) *m_end = *start; validate_end(); } template void ProtocolBuffer::move_unused() { std::memmove(begin(), position(), remaining()); set_end(remaining()); reset_position(); } } #endif libtorrent-0.13.2/src/net/socket_base.cc000644 000765 000024 00000005060 11705767056 021106 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "torrent/exceptions.h" #include "torrent/poll.h" #include "manager.h" #include "socket_base.h" namespace torrent { char* SocketBase::m_nullBuffer = new char[SocketBase::null_buffer_size]; SocketBase::~SocketBase() { if (get_fd().is_valid()) throw internal_error("SocketBase::~SocketBase() called but m_fd is still valid"); } bool SocketBase::read_oob(void* buffer) { int r = ::recv(m_fileDesc, buffer, 1, MSG_OOB); // if (r < 0) // m_errno = errno; return r == 1; } bool SocketBase::write_oob(const void* buffer) { int r = ::send(m_fileDesc, buffer, 1, MSG_OOB); // if (r < 0) // m_errno = errno; return r == 1; } void SocketBase::receive_throttle_down_activate() { manager->poll()->insert_read(this); } void SocketBase::receive_throttle_up_activate() { manager->poll()->insert_write(this); } } // namespace torrent libtorrent-0.13.2/src/net/socket_base.h000644 000765 000024 00000005375 11705767056 020761 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_SOCKET_BASE_H #define LIBTORRENT_NET_SOCKET_BASE_H #include #include #include "torrent/event.h" #include "socket_fd.h" namespace torrent { class SocketBase : public Event { public: SocketBase() { set_fd(SocketFd()); } virtual ~SocketBase(); // Ugly hack... But the alternative is to include SocketFd as part // of the library API or make SocketFd::m_fd into an non-modifiable // value. SocketFd& get_fd() { return *reinterpret_cast(&m_fileDesc); } const SocketFd& get_fd() const { return *reinterpret_cast(&m_fileDesc); } void set_fd(SocketFd fd) { m_fileDesc = fd.get_fd(); } bool read_oob(void* buffer); bool write_oob(const void* buffer); void receive_throttle_down_activate(); void receive_throttle_up_activate(); protected: // Disable copying SocketBase(const SocketBase&); void operator = (const SocketBase&); static const size_t null_buffer_size = 1 << 17; static char* m_nullBuffer; }; } #endif // LIBTORRENT_SOCKET_BASE_H libtorrent-0.13.2/src/net/socket_datagram.cc000644 000765 000024 00000005201 11705767056 021751 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "torrent/exceptions.h" #include #include "socket_datagram.h" namespace torrent { int SocketDatagram::read_datagram(void* buffer, unsigned int length, rak::socket_address* sa) { if (length == 0) throw internal_error("Tried to receive buffer length 0"); int r; socklen_t fromlen; if (sa != NULL) { fromlen = sizeof(rak::socket_address); r = ::recvfrom(m_fileDesc, buffer, length, 0, sa->c_sockaddr(), &fromlen); } else { r = ::recv(m_fileDesc, buffer, length, 0); } return r; } int SocketDatagram::write_datagram(const void* buffer, unsigned int length, rak::socket_address* sa) { if (length == 0) throw internal_error("Tried to send buffer length 0"); int r; if (sa != NULL) { r = ::sendto(m_fileDesc, buffer, length, 0, sa->sa_inet()->c_sockaddr(), sizeof(rak::socket_address_inet)); } else { r = ::send(m_fileDesc, buffer, length, 0); } return r; } } libtorrent-0.13.2/src/net/socket_datagram.h000644 000765 000024 00000004130 11705767056 021613 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_SOCKET_DGRAM_H #define LIBTORRENT_NET_SOCKET_DGRAM_H #include "socket_base.h" namespace torrent { class SocketDatagram : public SocketBase { public: // TODO: Make two seperate functions depending on whetever sa is // used. int read_datagram(void* buffer, unsigned int length, rak::socket_address* sa = NULL); int write_datagram(const void* buffer, unsigned int length, rak::socket_address* sa = NULL); }; } #endif libtorrent-0.13.2/src/net/socket_fd.cc000644 000765 000024 00000011343 11705767056 020566 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include #include #include #include #include #include "torrent/exceptions.h" #include "socket_fd.h" namespace torrent { inline void SocketFd::check_valid() const { if (!is_valid()) throw internal_error("SocketFd function called on an invalid fd."); } bool SocketFd::set_nonblock() { check_valid(); return fcntl(m_fd, F_SETFL, O_NONBLOCK) == 0; } bool SocketFd::set_priority(priority_type p) { check_valid(); int opt = p; return setsockopt(m_fd, IPPROTO_IP, IP_TOS, &opt, sizeof(opt)) == 0; } bool SocketFd::set_reuse_address(bool state) { check_valid(); int opt = state; return setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == 0; } bool SocketFd::set_send_buffer_size(uint32_t s) { check_valid(); int opt = s; return setsockopt(m_fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) == 0; } bool SocketFd::set_receive_buffer_size(uint32_t s) { check_valid(); int opt = s; return setsockopt(m_fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)) == 0; } int SocketFd::get_error() const { check_valid(); int err; socklen_t length = sizeof(err); if (getsockopt(m_fd, SOL_SOCKET, SO_ERROR, &err, &length) == -1) throw internal_error("SocketFd::get_error() could not get error"); return err; } bool SocketFd::open_stream() { return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1; } bool SocketFd::open_datagram() { return (m_fd = socket(rak::socket_address::pf_inet, SOCK_DGRAM, 0)) != -1; } bool SocketFd::open_local() { return (m_fd = socket(rak::socket_address::pf_local, SOCK_STREAM, 0)) != -1; } void SocketFd::close() { if (::close(m_fd) && errno == EBADF) throw internal_error("SocketFd::close() called on an invalid file descriptor"); } bool SocketFd::bind(const rak::socket_address& sa) { check_valid(); return !::bind(m_fd, sa.c_sockaddr(), sa.length()); } bool SocketFd::bind(const rak::socket_address& sa, unsigned int length) { check_valid(); return !::bind(m_fd, sa.c_sockaddr(), length); } bool SocketFd::connect(const rak::socket_address& sa) { check_valid(); return !::connect(m_fd, sa.c_sockaddr(), sa.length()) || errno == EINPROGRESS; } bool SocketFd::listen(int size) { check_valid(); return !::listen(m_fd, size); } SocketFd SocketFd::accept(rak::socket_address* sa) { check_valid(); socklen_t len = sizeof(rak::socket_address); return SocketFd(::accept(m_fd, sa != NULL ? sa->c_sockaddr() : NULL, &len)); } // unsigned int // SocketFd::get_read_queue_size() const { // unsigned int v; // if (!is_valid() || ioctl(m_fd, SIOCINQ, &v) < 0) // throw internal_error("SocketFd::get_read_queue_size() could not be performed"); // return v; // } // unsigned int // SocketFd::get_write_queue_size() const { // unsigned int v; // if (!is_valid() || ioctl(m_fd, SIOCOUTQ, &v) < 0) // throw internal_error("SocketFd::get_write_queue_size() could not be performed"); // return v; // } } libtorrent-0.13.2/src/net/socket_fd.h000644 000765 000024 00000006213 11741526504 020417 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_SOCKET_FD_H #define LIBTORRENT_NET_SOCKET_FD_H #include namespace rak { class socket_address; } namespace torrent { class SocketFd { public: typedef uint8_t priority_type; SocketFd() : m_fd(-1) {} explicit SocketFd(int fd) : m_fd(fd) {} bool is_valid() const { return m_fd >= 0; } int get_fd() const { return m_fd; } void set_fd(int fd) { m_fd = fd; } bool set_nonblock(); bool set_reuse_address(bool state); bool set_priority(priority_type p); bool set_send_buffer_size(uint32_t s); bool set_receive_buffer_size(uint32_t s); int get_error() const; bool open_stream(); bool open_datagram(); bool open_local(); void close(); void clear() { m_fd = -1; } bool bind(const rak::socket_address& sa); bool bind(const rak::socket_address& sa, unsigned int length); bool connect(const rak::socket_address& sa); bool listen(int size); SocketFd accept(rak::socket_address* sa); // unsigned int get_read_queue_size() const; // unsigned int get_write_queue_size() const; private: inline void check_valid() const; int m_fd; }; } #endif libtorrent-0.13.2/src/net/socket_set.cc000644 000765 000024 00000005045 11705767056 020772 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "socket_set.h" namespace torrent { const SocketSet::size_type SocketSet::npos; inline void SocketSet::_replace_with_last(size_type idx) { while (!base_type::empty() && base_type::back() == NULL) base_type::pop_back(); if (idx >= m_table.size()) throw internal_error("SocketSet::_replace_with_last(...) input out-of-bounds"); // This should handle both npos and those that have already been // removed with the above while loop. if (idx >= size()) return; *(begin() + idx) = base_type::back(); _index(base_type::back()) = idx; base_type::pop_back(); } void SocketSet::prepare() { std::for_each(m_erased.begin(), m_erased.end(), std::bind1st(std::mem_fun(&SocketSet::_replace_with_last), this)); m_erased.clear(); } void SocketSet::reserve(size_t openMax) { m_table.resize(openMax, npos); base_type::reserve(openMax); } } libtorrent-0.13.2/src/net/socket_set.h000644 000765 000024 00000010466 11705767056 020637 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_SOCKET_SET_H #define LIBTORRENT_NET_SOCKET_SET_H #include #include #include #include #include "torrent/exceptions.h" #include "torrent/event.h" namespace torrent { // SocketSet's Base is a vector of active SocketBase // instances. 'm_table' is a vector with the size 'openMax', each // element of which points to an active instance in the Base vector. // Propably should rename to EventSet... class SocketSet : private std::vector > { public: typedef uint32_t size_type; typedef std::vector > base_type; typedef std::vector > Table; static const size_type npos = static_cast(-1); using base_type::value_type; using base_type::iterator; using base_type::const_iterator; using base_type::reverse_iterator; using base_type::empty; using base_type::size; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; bool has(Event* s) const { return _index(s) != npos; } iterator find(Event* s); void insert(Event* s); void erase(Event* s); // Remove all erased elements from the container. void prepare(); // Allocate storage for fd's with up to 'openMax' value. TODO: Remove reserve void reserve(size_t openMax); size_t max_size() const { return m_table.size(); } private: size_type& _index(Event* s) { return m_table[s->file_descriptor()]; } const size_type& _index(Event* s) const { return m_table[s->file_descriptor()]; } inline void _replace_with_last(size_type idx); // TODO: Table of indexes or iterators? Table m_table; Table m_erased; }; inline SocketSet::iterator SocketSet::find(Event* s) { if (_index(s) == npos) return end(); return begin() + _index(s); } inline void SocketSet::insert(Event* s) { if (static_cast(s->file_descriptor()) >= m_table.size()) throw internal_error("Tried to insert an out-of-bounds file descriptor to SocketSet"); if (_index(s) != npos) return; _index(s) = size(); base_type::push_back(s); } inline void SocketSet::erase(Event* s) { if (static_cast(s->file_descriptor()) >= m_table.size()) throw internal_error("Tried to erase an out-of-bounds file descriptor from SocketSet"); size_type idx = _index(s); if (idx == npos) return; _index(s) = npos; *(begin() + idx) = NULL; m_erased.push_back(idx); } } #endif libtorrent-0.13.2/src/net/socket_stream.cc000644 000765 000024 00000005643 11705767056 021476 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "socket_stream.h" #include #include #include #include namespace torrent { std::string int_to_string(int v) { char buf[20]; std::sprintf(buf, "%i", v); return buf; } uint32_t SocketStream::read_stream_throws(void* buf, uint32_t length) { int r = read_stream(buf, length); if (r == 0) throw close_connection(); if (r < 0) { if (rak::error_number::current().is_blocked_momentary()) return 0; else if (rak::error_number::current().is_closed()) throw close_connection(); else if (rak::error_number::current().is_blocked_prolonged()) throw blocked_connection(); else throw connection_error(rak::error_number::current().value()); } return r; } uint32_t SocketStream::write_stream_throws(const void* buf, uint32_t length) { int r = write_stream(buf, length); if (r == 0) throw close_connection(); if (r < 0) { if (rak::error_number::current().is_blocked_momentary()) return 0; else if (rak::error_number::current().is_closed()) throw close_connection(); else if (rak::error_number::current().is_blocked_prolonged()) throw blocked_connection(); else throw connection_error(rak::error_number::current().value()); } return r; } } libtorrent-0.13.2/src/net/socket_stream.h000644 000765 000024 00000006611 11705767056 021334 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_SOCKET_STREAM_H #define LIBTORRENT_NET_SOCKET_STREAM_H #include #include #include "torrent/exceptions.h" #include "socket_base.h" namespace torrent { class SocketStream : public SocketBase { public: int read_stream(void* buf, uint32_t length); int write_stream(const void* buf, uint32_t length); // Returns the number of bytes read, or zero if the socket is // blocking. On errors or closed sockets it will throw an // appropriate exception. uint32_t read_stream_throws(void* buf, uint32_t length); uint32_t write_stream_throws(const void* buf, uint32_t length); // Handles all the error catching etc. Returns true if the buffer is // finished reading/writing. bool read_buffer(void* buf, uint32_t length, uint32_t& pos); bool write_buffer(const void* buf, uint32_t length, uint32_t& pos); uint32_t ignore_stream_throws(uint32_t length) { return read_stream_throws(m_nullBuffer, length); } }; inline bool SocketStream::read_buffer(void* buf, uint32_t length, uint32_t& pos) { pos += read_stream_throws(buf, length - pos); return pos == length; } inline bool SocketStream::write_buffer(const void* buf, uint32_t length, uint32_t& pos) { pos += write_stream_throws(buf, length - pos); return pos == length; } inline int SocketStream::read_stream(void* buf, uint32_t length) { if (length == 0) throw internal_error("Tried to read to buffer length 0."); return ::recv(m_fileDesc, buf, length, 0); } inline int SocketStream::write_stream(const void* buf, uint32_t length) { if (length == 0) throw internal_error("Tried to write to buffer length 0."); return ::send(m_fileDesc, buf, length, 0); } } #endif libtorrent-0.13.2/src/net/throttle_internal.cc000644 000765 000024 00000012217 11716350717 022361 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "net/throttle_internal.h" #include "net/throttle_list.h" #include "torrent/exceptions.h" #include "torrent/throttle.h" #include "globals.h" namespace torrent { // Plans: // // Make ThrottleList do a callback when it needs more? This would // allow us to remove us from the task scheduler when we're full. Also // this would let us be abit more flexible with the interval. ThrottleInternal::ThrottleInternal(int flags) : m_flags(flags), m_nextSlave(m_slaveList.end()), m_unusedQuota(0), m_timeLastTick(cachedTime) { if (is_root()) m_taskTick.slot() = std::tr1::bind(&ThrottleInternal::receive_tick, this); } ThrottleInternal::~ThrottleInternal() { if (is_root()) priority_queue_erase(&taskScheduler, &m_taskTick); std::for_each(m_slaveList.begin(), m_slaveList.end(), rak::call_delete()); } void ThrottleInternal::enable() { m_throttleList->enable(); std::for_each(m_slaveList.begin(), m_slaveList.end(), std::mem_fun(&ThrottleInternal::enable)); if (is_root()) { // We need to start the ticks, and make sure we set timeLastTick // to a value that gives an reasonable initial quota. m_timeLastTick = cachedTime - rak::timer::from_seconds(1); receive_tick(); } } void ThrottleInternal::disable() { m_throttleList->disable(); std::for_each(m_slaveList.begin(), m_slaveList.end(), std::mem_fun(&ThrottleInternal::disable)); if (is_root()) priority_queue_erase(&taskScheduler, &m_taskTick); } ThrottleInternal* ThrottleInternal::create_slave() { ThrottleInternal* slave = new ThrottleInternal(flag_none); slave->m_maxRate = m_maxRate; slave->m_throttleList = new ThrottleList(); if (m_throttleList->is_enabled()) slave->enable(); m_slaveList.push_back(slave); m_nextSlave = m_slaveList.end(); return slave; } void ThrottleInternal::receive_tick() { if (cachedTime <= m_timeLastTick + rak::timer::from_milliseconds(90)) throw internal_error("ThrottleInternal::receive_tick() called at a to short interval."); uint32_t quota = ((uint64_t)(cachedTime.usec() - m_ptr()->m_timeLastTick.usec())) * m_maxRate / 1000000; uint32_t fraction = ((uint64_t)(cachedTime.usec() - m_ptr()->m_timeLastTick.usec())) * fraction_base / 1000000; receive_quota(quota, fraction); priority_queue_insert(&taskScheduler, &m_taskTick, cachedTime + calculate_interval()); m_timeLastTick = cachedTime; } int32_t ThrottleInternal::receive_quota(uint32_t quota, uint32_t fraction) { uint32_t need; m_unusedQuota += quota; while (m_nextSlave != m_slaveList.end()) { need = std::min(quota, (uint64_t)fraction * (*m_nextSlave)->max_rate() >> fraction_bits); if (m_unusedQuota < need) break; m_unusedQuota -= (*m_nextSlave)->receive_quota(need, fraction); m_throttleList->add_rate((*m_nextSlave)->throttle_list()->rate_added()); ++m_nextSlave; } need = std::min(quota, (uint64_t)fraction * m_maxRate >> fraction_bits); if (m_nextSlave == m_slaveList.end() && m_unusedQuota >= need) { m_unusedQuota -= m_throttleList->update_quota(need); m_nextSlave = m_slaveList.begin(); } // Return how much quota we used, but keep as much as one // allocation's worth until the next tick to avoid rounding errors. int32_t used = quota; if (m_unusedQuota > quota) { used -= m_unusedQuota - quota; m_unusedQuota = quota; } // Amount used may be negative if rate changed between last tick and now. return used; } } libtorrent-0.13.2/src/net/throttle_internal.h000644 000765 000024 00000005616 11705767056 022236 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_THROTTLE_INTERNAL_H #define LIBTORRENT_NET_THROTTLE_INTERNAL_H #include #include #include "torrent/common.h" #include "torrent/throttle.h" namespace torrent { class ThrottleInternal : public Throttle { public: static const int flag_none = 0; static const int flag_root = 1; ThrottleInternal(int flags); ~ThrottleInternal(); ThrottleInternal* create_slave(); bool is_root() { return m_flags & flag_root; } void enable(); void disable(); private: // Fraction is a fixed-precision value with the given number of bits after the decimal point. static const uint32_t fraction_bits = 16; static const uint32_t fraction_base = (1 << fraction_bits); typedef std::vector SlaveList; void receive_tick(); // Distribute quota, return amount of quota used. May be negative // if it had more unused quota than is now allowed. int32_t receive_quota(uint32_t quota, uint32_t fraction); int m_flags; SlaveList m_slaveList; SlaveList::iterator m_nextSlave; uint32_t m_unusedQuota; rak::timer m_timeLastTick; rak::priority_item m_taskTick; }; } #endif libtorrent-0.13.2/src/net/throttle_list.cc000644 000765 000024 00000017414 11705767056 021532 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "throttle_list.h" #include "throttle_node.h" namespace torrent { ThrottleList::ThrottleList() : m_enabled(false), m_size(0), m_outstandingQuota(0), m_unallocatedQuota(0), m_unusedUnthrottledQuota(0), m_rateAdded(0), m_minChunkSize(2 << 10), m_maxChunkSize(16 << 10), m_rateSlow(60), m_splitActive(end()) { } bool ThrottleList::is_active(const ThrottleNode* node) const { return std::find(begin(), (const_iterator)m_splitActive, node) != m_splitActive; } bool ThrottleList::is_inactive(const ThrottleNode* node) const { return std::find((const_iterator)m_splitActive, end(), node) != end(); } bool ThrottleList::is_throttled(const ThrottleNode* node) const { return node->list_iterator() != end(); } // The quota already present in the node is preserved and unallocated // quota is transferred to the node. The node's quota will be less // than or equal to 'm_minChunkSize'. inline void ThrottleList::allocate_quota(ThrottleNode* node) { if (node->quota() >= m_minChunkSize) return; int quota = std::min(m_maxChunkSize - node->quota(), m_unallocatedQuota); node->set_quota(node->quota() + quota); m_outstandingQuota += quota; m_unallocatedQuota -= quota; } void ThrottleList::enable() { if (m_enabled) return; m_enabled = true; if (!empty() && m_splitActive == begin()) throw internal_error("ThrottleList::enable() m_splitActive is invalid."); } void ThrottleList::disable() { if (!m_enabled) return; m_enabled = false; m_outstandingQuota = 0; m_unallocatedQuota = 0; m_unusedUnthrottledQuota = 0; std::for_each(begin(), end(), std::mem_fun(&ThrottleNode::clear_quota)); std::for_each(m_splitActive, end(), std::mem_fun(&ThrottleNode::activate)); m_splitActive = end(); } int32_t ThrottleList::update_quota(uint32_t quota) { if (!m_enabled) throw internal_error("ThrottleList::update_quota(...) called but the object is not enabled."); // Distribute new quota to unthrottled quota first, and use // left-over unthrottled quota from last turn to be allocated // to throttled nodes this turn. // When distributing, we include the unallocated quota from the // previous turn. This will ensure that quota that was reclaimed // will have a chance of being used, even by those nodes that were // deactivated. m_unallocatedQuota += m_unusedUnthrottledQuota; m_unusedUnthrottledQuota = quota; // Add remaining to the next, even when less than activate border. while (m_splitActive != end()) { allocate_quota(*m_splitActive); if ((*m_splitActive)->quota() < m_minChunkSize) break; (*m_splitActive)->activate(); m_splitActive++; } // Use 'quota' as an upper bound to avoid accumulating unused quota // over time. Return actually used amount of quota. int32_t used = quota; if (m_unallocatedQuota > quota) { used -= m_unallocatedQuota - quota; m_unallocatedQuota = quota; } return used; } uint32_t ThrottleList::node_quota(ThrottleNode* node) { if (!m_enabled) { // Returns max for signed integer to ensure we don't overflow // claculations. return std::numeric_limits::max(); } else if (!is_active(node)) { throw internal_error(is_inactive(node) ? "ThrottleList::node_quota(...) called on an inactive node." : "ThrottleList::node_quota(...) could not find node."); } else if (node->quota() + m_unallocatedQuota >= m_minChunkSize) { return node->quota() + m_unallocatedQuota; } else { return 0; } } void ThrottleList::add_rate(uint32_t used) { m_rateSlow.insert(used); m_rateAdded += used; } uint32_t ThrottleList::node_used(ThrottleNode* node, uint32_t used) { add_rate(used); node->rate()->insert(used); if (used == 0 || !m_enabled || node->list_iterator() == end()) return used; uint32_t quota = std::min(used, node->quota()); if (quota > m_outstandingQuota) throw internal_error("ThrottleList::node_used(...) used too much quota."); node->set_quota(node->quota() - quota); m_outstandingQuota -= quota; m_unallocatedQuota -= std::min(used - quota, m_unallocatedQuota); return used; } uint32_t ThrottleList::node_used_unthrottled(uint32_t used) { add_rate(used); // Use what we can from the unthrottled quota, // if node used too much borrow from throttled quota. uint32_t avail = std::min(used, m_unusedUnthrottledQuota); m_unusedUnthrottledQuota -= avail; m_unallocatedQuota -= std::min(used - avail, m_unallocatedQuota); return used; } void ThrottleList::node_deactivate(ThrottleNode* node) { if (!is_active(node)) throw internal_error(is_inactive(node) ? "ThrottleList::node_deactivate(...) called on an inactive node." : "ThrottleList::node_deactivate(...) could not find node."); base_type::splice(end(), *this, node->list_iterator()); if (m_splitActive == end()) m_splitActive = node->list_iterator(); } void ThrottleList::insert(ThrottleNode* node) { if (node->list_iterator() != end()) return; if (!m_enabled) { // Add to waiting queue. node->set_list_iterator(base_type::insert(end(), node)); node->clear_quota(); } else { // Add before the active split, so if we only need to decrement // m_splitActive to change the queue it is in. node->set_list_iterator(base_type::insert(m_splitActive, node)); allocate_quota(node); } m_size++; } void ThrottleList::erase(ThrottleNode* node) { if (node->list_iterator() == end()) return; if (m_size == 0) throw internal_error("ThrottleList::erase(...) called on an empty list."); // Do we need an if-statement here? if (node->quota() != 0) { if (node->quota() > m_outstandingQuota) throw internal_error("ThrottleList::erase(...) node->quota() > m_outstandingQuota."); m_outstandingQuota -= node->quota(); m_unallocatedQuota += node->quota(); } if (node->list_iterator() == m_splitActive) m_splitActive = base_type::erase(node->list_iterator()); else base_type::erase(node->list_iterator()); node->clear_quota(); node->set_list_iterator(end()); m_size--; } } libtorrent-0.13.2/src/net/throttle_list.h000644 000765 000024 00000011670 11705767056 021372 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_THROTTLE_LIST_H #define LIBTORRENT_NET_THROTTLE_LIST_H #include #include "torrent/rate.h" // To allow conditional compilation depending on whether this patch is applied or not. #define LIBTORRENT_CUSTOM_THROTTLES 1 namespace torrent { class ThrottleNode; class ThrottleList : private std::list { public: typedef std::list base_type; using base_type::iterator; using base_type::const_iterator; using base_type::reverse_iterator; using base_type::clear; using base_type::size; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; ThrottleList(); bool is_enabled() const { return m_enabled; } bool is_active(const ThrottleNode* node) const; bool is_inactive(const ThrottleNode* node) const; bool is_throttled(const ThrottleNode* node) const; // When disabled all nodes are active at all times. void enable(); void disable(); // Returns the amount of quota used. May be negative if it had unused // quota left over from the last call that was more than is now allowed. int32_t update_quota(uint32_t quota); uint32_t size() const { return m_size; } uint32_t outstanding_quota() const { return m_outstandingQuota; } uint32_t unallocated_quota() const { return m_unallocatedQuota; } uint32_t min_chunk_size() const { return m_minChunkSize; } void set_min_chunk_size(uint32_t v) { m_minChunkSize = v; } uint32_t max_chunk_size() const { return m_maxChunkSize; } void set_max_chunk_size(uint32_t v) { m_maxChunkSize = v; } uint32_t node_quota(ThrottleNode* node); uint32_t node_used(ThrottleNode* node, uint32_t used); // both node_used functions uint32_t node_used_unthrottled(uint32_t used); // return the "used" argument void node_deactivate(ThrottleNode* node); const Rate* rate_slow() const { return &m_rateSlow; } void add_rate(uint32_t used); uint32_t rate_added() { uint32_t v = m_rateAdded; m_rateAdded = 0; return v; } // It is asumed that inserted nodes are currently active. It won't // matter if they do not get any initial quota as a later activation // of an active node should be safe. void insert(ThrottleNode* node); void erase(ThrottleNode* node); private: inline void allocate_quota(ThrottleNode* node); bool m_enabled; uint32_t m_size; uint32_t m_outstandingQuota; uint32_t m_unallocatedQuota; uint32_t m_unusedUnthrottledQuota; uint32_t m_rateAdded; uint32_t m_minChunkSize; uint32_t m_maxChunkSize; Rate m_rateSlow; // [m_splitActive,end> contains nodes that are inactive and need // more quote, sorted from the most urgent // node. [begin,m_splitActive> holds nodes with a large enough quota // to transmit, but are blocking. These are sorted from the longest // blocking node. iterator m_splitActive; }; } #endif libtorrent-0.13.2/src/net/throttle_node.h000644 000765 000024 00000006123 11705767056 021341 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_NET_THROTTLE_NODE_H #define LIBTORRENT_NET_THROTTLE_NODE_H #include #include "torrent/rate.h" #include "throttle_list.h" namespace torrent { class SocketBase; class ThrottleNode { public: typedef ThrottleList::iterator iterator; typedef ThrottleList::const_iterator const_iterator; typedef rak::mem_fun0 SlotActivate; ThrottleNode(uint32_t rateSpan) : m_rate(rateSpan) { clear_quota(); } Rate* rate() { return &m_rate; } const Rate* rate() const { return &m_rate; } uint32_t quota() const { return m_quota; } void clear_quota() { m_quota = 0; } void set_quota(uint32_t q) { m_quota = q; } iterator list_iterator() { return m_listIterator; } const_iterator list_iterator() const { return m_listIterator; } void set_list_iterator(iterator itr) { m_listIterator = itr; } void activate() { m_slotActivate(); } void slot_activate(SlotActivate s) { m_slotActivate = s; } private: ThrottleNode(const ThrottleNode&); void operator = (const ThrottleNode&); uint32_t m_quota; iterator m_listIterator; Rate m_rate; SlotActivate m_slotActivate; }; } #endif libtorrent-0.13.2/src/download/available_list.cc000644 000765 000024 00000005602 11716350717 022614 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "torrent/exceptions.h" #include "available_list.h" namespace torrent { AvailableList::value_type AvailableList::pop_random() { if (empty()) throw internal_error("AvailableList::pop_random() called on an empty container"); size_type idx = random() % size(); value_type tmp = *(begin() + idx); *(begin() + idx) = back(); pop_back(); return tmp; } void AvailableList::push_back(const rak::socket_address* sa) { if (std::find(begin(), end(), *sa) != end()) return; base_type::push_back(*sa); } void AvailableList::insert(AddressList* l) { if (!want_more()) return; std::sort(begin(), end()); // Can i use use the std::remove* semantics for this, and just copy // to 'l'?. // // 'l' is guaranteed to be sorted, so we can just do // std::set_difference. AddressList difference; std::set_difference(l->begin(), l->end(), begin(), end(), std::back_inserter(difference)); std::copy(difference.begin(), difference.end(), std::back_inserter(*static_cast(this))); } void AvailableList::erase(const rak::socket_address& sa) { iterator itr = std::find(begin(), end(), sa); if (itr != end()) { *itr = back(); pop_back(); } } } libtorrent-0.13.2/src/download/available_list.h000644 000765 000024 00000006714 11705767056 022471 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_AVAILABLE_LIST_H #define LIBTORRENT_DOWNLOAD_AVAILABLE_LIST_H #include #include #include #include "net/address_list.h" namespace torrent { class AvailableList : private std::vector { public: typedef std::vector base_type; typedef uint32_t size_type; using base_type::value_type; using base_type::reference; using base_type::const_reference; using base_type::iterator; using base_type::const_iterator; using base_type::reverse_iterator; using base_type::size; using base_type::capacity; using base_type::reserve; using base_type::empty; using base_type::clear; using base_type::back; using base_type::pop_back; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; AvailableList() : m_maxSize(1000) {} value_type pop_random(); // Fuzzy size limit. size_type max_size() const { return m_maxSize; } void set_max_size(size_type s) { m_maxSize = s; } bool want_more() const { return size() <= m_maxSize; } // This push is somewhat inefficient as it iterates through the // whole container to see if the address already exists. void push_back(const rak::socket_address* sa); void insert(AddressList* l); void erase(const rak::socket_address& sa); void erase(iterator itr) { *itr = back(); pop_back(); } // A place to temporarily put addresses before re-adding them to the // AvailableList. AddressList* buffer() { return &m_buffer; } private: size_type m_maxSize; AddressList m_buffer; }; } #endif libtorrent-0.13.2/src/download/chunk_selector.cc000644 000765 000024 00000022145 11705767056 022660 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include "protocol/peer_chunks.h" #include "torrent/exceptions.h" #include "chunk_selector.h" #include "chunk_statistics.h" namespace torrent { // Consider making statistics a part of selector. void ChunkSelector::initialize(ChunkStatistics* cs) { m_position = invalid_chunk; m_statistics = cs; Bitfield* completed = m_data->mutable_completed_bitfield(); Bitfield* untouched = m_data->mutable_untouched_bitfield(); untouched->set_size_bits(completed->size_bits()); untouched->allocate(); std::transform(completed->begin(), completed->end(), untouched->begin(), rak::invert()); untouched->update(); m_sharedQueue.enable(32); m_sharedQueue.clear(); } void ChunkSelector::cleanup() { m_data->mutable_untouched_bitfield()->clear(); m_statistics = NULL; } // Consider if ChunksSelector::not_using_index(...) needs to be // modified. void ChunkSelector::update_priorities() { if (empty()) return; m_sharedQueue.clear(); if (m_position == invalid_chunk) m_position = random() % size(); advance_position(); } uint32_t ChunkSelector::find(PeerChunks* pc, __UNUSED bool highPriority) { // This needs to be re-enabled. if (m_position == invalid_chunk) return invalid_chunk; // When we're a seeder, 'm_sharedQueue' is used. Since the peer's // bitfield is guaranteed to be filled we can use the same code as // for non-seeders. This generalization does incur a slight // performance hit as it compares against a bitfield we know has all // set. rak::partial_queue* queue = pc->is_seeder() ? &m_sharedQueue : pc->download_cache(); // Randomize position on average every 16 chunks to prevent // inefficient distribution with a slow seed and fast peers // all arriving at the same position. if ((random() & 63) == 0) { m_position = random() % size(); queue->clear(); } if (queue->is_enabled()) { // First check the cached queue. while (queue->prepare_pop()) { uint32_t pos = queue->pop(); if (!m_data->untouched_bitfield()->get(pos)) continue; return pos; } } else { // Only non-seeders can reach this branch as m_sharedQueue is // always enabled. queue->enable(8); } queue->clear(); (search_linear(pc->bitfield(), queue, m_data->high_priority(), m_position, size()) && search_linear(pc->bitfield(), queue, m_data->high_priority(), 0, m_position)); if (queue->prepare_pop()) { // Set that the peer has high priority pieces cached. } else { // Set that the peer has normal priority pieces cached. // Urgh... queue->clear(); (search_linear(pc->bitfield(), queue, m_data->normal_priority(), m_position, size()) && search_linear(pc->bitfield(), queue, m_data->normal_priority(), 0, m_position)); if (!queue->prepare_pop()) return invalid_chunk; } uint32_t pos = queue->pop(); if (!m_data->untouched_bitfield()->get(pos)) throw internal_error("ChunkSelector::find(...) bad index."); return pos; } bool ChunkSelector::is_wanted(uint32_t index) const { return m_data->untouched_bitfield()->get(index) && (m_data->normal_priority()->has(index) || m_data->high_priority()->has(index)); } void ChunkSelector::using_index(uint32_t index) { if (index >= size()) throw internal_error("ChunkSelector::select_index(...) index out of range."); if (!m_data->untouched_bitfield()->get(index)) throw internal_error("ChunkSelector::select_index(...) index already set."); m_data->mutable_untouched_bitfield()->unset(index); // We always know 'm_position' points to a wanted chunk. If it // changes, we need to move m_position to the next one. if (index == m_position) advance_position(); } void ChunkSelector::not_using_index(uint32_t index) { if (index >= size()) throw internal_error("ChunkSelector::deselect_index(...) index out of range."); if (m_data->untouched_bitfield()->get(index)) throw internal_error("ChunkSelector::deselect_index(...) index already unset."); m_data->mutable_untouched_bitfield()->set(index); // This will make sure that if we enable new chunks, it will start // downloading them event when 'index == invalid_chunk'. if (m_position == invalid_chunk) m_position = index; } // This could propably be split into two functions, one for checking // if it shoul insert into the download_queue(), and the other // whetever we are interested in the new piece. // // Since this gets called whenever a new piece arrives, we can skip // the rarity-first/linear etc searches through bitfields and just // start downloading. bool ChunkSelector::received_have_chunk(PeerChunks* pc, uint32_t index) { if (!m_data->untouched_bitfield()->get(index)) return false; // Also check if the peer only has high-priority chunks. if (!m_data->high_priority()->has(index) && !m_data->normal_priority()->has(index)) return false; if (pc->download_cache()->is_enabled()) pc->download_cache()->insert(m_statistics->rarity(index), index); return true; } bool ChunkSelector::search_linear(const Bitfield* bf, rak::partial_queue* pq, const download_data::priority_ranges* ranges, uint32_t first, uint32_t last) { download_data::priority_ranges::const_iterator itr = ranges->find(first); while (itr != ranges->end() && itr->first < last) { if (!search_linear_range(bf, pq, std::max(first, itr->first), std::min(last, itr->second))) return false; ++itr; } return true; } // Could propably add another argument for max seen or something, this // would be used to find better chunks to request. inline bool ChunkSelector::search_linear_range(const Bitfield* bf, rak::partial_queue* pq, uint32_t first, uint32_t last) { if (first >= last || last > size()) throw internal_error("ChunkSelector::search_linear_range(...) received an invalid range."); Bitfield::const_iterator local = m_data->untouched_bitfield()->begin() + first / 8; Bitfield::const_iterator source = bf->begin() + first / 8; // Unset any bits before 'first'. Bitfield::value_type wanted = (*source & *local) & Bitfield::mask_from(first % 8); while (m_data->untouched_bitfield()->position(local + 1) < last) { if (wanted && !search_linear_byte(pq, m_data->untouched_bitfield()->position(local), wanted)) return false; wanted = (*++source & *++local); } // Unset any bits from 'last'. wanted &= Bitfield::mask_before(last - m_data->untouched_bitfield()->position(local)); if (wanted) return search_linear_byte(pq, m_data->untouched_bitfield()->position(local), wanted); else return true; } // Take pointer to partial_queue inline bool ChunkSelector::search_linear_byte(rak::partial_queue* pq, uint32_t index, Bitfield::value_type wanted) { for (int i = 0; i < 8; ++i) { if (!(wanted & Bitfield::mask_at(i))) continue; if (!pq->insert(m_statistics->rarity(index + i), index + i) && pq->is_full()) return false; } return true; } void ChunkSelector::advance_position() { // Need to replace with a special-purpose function for finding the // next position. // int position = m_position; // ((m_position = search_linear(&m_bitfield, &m_highPriority, position, size())) == invalid_chunk && // (m_position = search_linear(&m_bitfield, &m_highPriority, 0, position)) == invalid_chunk && // (m_position = search_linear(&m_bitfield, &m_normalPriority, position, size())) == invalid_chunk && // (m_position = search_linear(&m_bitfield, &m_normalPriority, 0, position)) == invalid_chunk); } } libtorrent-0.13.2/src/download/chunk_selector.h000644 000765 000024 00000011447 11705767056 022525 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_CHUNK_SELECTOR_H #define LIBTORRENT_DOWNLOAD_CHUNK_SELECTOR_H #include #include #include "torrent/bitfield.h" #include "torrent/data/download_data.h" #include "torrent/utils/ranges.h" namespace torrent { // This class is responsible for deciding on which chunk index to // download next based on the peer's bitfield. It keeps its own // bitfield which starts out as a copy of Content::bitfield but sets // chunks that are being downloaded. // // When updating Content::bitfield, make sure you update this bitfield // and unmark any chunks in Delegator. class ChunkStatistics; class PeerChunks; class ChunkSelector { public: static const uint32_t invalid_chunk = ~(uint32_t)0; ChunkSelector(download_data* data) : m_data(data) {} bool empty() const { return size() == 0; } uint32_t size() const { return m_data->untouched_bitfield()->size_bits(); } // const Bitfield* bitfield() { return m_data->untouched_bitfield(); } // priority_ranges* high_priority() { return &m_highPriority; } // priority_ranges* normal_priority() { return &m_normalPriority; } // Initialize doesn't update the priority cache, so it is as if it // has empty priority ranges. void initialize(ChunkStatistics* cs); void cleanup(); // Call this once you've modified the bitfield or priorities to // update cached information. This must be called once before using // find. void update_priorities(); uint32_t find(PeerChunks* pc, bool highPriority); bool is_wanted(uint32_t index) const; // Call this to set the index as being downloaded, finished etc, // thus ignored. Propably should find a better name for this. void using_index(uint32_t index); void not_using_index(uint32_t index); // The caller must ensure that the chunk index is valid and has not // been set already. // // The user only needs to call this when it needs to know whetever // it should become interested, or if it is in the process of // downloading. // // Returns whetever we're interested in that piece. bool received_have_chunk(PeerChunks* pc, uint32_t index); private: bool search_linear(const Bitfield* bf, rak::partial_queue* pq, const download_data::priority_ranges* ranges, uint32_t first, uint32_t last); inline bool search_linear_range(const Bitfield* bf, rak::partial_queue* pq, uint32_t first, uint32_t last); inline bool search_linear_byte(rak::partial_queue* pq, uint32_t index, Bitfield::value_type wanted); // inline uint32_t search_rarest(const Bitfield* bf, priority_ranges* ranges, uint32_t first, uint32_t last); // inline uint32_t search_rarest_range(const Bitfield* bf, uint32_t first, uint32_t last); // inline uint32_t search_rarest_byte(uint8_t wanted); void advance_position(); download_data* m_data; ChunkStatistics* m_statistics; rak::partial_queue m_sharedQueue; uint32_t m_position; }; } #endif libtorrent-0.13.2/src/download/chunk_statistics.cc000644 000765 000024 00000011520 11705767056 023225 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/exceptions.h" #include "protocol/peer_chunks.h" #include "chunk_statistics.h" namespace torrent { inline bool ChunkStatistics::should_add(PeerChunks* pc) { return m_accounted < max_accounted; } void ChunkStatistics::initialize(size_type s) { if (!empty()) throw internal_error("ChunkStatistics::initialize(...) called on an initialized object."); base_type::resize(s); } void ChunkStatistics::clear() { if (m_complete != 0) throw internal_error("ChunkStatistics::clear() m_complete != 0."); base_type::clear(); } void ChunkStatistics::received_connect(PeerChunks* pc) { if (pc->using_counter()) throw internal_error("ChunkStatistics::received_connect(...) pc->using_counter() == true."); if (pc->bitfield()->is_all_set()) { pc->set_using_counter(true); m_complete++; } else if (!pc->bitfield()->is_all_unset() && should_add(pc)) { // There should be additional checks, so that we don't do this // when there's no need. pc->set_using_counter(true); m_accounted++; iterator itr = base_type::begin(); // Use a bitfield iterator instead. for (Bitfield::size_type index = 0; index < pc->bitfield()->size_bits(); ++index, ++itr) *itr += pc->bitfield()->get(index); } } void ChunkStatistics::received_disconnect(PeerChunks* pc) { // The 'using_counter' of complete peers is used, but not added to // 'm_accounted', so that we can safely disconnect peers right after // receiving the bitfield without calling 'received_connect'. if (!pc->using_counter()) return; pc->set_using_counter(false); if (pc->bitfield()->is_all_set()) { m_complete--; } else { if (m_accounted == 0) throw internal_error("ChunkStatistics::received_disconnect(...) m_accounted == 0."); m_accounted--; iterator itr = base_type::begin(); // Use a bitfield iterator instead. for (Bitfield::size_type index = 0; index < pc->bitfield()->size_bits(); ++index, ++itr) *itr -= pc->bitfield()->get(index); } } void ChunkStatistics::received_have_chunk(PeerChunks* pc, uint32_t index, uint32_t length) { // When the bitfield is empty, it is very cheap to add the peer to // the statistics. It needs to be done here else we need to check if // a connection has sent any messages, else it might send a bitfield. if (pc->bitfield()->is_all_unset() && should_add(pc)) { if (pc->using_counter()) throw internal_error("ChunkStatistics::received_have_chunk(...) pc->using_counter() == true."); pc->set_using_counter(true); m_accounted++; } pc->bitfield()->set(index); pc->peer_rate()->insert(length); if (pc->using_counter()) { base_type::operator[](index)++; // The below code should not cause useless work to be done in case // of immediate disconnect. if (pc->bitfield()->is_all_set()) { if (m_accounted == 0) throw internal_error("ChunkStatistics::received_disconnect(...) m_accounted == 0."); m_complete++; m_accounted--; for (iterator itr = base_type::begin(), last = base_type::end(); itr != last; ++itr) *itr -= 1; } } else { if (pc->bitfield()->is_all_set()) { pc->set_using_counter(true); m_complete++; } } } } libtorrent-0.13.2/src/download/chunk_statistics.h000644 000765 000024 00000010311 11705767056 023064 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_CHUNK_STATISTICS_H #define LIBTORRENT_DOWNLOAD_CHUNK_STATISTICS_H #include #include namespace torrent { class PeerChunks; class ChunkStatistics : public std::vector { public: typedef std::vector base_type; typedef uint32_t size_type; typedef base_type::value_type value_type; typedef base_type::reference reference; typedef base_type::const_reference const_reference; typedef base_type::iterator iterator; typedef base_type::const_iterator const_iterator; typedef base_type::reverse_iterator reverse_iterator; using base_type::empty; using base_type::size; static const size_type max_accounted = 255; ChunkStatistics() : m_complete(0), m_accounted(0) {} ~ChunkStatistics() {} size_type complete() const { return m_complete; } //size_type incomplete() const; // Number of non-complete peers whom's bitfield is added to the // statistics. size_type accounted() const { return m_accounted; } void initialize(size_type s); void clear(); // When a peer connects and sends a non-empty bitfield and is not a // seeder, we can be fairly sure it won't just disconnect // immediately. Thus it should be resonable to possibly spend the // effort adding it to the statistics if nessesary. // Where do we decide on policy? On whetever we count the chunks, // the type of connection shouldn't matter? As f.ex PCSeed will only // make sense when seeding, it won't be counted. // Might want to prefer to add peers we are interested in, but which // arn't in us. void received_connect(PeerChunks* pc); void received_disconnect(PeerChunks* pc); // The caller must ensure that the chunk index is valid and has not // been set already. void received_have_chunk(PeerChunks* pc, uint32_t index, uint32_t length); const_iterator begin() const { return base_type::begin(); } const_iterator end() const { return base_type::end(); } const_reference rarity(size_type n) const { return base_type::operator[](n); } const_reference operator [] (size_type n) const { return base_type::operator[](n); } private: inline bool should_add(PeerChunks* pc); ChunkStatistics(const ChunkStatistics&); void operator = (const ChunkStatistics&); size_type m_complete; size_type m_accounted; }; } #endif libtorrent-0.13.2/src/download/delegator.cc000644 000765 000024 00000017637 11705767056 021630 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Fucked up ugly piece of hack, this code. #include "config.h" #include #include #include "torrent/exceptions.h" #include "torrent/bitfield.h" #include "torrent/data/block.h" #include "torrent/data/block_list.h" #include "torrent/data/block_transfer.h" #include "protocol/peer_chunks.h" #include "delegator.h" namespace torrent { struct DelegatorCheckAffinity { DelegatorCheckAffinity(Delegator* delegator, Block** target, unsigned int index, const PeerInfo* peerInfo) : m_delegator(delegator), m_target(target), m_index(index), m_peerInfo(peerInfo) {} bool operator () (BlockList* d) { return m_index == d->index() && (*m_target = m_delegator->delegate_piece(d, m_peerInfo)) != NULL; } Delegator* m_delegator; Block** m_target; unsigned int m_index; const PeerInfo* m_peerInfo; }; struct DelegatorCheckSeeder { DelegatorCheckSeeder(Delegator* delegator, Block** target, const PeerInfo* peerInfo) : m_delegator(delegator), m_target(target), m_peerInfo(peerInfo) {} bool operator () (BlockList* d) { return d->by_seeder() && (*m_target = m_delegator->delegate_piece(d, m_peerInfo)) != NULL; } Delegator* m_delegator; Block** m_target; const PeerInfo* m_peerInfo; }; struct DelegatorCheckPriority { DelegatorCheckPriority(Delegator* delegator, Block** target, priority_t p, const PeerChunks* peerChunks) : m_delegator(delegator), m_target(target), m_priority(p), m_peerChunks(peerChunks) {} bool operator () (BlockList* d) { return m_priority == d->priority() && m_peerChunks->bitfield()->get(d->index()) && (*m_target = m_delegator->delegate_piece(d, m_peerChunks->peer_info())) != NULL; } Delegator* m_delegator; Block** m_target; priority_t m_priority; const PeerChunks* m_peerChunks; }; // TODO: Should this ensure we don't download pieces that are priority off? struct DelegatorCheckAggressive { DelegatorCheckAggressive(Delegator* delegator, Block** target, uint16_t* o, const PeerChunks* peerChunks) : m_delegator(delegator), m_target(target), m_overlapp(o), m_peerChunks(peerChunks) {} bool operator () (BlockList* d) { Block* tmp; if (!m_peerChunks->bitfield()->get(d->index()) || d->priority() == PRIORITY_OFF || (tmp = m_delegator->delegate_aggressive(d, m_overlapp, m_peerChunks->peer_info())) == NULL) return false; *m_target = tmp; return m_overlapp == 0; } Delegator* m_delegator; Block** m_target; uint16_t* m_overlapp; const PeerChunks* m_peerChunks; }; BlockTransfer* Delegator::delegate(PeerChunks* peerChunks, int affinity) { // TODO: Make sure we don't queue the same piece several time on the same peer when // it timeout cancels them. Block* target = NULL; // Find piece with same index as affinity. This affinity should ensure that we // never start another piece while the chunk this peer used to download is still // in progress. // // TODO: What if the hash failed? Don't want data from that peer again. if (affinity >= 0 && std::find_if(m_transfers.begin(), m_transfers.end(), DelegatorCheckAffinity(this, &target, affinity, peerChunks->peer_info())) != m_transfers.end()) return target->insert(peerChunks->peer_info()); if (peerChunks->is_seeder() && (target = delegate_seeder(peerChunks)) != NULL) return target->insert(peerChunks->peer_info()); // High priority pieces. if (std::find_if(m_transfers.begin(), m_transfers.end(), DelegatorCheckPriority(this, &target, PRIORITY_HIGH, peerChunks)) != m_transfers.end()) return target->insert(peerChunks->peer_info()); // Find normal priority pieces. if ((target = new_chunk(peerChunks, true))) return target->insert(peerChunks->peer_info()); // Normal priority pieces. if (std::find_if(m_transfers.begin(), m_transfers.end(), DelegatorCheckPriority(this, &target, PRIORITY_NORMAL, peerChunks)) != m_transfers.end()) return target->insert(peerChunks->peer_info()); if ((target = new_chunk(peerChunks, false))) return target->insert(peerChunks->peer_info()); if (!m_aggressive) return NULL; // Aggressive mode, look for possible downloads that already have // one or more queued. // No more than 4 per piece. uint16_t overlapped = 5; std::find_if(m_transfers.begin(), m_transfers.end(), DelegatorCheckAggressive(this, &target, &overlapped, peerChunks)); return target ? target->insert(peerChunks->peer_info()) : NULL; } Block* Delegator::delegate_seeder(PeerChunks* peerChunks) { Block* target = NULL; if (std::find_if(m_transfers.begin(), m_transfers.end(), DelegatorCheckSeeder(this, &target, peerChunks->peer_info())) != m_transfers.end()) return target; if ((target = new_chunk(peerChunks, true))) return target; if ((target = new_chunk(peerChunks, false))) return target; return NULL; } Block* Delegator::new_chunk(PeerChunks* pc, bool highPriority) { uint32_t index = m_slotChunkFind(pc, highPriority); if (index == ~(uint32_t)0) return NULL; TransferList::iterator itr = m_transfers.insert(Piece(index, 0, m_slotChunkSize(index)), block_size); (*itr)->set_by_seeder(pc->is_seeder()); if (highPriority) (*itr)->set_priority(PRIORITY_HIGH); else (*itr)->set_priority(PRIORITY_NORMAL); return &*(*itr)->begin(); } Block* Delegator::delegate_piece(BlockList* c, const PeerInfo* peerInfo) { Block* p = NULL; for (BlockList::iterator i = c->begin(); i != c->end(); ++i) { if (i->is_finished() || !i->is_stalled()) continue; if (i->size_all() == 0) { // No one is downloading this, assign. return &*i; } else if (p == NULL && i->find(peerInfo) == NULL) { // Stalled but we really want to finish this piece. Check 'p' so // that we don't end up queuing the pieces in reverse. p = &*i; } } return p; } Block* Delegator::delegate_aggressive(BlockList* c, uint16_t* overlapped, const PeerInfo* peerInfo) { Block* p = NULL; for (BlockList::iterator i = c->begin(); i != c->end() && *overlapped != 0; ++i) if (!i->is_finished() && i->size_not_stalled() < *overlapped && i->find(peerInfo) == NULL) { p = &*i; *overlapped = i->size_not_stalled(); } return p; } } // namespace torrent libtorrent-0.13.2/src/download/delegator.h000644 000765 000024 00000007142 11705767056 021460 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DELEGATOR_H #define LIBTORRENT_DELEGATOR_H #include #include #include #include "torrent/data/transfer_list.h" namespace torrent { class Block; class BlockList; class BlockTransfer; class FileList; class DownloadMain; class Piece; class PeerChunks; class PeerInfo; class ChunkSelector; class Delegator { public: typedef rak::mem_fun1 SlotChunkIndex; typedef rak::mem_fun2 SlotChunkFind; typedef rak::const_mem_fun1 SlotChunkSize; static const unsigned int block_size = 1 << 14; Delegator() : m_aggressive(false) { } TransferList* transfer_list() { return &m_transfers; } const TransferList* transfer_list() const { return &m_transfers; } BlockTransfer* delegate(PeerChunks* peerChunks, int affinity); bool get_aggressive() { return m_aggressive; } void set_aggressive(bool a) { m_aggressive = a; } void slot_chunk_find(SlotChunkFind s) { m_slotChunkFind = s; } void slot_chunk_size(SlotChunkSize s) { m_slotChunkSize = s; } // Don't call this from the outside. Block* delegate_piece(BlockList* c, const PeerInfo* peerInfo); Block* delegate_aggressive(BlockList* c, uint16_t* overlapped, const PeerInfo* peerInfo); private: // Start on a new chunk, returns .end() if none possible. bf is // remote peer's bitfield. Block* new_chunk(PeerChunks* pc, bool highPriority); Block* delegate_seeder(PeerChunks* peerChunks); TransferList m_transfers; bool m_aggressive; // Propably should add a m_slotChunkStart thing, which will take // care of enabling etc, and will be possible to listen to. SlotChunkFind m_slotChunkFind; SlotChunkSize m_slotChunkSize; }; } #endif libtorrent-0.13.2/src/download/download_constructor.cc000644 000765 000024 00000040221 11705767056 024117 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include #include "download/download_wrapper.h" #include "torrent/dht_manager.h" #include "torrent/exceptions.h" #include "torrent/object.h" #include "torrent/tracker_controller.h" #include "torrent/tracker_list.h" #include "torrent/data/file.h" #include "torrent/data/file_list.h" #include "download_constructor.h" #include "manager.h" namespace torrent { struct download_constructor_is_single_path { bool operator () (Object::map_type::const_reference v) const { return std::strncmp(v.first.c_str(), "name.", sizeof("name.") - 1) == 0 && v.second.is_string(); } }; struct download_constructor_is_multi_path { bool operator () (Object::map_type::const_reference v) const { return std::strncmp(v.first.c_str(), "path.", sizeof("path.") - 1) == 0 && v.second.is_list(); } }; struct download_constructor_encoding_match : public std::binary_function { bool operator () (const Path& p, const char* enc) { return strcasecmp(p.encoding().c_str(), enc) == 0; } }; void DownloadConstructor::initialize(Object& b) { if (!b.has_key_map("info") && b.has_key_string("magnet-uri")) parse_magnet_uri(b, b.get_key_string("magnet-uri")); if (b.has_key_string("encoding")) m_defaultEncoding = b.get_key_string("encoding"); if (b.has_key_value("creation date")) m_download->info()->set_creation_date(b.get_key_value("creation date")); if (b.get_key("info").has_key_value("private") && b.get_key("info").get_key_value("private") == 1) m_download->info()->set_private(); parse_name(b.get_key("info")); parse_info(b.get_key("info")); } // Currently using a hack of the path thingie to extract the correct // torrent name. void DownloadConstructor::parse_name(const Object& b) { if (is_invalid_path_element(b.get_key("name"))) throw input_error("Bad torrent file, \"name\" is an invalid path name."); std::list pathList; pathList.push_back(Path()); pathList.back().set_encoding(m_defaultEncoding); pathList.back().push_back(b.get_key_string("name")); for (Object::map_const_iterator itr = b.as_map().begin(); (itr = std::find_if(itr, b.as_map().end(), download_constructor_is_single_path())) != b.as_map().end(); ++itr) { pathList.push_back(Path()); pathList.back().set_encoding(itr->first.substr(sizeof("name.") - 1)); pathList.back().push_back(itr->second.as_string()); } if (pathList.empty()) throw input_error("Bad torrent file, an entry has no valid name."); Path name = choose_path(&pathList); if (name.empty()) throw internal_error("DownloadConstructor::parse_name(...) Ended up with an empty Path."); m_download->info()->set_name(name.front()); } void DownloadConstructor::parse_info(const Object& b) { FileList* fileList = m_download->main()->file_list(); if (!fileList->empty()) throw internal_error("parse_info received an already initialized Content object."); if (b.flags() & Object::flag_unordered) throw input_error("Download has unordered info dictionary."); uint32_t chunkSize; if (b.has_key_value("meta_download") && b.get_key_value("meta_download")) m_download->info()->set_flags(DownloadInfo::flag_meta_download); if (m_download->info()->is_meta_download()) { if (b.get_key_string("pieces").length() != HashString::size_data) throw input_error("Meta-download has invalid piece data."); chunkSize = 1; parse_single_file(b, chunkSize); } else { chunkSize = b.get_key_value("piece length"); if (chunkSize <= (1 << 10) || chunkSize > (128 << 20)) throw input_error("Torrent has an invalid \"piece length\"."); } if (b.has_key("length")) { parse_single_file(b, chunkSize); } else if (b.has_key("files")) { parse_multi_files(b.get_key("files"), chunkSize); fileList->set_root_dir("./" + m_download->info()->name()); } else if (!m_download->info()->is_meta_download()) { throw input_error("Torrent must have either length or files entry."); } if (fileList->size_bytes() == 0 && !m_download->info()->is_meta_download()) throw input_error("Torrent has zero length."); // Set chunksize before adding files to make sure the index range is // correct. m_download->set_complete_hash(b.get_key_string("pieces")); if (m_download->complete_hash().size() / 20 < fileList->size_chunks()) throw bencode_error("Torrent size and 'info:pieces' length does not match."); } void DownloadConstructor::parse_tracker(const Object& b) { const Object::list_type* announce_list = NULL; if (b.has_key_list("announce-list") && // Some torrent makers create empty/invalid 'announce-list' // entries while still having valid 'announce'. !(announce_list = &b.get_key_list("announce-list"))->empty() && std::find_if(announce_list->begin(), announce_list->end(), std::mem_fun_ref(&Object::is_list)) != announce_list->end()) std::for_each(announce_list->begin(), announce_list->end(), rak::make_mem_fun(this, &DownloadConstructor::add_tracker_group)); else if (b.has_key("announce")) add_tracker_single(b.get_key("announce"), 0); else if (!manager->dht_manager()->is_valid() || m_download->info()->is_private()) throw bencode_error("Could not find any trackers"); if (manager->dht_manager()->is_valid() && !m_download->info()->is_private()) m_download->main()->tracker_list()->insert_url(m_download->main()->tracker_list()->size_group(), "dht://"); if (manager->dht_manager()->is_valid() && b.has_key_list("nodes")) std::for_each(b.get_key_list("nodes").begin(), b.get_key_list("nodes").end(), rak::make_mem_fun(this, &DownloadConstructor::add_dht_node)); m_download->main()->tracker_list()->randomize_group_entries(); } void DownloadConstructor::add_tracker_group(const Object& b) { if (!b.is_list()) throw bencode_error("Tracker group list not a list"); std::for_each(b.as_list().begin(), b.as_list().end(), rak::bind2nd(rak::make_mem_fun(this, &DownloadConstructor::add_tracker_single), m_download->main()->tracker_list()->size_group())); } void DownloadConstructor::add_tracker_single(const Object& b, int group) { if (!b.is_string()) throw bencode_error("Tracker entry not a string"); m_download->main()->tracker_list()->insert_url(group, rak::trim_classic(b.as_string())); } void DownloadConstructor::add_dht_node(const Object& b) { if (!b.is_list() || b.as_list().size() < 2) return; Object::list_type::const_iterator el = b.as_list().begin(); if (!el->is_string()) return; const std::string& host = el->as_string(); if (!(++el)->is_value()) return; manager->dht_manager()->add_node(host, el->as_value()); } bool DownloadConstructor::is_valid_path_element(const Object& b) { return b.is_string() && b.as_string() != "." && b.as_string() != ".." && std::find(b.as_string().begin(), b.as_string().end(), '/') == b.as_string().end() && std::find(b.as_string().begin(), b.as_string().end(), '\0') == b.as_string().end(); } void DownloadConstructor::parse_single_file(const Object& b, uint32_t chunkSize) { if (is_invalid_path_element(b.get_key("name"))) throw input_error("Bad torrent file, \"name\" is an invalid path name."); FileList* fileList = m_download->main()->file_list(); fileList->initialize(chunkSize == 1 ? 1 : b.get_key_value("length"), chunkSize); fileList->set_multi_file(false); std::list pathList; pathList.push_back(Path()); pathList.back().set_encoding(m_defaultEncoding); pathList.back().push_back(b.get_key_string("name")); for (Object::map_const_iterator itr = b.as_map().begin(); (itr = std::find_if(itr, b.as_map().end(), download_constructor_is_single_path())) != b.as_map().end(); ++itr) { pathList.push_back(Path()); pathList.back().set_encoding(itr->first.substr(sizeof("name.") - 1)); pathList.back().push_back(itr->second.as_string()); } if (pathList.empty()) throw input_error("Bad torrent file, an entry has no valid filename."); *fileList->front()->mutable_path() = choose_path(&pathList); fileList->update_paths(fileList->begin(), fileList->end()); } void DownloadConstructor::parse_multi_files(const Object& b, uint32_t chunkSize) { const Object::list_type& objectList = b.as_list(); // Multi file torrent if (objectList.empty()) throw input_error("Bad torrent file, entry has no files."); int64_t torrentSize = 0; std::vector splitList(objectList.size()); std::vector::iterator splitItr = splitList.begin(); for (Object::list_const_iterator listItr = objectList.begin(), listLast = objectList.end(); listItr != listLast; ++listItr, ++splitItr) { std::list pathList; if (listItr->has_key_list("path")) pathList.push_back(create_path(listItr->get_key_list("path"), m_defaultEncoding)); Object::map_const_iterator itr = listItr->as_map().begin(); Object::map_const_iterator last = listItr->as_map().end(); while ((itr = std::find_if(itr, last, download_constructor_is_multi_path())) != last) { pathList.push_back(create_path(itr->second.as_list(), itr->first.substr(sizeof("path.") - 1))); ++itr; } if (pathList.empty()) throw input_error("Bad torrent file, an entry has no valid filename."); int64_t length = listItr->get_key_value("length"); if (length < 0 || torrentSize + length < 0) throw input_error("Bad torrent file, invalid length for file."); torrentSize += length; *splitItr = FileList::split_type(length, choose_path(&pathList)); } FileList* fileList = m_download->main()->file_list(); fileList->set_multi_file(true); fileList->initialize(torrentSize, chunkSize); fileList->split(fileList->begin(), &*splitList.begin(), &*splitList.end()); fileList->update_paths(fileList->begin(), fileList->end()); } inline Path DownloadConstructor::create_path(const Object::list_type& plist, const std::string enc) { // Make sure we are given a proper file path. if (plist.empty()) throw input_error("Bad torrent file, \"path\" has zero entries."); if (std::find_if(plist.begin(), plist.end(), std::ptr_fun(&DownloadConstructor::is_invalid_path_element)) != plist.end()) throw input_error("Bad torrent file, \"path\" has zero entries or a zero length entry."); Path p; p.set_encoding(enc); std::transform(plist.begin(), plist.end(), std::back_inserter(p), std::mem_fun_ref(&Object::as_string)); return p; } inline Path DownloadConstructor::choose_path(std::list* pathList) { std::list::iterator pathFirst = pathList->begin(); std::list::iterator pathLast = pathList->end(); EncodingList::const_iterator encodingFirst = m_encodingList->begin(); EncodingList::const_iterator encodingLast = m_encodingList->end(); for ( ; encodingFirst != encodingLast; ++encodingFirst) { std::list::iterator itr = std::find_if(pathFirst, pathLast, rak::bind2nd(download_constructor_encoding_match(), encodingFirst->c_str())); if (itr != pathLast) pathList->splice(pathFirst, *pathList, itr); } return pathList->front(); } static const char* parse_base32_sha1(const char* pos, HashString& hash) { HashString::iterator hashItr = hash.begin(); static const int base_shift = 8+8-5; int shift = base_shift; uint16_t decoded = 0; while (*pos) { char c = *pos++; uint16_t value; if (c >= 'A' && c <= 'Z') value = c - 'A'; else if (c >= 'a' && c <= 'z') value = c - 'a'; else if (c >= '2' && c <= '7') value = 26 + c - '2'; else if (c == '&') break; else return NULL; decoded |= (value << shift); if (shift <= 8) { // Too many characters for a base32 SHA1. if (hashItr == hash.end()) return NULL; *hashItr++ = (decoded >> 8); decoded <<= 8; shift += 3; } else { shift -= 5; } } return hashItr != hash.end() || shift != base_shift ? NULL : pos; } void DownloadConstructor::parse_magnet_uri(Object& b, const std::string& uri) { if (std::strncmp(uri.c_str(), "magnet:?", 8)) throw input_error("Invalid magnet URI."); const char* pos = uri.c_str() + 8; Object trackers(Object::create_list()); HashString hash; bool hashValid = false; while (*pos) { const char* tagStart = pos; while (*pos != '=') if (!*pos++) break; raw_string tag(tagStart, pos - tagStart); pos++; // hash may be base32 encoded (optional in BEP 0009 and common practice) if (raw_bencode_equal_c_str(tag, "xt")) { if (strncmp(pos, "urn:btih:", 9)) throw input_error("Invalid magnet URI."); pos += 9; const char* nextPos = parse_base32_sha1(pos, hash); if (nextPos != NULL) { pos = nextPos; hashValid = true; continue; } } // everything else, including sometimes the hash, is url encoded. std::string decoded; while (*pos) { char c = *pos++; if (c == '%') { if (sscanf(pos, "%02hhx", &c) != 1) throw input_error("Invalid magnet URI."); pos += 2; } else if (c == '&') { break; } decoded.push_back(c); } if (raw_bencode_equal_c_str(tag, "xt")) { // url-encoded hash as per magnet URN specs if (decoded.length() == hash.size_data) { hash = *HashString::cast_from(decoded); hashValid = true; // hex-encoded hash as per BEP 0009 } else if (decoded.length() == hash.size_data * 2) { std::string::iterator hexItr = decoded.begin(); for (HashString::iterator itr = hash.begin(), last = hash.end(); itr != last; itr++, hexItr += 2) *itr = (rak::hexchar_to_value(*hexItr) << 4) + rak::hexchar_to_value(*(hexItr + 1)); hashValid = true; } else { throw input_error("Invalid magnet URI."); } } else if (raw_bencode_equal_c_str(tag, "tr")) { trackers.insert_back(Object::create_list()).insert_back(decoded); } // could also handle "dn" = display name (torrent name), but we can't really use that } if (!hashValid) throw input_error("Invalid magnet URI."); Object& info = b.insert_key("info", Object::create_map()); info.insert_key("pieces", hash.str()); info.insert_key("name", rak::transform_hex(hash.str()) + ".meta"); info.insert_key("meta_download", (int64_t)1); if (!trackers.as_list().empty()) { b.insert_preserve_copy("announce", trackers.as_list().begin()->as_list().begin()->as_string()); b.insert_preserve_type("announce-list", trackers); } } } libtorrent-0.13.2/src/download/download_constructor.h000644 000765 000024 00000006331 11705767056 023765 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_PARSE_DOWNLOAD_CONSTRUCTOR_H #define LIBTORRENT_PARSE_DOWNLOAD_CONSTRUCTOR_H #include #include #include namespace torrent { class Object; class Content; class DownloadWrapper; class Path; typedef std::list EncodingList; class DownloadConstructor { public: DownloadConstructor() : m_download(NULL), m_encodingList(NULL) {} void initialize(Object& b); void parse_tracker(const Object& b); void set_download(DownloadWrapper* d) { m_download = d; } void set_encoding_list(const EncodingList* e) { m_encodingList = e; } private: void parse_name(const Object& b); void parse_info(const Object& b); void parse_magnet_uri(Object& b, const std::string& uri); void add_tracker_group(const Object& b); void add_tracker_single(const Object& b, int group); void add_dht_node(const Object& b); static bool is_valid_path_element(const Object& b); static bool is_invalid_path_element(const Object& b) { return !is_valid_path_element(b); } void parse_single_file(const Object& b, uint32_t chunkSize); void parse_multi_files(const Object& b, uint32_t chunkSize); inline Path create_path(const Object::list_type& plist, const std::string enc); inline Path choose_path(std::list* pathList); DownloadWrapper* m_download; const EncodingList* m_encodingList; std::string m_defaultEncoding; }; } #endif libtorrent-0.13.2/src/download/download_main.cc000644 000765 000024 00000042664 11744202530 022453 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "data/chunk_list.h" #include "protocol/extensions.h" #include "protocol/handshake_manager.h" #include "protocol/initial_seed.h" #include "protocol/peer_connection_base.h" #include "protocol/peer_factory.h" #include "torrent/download.h" #include "torrent/exceptions.h" #include "torrent/throttle.h" #include "torrent/data/file_list.h" #include "torrent/download/download_manager.h" #include "torrent/download/choke_queue.h" #include "torrent/download/choke_group.h" #include "torrent/peer/connection_list.h" #include "torrent/peer/peer.h" #include "torrent/peer/peer_info.h" #include "torrent/tracker_controller.h" #include "torrent/tracker_list.h" #include "available_list.h" #include "chunk_selector.h" #include "chunk_statistics.h" #include "download_main.h" #include "download_wrapper.h" namespace tr1 { using namespace std::tr1; } namespace torrent { DownloadInfo::DownloadInfo() : m_flags(flag_compact | flag_accepting_new_peers | flag_accepting_seeders | flag_pex_enabled | flag_pex_active), m_upRate(60), m_downRate(60), m_skipRate(60), m_uploadedBaseline(0), m_completedBaseline(0), m_sizePex(0), m_maxSizePex(8), m_metadataSize(0), m_creationDate(0), m_loadDate(rak::timer::current_seconds()), m_upload_unchoked(0), m_download_unchoked(0) { } DownloadMain::DownloadMain() : m_info(new DownloadInfo), m_choke_group(NULL), m_chunkList(new ChunkList), m_chunkSelector(new ChunkSelector(file_list()->mutable_data())), m_chunkStatistics(new ChunkStatistics), m_initialSeeding(NULL), m_uploadThrottle(NULL), m_downloadThrottle(NULL) { m_tracker_list = new TrackerList(); m_tracker_controller = new TrackerController(m_tracker_list); m_tracker_list->slot_success() = tr1::bind(&TrackerController::receive_success, m_tracker_controller, tr1::placeholders::_1, tr1::placeholders::_2); m_tracker_list->slot_failure() = tr1::bind(&TrackerController::receive_failure, m_tracker_controller, tr1::placeholders::_1, tr1::placeholders::_2); m_tracker_list->slot_scrape_success() = tr1::bind(&TrackerController::receive_scrape, m_tracker_controller, tr1::placeholders::_1); m_tracker_list->slot_tracker_enabled() = tr1::bind(&TrackerController::receive_tracker_enabled, m_tracker_controller, tr1::placeholders::_1); m_tracker_list->slot_tracker_disabled() = tr1::bind(&TrackerController::receive_tracker_disabled, m_tracker_controller, tr1::placeholders::_1); m_connectionList = new ConnectionList(this); m_delegator.slot_chunk_find(rak::make_mem_fun(m_chunkSelector, &ChunkSelector::find)); m_delegator.slot_chunk_size(rak::make_mem_fun(file_list(), &FileList::chunk_index_size)); m_delegator.transfer_list()->slot_canceled(std::bind1st(std::mem_fun(&ChunkSelector::not_using_index), m_chunkSelector)); m_delegator.transfer_list()->slot_queued(std::bind1st(std::mem_fun(&ChunkSelector::using_index), m_chunkSelector)); m_delegator.transfer_list()->slot_completed(std::bind1st(std::mem_fun(&DownloadMain::receive_chunk_done), this)); m_delegator.transfer_list()->slot_corrupt(std::bind1st(std::mem_fun(&DownloadMain::receive_corrupt_chunk), this)); m_delayDisconnectPeers.slot() = std::tr1::bind(&ConnectionList::disconnect_queued, m_connectionList); m_taskTrackerRequest.slot() = std::tr1::bind(&DownloadMain::receive_tracker_request, this); m_chunkList->set_data(file_list()->mutable_data()); m_chunkList->slot_create_chunk() = tr1::bind(&FileList::create_chunk_index, file_list(), tr1::placeholders::_1, tr1::placeholders::_2); m_chunkList->slot_free_diskspace() = tr1::bind(&FileList::free_diskspace, file_list()); } DownloadMain::~DownloadMain() { if (m_taskTrackerRequest.is_queued()) throw internal_error("DownloadMain::~DownloadMain(): m_taskTrackerRequest is queued."); // Check if needed. m_connectionList->clear(); m_tracker_list->clear(); if (m_info->size_pex() != 0) throw internal_error("DownloadMain::~DownloadMain(): m_info->size_pex() != 0."); delete m_tracker_controller; delete m_tracker_list; delete m_connectionList; delete m_chunkStatistics; delete m_chunkList; delete m_chunkSelector; delete m_info; m_ut_pex_delta.clear(); m_ut_pex_initial.clear(); } std::pair DownloadMain::throttles(const sockaddr* sa) { ThrottlePair pair = ThrottlePair(NULL, NULL); if (!manager->connection_manager()->address_throttle().empty()) pair = manager->connection_manager()->address_throttle()(sa); return std::make_pair(pair.first == NULL ? upload_throttle() : pair.first->throttle_list(), pair.second == NULL ? download_throttle() : pair.second->throttle_list()); } void DownloadMain::open(int flags) { if (info()->is_open()) throw internal_error("Tried to open a download that is already open"); file_list()->open(flags & FileList::open_no_create); m_chunkList->resize(file_list()->size_chunks()); m_chunkStatistics->initialize(file_list()->size_chunks()); info()->set_flags(DownloadInfo::flag_open); } void DownloadMain::close() { if (info()->is_active()) throw internal_error("Tried to close an active download"); if (!info()->is_open()) return; info()->unset_flags(DownloadInfo::flag_open); // Don't close the tracker manager here else it will cause STOPPED // requests to be lost. TODO: Check that this is valid. // m_trackerManager->close(); m_delegator.transfer_list()->clear(); file_list()->close(); // Clear the chunklist last as it requires all referenced chunks to // be released. m_chunkStatistics->clear(); m_chunkList->clear(); m_chunkSelector->cleanup(); } void DownloadMain::start() { if (!info()->is_open()) throw internal_error("Tried to start a closed download"); if (info()->is_active()) throw internal_error("Tried to start an active download"); info()->set_flags(DownloadInfo::flag_active); chunk_list()->set_flags(ChunkList::flag_active); m_delegator.set_aggressive(false); update_endgame(); receive_connect_peers(); } void DownloadMain::stop() { if (!info()->is_active()) return; // Set this early so functions like receive_connect_peers() knows // not to eat available peers. info()->unset_flags(DownloadInfo::flag_active); chunk_list()->unset_flags(ChunkList::flag_active); m_slotStopHandshakes(this); connection_list()->erase_remaining(connection_list()->begin(), ConnectionList::disconnect_available); delete m_initialSeeding; m_initialSeeding = NULL; priority_queue_erase(&taskScheduler, &m_delayDisconnectPeers); priority_queue_erase(&taskScheduler, &m_taskTrackerRequest); if (info()->upload_unchoked() != 0 || info()->download_unchoked() != 0) throw internal_error("DownloadMain::stop(): info()->upload_unchoked() != 0 || info()->download_unchoked() != 0."); } bool DownloadMain::start_initial_seeding() { if (!file_list()->is_done()) return false; m_initialSeeding = new InitialSeeding(this); return true; } void DownloadMain::initial_seeding_done(PeerConnectionBase* pcb) { if (m_initialSeeding == NULL) throw internal_error("DownloadMain::initial_seeding_done called when not initial seeding."); // Close all connections but the currently active one (pcb), that // one will be closed by throw close_connection() later. // // When calling initial_seed()->new_peer(...) the 'pcb' won't be in // the connection list, so don't treat it as an error. Make sure to // catch close_connection() at the caller of new_peer(...) and just // close the filedesc before proceeding as normal. ConnectionList::iterator pcb_itr = std::find(m_connectionList->begin(), m_connectionList->end(), pcb); if (pcb_itr != m_connectionList->end()) { std::iter_swap(m_connectionList->begin(), pcb_itr); m_connectionList->erase_remaining(m_connectionList->begin() + 1, ConnectionList::disconnect_available); } else { m_connectionList->erase_remaining(m_connectionList->begin(), ConnectionList::disconnect_available); } // Switch to normal seeding. DownloadManager::iterator itr = manager->download_manager()->find(m_info); (*itr)->set_connection_type(Download::CONNECTION_SEED); m_connectionList->slot_new_connection(&createPeerConnectionSeed); delete m_initialSeeding; m_initialSeeding = NULL; // And close the current connection. throw close_connection(); } void DownloadMain::update_endgame() { if (!m_delegator.get_aggressive() && file_list()->completed_chunks() + m_delegator.transfer_list()->size() + 5 >= file_list()->size_chunks()) m_delegator.set_aggressive(true); } void DownloadMain::receive_chunk_done(unsigned int index) { ChunkHandle handle = m_chunkList->get(index); if (!handle.is_valid()) throw storage_error("DownloadState::chunk_done(...) called with an index we couldn't retrieve from storage"); m_slotHashCheckAdd(handle); } void DownloadMain::receive_corrupt_chunk(PeerInfo* peerInfo) { peerInfo->set_failed_counter(peerInfo->failed_counter() + 1); // Just use some very primitive heuristics here to decide if we're // going to disconnect the peer. Also, consider adding a flag so we // don't recalculate these things whenever the peer reconnects. // That is... non at all ;) if (peerInfo->failed_counter() > HandshakeManager::max_failed) connection_list()->erase(peerInfo, ConnectionList::disconnect_unwanted); } void DownloadMain::add_peer(const rak::socket_address& sa) { m_slotStartHandshake(sa, this); } void DownloadMain::receive_connect_peers() { if (!info()->is_active()) return; // TODO: Is this actually going to be used? AddressList* alist = peer_list()->available_list()->buffer(); if (!alist->empty()) { alist->sort(); peer_list()->insert_available(alist); alist->clear(); } while (!peer_list()->available_list()->empty() && manager->connection_manager()->can_connect() && connection_list()->size() < connection_list()->min_size() && connection_list()->size() + m_slotCountHandshakes(this) < connection_list()->max_size()) { rak::socket_address sa = peer_list()->available_list()->pop_random(); if (connection_list()->find(sa.c_sockaddr()) == connection_list()->end()) m_slotStartHandshake(sa, this); } } void DownloadMain::receive_tracker_success() { if (!info()->is_active()) return; priority_queue_erase(&taskScheduler, &m_taskTrackerRequest); priority_queue_insert(&taskScheduler, &m_taskTrackerRequest, (cachedTime + rak::timer::from_seconds(30)).round_seconds()); } void DownloadMain::receive_tracker_request() { if (connection_list()->size() + peer_list()->available_list()->size() / 2 >= connection_list()->min_size()) { m_tracker_controller->stop_requesting(); return; } m_tracker_controller->start_requesting(); } struct SocketAddressCompact_less { bool operator () (const SocketAddressCompact& a, const SocketAddressCompact& b) const { return (a.addr < b.addr) || ((a.addr == b.addr) && (a.port < b.port)); } }; void DownloadMain::do_peer_exchange() { if (!info()->is_active()) throw internal_error("DownloadMain::do_peer_exchange called on inactive download."); // Check whether we should tell the peers to stop/start sending PEX // messages. int togglePex = 0; if (!m_info->is_pex_active() && m_connectionList->size() < m_connectionList->min_size() / 2 && m_peerList.available_list()->size() < m_peerList.available_list()->max_size() / 4) { m_info->set_flags(DownloadInfo::flag_pex_active); // Only set PEX_ENABLE if we don't have max_size_pex set to zero. if (m_info->size_pex() < m_info->max_size_pex()) togglePex = PeerConnectionBase::PEX_ENABLE; } else if (m_info->is_pex_active() && m_connectionList->size() >= m_connectionList->min_size()) { // m_peerList.available_list()->size() >= m_peerList.available_list()->max_size() / 2) { togglePex = PeerConnectionBase::PEX_DISABLE; m_info->unset_flags(DownloadInfo::flag_pex_active); } // Return if we don't really want to do anything? ProtocolExtension::PEXList current; for (ConnectionList::iterator itr = m_connectionList->begin(); itr != m_connectionList->end(); ++itr) { PeerConnectionBase* pcb = (*itr)->m_ptr(); const rak::socket_address* sa = rak::socket_address::cast_from(pcb->peer_info()->socket_address()); if (pcb->peer_info()->listen_port() != 0 && sa->family() == rak::socket_address::af_inet) current.push_back(SocketAddressCompact(sa->sa_inet()->address_n(), pcb->peer_info()->listen_port())); if (!pcb->extensions()->is_remote_supported(ProtocolExtension::UT_PEX)) continue; if (togglePex == PeerConnectionBase::PEX_ENABLE) { pcb->set_peer_exchange(true); if (m_info->size_pex() >= m_info->max_size_pex()) togglePex = 0; } else if (!pcb->extensions()->is_local_enabled(ProtocolExtension::UT_PEX)) { continue; } else if (togglePex == PeerConnectionBase::PEX_DISABLE) { pcb->set_peer_exchange(false); continue; } // Still using the old buffer? Make a copy in this rare case. DataBuffer* message = pcb->extension_message(); if (!message->empty() && (message->data() == m_ut_pex_initial.data() || message->data() == m_ut_pex_delta.data())) { char* buffer = new char[message->length()]; memcpy(buffer, message->data(), message->length()); message->set(buffer, buffer + message->length(), true); } pcb->do_peer_exchange(); } std::sort(current.begin(), current.end(), SocketAddressCompact_less()); ProtocolExtension::PEXList added; added.reserve(current.size()); std::set_difference(current.begin(), current.end(), m_ut_pex_list.begin(), m_ut_pex_list.end(), std::back_inserter(added), SocketAddressCompact_less()); ProtocolExtension::PEXList removed; removed.reserve(m_ut_pex_list.size()); std::set_difference(m_ut_pex_list.begin(), m_ut_pex_list.end(), current.begin(), current.end(), std::back_inserter(removed), SocketAddressCompact_less()); if (current.size() > m_info->max_size_pex_list()) { // This test is only correct as long as we have a constant max // size. if (added.size() < current.size() - m_info->max_size_pex_list()) throw internal_error("DownloadMain::do_peer_exchange() added.size() < current.size() - m_info->max_size_pex_list()."); // Randomize this: added.erase(added.end() - (current.size() - m_info->max_size_pex_list()), added.end()); // Create the new m_ut_pex_list by removing any 'removed' // addresses from the original list and then adding the new // addresses. m_ut_pex_list.erase(std::set_difference(m_ut_pex_list.begin(), m_ut_pex_list.end(), removed.begin(), removed.end(), m_ut_pex_list.begin(), SocketAddressCompact_less()), m_ut_pex_list.end()); m_ut_pex_list.insert(m_ut_pex_list.end(), added.begin(), added.end()); std::sort(m_ut_pex_list.begin(), m_ut_pex_list.end(), SocketAddressCompact_less()); } else { m_ut_pex_list.swap(current); } current.clear(); m_ut_pex_delta.clear(); // If no peers were added or removed, the initial message is still correct and // the delta message stays emptied. Otherwise generate the appropriate messages. if (!added.empty() || !m_ut_pex_list.empty()) { m_ut_pex_delta = ProtocolExtension::generate_ut_pex_message(added, removed); m_ut_pex_initial.clear(); m_ut_pex_initial = ProtocolExtension::generate_ut_pex_message(m_ut_pex_list, current); } } void DownloadMain::set_metadata_size(size_t size) { if (m_info->is_meta_download()) { if (m_fileList.size_bytes() < 2) file_list()->reset_filesize(size); else if (size != m_fileList.size_bytes()) throw communication_error("Peer-supplied metadata size mismatch."); } else if (m_info->metadata_size() && m_info->metadata_size() != size) { throw communication_error("Peer-supplied metadata size mismatch."); } m_info->set_metadata_size(size); } } libtorrent-0.13.2/src/download/download_main.h000644 000765 000024 00000020372 11744202530 022305 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_MAIN_H #define LIBTORRENT_DOWNLOAD_MAIN_H #include #include #include #include "globals.h" #include "delegator.h" #include "data/chunk_handle.h" #include "download/available_list.h" #include "net/data_buffer.h" #include "torrent/download_info.h" #include "torrent/download/group_entry.h" #include "torrent/data/file_list.h" #include "torrent/peer/peer_list.h" namespace torrent { class ChunkList; class ChunkSelector; class ChunkStatistics; class choke_group; class ConnectionList; class DownloadWrapper; class HandshakeManager; class TrackerController; class TrackerList; class DownloadInfo; class ThrottleList; class InitialSeeding; class DownloadMain { public: typedef std::deque > have_queue_type; typedef std::vector pex_list; DownloadMain(); ~DownloadMain(); void open(int flags); void close(); void start(); void stop(); class choke_group* choke_group() { return m_choke_group; } const class choke_group* c_choke_group() const { return m_choke_group; } void set_choke_group(class choke_group* grp) { m_choke_group = grp; } TrackerController* tracker_controller() { return m_tracker_controller; } TrackerList* tracker_list() { return m_tracker_list; } DownloadInfo* info() { return m_info; } // Only retrieve writable chunks when the download is active. ChunkList* chunk_list() { return m_chunkList; } ChunkSelector* chunk_selector() { return m_chunkSelector; } ChunkStatistics* chunk_statistics() { return m_chunkStatistics; } Delegator* delegator() { return &m_delegator; } have_queue_type* have_queue() { return &m_haveQueue; } InitialSeeding* initial_seeding() { return m_initialSeeding; } bool start_initial_seeding(); void initial_seeding_done(PeerConnectionBase* pcb); ConnectionList* connection_list() { return m_connectionList; } FileList* file_list() { return &m_fileList; } PeerList* peer_list() { return &m_peerList; } std::pair throttles(const sockaddr* sa); ThrottleList* upload_throttle() { return m_uploadThrottle; } void set_upload_throttle(ThrottleList* t) { m_uploadThrottle = t; } ThrottleList* download_throttle() { return m_downloadThrottle; } void set_download_throttle(ThrottleList* t) { m_downloadThrottle = t; } group_entry* up_group_entry() { return &m_up_group_entry; } group_entry* down_group_entry() { return &m_down_group_entry; } DataBuffer get_ut_pex(bool initial) { return (initial ? m_ut_pex_initial : m_ut_pex_delta).clone(); } bool want_pex_msg() { return m_info->is_pex_active() && m_peerList.available_list()->want_more(); }; void set_metadata_size(size_t s); // Carefull with these. void setup_delegator(); void setup_tracker(); typedef rak::const_mem_fun1 SlotCountHandshakes; typedef rak::mem_fun1 SlotHashCheckAdd; typedef rak::mem_fun2 slot_start_handshake_type; typedef rak::mem_fun1 slot_stop_handshakes_type; void slot_start_handshake(slot_start_handshake_type s) { m_slotStartHandshake = s; } void slot_stop_handshakes(slot_stop_handshakes_type s) { m_slotStopHandshakes = s; } void slot_count_handshakes(SlotCountHandshakes s) { m_slotCountHandshakes = s; } void slot_hash_check_add(SlotHashCheckAdd s) { m_slotHashCheckAdd = s; } void add_peer(const rak::socket_address& sa); void receive_connect_peers(); void receive_chunk_done(unsigned int index); void receive_corrupt_chunk(PeerInfo* peerInfo); void receive_tracker_success(); void receive_tracker_request(); void receive_do_peer_exchange(); void do_peer_exchange(); void update_endgame(); rak::priority_item& delay_download_done() { return m_delay_download_done; } rak::priority_item& delay_partially_done() { return m_delay_partially_done; } rak::priority_item& delay_partially_restarted() { return m_delay_partially_restarted; } rak::priority_item& delay_disconnect_peers() { return m_delayDisconnectPeers; } private: // Disable copy ctor and assignment. DownloadMain(const DownloadMain&); void operator = (const DownloadMain&); void setup_start(); void setup_stop(); DownloadInfo* m_info; TrackerController* m_tracker_controller; TrackerList* m_tracker_list; class choke_group* m_choke_group; group_entry m_up_group_entry; group_entry m_down_group_entry; ChunkList* m_chunkList; ChunkSelector* m_chunkSelector; ChunkStatistics* m_chunkStatistics; Delegator m_delegator; have_queue_type m_haveQueue; InitialSeeding* m_initialSeeding; ConnectionList* m_connectionList; FileList m_fileList; PeerList m_peerList; DataBuffer m_ut_pex_delta; DataBuffer m_ut_pex_initial; pex_list m_ut_pex_list; ThrottleList* m_uploadThrottle; ThrottleList* m_downloadThrottle; slot_start_handshake_type m_slotStartHandshake; slot_stop_handshakes_type m_slotStopHandshakes; SlotCountHandshakes m_slotCountHandshakes; SlotHashCheckAdd m_slotHashCheckAdd; rak::priority_item m_delay_download_done; rak::priority_item m_delay_partially_done; rak::priority_item m_delay_partially_restarted; rak::priority_item m_delayDisconnectPeers; rak::priority_item m_taskTrackerRequest; }; } #endif libtorrent-0.13.2/src/download/download_wrapper.cc000644 000765 000024 00000032167 11744202530 023204 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include "data/chunk_list.h" #include "data/hash_queue.h" #include "data/hash_torrent.h" #include "protocol/handshake_manager.h" #include "protocol/peer_connection_base.h" #include "torrent/exceptions.h" #include "torrent/object.h" #include "torrent/tracker_list.h" #include "torrent/data/file.h" #include "torrent/data/file_list.h" #include "torrent/data/file_manager.h" #include "torrent/peer/peer.h" #include "torrent/peer/connection_list.h" #include "torrent/tracker_controller.h" #include "torrent/tracker_list.h" #include "available_list.h" #include "chunk_selector.h" #include "download_wrapper.h" namespace tr1 { using namespace std::tr1; } namespace torrent { DownloadWrapper::DownloadWrapper() : m_main(new DownloadMain), m_bencode(NULL), m_hashChecker(NULL), m_connectionType(0) { m_main->delay_download_done().slot() = std::tr1::bind(&download_data::call_download_done, data()); m_main->tracker_list()->set_info(info()); m_main->tracker_controller()->slot_success() = tr1::bind(&DownloadWrapper::receive_tracker_success, this, tr1::placeholders::_1); m_main->tracker_controller()->slot_failure() = tr1::bind(&DownloadWrapper::receive_tracker_failed, this, tr1::placeholders::_1); m_main->chunk_list()->slot_storage_error() = tr1::bind(&DownloadWrapper::receive_storage_error, this, tr1::placeholders::_1); } DownloadWrapper::~DownloadWrapper() { if (info()->is_active()) m_main->stop(); if (info()->is_open()) close(); // If the client wants to do a quick cleanup after calling close, it // will need to manually cancel the tracker requests. m_main->tracker_controller()->close(); delete m_hashChecker; delete m_bencode; delete m_main; } void DownloadWrapper::initialize(const std::string& hash, const std::string& id) { char hashObfuscated[20]; sha1_salt("req2", 4, hash.c_str(), hash.length(), hashObfuscated); info()->mutable_hash().assign(hash.c_str()); info()->mutable_hash_obfuscated().assign(hashObfuscated); info()->mutable_local_id().assign(id.c_str()); info()->slot_left() = sigc::mem_fun(m_main->file_list(), &FileList::left_bytes); info()->slot_completed() = sigc::mem_fun(m_main->file_list(), &FileList::completed_bytes); file_list()->mutable_data()->mutable_hash().assign(hash.c_str()); m_main->slot_hash_check_add(rak::make_mem_fun(this, &DownloadWrapper::check_chunk_hash)); // Info hash must be calculate from here on. m_hashChecker = new HashTorrent(m_main->chunk_list()); // Connect various signals and slots. m_hashChecker->slot_check(rak::make_mem_fun(this, &DownloadWrapper::check_chunk_hash)); // m_hashChecker->slot_storage_error(rak::make_mem_fun(this, &DownloadWrapper::receive_storage_error)); m_hashChecker->delay_checked().slot() = std::tr1::bind(&DownloadWrapper::receive_initial_hash, this); } void DownloadWrapper::close() { // Stop the hashing first as we need to make sure all chunks are // released when DownloadMain::close() is called. m_hashChecker->clear(); // Clear after m_hashChecker to ensure that the empty hash done signal does // not get passed to HashTorrent. hash_queue()->remove(data()); // This could/should be async as we do not care that much if it // succeeds or not, any chunks not included in that last // hash_resume_save get ignored anyway. m_main->chunk_list()->sync_chunks(ChunkList::sync_all | ChunkList::sync_force | ChunkList::sync_sloppy | ChunkList::sync_ignore_error); m_main->close(); // Should this perhaps be in stop? priority_queue_erase(&taskScheduler, &m_main->delay_download_done()); } bool DownloadWrapper::is_stopped() const { return !m_main->tracker_controller()->is_active() && !m_main->tracker_list()->has_active(); } void DownloadWrapper::receive_initial_hash() { if (info()->is_active()) throw internal_error("DownloadWrapper::receive_initial_hash() but we're in a bad state."); if (!m_hashChecker->is_checking()) { receive_storage_error("Hash checker was unable to map chunk: " + std::string(rak::error_number(m_hashChecker->error_number()).c_str())); } else { m_hashChecker->confirm_checked(); if (hash_queue()->has(data())) throw internal_error("DownloadWrapper::receive_initial_hash() found a chunk in the HashQueue."); // Initialize the ChunkSelector here so that no chunks will be // marked by HashTorrent that are not accounted for. m_main->chunk_selector()->initialize(m_main->chunk_statistics()); receive_update_priorities(); } if (data()->slot_initial_hash()) data()->slot_initial_hash()(); } void DownloadWrapper::receive_hash_done(ChunkHandle handle, const char* hash) { if (!handle.is_valid()) throw internal_error("DownloadWrapper::receive_hash_done(...) called on an invalid chunk."); if (!info()->is_open()) throw internal_error("DownloadWrapper::receive_hash_done(...) called but the download is not open."); if (m_hashChecker->is_checking()) { if (hash == NULL) { m_hashChecker->receive_chunk_cleared(handle.index()); } else { if (std::memcmp(hash, chunk_hash(handle.index()), 20) == 0) m_main->file_list()->mark_completed(handle.index()); m_hashChecker->receive_chunkdone(handle.index()); } m_main->chunk_list()->release(&handle, ChunkList::get_dont_log); return; } // If hash == NULL we're clearing the queue, so do nothing. if (hash != NULL) { if (!m_hashChecker->is_checked()) throw internal_error("DownloadWrapper::receive_hash_done(...) Was not expecting non-NULL hash."); // Receiving chunk hashes after stopping the torrent should be // safe. if (data()->untouched_bitfield()->get(handle.index())) throw internal_error("DownloadWrapper::receive_hash_done(...) received a chunk that isn't set in ChunkSelector."); if (std::memcmp(hash, chunk_hash(handle.index()), 20) == 0) { m_main->file_list()->mark_completed(handle.index()); m_main->delegator()->transfer_list()->hash_succeeded(handle.index(), handle.chunk()); m_main->update_endgame(); if (m_main->file_list()->is_done()) finished_download(); if (!m_main->have_queue()->empty() && m_main->have_queue()->front().first >= cachedTime) m_main->have_queue()->push_front(DownloadMain::have_queue_type::value_type(m_main->have_queue()->front().first + 1, handle.index())); else m_main->have_queue()->push_front(DownloadMain::have_queue_type::value_type(cachedTime, handle.index())); rak::slot_list_call(info()->signal_chunk_passed(), handle.index()); } else { // This needs to ensure the chunk is still valid. m_main->delegator()->transfer_list()->hash_failed(handle.index(), handle.chunk()); rak::slot_list_call(info()->signal_chunk_failed(), handle.index()); } } m_main->chunk_list()->release(&handle); } void DownloadWrapper::check_chunk_hash(ChunkHandle handle) { // TODO: Hack... ChunkHandle new_handle = m_main->chunk_list()->get(handle.index(), ChunkList::get_blocking); m_main->chunk_list()->release(&handle); hash_queue()->push_back(new_handle, data(), tr1::bind(&DownloadWrapper::receive_hash_done, this, tr1::placeholders::_1, tr1::placeholders::_2)); } void DownloadWrapper::receive_storage_error(const std::string& str) { m_main->stop(); close(); m_main->tracker_controller()->disable(); m_main->tracker_controller()->close(); rak::slot_list_call(info()->signal_storage_error(), str); } uint32_t DownloadWrapper::receive_tracker_success(AddressList* l) { uint32_t inserted = m_main->peer_list()->insert_available(l); m_main->receive_connect_peers(); m_main->receive_tracker_success(); rak::slot_list_call(info()->signal_tracker_success()); return inserted; } void DownloadWrapper::receive_tracker_failed(const std::string& msg) { rak::slot_list_call(info()->signal_tracker_failed(), msg); } void DownloadWrapper::receive_tick(uint32_t ticks) { // Trigger culling of PeerInfo's every hour. This should be called // before the is_open check to ensure that stopped torrents reduce // their memory usage. if (ticks % 120 == 0) // if (ticks % 1 == 0) m_main->peer_list()->cull_peers(PeerList::cull_old | PeerList::cull_keep_interesting); if (!info()->is_open()) return; // Every 2 minutes. if (ticks % 4 == 0) { if (info()->is_active()) { if (info()->is_pex_enabled()) { m_main->do_peer_exchange(); // If PEX was disabled since the last peer exchange, deactivate it now. } else if (info()->is_pex_active()) { info()->unset_flags(DownloadInfo::flag_pex_active); for (ConnectionList::iterator itr = m_main->connection_list()->begin(); itr != m_main->connection_list()->end(); ++itr) (*itr)->m_ptr()->set_peer_exchange(false); } } for (ConnectionList::iterator itr = m_main->connection_list()->begin(); itr != m_main->connection_list()->end(); ) if (!(*itr)->m_ptr()->receive_keepalive()) itr = m_main->connection_list()->erase(itr, ConnectionList::disconnect_available); else itr++; } DownloadMain::have_queue_type* haveQueue = m_main->have_queue(); haveQueue->erase(std::find_if(haveQueue->rbegin(), haveQueue->rend(), rak::less(cachedTime - rak::timer::from_seconds(600), rak::mem_ref(&DownloadMain::have_queue_type::value_type::first))).base(), haveQueue->end()); m_main->receive_connect_peers(); } void DownloadWrapper::receive_update_priorities() { if (m_main->chunk_selector()->empty()) return; data()->mutable_high_priority()->clear(); data()->mutable_normal_priority()->clear(); for (FileList::iterator itr = m_main->file_list()->begin(); itr != m_main->file_list()->end(); ++itr) { switch ((*itr)->priority()) { case PRIORITY_NORMAL: { File::range_type range = (*itr)->range(); if ((*itr)->has_flags(File::flag_prioritize_first) && range.first != range.second) { data()->mutable_high_priority()->insert(range.first, range.first + 1); range.first++; } if ((*itr)->has_flags(File::flag_prioritize_last) && range.first != range.second) { data()->mutable_high_priority()->insert(range.second - 1, range.second); range.second--; } data()->mutable_normal_priority()->insert(range); break; } case PRIORITY_HIGH: data()->mutable_high_priority()->insert((*itr)->range().first, (*itr)->range().second); break; default: break; } } data()->update_wanted_chunks(); m_main->chunk_selector()->update_priorities(); std::for_each(m_main->connection_list()->begin(), m_main->connection_list()->end(), rak::on(std::mem_fun(&Peer::m_ptr), std::mem_fun(&PeerConnectionBase::update_interested))); // TODO: Trigger event if this results in the torrent being // partially finished, or going from partially finished to needing // to download more. } void DownloadWrapper::finished_download() { // We delay emitting the signal to allow the delegator to // clean up. If we do a straight call it would cause problems // for clients that wish to close and reopen the torrent, as // HashQueue, Delegator etc shouldn't be cleaned up at this // point. // // This needs to be seperated into a new function. if (!m_main->delay_download_done().is_queued()) priority_queue_insert(&taskScheduler, &m_main->delay_download_done(), cachedTime); m_main->connection_list()->erase_seeders(); info()->mutable_down_rate()->reset_rate(); } } libtorrent-0.13.2/src/download/download_wrapper.h000644 000765 000024 00000011550 11744202530 023037 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DOWNLOAD_WRAPPER_H #define LIBTORRENT_DOWNLOAD_WRAPPER_H #include #include #include "data/chunk_handle.h" #include "download_main.h" namespace torrent { // Remember to clean up the pointers, DownloadWrapper won't do it. class AddressList; class FileManager; class HashQueue; class HashTorrent; class HandshakeManager; class DownloadInfo; class Object; class Peer; class DownloadWrapper { public: typedef sigc::signal0 Signal; typedef sigc::signal1 SignalChunk; typedef sigc::signal1 SignalString; DownloadWrapper(); ~DownloadWrapper(); DownloadInfo* info() { return m_main->info(); } download_data* data() { return m_main->file_list()->mutable_data(); } FileList* file_list() { return m_main->file_list(); } ChunkList* chunk_list() { return m_main->chunk_list(); } // Initialize hash checker and various download stuff. void initialize(const std::string& hash, const std::string& id); void close(); bool is_stopped() const; DownloadMain* main() { return m_main; } const DownloadMain* main() const { return m_main; } HashTorrent* hash_checker() { return m_hashChecker; } Object* bencode() { return m_bencode; } void set_bencode(Object* o) { m_bencode = o; } HashQueue* hash_queue() { return m_hashQueue; } void set_hash_queue(HashQueue* q) { m_hashQueue = q; } const std::string& complete_hash() { return m_hash; } const char* chunk_hash(unsigned int index) { return m_hash.c_str() + 20 * index; } void set_complete_hash(const std::string& hash) { m_hash = hash; } int connection_type() const { return m_connectionType; } void set_connection_type(int t) { m_connectionType = t; } // // Internal: // void receive_initial_hash(); void receive_hash_done(ChunkHandle handle, const char* hash); void check_chunk_hash(ChunkHandle handle); void receive_storage_error(const std::string& str); uint32_t receive_tracker_success(AddressList* l); void receive_tracker_failed(const std::string& msg); void receive_tick(uint32_t ticks); void receive_update_priorities(); private: DownloadWrapper(const DownloadWrapper&); void operator = (const DownloadWrapper&); void finished_download(); DownloadMain* m_main; Object* m_bencode; HashTorrent* m_hashChecker; HashQueue* m_hashQueue; std::string m_hash; int m_connectionType; sigc::connection m_connectionChunkPassed; sigc::connection m_connectionChunkFailed; }; } #endif libtorrent-0.13.2/src/download/Makefile.am000644 000765 000024 00000000644 11705767056 021375 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_download.la libsub_download_la_SOURCES = \ available_list.cc \ available_list.h \ chunk_selector.cc \ chunk_selector.h \ chunk_statistics.cc \ chunk_statistics.h \ delegator.cc \ delegator.h \ download_constructor.cc \ download_constructor.h \ download_main.cc \ download_main.h \ download_wrapper.cc \ download_wrapper.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrent-0.13.2/src/download/Makefile.in000644 000765 000024 00000040750 11744204216 021373 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/download DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_download_la_LIBADD = am_libsub_download_la_OBJECTS = available_list.lo chunk_selector.lo \ chunk_statistics.lo delegator.lo download_constructor.lo \ download_main.lo download_wrapper.lo libsub_download_la_OBJECTS = $(am_libsub_download_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_download_la_SOURCES) DIST_SOURCES = $(libsub_download_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_download.la libsub_download_la_SOURCES = \ available_list.cc \ available_list.h \ chunk_selector.cc \ chunk_selector.h \ chunk_statistics.cc \ chunk_statistics.h \ delegator.cc \ delegator.h \ download_constructor.cc \ download_constructor.h \ download_main.cc \ download_main.h \ download_wrapper.cc \ download_wrapper.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/download/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/download/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_download.la: $(libsub_download_la_OBJECTS) $(libsub_download_la_DEPENDENCIES) $(EXTRA_libsub_download_la_DEPENDENCIES) $(CXXLINK) $(libsub_download_la_OBJECTS) $(libsub_download_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/available_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk_selector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk_statistics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/delegator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_constructor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_main.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_wrapper.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/dht/dht_bucket.cc000644 000765 000024 00000013556 11705767056 020742 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/exceptions.h" #include "dht_bucket.h" #include "dht_node.h" namespace torrent { DhtBucket::DhtBucket(const HashString& begin, const HashString& end) : m_parent(NULL), m_child(NULL), m_lastChanged(cachedTime.seconds()), m_good(0), m_bad(0), m_fullCacheLength(0), m_begin(begin), m_end(end) { reserve(num_nodes); } void DhtBucket::add_node(DhtNode* n) { push_back(n); touch(); if (n->is_good()) m_good++; else if (n->is_bad()) m_bad++; m_fullCacheLength = 0; } void DhtBucket::remove_node(DhtNode* n) { iterator itr = std::find_if(begin(), end(), std::bind2nd(std::equal_to(), n)); if (itr == end()) throw internal_error("DhtBucket::remove_node called for node not in bucket."); erase(itr); if (n->is_good()) m_good--; else if (n->is_bad()) m_bad--; m_fullCacheLength = 0; } void DhtBucket::count() { m_good = std::count_if(begin(), end(), std::mem_fun(&DhtNode::is_good)); m_bad = std::count_if(begin(), end(), std::mem_fun(&DhtNode::is_bad)); } // Called every 15 minutes for housekeeping. void DhtBucket::update() { count(); // In case adjacent buckets whose nodes we borrowed have changed, // we force an update of the cache. m_fullCacheLength = 0; } DhtBucket::iterator DhtBucket::find_replacement_candidate(bool onlyOldest) { iterator oldest = end(); unsigned int oldestTime = std::numeric_limits::max(); for (iterator itr = begin(); itr != end(); ++itr) { if ((*itr)->is_bad() && !onlyOldest) return itr; if ((*itr)->last_seen() < oldestTime) { oldestTime = (*itr)->last_seen(); oldest = itr; } } return oldest; } void DhtBucket::get_mid_point(HashString* middle) const { *middle = m_end; for (unsigned int i=0; i0; i--) { unsigned int sum = (uint8_t)mid_range[i-1] + carry; m_begin[i-1] = (uint8_t)sum; carry = sum >> 8; } // Move nodes over to other bucket if they fall in its range, then // delete them from this one. iterator split = std::partition(begin(), end(), std::bind2nd(std::mem_fun(&DhtNode::is_in_range), this)); other->insert(other->end(), split, end()); std::for_each(other->begin(), other->end(), std::bind2nd(std::mem_fun(&DhtNode::set_bucket), other)); erase(split, end()); other->set_time(m_lastChanged); other->count(); count(); // Maintain child (adjacent narrower bucket) and parent (adjacent wider bucket) // so that given router ID is in child. if (other->is_in_range(id)) { // Make other become our new child. m_child = other; other->m_parent = this; } else { // We become other's child, other becomes our parent's child. if (parent() != NULL) { parent()->m_child = other; other->m_parent = parent(); } m_parent = other; other->m_child = this; } return other; } void DhtBucket::build_full_cache() { DhtBucketChain chain(this); char* pos = m_fullCache; do { for (const_iterator itr = chain.bucket()->begin(); itr != chain.bucket()->end() && pos < m_fullCache + sizeof(m_fullCache); ++itr) { if (!(*itr)->is_bad()) { pos = (*itr)->store_compact(pos); if (pos > m_fullCache + sizeof(m_fullCache)) throw internal_error("DhtRouter::store_closest_nodes wrote past buffer end."); } } } while (pos < m_fullCache + sizeof(m_fullCache) && chain.next() != NULL); m_fullCacheLength = pos - m_fullCache; } } libtorrent-0.13.2/src/dht/dht_bucket.h000644 000765 000024 00000015543 11705767056 020602 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DHT_BUCKET_H #define LIBTORRENT_DHT_BUCKET_H #include #include "globals.h" #include "torrent/hash_string.h" #include "torrent/object_raw_bencode.h" namespace torrent { class DhtNode; // A container holding a small number of nodes that fall in a given binary // partition of the 160-bit ID space (i.e. the range ID1..ID2 where ID2-ID1+1 is // a power of 2.) class DhtBucket : private std::vector { public: static const unsigned int num_nodes = 8; typedef std::vector base_type; using base_type::const_iterator; using base_type::iterator; using base_type::begin; using base_type::end; using base_type::size; using base_type::empty; DhtBucket(const HashString& begin, const HashString& end); // Add new node. Does NOT set node's bucket automatically (to allow adding a // node to multiple buckets, with only one "main" bucket.) void add_node(DhtNode* n); void remove_node(DhtNode* n); // Bucket's ID range functions. const HashString& id_range_begin() const { return m_begin; } HashString& id_range_begin() { return m_begin; } const HashString& id_range_end() const { return m_end; } bool is_in_range(const HashString& id) const { return m_begin <= id && id <= m_end; } // Find middle or random ID in bucket. void get_mid_point(HashString* middle) const; void get_random_id(HashString* rand_id) const; // Node counts and bucket stats. bool is_full() const { return size() >= num_nodes; } bool has_space() const { return !is_full() || num_bad() > 0; } unsigned int num_good() const { return m_good; } unsigned int num_bad() const { return m_bad; } unsigned int age() const { return cachedTime.seconds() - m_lastChanged; } void touch() { m_lastChanged = cachedTime.seconds(); } void set_time(int32_t time) { m_lastChanged = time; } // Called every 15 minutes after updating nodes. void update(); // Return candidate for replacement (a bad node or the oldest node); may // return end() unless has_space() is true. iterator find_replacement_candidate(bool onlyOldest = false); // Split the bucket in two and redistribute nodes. Returned bucket is the // lower half, "this" bucket keeps the upper half. Sets parent/child so // that the bucket the given ID falls in is the child. DhtBucket* split(const HashString& id); // Parent and child buckets. Parent is the adjacent bucket with double the // ID width, child the adjacent bucket with half the width (except the very // last child which has the same width.) DhtBucket* parent() const { return m_parent; } DhtBucket* child() const { return m_child; } // Return a full bucket's worth of compact node data. If this bucket is not // full, it uses nodes from the child/parent buckets until we have enough. raw_string full_bucket(); // Called by the DhtNode on its bucket to update good/bad node counts. void node_now_good(bool was_bad); void node_now_bad(bool was_good); private: void count(); void build_full_cache(); DhtBucket* m_parent; DhtBucket* m_child; int32_t m_lastChanged; unsigned int m_good; unsigned int m_bad; size_t m_fullCacheLength; // These are 40 bytes together, so might as well put them last. // m_end is const because it is used as key for the DhtRouter routing table // map, which would be inconsistent if m_end were changed carelessly. HashString m_begin; const HashString m_end; char m_fullCache[num_nodes * 26]; }; // Helper class to recursively follow a chain of buckets. It first recurses // into the bucket's children since they are by definition closer to the bucket, // then continues with the bucket's parents. class DhtBucketChain { public: DhtBucketChain(const DhtBucket* b) : m_restart(b), m_cur(b) { } const DhtBucket* bucket() { return m_cur; } const DhtBucket* next(); private: const DhtBucket* m_restart; const DhtBucket* m_cur; }; inline void DhtBucket::node_now_good(bool was_bad) { m_bad -= was_bad; m_good++; } inline void DhtBucket::node_now_bad(bool was_good) { m_good -= was_good; m_bad++; } inline raw_string DhtBucket::full_bucket() { if (!m_fullCacheLength) build_full_cache(); return raw_string(m_fullCache, m_fullCacheLength); } inline const DhtBucket* DhtBucketChain::next() { // m_restart is clear when we're done recursing into the children and // follow the parents instead. if (m_restart == NULL) { m_cur = m_cur->parent(); } else { m_cur = m_cur->child(); if (m_cur == NULL) { m_cur = m_restart->parent(); m_restart = NULL; } } return m_cur; } } #endif libtorrent-0.13.2/src/dht/dht_hash_map.h000644 000765 000024 00000015131 11716350717 021070 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DHT_HASH_MAP_H #define LIBTORRENT_DHT_HASH_MAP_H #include "config.h" #if HAVE_TR1 #include #else #include #endif #include "torrent/hash_string.h" #include "dht_node.h" #include "dht_tracker.h" namespace torrent { #if HAVE_TR1 // Hash functions for HashString keys, and dereferencing HashString pointers. // Since the first few bits are very similar if not identical (since the IDs // will be close to our own node ID), we use an offset of 64 bits in the hash // string. These bits will be uniformly distributed until the number of DHT // nodes on the planet approaches 2^64 which is... unlikely. // An offset of 64 bits provides 96 significant bits which is fine as long as // the size of size_t does not exceed 12 bytes, while still having correctly // aligned 64-bit access. static const unsigned int hashstring_hash_ofs = 8; struct hashstring_ptr_hash : public std::unary_function { size_t operator () (const HashString* n) const { #if USE_ALIGNED size_t result = 0; const char *first = n->data() + hashstring_hash_ofs; const char *last = first + sizeof(size_t); while (first != last) result = (result << 8) + *first++; return result; #else return *(size_t*)(n->data() + hashstring_hash_ofs); #endif } }; struct hashstring_hash : public std::unary_function { size_t operator () (const HashString& n) const { #if USE_ALIGNED size_t result = 0; const char *first = n.data() + hashstring_hash_ofs; const char *last = first + sizeof(size_t); while (first != last) result = (result << 8) + *first++; return result; #else return *(size_t*)(n.data() + hashstring_hash_ofs); #endif } }; // Compare HashString pointers by dereferencing them. struct hashstring_ptr_equal : public std::binary_function { size_t operator () (const HashString* one, const HashString* two) const { return *one == *two; } }; class DhtNodeList : public std::tr1::unordered_map { public: typedef std::tr1::unordered_map base_type; // Define accessor iterator with more convenient access to the key and // element values. Allows changing the map definition more easily if needed. template struct accessor_wrapper : public T { accessor_wrapper(const T& itr) : T(itr) { } const HashString& id() const { return *(**this).first; } DhtNode* node() const { return (**this).second; } }; typedef accessor_wrapper const_accessor; typedef accessor_wrapper accessor; DhtNode* add_node(DhtNode* n); }; class DhtTrackerList : public std::tr1::unordered_map { public: typedef std::tr1::unordered_map base_type; template struct accessor_wrapper : public T { accessor_wrapper(const T& itr) : T(itr) { } const HashString& id() const { return (**this).first; } DhtTracker* tracker() const { return (**this).second; } }; typedef accessor_wrapper const_accessor; typedef accessor_wrapper accessor; }; #else // Compare HashString pointers by dereferencing them. struct hashstring_ptr_less : public std::binary_function { size_t operator () (const HashString* one, const HashString* two) const { return *one < *two; } }; class DhtNodeList : public std::map { public: typedef std::map base_type; // Define accessor iterator with more convenient access to the key and // element values. Allows changing the map definition more easily if needed. template struct accessor_wrapper : public T { accessor_wrapper(const T& itr) : T(itr) { } const HashString& id() const { return *(**this).first; } DhtNode* node() const { return (**this).second; } }; typedef accessor_wrapper const_accessor; typedef accessor_wrapper accessor; DhtNode* add_node(DhtNode* n); }; class DhtTrackerList : public std::map { public: typedef std::map base_type; template struct accessor_wrapper : public T { accessor_wrapper(const T& itr) : T(itr) { } const HashString& id() const { return (**this).first; } DhtTracker* tracker() const { return (**this).second; } }; typedef accessor_wrapper const_accessor; typedef accessor_wrapper accessor; }; #endif // HAVE_TR1 inline DhtNode* DhtNodeList::add_node(DhtNode* n) { insert(std::make_pair((const HashString*)n, (DhtNode*)n)); return n; } } #endif libtorrent-0.13.2/src/dht/dht_node.cc000644 000765 000024 00000005734 11705767056 020411 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "globals.h" #include "torrent/exceptions.h" #include "torrent/object.h" #include "net/address_list.h" // For SA. #include "dht_node.h" namespace torrent { DhtNode::DhtNode(const HashString& id, const rak::socket_address* sa) : HashString(id), m_socketAddress(*sa), m_lastSeen(0), m_recentlyActive(false), m_recentlyInactive(0), m_bucket(NULL) { if (sa->family() != rak::socket_address::af_inet) throw resource_error("Address not af_inet"); } DhtNode::DhtNode(const std::string& id, const Object& cache) : HashString(*HashString::cast_from(id.c_str())), m_recentlyActive(false), m_recentlyInactive(0), m_bucket(NULL) { rak::socket_address_inet* sa = m_socketAddress.sa_inet(); sa->set_family(); sa->set_address_h(cache.get_key_value("i")); sa->set_port(cache.get_key_value("p")); m_lastSeen = cache.get_key_value("t"); update(); } char* DhtNode::store_compact(char* buffer) const { HashString::cast_from(buffer)->assign(data()); SocketAddressCompact sa(address()->sa_inet()); std::memcpy(buffer + 20, sa.c_str(), 6); return buffer + 26; } Object* DhtNode::store_cache(Object* container) const { container->insert_key("i", m_socketAddress.sa_inet()->address_h()); container->insert_key("p", m_socketAddress.sa_inet()->port()); container->insert_key("t", m_lastSeen); return container; } } libtorrent-0.13.2/src/dht/dht_node.h000644 000765 000024 00000011732 11705767056 020246 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DHT_NODE_H #define LIBTORRENT_DHT_NODE_H #include "globals.h" #include #include "torrent/hash_string.h" #include "torrent/object_raw_bencode.h" #include "dht_bucket.h" namespace torrent { class DhtBucket; class DhtNode : public HashString { friend class DhtSearch; public: // A node is considered bad if it failed to reply to this many queries. static const unsigned int max_failed_replies = 5; DhtNode(const HashString& id, const rak::socket_address* sa); DhtNode(const std::string& id, const Object& cache); const HashString& id() const { return *this; } raw_string id_raw_string() const { return raw_string(data(), size_data); } const rak::socket_address* address() const { return &m_socketAddress; } void set_address(const rak::socket_address* sa) { m_socketAddress = *sa; } // For determining node quality. unsigned int last_seen() const { return m_lastSeen; } unsigned int age() const { return cachedTime.seconds() - m_lastSeen; } bool is_good() const { return m_recentlyActive; } bool is_questionable() const { return !m_recentlyActive; } bool is_bad() const { return m_recentlyInactive >= max_failed_replies; }; bool is_active() const { return m_lastSeen; } // Update is called once every 15 minutes. void update() { m_recentlyActive = age() < 15 * 60; } // Called when node replies to us, queries us, or fails to reply. void replied() { set_good(); } void queried() { if (m_lastSeen) set_good(); } void inactive(); DhtBucket* bucket() const { return m_bucket; } DhtBucket* set_bucket(DhtBucket* b) { m_bucket = b; return b; } bool is_in_range(const DhtBucket* b) { return b->is_in_range(*this); } // Store compact node information (26 bytes address, port and ID) in the given // buffer and return pointer to end of stored information. char* store_compact(char* buffer) const; // Store node cache in the given container object and return it. Object* store_cache(Object* container) const; private: DhtNode(); void set_good(); void set_bad(); rak::socket_address m_socketAddress; unsigned int m_lastSeen; bool m_recentlyActive; unsigned int m_recentlyInactive; DhtBucket* m_bucket; }; inline void DhtNode::set_good() { if (m_bucket != NULL && !is_good()) m_bucket->node_now_good(is_bad()); m_lastSeen = cachedTime.seconds(); m_recentlyInactive = 0; m_recentlyActive = true; } inline void DhtNode::set_bad() { if (m_bucket != NULL && !is_bad()) m_bucket->node_now_bad(is_good()); m_recentlyInactive = max_failed_replies; m_recentlyActive = false; } inline void DhtNode::inactive() { if (m_recentlyInactive + 1 == max_failed_replies) set_bad(); else m_recentlyInactive++; } } #endif libtorrent-0.13.2/src/dht/dht_router.cc000644 000765 000024 00000051025 11716350717 020770 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "globals.h" #include #include #include "torrent/dht_manager.h" #include "torrent/download_info.h" #include "torrent/exceptions.h" #include "utils/sha1.h" #include "manager.h" #include "dht_bucket.h" #include "dht_router.h" #include "dht_tracker.h" #include "dht_transaction.h" namespace torrent { HashString DhtRouter::zero_id; DhtRouter::DhtRouter(const Object& cache, const rak::socket_address* sa) : DhtNode(zero_id, sa), // actual ID is set later m_server(this), m_contacts(NULL), m_numRefresh(0), m_curToken(random()), m_prevToken(random()) { HashString ones_id; zero_id.clear(); ones_id.clear(0xFF); if (cache.has_key("self_id")) { const std::string& id = cache.get_key_string("self_id"); if (id.length() != HashString::size_data) throw bencode_error("Loading cache: Invalid ID."); assign(id.c_str()); } else { long buffer[size_data]; for (long* itr = buffer; itr != buffer + size_data; ++itr) *itr = random(); Sha1 sha; sha.init(); sha.update(buffer, sizeof(buffer)); sha.final_c(data()); } set_bucket(new DhtBucket(zero_id, ones_id)); m_routingTable.insert(std::make_pair(bucket()->id_range_end(), bucket())); if (cache.has_key("nodes")) { const Object::map_type& nodes = cache.get_key_map("nodes"); for (Object::map_type::const_iterator itr = nodes.begin(); itr != nodes.end(); ++itr) { if (itr->first.length() != HashString::size_data) throw bencode_error("Loading cache: Invalid node hash."); add_node_to_bucket(m_nodes.add_node(new DhtNode(itr->first, itr->second))); } } if (m_nodes.size() < num_bootstrap_complete) { m_contacts = new std::deque; if (cache.has_key("contacts")) { const Object::list_type& contacts = cache.get_key_list("contacts"); for (Object::list_type::const_iterator itr = contacts.begin(); itr != contacts.end(); ++itr) { Object::list_type::const_iterator litr = itr->as_list().begin(); const std::string& host = litr->as_string(); int port = (++litr)->as_value(); m_contacts->push_back(std::make_pair(host, port)); } } } } DhtRouter::~DhtRouter() { stop(); delete m_contacts; std::for_each(m_routingTable.begin(), m_routingTable.end(), rak::on(rak::mem_ref(&DhtBucketList::value_type::second), rak::call_delete())); std::for_each(m_trackers.begin(), m_trackers.end(), rak::on(rak::mem_ref(&DhtTrackerList::value_type::second), rak::call_delete())); std::for_each(m_nodes.begin(), m_nodes.end(), rak::on(rak::mem_ref(&DhtNodeList::value_type::second), rak::call_delete())); } void DhtRouter::start(int port) { m_server.start(port); // Set timeout slot and schedule it to be called immediately for initial bootstrapping if necessary. m_taskTimeout.slot() = std::tr1::bind(&DhtRouter::receive_timeout_bootstrap, this); priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(1)).round_seconds()); } void DhtRouter::stop() { priority_queue_erase(&taskScheduler, &m_taskTimeout); m_server.stop(); } // Start a DHT get_peers and announce_peer request. void DhtRouter::announce(DownloadInfo* info, TrackerDht* tracker) { m_server.announce(*find_bucket(info->hash())->second, info->hash(), tracker); } // Cancel any running requests from the given tracker. // If info or tracker is not NULL, only cancel matching requests. void DhtRouter::cancel_announce(DownloadInfo* info, const TrackerDht* tracker) { m_server.cancel_announce(info, tracker); } DhtTracker* DhtRouter::get_tracker(const HashString& hash, bool create) { DhtTrackerList::accessor itr = m_trackers.find(hash); if (itr != m_trackers.end()) return itr.tracker(); if (!create) return NULL; std::pair res = m_trackers.insert(std::make_pair(hash, new DhtTracker())); if (!res.second) throw internal_error("DhtRouter::get_tracker did not actually insert tracker."); return res.first.tracker(); } bool DhtRouter::want_node(const HashString& id) { // We don't want to add ourself. Also, too many broken implementations // advertise an ID of 0, which causes collisions, so reject that. if (id == this->id() || id == zero_id) return false; // We are always interested in more nodes for our own bucket (causing it // to be split if full); in other buckets only if there's space. DhtBucket* b = find_bucket(id)->second; return b == bucket() || b->has_space(); } DhtNode* DhtRouter::get_node(const HashString& id) { DhtNodeList::accessor itr = m_nodes.find(&id); if (itr == m_nodes.end()) { if (id == this->id()) return this; else return NULL; } return itr.node(); } DhtRouter::DhtBucketList::iterator DhtRouter::find_bucket(const HashString& id) { DhtBucketList::iterator itr = m_routingTable.lower_bound(id); #ifdef USE_EXTRA_DEBUG if (itr == m_routingTable.end()) throw internal_error("DHT Buckets not covering entire ID space."); if (!itr->second->is_in_range(id)) throw internal_error("DhtRouter::find_bucket, m_routingTable.lower_bound did not find correct bucket."); #endif return itr; } void DhtRouter::add_contact(const std::string& host, int port) { // Externally obtained nodes are added to the contact list, but only if // we're still bootstrapping. We don't contact external nodes after that. if (m_contacts != NULL) { if (m_contacts->size() >= num_bootstrap_contacts) m_contacts->pop_front(); m_contacts->push_back(std::make_pair(host, port)); } } void DhtRouter::contact(const rak::socket_address* sa, int port) { if (is_active()) { rak::socket_address sa_port = *sa; sa_port.set_port(port); m_server.ping(zero_id, &sa_port); } } // Received a query from the given node. If it has previously replied // to one of our queries, consider it alive and update the bucket mtime, // otherwise if we could use it in a bucket, try contacting it. DhtNode* DhtRouter::node_queried(const HashString& id, const rak::socket_address* sa) { DhtNode* node = get_node(id); if (node == NULL) { if (want_node(id)) m_server.ping(id, sa); return NULL; } // If we know the ID but the address is different, don't set the original node // active, but neither use this new address to prevent rogue nodes from polluting // our routing table with fake source addresses. if (node->address()->sa_inet()->address_n() != sa->sa_inet()->address_n()) return NULL; node->queried(); if (node->is_good()) node->bucket()->touch(); return node; } // Received a reply from a node we queried. // Check that it matches the information we have, set that it has replied // and update the bucket mtime. DhtNode* DhtRouter::node_replied(const HashString& id, const rak::socket_address* sa) { DhtNode* node = get_node(id); if (node == NULL) { if (!want_node(id)) return NULL; // New node, create it. It's a good node (it replied!) so add it to a bucket. node = m_nodes.add_node(new DhtNode(id, sa)); if (!add_node_to_bucket(node)) // deletes the node if it fails return NULL; } if (node->address()->sa_inet()->address_n() != sa->sa_inet()->address_n()) return NULL; node->replied(); node->bucket()->touch(); return node; } // A node has not replied to one of our queries. DhtNode* DhtRouter::node_inactive(const HashString& id, const rak::socket_address* sa) { DhtNodeList::accessor itr = m_nodes.find(&id); // If not found add it to some blacklist so we won't try contacting it again immediately? if (itr == m_nodes.end()) return NULL; // Check source address. Normally node_inactive is called if we DON'T receive a reply, // however it can also be called if a node replied with an malformed response packet, // so check that the address matches so that a rogue node cannot cause other nodes // to be considered bad by sending malformed packets. if (itr.node()->address()->sa_inet()->address_n() != sa->sa_inet()->address_n()) return NULL; itr.node()->inactive(); // Old node age normally implies no replies for many consecutive queries, however // after loading the node cache after a day or more we want to give each node a few // chances to reply again instead of removing all nodes instantly. if (itr.node()->is_bad() && itr.node()->age() >= timeout_remove_node) { delete_node(itr); return NULL; } return itr.node(); } // We sent a query to the given node ID, but received a reply from a different // node ID, that means the address of the original ID is invalid now. void DhtRouter::node_invalid(const HashString& id) { DhtNode* node = get_node(id); if (node == NULL || node == this) return; delete_node(m_nodes.find(&node->id())); } Object* DhtRouter::store_cache(Object* container) const { container->insert_key("self_id", str()); // Insert all nodes. Object& nodes = container->insert_key("nodes", Object::create_map()); for (DhtNodeList::const_accessor itr = m_nodes.begin(); itr != m_nodes.end(); ++itr) { if (!itr.node()->is_bad()) itr.node()->store_cache(&nodes.insert_key(itr.id().str(), Object::create_map())); } // Insert contacts, if we have any. if (m_contacts != NULL) { Object& contacts = container->insert_key("contacts", Object::create_list()); for (std::deque::const_iterator itr = m_contacts->begin(); itr != m_contacts->end(); ++itr) { Object::list_type& list = contacts.insert_back(Object::create_list()).as_list(); list.push_back(itr->first); list.push_back(itr->second); } } return container; } DhtManager::statistics_type DhtRouter::get_statistics() const { DhtManager::statistics_type stats(*m_server.upload_throttle_node()->rate(), *m_server.download_throttle_node()->rate()); if (!m_server.is_active()) stats.cycle = 0; else if (m_numRefresh < 2) // still bootstrapping stats.cycle = 1; else stats.cycle = m_numRefresh; stats.queries_received = m_server.queries_received(); stats.queries_sent = m_server.queries_sent(); stats.replies_received = m_server.replies_received(); stats.errors_received = m_server.errors_received(); stats.errors_caught = m_server.errors_caught(); stats.num_nodes = m_nodes.size(); stats.num_buckets = m_routingTable.size(); stats.num_peers = 0; stats.max_peers = 0; stats.num_trackers = m_trackers.size(); for (DhtTrackerList::const_accessor itr = m_trackers.begin(); itr != m_trackers.end(); ++itr) { unsigned int peers = itr.tracker()->size(); stats.num_peers += peers; stats.max_peers = std::max(peers, stats.max_peers); } return stats; } void DhtRouter::receive_timeout_bootstrap() { // If we're still bootstrapping, restart the process every 60 seconds until // we have enough nodes in our routing table. After we have 32 nodes, we switch // to a less aggressive non-bootstrap mode of collecting nodes that contact us // and through doing normal torrent announces. if (m_nodes.size() < num_bootstrap_complete) { if (m_contacts == NULL) throw internal_error("DhtRouter::receive_timeout_bootstrap called without contact list."); if (!m_nodes.empty() || !m_contacts->empty()) bootstrap(); // Retry in 60 seconds. priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(timeout_bootstrap_retry)).round_seconds()); m_numRefresh = 1; // still bootstrapping } else { // We won't be needing external contacts after this. delete m_contacts; m_contacts = NULL; m_taskTimeout.slot() = std::tr1::bind(&DhtRouter::receive_timeout, this); if (!m_numRefresh) { // If we're still in the startup, do the usual refreshing too. receive_timeout(); } else { // Otherwise just set the 15 minute timer. priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(timeout_update)).round_seconds()); } m_numRefresh = 2; } } void DhtRouter::receive_timeout() { priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(timeout_update)).round_seconds()); m_prevToken = m_curToken; m_curToken = random(); // Do some periodic accounting, refreshing buckets and marking // bad nodes. // Update nodes. for (DhtNodeList::accessor itr = m_nodes.begin(); itr != m_nodes.end(); ++itr) { if (!itr.node()->bucket()) throw internal_error("DhtRouter::receive_timeout has node without bucket."); itr.node()->update(); // Try contacting nodes we haven't received anything from for a while. // Don't contact repeatedly unresponsive nodes; we keep them in case they // do send a query, until we find a better node. However, give it a last // chance just before deleting it. if (itr.node()->is_questionable() && (!itr.node()->is_bad() || itr.node()->age() >= timeout_remove_node)) m_server.ping(itr.node()->id(), itr.node()->address()); } // If bucket isn't full yet or hasn't received replies/queries from // its nodes for a while, try to find new nodes now. for (DhtBucketList::const_iterator itr = m_routingTable.begin(); itr != m_routingTable.end(); ++itr) { itr->second->update(); if (!itr->second->is_full() || itr->second == bucket() || itr->second->age() > timeout_bucket_bootstrap) bootstrap_bucket(itr->second); } // Remove old peers and empty torrents from the tracker. for (DhtTrackerList::accessor itr = m_trackers.begin(); itr != m_trackers.end(); ) { itr.tracker()->prune(timeout_peer_announce); if (itr.tracker()->empty()) { delete itr.tracker(); m_trackers.erase(itr++); } else { ++itr; } } m_server.update(); m_numRefresh++; } char* DhtRouter::generate_token(const rak::socket_address* sa, int token, char buffer[20]) { Sha1 sha; uint32_t key = sa->sa_inet()->address_n(); sha.init(); sha.update(&token, sizeof(token)); sha.update(&key, 4); sha.final_c(buffer); return buffer; } bool DhtRouter::token_valid(raw_string token, const rak::socket_address* sa) { if (token.size() != size_token) return false; // Compare given token to the reference token. char reference[20]; // First try current token. // // Else if token recently changed, some clients may be using the older one. // That way a token is valid for 15-30 minutes, instead of 0-15. return token == raw_string(generate_token(sa, m_curToken, reference), size_token) || token == raw_string(generate_token(sa, m_prevToken, reference), size_token); } DhtNode* DhtRouter::find_node(const rak::socket_address* sa) { for (DhtNodeList::accessor itr = m_nodes.begin(); itr != m_nodes.end(); ++itr) if (itr.node()->address()->sa_inet()->address_n() == sa->sa_inet()->address_n()) return itr.node(); return NULL; } DhtRouter::DhtBucketList::iterator DhtRouter::split_bucket(const DhtBucketList::iterator& itr, DhtNode* node) { // Split bucket. Current bucket keeps the upper half thus keeping the // map key valid, new bucket is the lower half of the original bucket. DhtBucket* newBucket = itr->second->split(id()); // If our bucket has a child now (the new bucket), move ourself into it. if (bucket()->child() != NULL) set_bucket(bucket()->child()); if (!bucket()->is_in_range(id())) throw internal_error("DhtRouter::split_bucket router ID ended up in wrong bucket."); // Insert new bucket with iterator hint = just before current bucket. DhtBucketList::iterator other = m_routingTable.insert(itr, std::make_pair(newBucket->id_range_end(), newBucket)); // Check that the bucket we're not adding the node to isn't empty. if (other->second->is_in_range(node->id())) { if (itr->second->empty()) bootstrap_bucket(itr->second); } else { if (other->second->empty()) bootstrap_bucket(other->second); other = itr; } return other; } bool DhtRouter::add_node_to_bucket(DhtNode* node) { DhtBucketList::iterator itr = find_bucket(node->id()); while (itr->second->is_full()) { // Bucket is full. If there are any bad nodes, remove the oldest. DhtBucket::iterator nodeItr = itr->second->find_replacement_candidate(); if (nodeItr == itr->second->end()) throw internal_error("DhtBucket::find_candidate returned no node."); if ((*nodeItr)->is_bad()) { delete_node(m_nodes.find(&(*nodeItr)->id())); } else { // Bucket is full of good nodes; if our own ID falls in // range then split the bucket else discard new node. if (itr->second != bucket()) { delete_node(m_nodes.find(&node->id())); return false; } itr = split_bucket(itr, node); } } itr->second->add_node(node); node->set_bucket(itr->second); return true; } void DhtRouter::delete_node(const DhtNodeList::accessor& itr) { if (itr == m_nodes.end()) throw internal_error("DhtRouter::delete_node called with invalid iterator."); if (itr.node()->bucket() != NULL) itr.node()->bucket()->remove_node(itr.node()); delete itr.node(); m_nodes.erase(itr); } struct contact_node_t { contact_node_t(DhtRouter* router, int port) : m_router(router), m_port(port) { } void operator() (const sockaddr* sa, int err) { if (sa != NULL) m_router->contact(rak::socket_address::cast_from(sa), m_port); } DhtRouter* m_router; int m_port; }; void DhtRouter::bootstrap() { // Contact up to 8 nodes from the contact list (newest first). for (int count = 0; count < 8 && !m_contacts->empty(); count++) { manager->connection_manager()->resolver()(m_contacts->back().first.c_str(), (int)rak::socket_address::pf_inet, SOCK_DGRAM, contact_node_t(this, m_contacts->back().second)); m_contacts->pop_back(); } // Abort unless we already found some nodes for a search. if (m_nodes.empty()) return; bootstrap_bucket(bucket()); // Aggressively ping all questionable nodes in our own bucket to weed // out bad nodes as early as possible and make room for fresh nodes. for (DhtBucket::iterator itr = bucket()->begin(); itr != bucket()->end(); ++itr) if (!(*itr)->is_good()) m_server.ping((*itr)->id(), (*itr)->address()); // Also bootstrap a random bucket, if there are others. if (m_routingTable.size() < 2) return; DhtBucketList::iterator itr = m_routingTable.begin(); std::advance(itr, random() % m_routingTable.size()); if (itr->second != bucket() && itr != m_routingTable.end()) bootstrap_bucket(itr->second); } void DhtRouter::bootstrap_bucket(const DhtBucket* bucket) { if (!m_server.is_active()) return; // Do a search for a random ID, or the ID adjacent to our // own when bootstrapping our own bucket. We don't search for // our own exact ID to avoid receiving only our own node info // instead of closest nodes, from nodes that know us already. HashString contactId; if (bucket == this->bucket()) { contactId = id(); contactId[contactId.size() - 1] ^= 1; } else { bucket->get_random_id(&contactId); } m_server.find_node(*bucket, contactId); } } libtorrent-0.13.2/src/dht/dht_router.h000644 000765 000024 00000017216 11705767056 020644 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DHT_ROUTER_H #define LIBTORRENT_DHT_ROUTER_H #include #include #include "torrent/dht_manager.h" #include "torrent/hash_string.h" #include "torrent/object.h" #include "dht_node.h" #include "dht_hash_map.h" #include "dht_server.h" namespace torrent { class DhtBucket; class DhtTracker; class TrackerDht; // Main DHT class, maintains the routing table of known nodes and talks to the // DhtServer object that handles the actual communication. class DhtRouter : public DhtNode { public: // How many bytes to return and verify from the 20-byte SHA token. static const unsigned int size_token = 8; static const unsigned int timeout_bootstrap_retry = 60; // Retry initial bootstrapping every minute. static const unsigned int timeout_update = 15 * 60; // Regular housekeeping updates every 15 minutes. static const unsigned int timeout_bucket_bootstrap = 15 * 60; // Bootstrap idle buckets after 15 minutes. static const unsigned int timeout_remove_node = 4 * 60 * 60; // Remove unresponsive nodes after 4 hours. static const unsigned int timeout_peer_announce = 30 * 60; // Remove peers which haven't reannounced for 30 minutes. // A node ID of all zero. static HashString zero_id; DhtRouter(const Object& cache, const rak::socket_address* sa); ~DhtRouter(); // Start and stop the router. This starts/stops the UDP server as well. void start(int port); void stop(); bool is_active() { return m_server.is_active(); } // Find peers for given download and announce ourselves. void announce(DownloadInfo* info, TrackerDht* tracker); // Cancel any pending transactions related to the given download (or all if NULL). void cancel_announce(DownloadInfo* info, const TrackerDht* tracker); // Retrieve tracked torrent for the hash. // Returns NULL if not tracking the torrent unless create is true. DhtTracker* get_tracker(const HashString& hash, bool create); // Check if we are interested in inserting a new node of the given ID // into our table (i.e. if we have space or bad nodes in the corresponding bucket). bool want_node(const HashString& id); // Add the given host to the list of potential contacts if we haven't // completed the bootstrap process, or contact the given address directly. void add_contact(const std::string& host, int port); void contact(const rak::socket_address* sa, int port); // Retrieve node of given ID in constant time. Return NULL if not found, unless // it's our own ID in which case it returns the DhtRouter object. DhtNode* get_node(const HashString& id); // Search for node with given address in O(n), disregarding the port. DhtNode* find_node(const rak::socket_address* sa); // Whenever a node queries us, replies, or is confirmed inactive (no reply) or // invalid (reply with wrong ID), we need to update its status. DhtNode* node_queried(const HashString& id, const rak::socket_address* sa); DhtNode* node_replied(const HashString& id, const rak::socket_address* sa); DhtNode* node_inactive(const HashString& id, const rak::socket_address* sa); void node_invalid(const HashString& id); // Store compact node information (26 bytes) for nodes closest to the // given ID in the given buffer, return new buffer end. raw_string get_closest_nodes(const HashString& id) { return find_bucket(id)->second->full_bucket(); } // Store DHT cache in the given container. Object* store_cache(Object* container) const; // Create and verify a token. Tokens are valid between 15-30 minutes from creation. raw_string make_token(const rak::socket_address* sa, char* buffer); bool token_valid(raw_string token, const rak::socket_address* sa); DhtManager::statistics_type get_statistics() const; void reset_statistics() { m_server.reset_statistics(); } void set_upload_throttle(ThrottleList* t) { m_server.set_upload_throttle(t); } void set_download_throttle(ThrottleList* t) { m_server.set_download_throttle(t); } private: // Hostname and port of potential bootstrap nodes. typedef std::pair contact_t; // Number of nodes we need to consider the bootstrap process complete. static const unsigned int num_bootstrap_complete = 32; // Maximum number of potential contacts to keep until bootstrap complete. static const unsigned int num_bootstrap_contacts = 64; typedef std::map DhtBucketList; DhtBucketList::iterator find_bucket(const HashString& id); bool add_node_to_bucket(DhtNode* node); void delete_node(const DhtNodeList::accessor& itr); void store_closest_nodes(const HashString& id, DhtBucket* bucket); DhtBucketList::iterator split_bucket(const DhtBucketList::iterator& itr, DhtNode* node); void bootstrap(); void bootstrap_bucket(const DhtBucket* bucket); void receive_timeout(); void receive_timeout_bootstrap(); // buffer needs to hold an SHA1 hash (20 bytes), not just the token (8 bytes) char* generate_token(const rak::socket_address* sa, int token, char buffer[20]); rak::priority_item m_taskTimeout; DhtServer m_server; DhtNodeList m_nodes; DhtBucketList m_routingTable; DhtTrackerList m_trackers; std::deque* m_contacts; int m_numRefresh; bool m_networkUp; // Secret keys used for generating announce tokens. int m_curToken; int m_prevToken; }; inline raw_string DhtRouter::make_token(const rak::socket_address* sa, char* buffer) { return raw_string(generate_token(sa, m_curToken, buffer), size_token); } } #endif libtorrent-0.13.2/src/dht/dht_server.cc000644 000765 000024 00000070737 11716350717 020771 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "globals.h" #include #include #include "torrent/exceptions.h" #include "torrent/connection_manager.h" #include "torrent/download_info.h" #include "torrent/object.h" #include "torrent/object_stream.h" #include "torrent/poll.h" #include "torrent/object_static_map.h" #include "torrent/throttle.h" #include "tracker/tracker_dht.h" #include "dht_bucket.h" #include "dht_router.h" #include "dht_transaction.h" #include "manager.h" namespace torrent { const char* DhtServer::queries[] = { "ping", "find_node", "get_peers", "announce_peer", }; // List of all possible keys we need/support in a DHT message. // Unsupported keys we receive are dropped (ignored) while decoding. // See torrent/object_static_map.h for how this works. template <> const DhtMessage::key_list_type DhtMessage::base_type::keys = { { key_a_id, "a::id*S" }, { key_a_infoHash, "a::info_hash*S" }, { key_a_port, "a::port", }, { key_a_target, "a::target*S" }, { key_a_token, "a::token*S" }, { key_e_0, "e[]*" }, { key_e_1, "e[]*" }, { key_q, "q*S" }, { key_r_id, "r::id*S" }, { key_r_nodes, "r::nodes*S" }, { key_r_token, "r::token*S" }, { key_r_values, "r::values*L" }, { key_t, "t*S" }, { key_v, "v*" }, { key_y, "y*S" }, }; // Error in DHT protocol, avoids std::string ctor from communication_error class dht_error : public network_error { public: dht_error(int code, const char* message) : m_message(message), m_code(code) {} virtual int code() const throw() { return m_code; } virtual const char* what() const throw() { return m_message; } private: const char* m_message; int m_code; }; DhtServer::DhtServer(DhtRouter* router) : m_router(router), m_uploadNode(60), m_downloadNode(60), m_uploadThrottle(manager->upload_throttle()->throttle_list()), m_downloadThrottle(manager->download_throttle()->throttle_list()), m_networkUp(false) { get_fd().clear(); reset_statistics(); // Reserve a socket for the DHT server, even though we don't // actually open it until the server is started, which may not // happen until the first non-private torrent is started. manager->connection_manager()->inc_socket_count(); } DhtServer::~DhtServer() { stop(); std::for_each(m_highQueue.begin(), m_highQueue.end(), rak::call_delete()); std::for_each(m_lowQueue.begin(), m_lowQueue.end(), rak::call_delete()); manager->connection_manager()->dec_socket_count(); } void DhtServer::start(int port) { try { if (!get_fd().open_datagram() || !get_fd().set_nonblock()) throw resource_error("Could not allocate datagram socket."); if (!get_fd().set_reuse_address(true)) throw resource_error("Could not set listening port to reuse address."); rak::socket_address sa = *m_router->address(); sa.set_port(port); if (!get_fd().bind(sa)) throw resource_error("Could not bind datagram socket."); } catch (torrent::base_error& e) { get_fd().close(); get_fd().clear(); throw; } m_taskTimeout.slot() = std::tr1::bind(&DhtServer::receive_timeout, this); m_uploadNode.set_list_iterator(m_uploadThrottle->end()); m_uploadNode.slot_activate(rak::make_mem_fun(static_cast(this), &SocketBase::receive_throttle_up_activate)); m_downloadNode.set_list_iterator(m_downloadThrottle->end()); m_downloadThrottle->insert(&m_downloadNode); manager->poll()->open(this); manager->poll()->insert_read(this); manager->poll()->insert_error(this); } void DhtServer::stop() { if (!is_active()) return; clear_transactions(); priority_queue_erase(&taskScheduler, &m_taskTimeout); m_uploadThrottle->erase(&m_uploadNode); m_downloadThrottle->erase(&m_downloadNode); manager->poll()->remove_read(this); manager->poll()->remove_write(this); manager->poll()->remove_error(this); manager->poll()->close(this); get_fd().close(); get_fd().clear(); m_networkUp = false; } void DhtServer::reset_statistics() { m_queriesReceived = 0; m_queriesSent = 0; m_repliesReceived = 0; m_errorsReceived = 0; m_errorsCaught = 0; m_uploadNode.rate()->set_total(0); m_downloadNode.rate()->set_total(0); } // Ping a node whose ID we know. void DhtServer::ping(const HashString& id, const rak::socket_address* sa) { // No point pinging a node that we're already contacting otherwise. transaction_itr itr = m_transactions.lower_bound(DhtTransaction::key(sa, 0)); if (itr == m_transactions.end() || !DhtTransaction::key_match(itr->first, sa)) add_transaction(new DhtTransactionPing(id, sa), packet_prio_low); } // Contact nodes in given bucket and ask for their nodes closest to target. void DhtServer::find_node(const DhtBucket& contacts, const HashString& target) { DhtSearch* search = new DhtSearch(target, contacts); DhtSearch::const_accessor n; while ((n = search->get_contact()) != search->end()) add_transaction(new DhtTransactionFindNode(n), packet_prio_low); // This shouldn't happen, it means we had no contactable nodes at all. if (!search->start()) delete search; } void DhtServer::announce(const DhtBucket& contacts, const HashString& infoHash, TrackerDht* tracker) { DhtAnnounce* announce = new DhtAnnounce(infoHash, tracker, contacts); DhtSearch::const_accessor n; while ((n = announce->get_contact()) != announce->end()) add_transaction(new DhtTransactionFindNode(n), packet_prio_high); // This can only happen if all nodes we know are bad. if (!announce->start()) delete announce; else announce->update_status(); } void DhtServer::cancel_announce(DownloadInfo* info, const TrackerDht* tracker) { transaction_itr itr = m_transactions.begin(); while (itr != m_transactions.end()) { if (itr->second->is_search() && itr->second->as_search()->search()->is_announce()) { DhtAnnounce* announce = static_cast(itr->second->as_search()->search()); if ((info == NULL || announce->target() == info->hash()) && (tracker == NULL || announce->tracker() == tracker)) { delete itr->second; m_transactions.erase(itr++); continue; } } ++itr; } } void DhtServer::update() { // Reset this every 15 minutes. It'll get set back to true if we receive // any valid packets. This allows detecting when the entire network goes // down, and prevents all nodes from getting removed as unresponsive. m_networkUp = false; } void DhtServer::process_query(const HashString& id, const rak::socket_address* sa, const DhtMessage& msg) { m_queriesReceived++; m_networkUp = true; raw_string query = msg[key_q].as_raw_string(); // Construct reply. DhtMessage reply; if (query == raw_string::from_c_str("find_node")) create_find_node_response(msg, reply); else if (query == raw_string::from_c_str("get_peers")) create_get_peers_response(msg, sa, reply); else if (query == raw_string::from_c_str("announce_peer")) create_announce_peer_response(msg, sa, reply); else if (query != raw_string::from_c_str("ping")) throw dht_error(dht_error_bad_method, "Unknown query type."); m_router->node_queried(id, sa); create_response(msg, sa, reply); } void DhtServer::create_find_node_response(const DhtMessage& req, DhtMessage& reply) { raw_string target = req[key_a_target].as_raw_string(); if (target.size() < HashString::size_data) throw dht_error(dht_error_protocol, "target string too short"); reply[key_r_nodes] = m_router->get_closest_nodes(*HashString::cast_from(target.data())); if (reply[key_r_nodes].as_raw_string().empty()) throw dht_error(dht_error_generic, "No nodes"); } void DhtServer::create_get_peers_response(const DhtMessage& req, const rak::socket_address* sa, DhtMessage& reply) { reply[key_r_token] = m_router->make_token(sa, reply.data_end); reply.data_end += reply[key_r_token].as_raw_string().size(); raw_string info_hash_str = req[key_a_infoHash].as_raw_string(); if (info_hash_str.size() < HashString::size_data) throw dht_error(dht_error_protocol, "info hash too short"); const HashString* info_hash = HashString::cast_from(info_hash_str.data()); DhtTracker* tracker = m_router->get_tracker(*info_hash, false); // If we're not tracking or have no peers, send closest nodes. if (!tracker || tracker->empty()) { raw_string nodes = m_router->get_closest_nodes(*info_hash); if (nodes.empty()) throw dht_error(dht_error_generic, "No peers nor nodes"); reply[key_r_nodes] = nodes; } else { reply[key_r_values] = tracker->get_peers(); } } void DhtServer::create_announce_peer_response(const DhtMessage& req, const rak::socket_address* sa, DhtMessage& reply) { raw_string info_hash = req[key_a_infoHash].as_raw_string(); if (info_hash.size() < HashString::size_data) throw dht_error(dht_error_protocol, "info hash too short"); if (!m_router->token_valid(req[key_a_token].as_raw_string(), sa)) throw dht_error(dht_error_protocol, "Token invalid."); DhtTracker* tracker = m_router->get_tracker(*HashString::cast_from(info_hash.data()), true); tracker->add_peer(sa->sa_inet()->address_n(), req[key_a_port].as_value()); } void DhtServer::process_response(const HashString& id, const rak::socket_address* sa, const DhtMessage& response) { int transactionId = (unsigned char)response[key_t].as_raw_string().data()[0]; transaction_itr itr = m_transactions.find(DhtTransaction::key(sa, transactionId)); // Response to a transaction we don't have in our table. At this point it's // impossible to tell whether it used to be a valid transaction but timed out // the node did not return the ID we sent it, or it returned it with a // different address than we sent it o. Best we can do is ignore the reply, // since the protocol doesn't call for returning errors in responses. if (itr == m_transactions.end()) return; m_repliesReceived++; m_networkUp = true; // Make sure transaction is erased even if an exception is thrown. try { DhtTransaction* transaction = itr->second; #ifdef USE_EXTRA_DEBUG if (DhtTransaction::key(sa, transactionId) != transaction->key(transactionId)) throw internal_error("DhtServer::process_response key mismatch."); #endif // If we contact a node but its ID is not the one we expect, ignore the reply // to prevent interference from rogue nodes. if ((id != transaction->id() && transaction->id() != m_router->zero_id)) return; switch (transaction->type()) { case DhtTransaction::DHT_FIND_NODE: parse_find_node_reply(transaction->as_find_node(), response[key_r_nodes].as_raw_string()); break; case DhtTransaction::DHT_GET_PEERS: parse_get_peers_reply(transaction->as_get_peers(), response); break; // Nothing to do for DHT_PING and DHT_ANNOUNCE_PEER default: break; } // Mark node responsive only if all processing was successful, without errors. m_router->node_replied(id, sa); } catch (std::exception& e) { delete itr->second; m_transactions.erase(itr); m_errorsCaught++; throw; } delete itr->second; m_transactions.erase(itr); } void DhtServer::process_error(const rak::socket_address* sa, const DhtMessage& error) { int transactionId = (unsigned char)error[key_t].as_raw_string().data()[0]; transaction_itr itr = m_transactions.find(DhtTransaction::key(sa, transactionId)); if (itr == m_transactions.end()) return; m_repliesReceived++; m_errorsReceived++; m_networkUp = true; // Don't mark node as good (because it replied) or bad (because it returned an error). // If it consistently returns errors for valid queries it's probably broken. But a // few error messages are acceptable. So we do nothing and pretend the query never happened. delete itr->second; m_transactions.erase(itr); } void DhtServer::parse_find_node_reply(DhtTransactionSearch* transaction, raw_string nodes) { transaction->complete(true); if (sizeof(const compact_node_info) != 26) throw internal_error("DhtServer::parse_find_node_reply(...) bad struct size."); node_info_list list; std::copy(reinterpret_cast(nodes.data()), reinterpret_cast(nodes.data() + nodes.size() - nodes.size() % sizeof(compact_node_info)), std::back_inserter(list)); for (node_info_list::iterator itr = list.begin(); itr != list.end(); ++itr) { if (itr->id() != m_router->id()) { rak::socket_address sa = itr->address(); transaction->search()->add_contact(itr->id(), &sa); } } find_node_next(transaction); } void DhtServer::parse_get_peers_reply(DhtTransactionGetPeers* transaction, const DhtMessage& response) { DhtAnnounce* announce = static_cast(transaction->as_search()->search()); transaction->complete(true); if (response[key_r_values].is_raw_list()) announce->receive_peers(response[key_r_values].as_raw_list()); if (response[key_r_token].is_raw_string()) add_transaction(new DhtTransactionAnnouncePeer(transaction->id(), transaction->address(), announce->target(), response[key_r_token].as_raw_string()), packet_prio_low); announce->update_status(); } void DhtServer::find_node_next(DhtTransactionSearch* transaction) { int priority = packet_prio_low; if (transaction->search()->is_announce()) priority = packet_prio_high; DhtSearch::const_accessor node; while ((node = transaction->search()->get_contact()) != transaction->search()->end()) add_transaction(new DhtTransactionFindNode(node), priority); if (!transaction->search()->is_announce()) return; DhtAnnounce* announce = static_cast(transaction->search()); if (announce->complete()) { // We have found the 8 closest nodes to the info hash. Retrieve peers // from them and announce to them. for (node = announce->start_announce(); node != announce->end(); ++node) add_transaction(new DhtTransactionGetPeers(node), packet_prio_high); } announce->update_status(); } void DhtServer::add_packet(DhtTransactionPacket* packet, int priority) { switch (priority) { // High priority packets are for important queries, and quite small. // They're added to front of high priority queue and thus will be the // next packets sent. case packet_prio_high: m_highQueue.push_front(packet); break; // Low priority query packets are added to the back of the high priority // queue and will be sent when all high priority packets have been transmitted. case packet_prio_low: m_highQueue.push_back(packet); break; // Reply packets will be processed after all of our own packets have been send. case packet_prio_reply: m_lowQueue.push_back(packet); break; default: throw internal_error("DhtServer::add_packet called with invalid priority."); } } void DhtServer::create_query(transaction_itr itr, int tID, const rak::socket_address* sa, int priority) { if (itr->second->id() == m_router->id()) throw internal_error("DhtServer::create_query trying to send to itself."); DhtMessage query; // Transaction ID is a bencode string. query[key_t] = raw_bencode(query.data_end, 3); *query.data_end++ = '1'; *query.data_end++ = ':'; *query.data_end++ = tID; DhtTransaction* transaction = itr->second; query[key_q] = raw_string::from_c_str(queries[transaction->type()]); query[key_y] = raw_bencode::from_c_str("1:q"); query[key_v] = raw_bencode("4:" PEER_VERSION, 6); query[key_a_id] = m_router->id_raw_string(); switch (transaction->type()) { case DhtTransaction::DHT_PING: // nothing to do break; case DhtTransaction::DHT_FIND_NODE: query[key_a_target] = transaction->as_find_node()->search()->target_raw_string(); break; case DhtTransaction::DHT_GET_PEERS: query[key_a_infoHash] = transaction->as_get_peers()->search()->target_raw_string(); break; case DhtTransaction::DHT_ANNOUNCE_PEER: query[key_a_infoHash] = transaction->as_announce_peer()->info_hash_raw_string(); query[key_a_token] = transaction->as_announce_peer()->token(); query[key_a_port] = manager->connection_manager()->listen_port(); break; } DhtTransactionPacket* packet = new DhtTransactionPacket(transaction->address(), query, tID, transaction); transaction->set_packet(packet); add_packet(packet, priority); m_queriesSent++; } void DhtServer::create_response(const DhtMessage& req, const rak::socket_address* sa, DhtMessage& reply) { reply[key_r_id] = m_router->id_raw_string(); reply[key_t] = req[key_t]; reply[key_y] = raw_bencode::from_c_str("1:r"); reply[key_v] = raw_bencode("4:" PEER_VERSION, 6); add_packet(new DhtTransactionPacket(sa, reply), packet_prio_reply); } void DhtServer::create_error(const DhtMessage& req, const rak::socket_address* sa, int num, const char* msg) { DhtMessage error; if (req[key_t].is_raw_bencode() || req[key_t].is_raw_string()) error[key_t] = req[key_t]; error[key_y] = raw_bencode::from_c_str("1:e"); error[key_v] = raw_bencode("4:" PEER_VERSION, 6); error[key_e_0] = num; error[key_e_1] = raw_string::from_c_str(msg); add_packet(new DhtTransactionPacket(sa, error), packet_prio_reply); } int DhtServer::add_transaction(DhtTransaction* transaction, int priority) { // Try random transaction ID. This is to make it less likely that we reuse // a transaction ID from an earlier transaction which timed out and we forgot // about it, so that if the node replies after the timeout it's less likely // that we match the reply to the wrong transaction. // // If there's an existing transaction with the random ID we search for the next // unused one. Since normally only one or two transactions will be active per // node, a collision is extremely unlikely, and a linear search for the first // open one is the most efficient. unsigned int rnd = (uint8_t)random(); unsigned int id = rnd; transaction_itr insertItr = m_transactions.lower_bound(transaction->key(rnd)); // If key matches, keep trying successive IDs. while (insertItr != m_transactions.end() && insertItr->first == transaction->key(id)) { ++insertItr; id = (uint8_t)(id + 1); // Give up after trying all possible IDs. This should never happen. if (id == rnd) { delete transaction; return -1; } // Transaction ID wrapped around, reset iterator. if (id == 0) insertItr = m_transactions.lower_bound(transaction->key(id)); } // We know where to insert it, so pass that as hint. insertItr = m_transactions.insert(insertItr, std::make_pair(transaction->key(id), transaction)); create_query(insertItr, id, transaction->address(), priority); start_write(); return id; } // Transaction received no reply and timed out. Mark node as bad and remove // transaction (except if it was only the quick timeout). DhtServer::transaction_itr DhtServer::failed_transaction(transaction_itr itr, bool quick) { DhtTransaction* transaction = itr->second; // If it was a known node, remember that it didn't reply, unless the transaction // is only stalled (had quick timeout, but not full timeout). Also if the // transaction still has an associated packet, the packet never got sent due to // throttling, so don't blame the remote node for not replying. // Finally, if we haven't received anything whatsoever so far, assume the entire // network is down and so we can't blame the node either. if (!quick && m_networkUp && transaction->packet() == NULL && transaction->id() != m_router->zero_id) m_router->node_inactive(transaction->id(), transaction->address()); if (transaction->type() == DhtTransaction::DHT_FIND_NODE) { if (quick) transaction->as_find_node()->set_stalled(); else transaction->as_find_node()->complete(false); try { find_node_next(transaction->as_find_node()); } catch (std::exception& e) { if (!quick) { delete itr->second; m_transactions.erase(itr); } throw; } } if (quick) { return ++itr; // don't actually delete the transaction until the final timeout } else { delete itr->second; m_transactions.erase(itr++); return itr; } } void DhtServer::clear_transactions() { std::for_each(m_transactions.begin(), m_transactions.end(), rak::on(rak::mem_ref(&transaction_map::value_type::second), rak::call_delete())); m_transactions.clear(); } void DhtServer::event_read() { uint32_t total = 0; while (true) { Object request; rak::socket_address sa; int type = '?'; DhtMessage message; const HashString* nodeId = NULL; try { char buffer[2048]; int32_t read = read_datagram(buffer, sizeof(buffer), &sa); if (read < 0) break; total += read; // If it's not a valid bencode dictionary at all, it's probably not a DHT // packet at all, so we don't throw an error to prevent bounce loops. try { static_map_read_bencode(buffer, buffer + read, message); } catch (bencode_error& e) { continue; } if (!message[key_t].is_raw_string()) throw dht_error(dht_error_protocol, "No transaction ID"); if (!message[key_y].is_raw_string()) throw dht_error(dht_error_protocol, "No message type"); if (message[key_y].as_raw_string().size() != 1) throw dht_error(dht_error_bad_method, "Unsupported message type"); type = message[key_y].as_raw_string().data()[0]; // Queries and replies have node ID in different dictionaries. if (type == 'r' || type == 'q') { if (!message[type == 'q' ? key_a_id : key_r_id].is_raw_string()) throw dht_error(dht_error_protocol, "Invalid `id' value"); raw_string nodeIdStr = message[type == 'q' ? key_a_id : key_r_id].as_raw_string(); if (nodeIdStr.size() < HashString::size_data) throw dht_error(dht_error_protocol, "`id' value too short"); nodeId = HashString::cast_from(nodeIdStr.data()); } // Sanity check the returned transaction ID. if ((type == 'r' || type == 'e') && (!message[key_t].is_raw_string() || message[key_t].as_raw_string().size() != 1)) throw dht_error(dht_error_protocol, "Invalid transaction ID type/length."); // Stupid broken implementations. if (nodeId != NULL && *nodeId == m_router->id()) throw dht_error(dht_error_protocol, "Send your own ID, not mine"); switch (type) { case 'q': process_query(*nodeId, &sa, message); break; case 'r': process_response(*nodeId, &sa, message); break; case 'e': process_error(&sa, message); break; default: throw dht_error(dht_error_bad_method, "Unknown message type."); } // If node was querying us, reply with error packet, otherwise mark the node as "query failed", // so that if it repeatedly sends malformed replies we will drop it instead of propagating it // to other nodes. } catch (bencode_error& e) { if ((type == 'r' || type == 'e') && nodeId != NULL) { m_router->node_inactive(*nodeId, &sa); } else { snprintf(message.data_end, message.data + message.data_size - message.data_end - 1, "Malformed packet: %s", e.what()); message.data[message.data_size - 1] = '\0'; create_error(message, &sa, dht_error_protocol, message.data_end); } } catch (dht_error& e) { if ((type == 'r' || type == 'e') && nodeId != NULL) m_router->node_inactive(*nodeId, &sa); else create_error(message, &sa, e.code(), e.what()); } catch (network_error& e) { } } m_downloadThrottle->node_used_unthrottled(total); m_downloadNode.rate()->insert(total); start_write(); } bool DhtServer::process_queue(packet_queue& queue, uint32_t* quota) { uint32_t used = 0; while (!queue.empty()) { DhtTransactionPacket* packet = queue.front(); // Make sure its transaction hasn't timed out yet, if it has/had one // and don't bother sending non-transaction packets (replies) after // more than 15 seconds in the queue. if (packet->has_failed() || packet->age() > 15) { delete packet; queue.pop_front(); continue; } if (packet->length() > *quota) { m_uploadThrottle->node_used(&m_uploadNode, used); return false; } queue.pop_front(); try { int written = write_datagram(packet->c_str(), packet->length(), packet->address()); if (written == -1) throw network_error(); used += written; *quota -= written; if ((unsigned int)written != packet->length()) throw network_error(); } catch (network_error& e) { // Couldn't write packet, maybe something wrong with node address or routing, so mark node as bad. if (packet->has_transaction()) { transaction_itr itr = m_transactions.find(packet->transaction()->key(packet->id())); if (itr == m_transactions.end()) throw internal_error("DhtServer::process_queue could not find transaction."); failed_transaction(itr, false); } } if (packet->has_transaction()) packet->transaction()->set_packet(NULL); delete packet; } m_uploadThrottle->node_used(&m_uploadNode, used); return true; } void DhtServer::event_write() { if (m_highQueue.empty() && m_lowQueue.empty()) throw internal_error("DhtServer::event_write called but both write queues are empty."); if (!m_uploadThrottle->is_throttled(&m_uploadNode)) throw internal_error("DhtServer::event_write called while not in throttle list."); uint32_t quota = m_uploadThrottle->node_quota(&m_uploadNode); if (quota == 0 || !process_queue(m_highQueue, "a) || !process_queue(m_lowQueue, "a)) { manager->poll()->remove_write(this); m_uploadThrottle->node_deactivate(&m_uploadNode); } else if (m_highQueue.empty() && m_lowQueue.empty()) { manager->poll()->remove_write(this); m_uploadThrottle->erase(&m_uploadNode); } } void DhtServer::event_error() { } void DhtServer::start_write() { if ((!m_highQueue.empty() || !m_lowQueue.empty()) && !m_uploadThrottle->is_throttled(&m_uploadNode)) { m_uploadThrottle->insert(&m_uploadNode); manager->poll()->insert_write(this); } if (!m_taskTimeout.is_queued() && !m_transactions.empty()) priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(5)).round_seconds()); } void DhtServer::receive_timeout() { transaction_itr itr = m_transactions.begin(); while (itr != m_transactions.end()) { if (itr->second->has_quick_timeout() && itr->second->quick_timeout() < cachedTime.seconds()) { itr = failed_transaction(itr, true); } else if (itr->second->timeout() < cachedTime.seconds()) { itr = failed_transaction(itr, false); } else { ++itr; } } start_write(); } } libtorrent-0.13.2/src/dht/dht_server.h000644 000765 000024 00000017221 11716630446 020620 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DHT_SERVER_H #define LIBTORRENT_DHT_SERVER_H #include #include #include #include #include "net/socket_datagram.h" #include "net/throttle_node.h" #include "torrent/hash_string.h" #include "torrent/object_raw_bencode.h" #include "dht_transaction.h" namespace torrent { class DhtBucket; class DhtNode; class DhtRouter; class DownloadInfo; class DhtMessage; class TrackerDht; // UDP server that handles the DHT node communications. class DhtServer : public SocketDatagram { public: DhtServer(DhtRouter* self); ~DhtServer(); const char* type_name() const { return "dht"; } void start(int port); void stop(); bool is_active() const { return get_fd().is_valid(); } unsigned int queries_received() const { return m_queriesReceived; } unsigned int queries_sent() const { return m_queriesSent; } unsigned int replies_received() const { return m_repliesReceived; } unsigned int errors_received() const { return m_errorsReceived; } unsigned int errors_caught() const { return m_errorsCaught; } void reset_statistics(); // Contact a node to see if it replies. Set id=0 if unknown. void ping(const HashString& id, const rak::socket_address* sa); // Do a find_node search with the given contacts as starting point for the // search. void find_node(const DhtBucket& contacts, const HashString& target); // Do DHT announce, starting with the given contacts. void announce(const DhtBucket& contacts, const HashString& infoHash, TrackerDht* tracker); // Cancel given announce for given tracker, or all matching announces if info/tracker NULL. void cancel_announce(DownloadInfo* info, const TrackerDht* tracker); // Called every 15 minutes. void update(); ThrottleNode* upload_throttle_node() { return &m_uploadNode; } const ThrottleNode* upload_throttle_node() const { return &m_uploadNode; } ThrottleNode* download_throttle_node() { return &m_downloadNode; } const ThrottleNode* download_throttle_node() const { return &m_downloadNode; } void set_upload_throttle(ThrottleList* t) { m_uploadThrottle = t; } void set_download_throttle(ThrottleList* t) { m_downloadThrottle = t; } virtual void event_read(); virtual void event_write(); virtual void event_error(); private: // DHT error codes. static const int dht_error_generic = 201; static const int dht_error_server = 202; static const int dht_error_protocol = 203; static const int dht_error_bad_method = 204; struct compact_node_info { char _id[20]; SocketAddressCompact _addr; HashString& id() { return *HashString::cast_from(_id); } rak::socket_address address() { return rak::socket_address(_addr); } } __attribute__ ((packed)); typedef std::deque packet_queue; typedef std::list node_info_list; // Pending transactions. typedef std::map transaction_map; typedef transaction_map::iterator transaction_itr; // DHT transaction names for given transaction type. static const char* queries[]; // Priorities for the outgoing packets. static const int packet_prio_high = 2; // For important queries we send (announces). static const int packet_prio_low = 1; // For (relatively) unimportant queries we send. static const int packet_prio_reply = 0; // For replies to peer queries. void start_write(); void process_query(const HashString& id, const rak::socket_address* sa, const DhtMessage& req); void process_response(const HashString& id, const rak::socket_address* sa, const DhtMessage& req); void process_error(const rak::socket_address* sa, const DhtMessage& error); void parse_find_node_reply(DhtTransactionSearch* t, raw_string nodes); void parse_get_peers_reply(DhtTransactionGetPeers* t, const DhtMessage& res); void find_node_next(DhtTransactionSearch* t); void add_packet(DhtTransactionPacket* packet, int priority); void create_query(transaction_itr itr, int tID, const rak::socket_address* sa, int priority); void create_response(const DhtMessage& req, const rak::socket_address* sa, DhtMessage& reply); void create_error(const DhtMessage& req, const rak::socket_address* sa, int num, const char* msg); void create_find_node_response(const DhtMessage& arg, DhtMessage& reply); void create_get_peers_response(const DhtMessage& arg, const rak::socket_address* sa, DhtMessage& reply); void create_announce_peer_response(const DhtMessage& arg, const rak::socket_address* sa, DhtMessage& reply); int add_transaction(DhtTransaction* t, int priority); // This returns the iterator after the given one or end() transaction_itr failed_transaction(transaction_itr itr, bool quick); void clear_transactions(); bool process_queue(packet_queue& queue, uint32_t* quota); void receive_timeout(); DhtRouter* m_router; packet_queue m_highQueue; packet_queue m_lowQueue; transaction_map m_transactions; rak::priority_item m_taskTimeout; ThrottleNode m_uploadNode; ThrottleNode m_downloadNode; ThrottleList* m_uploadThrottle; ThrottleList* m_downloadThrottle; unsigned int m_queriesReceived; unsigned int m_queriesSent; unsigned int m_repliesReceived; unsigned int m_errorsReceived; unsigned int m_errorsCaught; bool m_networkUp; }; } #endif libtorrent-0.13.2/src/dht/dht_tracker.cc000644 000765 000024 00000010052 11705767056 021104 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/object.h" #include "dht_tracker.h" namespace torrent { void DhtTracker::add_peer(uint32_t addr, uint16_t port) { if (port == 0) return; SocketAddressCompact compact(addr, port); unsigned int oldest = 0; uint32_t minSeen = ~uint32_t(); // Check if peer exists. If not, find oldest peer. for (unsigned int i = 0; i < size(); i++) { if (m_peers[i].peer.addr == compact.addr) { m_peers[i].peer.port = compact.port; m_lastSeen[i] = cachedTime.seconds(); return; } else if (m_lastSeen[i] < minSeen) { minSeen = m_lastSeen[i]; oldest = i; } } // If peer doesn't exist, append to list if the table is not full. if (size() < max_size) { m_peers.push_back(compact); m_lastSeen.push_back(cachedTime.seconds()); // Peer doesn't exist and table is full: replace oldest peer. } else { m_peers[oldest] = compact; m_lastSeen[oldest] = cachedTime.seconds(); } } // Return compact info as bencoded string (8 bytes per peer) for up to 30 peers, // returning different peers for each call if there are more. raw_list DhtTracker::get_peers(unsigned int maxPeers) { if (sizeof(BencodeAddress) != 8) throw internal_error("DhtTracker::BencodeAddress is packed incorrectly."); PeerList::iterator first = m_peers.begin(); PeerList::iterator last = m_peers.end(); // If we have more than max_peers, randomly return block of peers. // The peers in overlapping blocks get picked twice as often, but // that's better than returning fewer peers. if (m_peers.size() > maxPeers) { unsigned int blocks = (m_peers.size() + maxPeers - 1) / maxPeers; first += (random() % blocks) * (m_peers.size() - maxPeers) / (blocks - 1); last = first + maxPeers; } return raw_list(first->bencode(), last->bencode() - first->bencode()); } // Remove old announces. void DhtTracker::prune(uint32_t maxAge) { uint32_t minSeen = cachedTime.seconds() - maxAge; for (unsigned int i = 0; i < m_lastSeen.size(); i++) if (m_lastSeen[i] < minSeen) m_peers[i].peer.port = 0; m_peers.erase(std::remove_if(m_peers.begin(), m_peers.end(), std::mem_fun_ref(&BencodeAddress::empty)), m_peers.end()); m_lastSeen.erase(std::remove_if(m_lastSeen.begin(), m_lastSeen.end(), std::bind2nd(std::less(), minSeen)), m_lastSeen.end()); if (m_peers.size() != m_lastSeen.size()) throw internal_error("DhtTracker::prune did inconsistent peer pruning."); } } libtorrent-0.13.2/src/dht/dht_tracker.h000644 000765 000024 00000006725 11705767056 020762 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DHT_TRACKER_H #define LIBTORRENT_DHT_TRACKER_H #include "globals.h" #include #include #include "net/address_list.h" // For SA. #include "torrent/object_raw_bencode.h" namespace torrent { // Container for peers tracked in a torrent. class DhtTracker { public: // Maximum number of peers we return for a GET_PEERS query (default value only). // Needs to be small enough so that a packet with a payload of num_peers*6 bytes // does not need fragmentation. Value chosen so that the size is approximately // equal to a FIND_NODE reply (8*26 bytes). static const unsigned int max_peers = 32; // Maximum number of peers we keep track of. For torrents with more peers, // we replace the oldest peer with each new announce to avoid excessively // large peer tables for very active torrents. static const unsigned int max_size = 128; bool empty() const { return m_peers.empty(); } size_t size() const { return m_peers.size(); } void add_peer(uint32_t addr, uint16_t port); raw_list get_peers(unsigned int maxPeers = max_peers); // Remove old announces from the tracker that have not reannounced for // more than the given number of seconds. void prune(uint32_t maxAge); private: // We need to store the address as a bencoded string. struct BencodeAddress { char header[2]; SocketAddressCompact peer; BencodeAddress(const SocketAddressCompact& p) : peer(p) { header[0] = '6'; header[1] = ':'; } const char* bencode() const { return header; } bool empty() const { return !peer.port; } } __attribute__ ((packed)); typedef std::vector PeerList; PeerList m_peers; std::vector m_lastSeen; }; } #endif libtorrent-0.13.2/src/dht/dht_transaction.cc000644 000765 000024 00000021606 11705767056 022005 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "torrent/exceptions.h" #include "torrent/object_stream.h" #include "tracker/tracker_dht.h" #include "dht_bucket.h" #include "dht_transaction.h" namespace torrent { DhtSearch::DhtSearch(const HashString& target, const DhtBucket& contacts) : base_type(dht_compare_closer(m_target = target)), m_pending(0), m_contacted(0), m_replied(0), m_concurrency(3), m_restart(false), m_started(false), m_next(end()) { add_contacts(contacts); } DhtSearch::~DhtSearch() { // Make sure transactions were destructed first. Since it is the destruction // of a transaction that triggers this destructor, that should always be the // case. if (m_pending) throw internal_error("DhtSearch::~DhtSearch called with pending transactions."); if (m_concurrency != 3) throw internal_error("DhtSearch::~DhtSearch with invalid concurrency limit."); for (accessor itr = begin(); itr != end(); ++itr) delete itr.node(); } bool DhtSearch::add_contact(const HashString& id, const rak::socket_address* sa) { DhtNode* n = new DhtNode(id, sa); bool added = insert(std::make_pair(n, this)).second; if (!added) delete n; else m_restart = true; return added; } void DhtSearch::add_contacts(const DhtBucket& contacts) { DhtBucketChain chain(&contacts); // Add max_contacts=18 closest nodes, and fill up so we also have at least 8 good nodes. int needClosest = max_contacts - size(); int needGood = DhtBucket::num_nodes; for (DhtBucket::const_iterator itr = chain.bucket()->begin(); needClosest > 0 || needGood > 0; ++itr) { while (itr == chain.bucket()->end()) { if (!chain.next()) return; itr = chain.bucket()->begin(); } if ((!(*itr)->is_bad() || needClosest > 0) && add_contact((*itr)->id(), (*itr)->address())) { needGood -= !(*itr)->is_bad(); needClosest--; } } } // Check if a node has been contacted yet. This is the case if it is not currently // being contacted, nor has it been found to be good or bad. bool DhtSearch::node_uncontacted(const DhtNode* node) const { return !node->is_active() && !node->is_good() && !node->is_bad(); } // After more contacts have been added, discard least closest nodes // except if node has a transaction pending. void DhtSearch::trim(bool final) { // We keep: // - the max_contacts=18 closest good or unknown nodes and all nodes closer // than them (to see if further searches find closer ones) // - for announces, also the 3 closest good nodes (i.e. nodes that have // replied) to have at least that many for the actual announce // - any node that currently has transactions pending // // However, after exhausting all search nodes, we only keep good nodes. // // For our purposes, the node status is as follows: // node is bad (contacted but hasn't replied) if is_bad() // node is good (contacted and replied) if is_good() // node is currently being contacted if is_active() // node is new and unknown otherwise int needClosest = final ? 0 : max_contacts; int needGood = is_announce() ? max_announce : 0; // We're done if we can't find any more nodes to contact. m_next = end(); for (accessor itr = base_type::begin(); itr != end(); ) { // If we have all we need, delete current node unless it is // currently being contacted. if (!itr.node()->is_active() && needClosest <= 0 && (!itr.node()->is_good() || needGood <= 0)) { delete itr.node(); erase(itr++); continue; } // Otherwise adjust needed counts appropriately. needClosest--; needGood -= itr.node()->is_good(); // Remember the first uncontacted node as the closest one to contact next. if (m_next == end() && node_uncontacted(itr.node())) m_next = const_accessor(itr); ++itr; } m_restart = false; } DhtSearch::const_accessor DhtSearch::get_contact() { if (m_pending >= m_concurrency) return end(); if (m_restart) trim(false); const_accessor ret = m_next; if (ret == end()) return ret; set_node_active(ret, true); m_pending++; m_contacted++; // Find next node to contact: any node we haven't contacted yet. while (++m_next != end()) { if (node_uncontacted(m_next.node())) break; } return ret; } void DhtSearch::node_status(const_accessor& n, bool success) { if (n == end() || !n.node()->is_active()) throw internal_error("DhtSearch::node_status called for invalid/inactive node."); if (success) { n.node()->set_good(); m_replied++; } else { n.node()->set_bad(); } m_pending--; set_node_active(n, false); } DhtAnnounce::~DhtAnnounce() { if (!complete()) throw internal_error("DhtAnnounce::~DhtAnnounce called while announce not complete."); const char* failure = NULL; if (m_tracker->get_state() != TrackerDht::state_announcing) { if (!m_contacted) failure = "No DHT nodes available for peer search."; else failure = "DHT search unsuccessful."; } else { if (!m_contacted) failure = "DHT search unsuccessful."; else if (m_replied == 0 && !m_tracker->has_peers()) failure = "Announce failed"; } if (failure != NULL) m_tracker->receive_failed(failure); else m_tracker->receive_success(); } DhtSearch::const_accessor DhtAnnounce::start_announce() { trim(true); if (empty()) return end(); if (!complete() || m_next != end() || size() > DhtBucket::num_nodes) throw internal_error("DhtSearch::start_announce called in inconsistent state."); m_contacted = m_pending = size(); m_replied = 0; m_tracker->set_state(TrackerDht::state_announcing); for (const_accessor itr(begin()); itr != end(); ++itr) set_node_active(itr, true); return const_accessor(begin()); } void DhtTransactionPacket::build_buffer(const DhtMessage& msg) { char buffer[1500]; // If the message would exceed an Ethernet frame, something went very wrong. object_buffer_t result = static_map_write_bencode_c(object_write_to_buffer, NULL, std::make_pair(buffer, buffer + sizeof(buffer)), msg); m_length = result.second - buffer; m_data = new char[m_length]; memcpy(m_data, buffer, m_length); } DhtTransaction::DhtTransaction(int quick_timeout, int timeout, const HashString& id, const rak::socket_address* sa) : m_id(id), m_hasQuickTimeout(quick_timeout > 0), m_sa(*sa), m_timeout(cachedTime.seconds() + timeout), m_quickTimeout(cachedTime.seconds() + quick_timeout), m_packet(NULL) { } DhtTransaction::~DhtTransaction() { if (m_packet != NULL) m_packet->set_failed(); } void DhtTransactionSearch::set_stalled() { if (!m_hasQuickTimeout) throw internal_error("DhtTransactionSearch::set_stalled called on already stalled transaction."); m_hasQuickTimeout = false; m_search->m_concurrency++; } void DhtTransactionSearch::complete(bool success) { if (m_node == m_search->end()) throw internal_error("DhtTransactionSearch::complete called multiple times."); if (m_node.search() != m_search) throw internal_error("DhtTransactionSearch::complete called for node from wrong search."); if (!m_hasQuickTimeout) m_search->m_concurrency--; m_search->node_status(m_node, success); m_node = m_search->end(); } DhtTransactionSearch::~DhtTransactionSearch() { if (m_node != m_search->end()) complete(false); if (m_search->complete()) delete m_search; } } libtorrent-0.13.2/src/dht/dht_transaction.h000644 000765 000024 00000037320 11705767056 021647 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DHT_TRANSACTION_H #define LIBTORRENT_DHT_TRANSACTION_H #include #include #include "dht/dht_node.h" #include "torrent/hash_string.h" #include "torrent/object_static_map.h" #include "tracker/tracker_dht.h" namespace torrent { class TrackerDht; class DhtBucket; class DhtSearch; class DhtAnnounce; class DhtTransactionSearch; class DhtTransaction; class DhtTransactionPing; class DhtTransactionFindNode; class DhtTransactionFindNodeAnnounce; class DhtTransactionGetPeers; class DhtTransactionAnnouncePeer; // DhtSearch implements the DHT search algorithm and holds search data // that needs to be persistent across multiple find_node transactions. // // DhtAnnounce is a derived class used for searches that will eventually // lead to an announce to the closest nodes. // Compare predicate for ID closeness. struct dht_compare_closer : public std::binary_function { dht_compare_closer(const HashString& target) : m_target(target) { } bool operator () (const DhtNode* one, const DhtNode* two) const; const HashString& target() const { return m_target; } raw_string target_raw_string() const { return raw_string(m_target.data(), HashString::size_data); } private: const HashString& m_target; }; // DhtSearch contains a list of nodes sorted by closeness to the given target, // and returns what nodes to contact with up to three concurrent transactions pending. // The map element is the DhtSearch object itself to allow the returned accessors // to know which search a given node belongs to. class DhtSearch : protected std::map { friend class DhtTransactionSearch; public: typedef std::map base_type; // Number of closest potential contact nodes to keep. static const unsigned int max_contacts = 18; // Number of closest nodes we actually announce to. static const unsigned int max_announce = 3; DhtSearch(const HashString& target, const DhtBucket& contacts); virtual ~DhtSearch(); // Wrapper for iterators, allowing more convenient access to the key // and element values, which also makes it easier to change the container // without having to modify much code using iterators. template struct accessor_wrapper : public T { accessor_wrapper() { } accessor_wrapper(const T& itr) : T(itr) { } DhtNode* node() const { return (**this).first; } DhtSearch* search() const { return (**this).second; } }; typedef accessor_wrapper const_accessor; typedef accessor_wrapper accessor; // Add a potential node to contact for the search. bool add_contact(const HashString& id, const rak::socket_address* sa); void add_contacts(const DhtBucket& contacts); // Return next node to contact. Up to concurrent_searches nodes are returned, // and end() after that. Don't advance the accessor to get further contacts! const_accessor get_contact(); // Search statistics. int num_contacted() { return m_contacted; } int num_replied() { return m_replied; } bool start() { m_started = true; return m_pending; } bool complete() const { return m_started && !m_pending; } const HashString& target() const { return m_target; } raw_string target_raw_string() const { return raw_string(m_target.data(), HashString::size_data); } virtual bool is_announce() const { return false; } // Expose the otherwise private end() function but return an accessor, // to allow code checking whether get_contact returned a valid accessor. const_accessor end() const { return base_type::end(); } // Used by the sorting/comparison predicate to see which node is closer. static bool is_closer(const HashString& one, const HashString& two, const HashString& target); protected: void trim(bool final); void node_status(const_accessor& n, bool success); void set_node_active(const_accessor& n, bool active); // Statistics about contacted nodes. unsigned int m_pending; unsigned int m_contacted; unsigned int m_replied; unsigned int m_concurrency; bool m_restart; // If true, trim nodes and reset m_next on the following get_contact call. bool m_started; // Next node to return in get_contact, is end() if we have no more contactable nodes. const_accessor m_next; private: DhtSearch(const DhtSearch& s); bool node_uncontacted(const DhtNode* node) const; HashString m_target; }; class DhtAnnounce : public DhtSearch { public: DhtAnnounce(const HashString& infoHash, TrackerDht* tracker, const DhtBucket& contacts) : DhtSearch(infoHash, contacts), m_tracker(tracker) { } ~DhtAnnounce(); virtual bool is_announce() const { return true; } const TrackerDht* tracker() const { return m_tracker; } // Start announce and return final set of nodes in get_contact() calls. // This resets DhtSearch's completed() function, which now // counts announces instead. const_accessor start_announce(); void receive_peers(raw_list peers) { m_tracker->receive_peers(peers); } void update_status() { m_tracker->receive_progress(m_replied, m_contacted); } private: TrackerDht* m_tracker; }; // Possible bencode keys in a DHT message. enum dht_keys { key_a_id, key_a_infoHash, key_a_port, key_a_target, key_a_token, key_e_0, key_e_1, key_q, key_r_id, key_r_nodes, key_r_token, key_r_values, key_t, key_v, key_y, key_LAST, }; class DhtMessage : public static_map_type { public: typedef static_map_type base_type; DhtMessage() : data_end(data) {}; // Must be big enough to hold one of the possible variable-sized reply data. // Currently either: // - error message (size doesn't really matter, it'll be truncated at worst) // - announce token (8 bytes, needs 20 bytes buffer to build) // Never more than one of the above. // And additionally for queries we send: // - transaction ID (3 bytes) static const size_t data_size = 64; char data[data_size]; char* data_end; }; // Class holding transaction data to be transmitted. class DhtTransactionPacket { public: // transaction packet DhtTransactionPacket(const rak::socket_address* s, const DhtMessage& d, unsigned int id, DhtTransaction* t) : m_sa(*s), m_id(id), m_transaction(t) { build_buffer(d); }; // non-transaction packet DhtTransactionPacket(const rak::socket_address* s, const DhtMessage& d) : m_sa(*s), m_id(-cachedTime.seconds()), m_transaction(NULL) { build_buffer(d); }; ~DhtTransactionPacket() { delete[] m_data; } bool has_transaction() const { return m_id >= -1; } bool has_failed() const { return m_id == -1; } void set_failed() { m_id = -1; } const rak::socket_address* address() const { return &m_sa; } rak::socket_address* address() { return &m_sa; } const char* c_str() const { return m_data; } size_t length() const { return m_length; } int id() const { return m_id; } int age() const { return has_transaction() ? 0 : cachedTime.seconds() + m_id; } const DhtTransaction* transaction() const { return m_transaction; } DhtTransaction* transaction() { return m_transaction; } private: void build_buffer(const DhtMessage& data); rak::socket_address m_sa; char* m_data; size_t m_length; int m_id; DhtTransaction* m_transaction; }; // DHT Transaction classes. DhtTransaction and DhtTransactionSearch // are not directly usable with no public constructor, since type() // is a pure virtual function. class DhtTransaction { public: virtual ~DhtTransaction(); typedef enum { DHT_PING, DHT_FIND_NODE, DHT_GET_PEERS, DHT_ANNOUNCE_PEER, } transaction_type; virtual transaction_type type() = 0; virtual bool is_search() { return false; } // Key to uniquely identify a transaction with given per-node transaction id. typedef uint64_t key_type; key_type key(int id) const { return key(&m_sa, id); } static key_type key(const rak::socket_address* sa, int id); static bool key_match(key_type key, const rak::socket_address* sa); // Node ID and address. const HashString& id() { return m_id; } const rak::socket_address* address() { return &m_sa; } int timeout() { return m_timeout; } int quick_timeout() { return m_quickTimeout; } bool has_quick_timeout() { return m_hasQuickTimeout; } DhtTransactionPacket* packet() { return m_packet; } void set_packet(DhtTransactionPacket* p) { m_packet = p; } DhtTransactionSearch* as_search(); DhtTransactionPing* as_ping(); DhtTransactionFindNode* as_find_node(); DhtTransactionGetPeers* as_get_peers(); DhtTransactionAnnouncePeer* as_announce_peer(); protected: DhtTransaction(int quick_timeout, int timeout, const HashString& id, const rak::socket_address* sa); // m_id must be the first element to ensure it is aligned properly, // because we later read a size_t value from it. const HashString m_id; bool m_hasQuickTimeout; private: DhtTransaction(const DhtTransaction& t); rak::socket_address m_sa; int m_timeout; int m_quickTimeout; DhtTransactionPacket* m_packet; }; class DhtTransactionSearch : public DhtTransaction { public: virtual ~DhtTransactionSearch(); virtual bool is_search() { return true; } DhtSearch::const_accessor node() { return m_node; } DhtSearch* search() { return m_search; } void set_stalled(); void complete(bool success); protected: DhtTransactionSearch(int quick_timeout, int timeout, DhtSearch::const_accessor& node) : DhtTransaction(quick_timeout, timeout, node.node()->id(), node.node()->address()), m_node(node), m_search(node.search()) { if (!m_hasQuickTimeout) m_search->m_concurrency++; } private: DhtSearch::const_accessor m_node; DhtSearch* m_search; }; // Actual transaction classes. class DhtTransactionPing : public DhtTransaction { public: DhtTransactionPing(const HashString& id, const rak::socket_address* sa) : DhtTransaction(-1, 30, id, sa) { } virtual transaction_type type() { return DHT_PING; } }; class DhtTransactionFindNode : public DhtTransactionSearch { public: DhtTransactionFindNode(DhtSearch::const_accessor& node) : DhtTransactionSearch(4, 30, node) { } virtual transaction_type type() { return DHT_FIND_NODE; } }; class DhtTransactionGetPeers : public DhtTransactionSearch { public: DhtTransactionGetPeers(DhtSearch::const_accessor& node) : DhtTransactionSearch(-1, 30, node) { } virtual transaction_type type() { return DHT_GET_PEERS; } }; class DhtTransactionAnnouncePeer : public DhtTransaction { public: DhtTransactionAnnouncePeer(const HashString& id, const rak::socket_address* sa, const HashString& infoHash, raw_string token) : DhtTransaction(-1, 30, id, sa), m_infoHash(infoHash), m_token(token) { } virtual transaction_type type() { return DHT_ANNOUNCE_PEER; } const HashString& info_hash() { return m_infoHash; } raw_string info_hash_raw_string() const { return raw_string(m_infoHash.data(), HashString::size_data); } raw_string token() { return m_token; } private: HashString m_infoHash; raw_string m_token; }; inline bool DhtSearch::is_closer(const HashString& one, const HashString& two, const HashString& target) { for (unsigned int i=0; im_lastSeen = active; } inline bool dht_compare_closer::operator () (const DhtNode* one, const DhtNode* two) const { return DhtSearch::is_closer(*one, *two, m_target); } inline DhtTransaction::key_type DhtTransaction::key(const rak::socket_address* sa, int id) { return ((uint64_t)sa->sa_inet()->address_n() << 32) + id; } inline bool DhtTransaction::key_match(key_type key, const rak::socket_address* sa) { return (key >> 32) == sa->sa_inet()->address_n(); } // These could (should?) check that the type matches, or use dynamic_cast if we have RTTI. inline DhtTransactionSearch* DhtTransaction::as_search() { return static_cast(this); } inline DhtTransactionPing* DhtTransaction::as_ping() { return static_cast(this); } inline DhtTransactionFindNode* DhtTransaction::as_find_node() { return static_cast(this); } inline DhtTransactionGetPeers* DhtTransaction::as_get_peers() { return static_cast(this); } inline DhtTransactionAnnouncePeer* DhtTransaction::as_announce_peer() { return static_cast(this); } } #endif libtorrent-0.13.2/src/dht/Makefile.am000644 000765 000024 00000000523 11705767056 020341 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_dht.la libsub_dht_la_SOURCES = \ dht_bucket.cc \ dht_bucket.h \ dht_hash_map.h \ dht_node.cc \ dht_node.h \ dht_router.cc \ dht_router.h \ dht_server.cc \ dht_server.h \ dht_tracker.cc \ dht_tracker.h \ dht_transaction.cc \ dht_transaction.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrent-0.13.2/src/dht/Makefile.in000644 000765 000024 00000040270 11744204216 020340 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/dht DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_dht_la_LIBADD = am_libsub_dht_la_OBJECTS = dht_bucket.lo dht_node.lo dht_router.lo \ dht_server.lo dht_tracker.lo dht_transaction.lo libsub_dht_la_OBJECTS = $(am_libsub_dht_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_dht_la_SOURCES) DIST_SOURCES = $(libsub_dht_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_dht.la libsub_dht_la_SOURCES = \ dht_bucket.cc \ dht_bucket.h \ dht_hash_map.h \ dht_node.cc \ dht_node.h \ dht_router.cc \ dht_router.h \ dht_server.cc \ dht_server.h \ dht_tracker.cc \ dht_tracker.h \ dht_transaction.cc \ dht_transaction.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dht/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/dht/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_dht.la: $(libsub_dht_la_OBJECTS) $(libsub_dht_la_DEPENDENCIES) $(EXTRA_libsub_dht_la_DEPENDENCIES) $(CXXLINK) $(libsub_dht_la_OBJECTS) $(libsub_dht_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_bucket.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_node.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_router.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_server.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_tracker.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_transaction.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/data/chunk.cc000644 000765 000024 00000017317 11705767056 020067 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include "torrent/exceptions.h" #include "chunk.h" #include "chunk_iterator.h" namespace torrent { bool Chunk::is_all_valid() const { return !empty() && std::find_if(begin(), end(), std::not1(std::mem_fun_ref(&ChunkPart::is_valid))) == end(); } void Chunk::clear() { std::for_each(begin(), end(), std::mem_fun_ref(&ChunkPart::clear)); m_chunkSize = 0; m_prot = ~0; base_type::clear(); } // Each add calls vector's reserve adding 1. This should keep // the size of the vector at exactly what we need. Though it // will require a few more cycles, it won't matter as we only // rarely have more than 1 or 2 nodes. // // If the user knows how many chunk parts he is going to add, then he // may call reserve prior to this. void Chunk::push_back(value_type::mapped_type mapped, const MemoryChunk& c) { m_prot &= c.get_prot(); // Gcc starts the reserved size at 1 for the first insert, so we // won't be wasting any space in the general case. base_type::insert(end(), ChunkPart(mapped, c, m_chunkSize)); m_chunkSize += c.size(); } Chunk::iterator Chunk::at_position(uint32_t pos) { if (pos >= m_chunkSize) throw internal_error("Chunk::at_position(...) tried to get Chunk position out of range."); iterator itr = std::find_if(begin(), end(), std::bind2nd(std::mem_fun_ref(&ChunkPart::is_contained), pos)); if (itr == end()) throw internal_error("Chunk::at_position(...) might be mangled, at_position failed horribly"); if (itr->size() == 0) throw internal_error("Chunk::at_position(...) tried to return a node with length 0"); return itr; } Chunk::data_type Chunk::at_memory(uint32_t offset, iterator part) { if (part == end()) throw internal_error("Chunk::at_memory(...) reached end."); if (!part->chunk().is_valid()) throw internal_error("Chunk::at_memory(...) chunk part isn't valid."); if (offset < part->position() || offset >= part->position() + part->size()) throw internal_error("Chunk::at_memory(...) out of range."); offset -= part->position(); return data_type(part->chunk().begin() + offset, part->size() - offset); } bool Chunk::is_incore(uint32_t pos, uint32_t length) { iterator itr = at_position(pos); if (itr == end()) throw internal_error("Chunk::incore_length(...) at end()"); uint32_t last = pos + std::min(length, chunk_size() - pos); while (itr->is_incore(pos, last - pos)) { if (++itr == end() || itr->position() >= last) return true; pos = itr->position(); } return false; } // TODO: Buggy, hitting internal_error. Likely need to fix // ChunkPart::incore_length's length align. uint32_t Chunk::incore_length(uint32_t pos, uint32_t length) { uint32_t result = 0; iterator itr = at_position(pos); if (itr == end()) throw internal_error("Chunk::incore_length(...) at end()"); length = std::min(length, chunk_size() - pos); do { uint32_t incore_len = itr->incore_length(pos, length); if (incore_len > length) throw internal_error("Chunk::incore_length(...) incore_len > length."); pos += incore_len; length -= incore_len; result += incore_len; } while (pos == itr->position() + itr->size() && ++itr != end()); return result; } bool Chunk::sync(int flags) { bool success = true; for (iterator itr = begin(), last = end(); itr != last; ++itr) if (!itr->chunk().sync(0, itr->chunk().size(), flags)) success = false; return success; } void Chunk::preload(uint32_t position, uint32_t length, bool useAdvise) { if (position >= m_chunkSize) throw internal_error("Chunk::preload(...) position > m_chunkSize."); if (length == 0) return; Chunk::data_type data; ChunkIterator itr(this, position, position + std::min(length, m_chunkSize - position)); do { data = itr.data(); // Don't do preloading for zero-length chunks. if (useAdvise) { itr.memory_chunk()->advise(itr.memory_chunk_first(), data.second, MemoryChunk::advice_willneed); } else { for (char* first = (char*)data.first, *last = (char*)data.first + data.second; first < last; first += 4096) volatile char __UNUSED touchChunk = *(char*)data.first; // Make sure we touch the last page in the range. volatile char __UNUSED touchChunk = *((char*)data.first + data.second - 1); } } while (itr.next()); } // Consider using uint32_t returning first mismatch or length if // matching. bool Chunk::to_buffer(void* buffer, uint32_t position, uint32_t length) { if (position + length > m_chunkSize) throw internal_error("Chunk::to_buffer(...) position + length > m_chunkSize."); if (length == 0) return true; Chunk::data_type data; ChunkIterator itr(this, position, position + length); do { data = itr.data(); std::memcpy(buffer, data.first, data.second); buffer = static_cast(buffer) + data.second; } while (itr.next()); return true; } // Consider using uint32_t returning first mismatch or length if // matching. bool Chunk::from_buffer(const void* buffer, uint32_t position, uint32_t length) { if (position + length > m_chunkSize) throw internal_error("Chunk::from_buffer(...) position + length > m_chunkSize."); if (length == 0) return true; Chunk::data_type data; ChunkIterator itr(this, position, position + length); do { data = itr.data(); std::memcpy(data.first, buffer, data.second); buffer = static_cast(buffer) + data.second; } while (itr.next()); return true; } // Consider using uint32_t returning first mismatch or length if // matching. bool Chunk::compare_buffer(const void* buffer, uint32_t position, uint32_t length) { if (position + length > m_chunkSize) throw internal_error("Chunk::compare_buffer(...) position + length > m_chunkSize."); if (length == 0) return true; Chunk::data_type data; ChunkIterator itr(this, position, position + length); do { data = itr.data(); if (std::memcmp(data.first, buffer, data.second) != 0) return false; buffer = static_cast(buffer) + data.second; } while (itr.next()); return true; } } libtorrent-0.13.2/src/data/chunk.h000644 000765 000024 00000010406 11705767056 017721 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_STORAGE_CHUNK_H #define LIBTORRENT_STORAGE_CHUNK_H #include #include #include #include "chunk_part.h" namespace torrent { class Chunk : private std::vector { public: typedef std::vector base_type; typedef std::pair data_type; using base_type::value_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::const_iterator; using base_type::empty; using base_type::reserve; using base_type::begin; using base_type::end; using base_type::rbegin; using base_type::rend; using base_type::front; using base_type::back; Chunk() : m_chunkSize(0), m_prot(~0) {} ~Chunk() { clear(); } bool is_all_valid() const; // All permissions are set for empty chunks. bool is_readable() const { return m_prot & MemoryChunk::prot_read; } bool is_writable() const { return m_prot & MemoryChunk::prot_write; } bool has_permissions(int prot) const { return !(prot & ~m_prot); } uint32_t chunk_size() const { return m_chunkSize; } void clear(); void push_back(value_type::mapped_type mapped, const MemoryChunk& c); // The at_position functions only returns non-zero length iterators // or end. iterator at_position(uint32_t pos); iterator at_position(uint32_t pos, iterator itr); data_type at_memory(uint32_t offset, iterator part); iterator find_address(void* ptr); // Check how much of the chunk is incore from pos. bool is_incore(uint32_t pos, uint32_t length = ~uint32_t()); uint32_t incore_length(uint32_t pos, uint32_t length = ~uint32_t()); bool sync(int flags); void preload(uint32_t position, uint32_t length, bool useAdvise); bool to_buffer(void* buffer, uint32_t position, uint32_t length); bool from_buffer(const void* buffer, uint32_t position, uint32_t length); bool compare_buffer(const void* buffer, uint32_t position, uint32_t length); private: Chunk(const Chunk&); void operator = (const Chunk&); uint32_t m_chunkSize; int m_prot; }; inline Chunk::iterator Chunk::at_position(uint32_t pos, iterator itr) { while (itr != end() && itr->position() + itr->size() <= pos) itr++; return itr; } inline Chunk::iterator Chunk::find_address(void* ptr) { return std::find_if(begin(), end(), std::bind2nd(std::mem_fun_ref(&ChunkPart::has_address), ptr)); } } #endif libtorrent-0.13.2/src/data/chunk_handle.h000644 000765 000024 00000006147 11716350717 021235 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_CHUNK_HANDLE_H #define LIBTORRENT_DATA_CHUNK_HANDLE_H #include #include "chunk_list_node.h" namespace torrent { class ChunkListNode; class ChunkHandle { public: ChunkHandle(ChunkListNode* c = NULL, bool wr = false, bool blk = false) : m_node(c), m_writable(wr), m_blocking(blk) {} bool is_valid() const { return m_node != NULL; } bool is_loaded() const { return m_node != NULL && m_node->is_valid(); } bool is_writable() const { return m_writable; } bool is_blocking() const { return m_blocking; } void clear() { m_node = NULL; m_writable = false; m_blocking = false; } rak::error_number error_number() const { return m_errorNumber; } void set_error_number(rak::error_number e) { m_errorNumber = e; } ChunkListNode* object() const { return m_node; } Chunk* chunk() const { return m_node->chunk(); } uint32_t index() const { return m_node->index(); } static ChunkHandle from_error(rak::error_number e) { ChunkHandle h; h.set_error_number(e); return h; } private: ChunkListNode* m_node; bool m_writable; bool m_blocking; rak::error_number m_errorNumber; }; } #endif libtorrent-0.13.2/src/data/chunk_iterator.h000644 000765 000024 00000007107 11705767056 021636 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_CHUNK_ITERATOR_H #define LIBTORRENT_DATA_CHUNK_ITERATOR_H #include "chunk.h" namespace torrent { class ChunkIterator { public: ChunkIterator(Chunk* chunk, uint32_t first, uint32_t last); bool empty() const { return m_iterator == m_chunk->end() || m_first >= m_last; } // Only non-zero length ranges will be returned. Chunk::data_type data(); MemoryChunk* memory_chunk() { return &m_iterator->chunk(); } uint32_t memory_chunk_first() const { return m_first - m_iterator->position(); } uint32_t memory_chunk_last() const { return m_last - m_iterator->position(); } bool next(); bool forward(uint32_t length); private: Chunk* m_chunk; Chunk::iterator m_iterator; uint32_t m_first; uint32_t m_last; }; inline ChunkIterator::ChunkIterator(Chunk* chunk, uint32_t first, uint32_t last) : m_chunk(chunk), m_iterator(chunk->at_position(first)), m_first(first), m_last(last) { } inline Chunk::data_type ChunkIterator::data() { Chunk::data_type data = m_chunk->at_memory(m_first, m_iterator); data.second = std::min(data.second, m_last - m_first); return data; } inline bool ChunkIterator::next() { m_first = m_iterator->position() + m_iterator->size(); while (++m_iterator != m_chunk->end()) { if (m_iterator->size() != 0) return m_first < m_last; } return false; } // Returns true if the new position is on a file boundary while not at // the edges of the chunk. // // Do not return true if the length was zero, in order to avoid // getting stuck looping when no data is being read/written. inline bool ChunkIterator::forward(uint32_t length) { m_first += length; if (m_first >= m_last) return false; do { if (m_first < m_iterator->position() + m_iterator->size()) return true; m_iterator++; } while (m_iterator != m_chunk->end()); return false; } } #endif libtorrent-0.13.2/src/data/chunk_list.cc000644 000765 000024 00000035351 11721117103 021074 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #define __STDC_FORMAT_MACROS #include #include #include "torrent/exceptions.h" #include "torrent/chunk_manager.h" #include "torrent/data/download_data.h" #include "torrent/utils/log.h" #include "torrent/utils/log_files.h" #include "chunk_list.h" #include "chunk.h" #include "globals.h" #define LT_LOG_THIS(log_level, log_fmt, ...) \ lt_log_print_data(LOG_STORAGE_##log_level, m_data, "chunk_list", log_fmt, __VA_ARGS__); namespace torrent { struct chunk_list_earliest_modified { chunk_list_earliest_modified() : m_time(cachedTime) {} void operator () (ChunkListNode* node) { if (node->time_modified() < m_time && node->time_modified() != rak::timer()) m_time = node->time_modified(); } rak::timer m_time; }; struct chunk_list_sort_index { bool operator () (ChunkListNode* node1, ChunkListNode* node2) { return node1->index() < node2->index(); } }; inline bool ChunkList::is_queued(ChunkListNode* node) { return std::find(m_queue.begin(), m_queue.end(), node) != m_queue.end(); } bool ChunkList::has_chunk(size_type index, int prot) const { return base_type::at(index).is_valid() && base_type::at(index).chunk()->has_permissions(prot); } void ChunkList::resize(size_type to_size) { LT_LOG_THIS(INFO, "Resizing: from:%" PRIu32 " to:%" PRIu32 ".", size(), to_size); if (!empty()) throw internal_error("ChunkList::resize(...) called on an non-empty object."); base_type::resize(to_size); uint32_t index = 0; for (iterator itr = begin(), last = end(); itr != last; ++itr, ++index) itr->set_index(index); } void ChunkList::clear() { LT_LOG_THIS(INFO, "Clearing.", 0); // Don't do any sync'ing as whomever decided to shut down really // doesn't care, so just de-reference all chunks in queue. for (Queue::iterator itr = m_queue.begin(), last = m_queue.end(); itr != last; ++itr) { if ((*itr)->references() != 1 || (*itr)->writable() != 1) throw internal_error("ChunkList::clear() called but a node in the queue is still referenced."); (*itr)->dec_rw(); clear_chunk(*itr); } m_queue.clear(); if (std::find_if(begin(), end(), std::mem_fun_ref(&ChunkListNode::chunk)) != end()) throw internal_error("ChunkList::clear() called but a node with a valid chunk was found."); if (std::find_if(begin(), end(), std::mem_fun_ref(&ChunkListNode::references)) != end()) throw internal_error("ChunkList::clear() called but a node with references != 0 was found."); if (std::find_if(begin(), end(), std::mem_fun_ref(&ChunkListNode::writable)) != end()) throw internal_error("ChunkList::clear() called but a node with writable != 0 was found."); if (std::find_if(begin(), end(), std::mem_fun_ref(&ChunkListNode::blocking)) != end()) throw internal_error("ChunkList::clear() called but a node with blocking != 0 was found."); base_type::clear(); } ChunkHandle ChunkList::get(size_type index, int flags) { LT_LOG_THIS(DEBUG, "Get: index:%" PRIu32 " flags:%#x.", index, flags); rak::error_number::clear_global(); ChunkListNode* node = &base_type::at(index); int allocate_flags = (flags & get_dont_log) ? ChunkManager::allocate_dont_log : 0; int prot_flags = MemoryChunk::prot_read | ((flags & get_writable) ? MemoryChunk::prot_write : 0); if (!node->is_valid()) { if (!m_manager->allocate(m_chunk_size, allocate_flags)) { LT_LOG_THIS(DEBUG, "Could not allocate: memory:%" PRIu64 " block:%" PRIu32 ".", m_manager->memory_usage(), m_manager->memory_block_count()); return ChunkHandle::from_error(rak::error_number::e_nomem); } Chunk* chunk = m_slot_create_chunk(index, prot_flags); if (chunk == NULL) { rak::error_number current_error = rak::error_number::current(); LT_LOG_THIS(DEBUG, "Could not create: memory:%" PRIu64 " block:%" PRIu32 " errno:%i errmsg:%s.", m_manager->memory_usage(), m_manager->memory_block_count(), current_error.value(), current_error.c_str()); m_manager->deallocate(m_chunk_size, allocate_flags | ChunkManager::allocate_revert_log); return ChunkHandle::from_error(current_error.is_valid() ? current_error : rak::error_number::e_noent); } node->set_chunk(chunk); node->set_time_modified(rak::timer()); } else if (flags & get_writable && !node->chunk()->is_writable()) { if (node->blocking() != 0) { if ((flags & get_nonblock)) return ChunkHandle::from_error(rak::error_number::e_again); throw internal_error("No support yet for getting write permission for blocked chunk."); } Chunk* chunk = m_slot_create_chunk(index, prot_flags); if (chunk == NULL) return ChunkHandle::from_error(rak::error_number::current().is_valid() ? rak::error_number::current() : rak::error_number::e_noent); delete node->chunk(); node->set_chunk(chunk); node->set_time_modified(rak::timer()); } node->inc_references(); if (flags & get_writable) { node->inc_writable(); // Make sure that periodic syncing uses async on any subsequent // changes even if it was triggered before this get. node->set_sync_triggered(false); } if (flags & get_blocking) { node->inc_blocking(); } return ChunkHandle(node, flags & get_writable, flags & get_blocking); } // The chunks in 'm_queue' have been modified and need to be synced // when appropriate. Hopefully keeping the chunks mmap'ed for a while // will allow us to schedule writes at more resonable intervals. void ChunkList::release(ChunkHandle* handle, int release_flags) { if (!handle->is_valid()) throw internal_error("ChunkList::release(...) received an invalid handle."); if (handle->object() < &*begin() || handle->object() >= &*end()) throw internal_error("ChunkList::release(...) received an unknown handle."); LT_LOG_THIS(DEBUG, "Release: index:%" PRIu32 " flags:%#x.", handle->index(), release_flags); if (handle->object()->references() <= 0 || (handle->is_writable() && handle->object()->writable() <= 0) || (handle->is_blocking() && handle->object()->blocking() <= 0)) throw internal_error("ChunkList::release(...) received a node with bad reference count."); if (handle->is_blocking()) { handle->object()->dec_blocking(); } if (handle->is_writable()) { if (handle->object()->writable() == 1) { if (is_queued(handle->object())) throw internal_error("ChunkList::release(...) tried to queue an already queued chunk."); // Only add those that have a modification time set? // // Only chunks that are not already in the queue will execute // this branch. m_queue.push_back(handle->object()); } else { handle->object()->dec_rw(); } } else { if (handle->object()->dec_references() == 0) { if (is_queued(handle->object())) throw internal_error("ChunkList::release(...) tried to unmap a queued chunk."); clear_chunk(handle->object(), release_flags); } } handle->clear(); } void ChunkList::clear_chunk(ChunkListNode* node, int flags) { if (!node->is_valid()) throw internal_error("ChunkList::clear_chunk(...) !node->is_valid()."); delete node->chunk(); node->set_chunk(NULL); m_manager->deallocate(m_chunk_size, (flags & get_dont_log) ? ChunkManager::allocate_dont_log : 0); } inline bool ChunkList::sync_chunk(ChunkListNode* node, std::pair options) { if (node->references() <= 0 || node->writable() <= 0) throw internal_error("ChunkList::sync_chunk(...) got a node with invalid reference count."); if (!node->chunk()->sync(options.first)) return false; node->set_sync_triggered(true); // When returning here we're not properly deallocating the piece. // // Only release the chunk after a blocking sync. if (!options.second) return true; node->dec_rw(); if (node->references() == 0) clear_chunk(node); return true; } uint32_t ChunkList::sync_chunks(int flags) { LT_LOG_THIS(DEBUG, "Sync chunks: flags:%#x.", flags); Queue::iterator split; if (flags & sync_all) split = m_queue.begin(); else split = std::stable_partition(m_queue.begin(), m_queue.end(), rak::not_equal(1, std::mem_fun(&ChunkListNode::writable))); // Allow a flag that does more culling, so that we only get large // continous sections. // // How does this interact with timers, should be make it so that // only areas with timers are (preferably) synced? std::sort(split, m_queue.end()); // If we got enough diskspace and have not requested safe syncing, // then sync all chunks with MS_ASYNC. if (!(flags & (sync_safe | sync_sloppy))) { if (m_manager->safe_sync() || m_slot_free_diskspace() <= m_manager->safe_free_diskspace()) flags |= sync_safe; else flags |= sync_force; } // TODO: This won't trigger for default sync_force. if ((flags & sync_use_timeout) && !(flags & sync_force)) split = partition_optimize(split, m_queue.end(), 50, 5, false); uint32_t failed = 0; for (Queue::iterator itr = split, last = m_queue.end(); itr != last; ++itr) { // We can easily skip pieces by swap_iter, so there should be no // problem being selective about the ranges we sync. // Use a function for checking the next few chunks and see how far // we want to sync. When we want to sync everything use end. Call // before the loop, or add a check. // if we don't want to sync, swap and break. std::pair options = sync_options(*itr, flags); if (!sync_chunk(*itr, options)) { std::iter_swap(itr, split++); failed++; continue; } if (!options.second) std::iter_swap(itr, split++); } if (log_files[LOG_MINCORE_STATS].is_open()) { log_mincore_stats_func_sync_success(std::distance(split, m_queue.end())); log_mincore_stats_func_sync_failed(failed); log_mincore_stats_func_sync_not_synced(std::distance(m_queue.begin(), split)); log_mincore_stats_func_sync_not_deallocated(std::count_if(split, m_queue.end(), std::mem_fun(&ChunkListNode::is_valid))); } m_queue.erase(split, m_queue.end()); // The caller must either make sure that it is safe to close the // download or set the sync_ignore_error flag. if (failed && !(flags & sync_ignore_error)) m_slot_storage_error("Could not sync chunk: " + std::string(rak::error_number::current().c_str())); return failed; } std::pair ChunkList::sync_options(ChunkListNode* node, int flags) { // Using if statements since some linkers have problem with static // const int members inside the ?: operators. The compiler should // be optimizing this anyway. if (flags & sync_force) { if (flags & sync_safe) return std::make_pair(MemoryChunk::sync_sync, true); else return std::make_pair(MemoryChunk::sync_async, true); } else if (flags & sync_safe) { if (node->sync_triggered()) return std::make_pair(MemoryChunk::sync_sync, true); else return std::make_pair(MemoryChunk::sync_async, false); } else { return std::make_pair(MemoryChunk::sync_async, true); } } // Using a rather simple algorithm for now. This should really be more // robust against holes withing otherwise compact ranges and take into // consideration chunk size. inline ChunkList::Queue::iterator ChunkList::seek_range(Queue::iterator first, Queue::iterator last) { uint32_t prevIndex = (*first)->index(); while (++first != last) { if ((*first)->index() - prevIndex > 5) break; prevIndex = (*first)->index(); } return first; } inline bool ChunkList::check_node(ChunkListNode* node) { return node->time_modified() != rak::timer() && node->time_modified() + rak::timer::from_seconds(m_manager->timeout_sync()) < cachedTime; } // Optimize the selection of chunks to sync. Continuous regions are // preferred, while if too fragmented or if too few chunks are // available it skips syncing of all chunks. ChunkList::Queue::iterator ChunkList::partition_optimize(Queue::iterator first, Queue::iterator last, int weight, int maxDistance, bool dontSkip) { for (Queue::iterator itr = first; itr != last;) { Queue::iterator range = seek_range(itr, last); bool required = std::find_if(itr, range, std::bind1st(std::mem_fun(&ChunkList::check_node), this)) != range; dontSkip = dontSkip || required; if (!required && std::distance(itr, range) < maxDistance) { // Don't sync this range. unsigned int l = std::min(range - itr, itr - first); std::swap_ranges(first, first + l, range - l); first += l; } else { // This probably increases too fast. weight -= std::distance(itr, range) * std::distance(itr, range); } itr = range; } // These values are all arbritrary... if (!dontSkip && weight > 0) return last; return first; } ChunkList::chunk_address_result ChunkList::find_address(void* ptr) { iterator first = begin(); iterator last = end(); for (; first != last; first++) { if (!first->is_valid()) continue; Chunk::iterator partition = first->chunk()->find_address(ptr); if (partition != first->chunk()->end()) return chunk_address_result(first, partition); first++; } return chunk_address_result(end(), Chunk::iterator()); } } libtorrent-0.13.2/src/data/chunk_list.h000644 000765 000024 00000013553 11720140327 020741 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_CHUNK_LIST_H #define LIBTORRENT_DATA_CHUNK_LIST_H #include #include #include #include "chunk.h" #include "chunk_handle.h" #include "chunk_list_node.h" namespace torrent { class ChunkManager; class Content; class download_data; class DownloadWrapper; class FileList; class ChunkList : private std::vector { public: typedef uint32_t size_type; typedef std::vector base_type; typedef std::vector Queue; typedef std::tr1::function slot_chunk_index; typedef std::tr1::function slot_value; typedef std::tr1::function slot_string; using base_type::value_type; using base_type::reference; using base_type::difference_type; using base_type::iterator; using base_type::reverse_iterator; using base_type::const_iterator; using base_type::begin; using base_type::end; using base_type::size; using base_type::empty; using base_type::operator[]; static const int sync_all = (1 << 0); static const int sync_force = (1 << 1); static const int sync_safe = (1 << 2); static const int sync_sloppy = (1 << 3); static const int sync_use_timeout = (1 << 4); static const int sync_ignore_error = (1 << 5); static const int get_writable = (1 << 0); static const int get_blocking = (1 << 1); static const int get_dont_log = (1 << 2); static const int get_nonblock = (1 << 3); static const int flag_active = (1 << 0); ChunkList() : m_data(NULL), m_manager(NULL), m_flags(0), m_chunk_size(0) {} ~ChunkList() { clear(); } int flags() const { return m_flags; } void set_flags(int flags) { m_flags |= flags; } void unset_flags(int flags) { m_flags &= ~flags; } void change_flags(int flags, bool state) { if (state) set_flags(flags); else unset_flags(flags); } uint32_t chunk_size() const { return m_chunk_size; } size_type queue_size() const { return m_queue.size(); } download_data* data() { return m_data; } void set_data(download_data* data) { m_data = data; } void set_manager(ChunkManager* manager) { m_manager = manager; } void set_chunk_size(uint32_t cs) { m_chunk_size = cs; } bool has_chunk(size_type index, int prot) const; void resize(size_type to_size); void clear(); ChunkHandle get(size_type index, int flags = 0); void release(ChunkHandle* handle, int flags = 0); // Replace use_timeout with something like performance related // keyword. Then use that flag to decide if we should skip // non-continious regions. // Returns the number of failed syncs. uint32_t sync_chunks(int flags); slot_string& slot_storage_error() { return m_slot_storage_error; } slot_chunk_index& slot_create_chunk() { return m_slot_create_chunk; } slot_value& slot_free_diskspace() { return m_slot_free_diskspace; } typedef std::pair chunk_address_result; chunk_address_result find_address(void* ptr); private: inline bool is_queued(ChunkListNode* node); inline void clear_chunk(ChunkListNode* node, int flags = 0); inline bool sync_chunk(ChunkListNode* node, std::pair options); Queue::iterator partition_optimize(Queue::iterator first, Queue::iterator last, int weight, int maxDistance, bool dontSkip); inline Queue::iterator seek_range(Queue::iterator first, Queue::iterator last); inline bool check_node(ChunkListNode* node); std::pair sync_options(ChunkListNode* node, int flags); download_data* m_data; ChunkManager* m_manager; Queue m_queue; int m_flags; uint32_t m_chunk_size; slot_string m_slot_storage_error; slot_chunk_index m_slot_create_chunk; slot_value m_slot_free_diskspace; }; } #endif libtorrent-0.13.2/src/data/chunk_list_node.h000644 000765 000024 00000010427 11716350717 021756 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_CHUNK_LIST_NODE_H #define LIBTORRENT_DATA_CHUNK_LIST_NODE_H #include #include namespace torrent { class Chunk; // ChunkNode can contain information like how long since it was last // used, last synced, last checked with mincore and how many // references there are to it. // // ChunkList will make sure all the nodes are cleaned up properly, so // no dtor is needed. class ChunkListNode { public: static const uint32_t invalid_index = ~uint32_t(); ChunkListNode() : m_index(invalid_index), m_chunk(NULL), m_references(0), m_writable(0), m_blocking(0), m_asyncTriggered(false) {} bool is_valid() const { return m_chunk != NULL; } uint32_t index() const { return m_index; } void set_index(uint32_t idx) { m_index = idx; } Chunk* chunk() const { return m_chunk; } void set_chunk(Chunk* c) { m_chunk = c; } const rak::timer& time_modified() const { return m_timeModified; } void set_time_modified(rak::timer t) { m_timeModified = t; } const rak::timer& time_preloaded() const { return m_timePreloaded; } void set_time_preloaded(rak::timer t) { m_timePreloaded = t; } bool sync_triggered() const { return m_asyncTriggered; } void set_sync_triggered(bool v) { m_asyncTriggered = v; } int references() const { return m_references; } int dec_references() { return --m_references; } int inc_references() { return ++m_references; } int writable() const { return m_writable; } int dec_writable() { return --m_writable; } int inc_writable() { return ++m_writable; } int blocking() const { return m_blocking; } int dec_blocking() { return --m_blocking; } int inc_blocking() { return ++m_blocking; } void inc_rw() { inc_writable(); inc_references(); } void dec_rw() { dec_writable(); dec_references(); } private: uint32_t m_index; Chunk* m_chunk; int m_references; int m_writable; int m_blocking; bool m_asyncTriggered; rak::timer m_timeModified; rak::timer m_timePreloaded; }; } #endif libtorrent-0.13.2/src/data/chunk_part.cc000644 000765 000024 00000006054 11705767056 021111 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include "torrent/exceptions.h" #include "chunk_part.h" namespace torrent { void ChunkPart::clear() { switch (m_mapped) { case MAPPED_MMAP: m_chunk.unmap(); break; default: case MAPPED_STATIC: throw internal_error("ChunkPart::clear() only MAPPED_MMAP supported."); break; } m_chunk.clear(); } bool ChunkPart::is_incore(uint32_t pos, uint32_t length) { length = std::min(length, remaining_from(pos)); pos = pos - m_position; if (pos > size()) throw internal_error("ChunkPart::is_incore(...) got invalid position."); if (length > size() || pos + length > size()) throw internal_error("ChunkPart::is_incore(...) got invalid length."); return m_chunk.is_incore(pos, length); } // TODO: Buggy. uint32_t ChunkPart::incore_length(uint32_t pos, uint32_t length) { // Do we want to use this? length = std::min(length, remaining_from(pos)); pos = pos - m_position; if (pos >= size()) throw internal_error("ChunkPart::incore_length(...) got invalid position"); uint32_t touched = m_chunk.pages_touched(pos, length); char buf[touched]; m_chunk.incore(buf, pos, length); uint32_t dist = std::distance(buf, std::find(buf, buf + touched, 0)); // This doesn't properly account for alignment when calculating the length. return std::min(dist ? (dist * m_chunk.page_size() - m_chunk.page_align()) : 0, length); } } libtorrent-0.13.2/src/data/chunk_part.h000644 000765 000024 00000007203 11705767056 020750 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_STORAGE_CHUNK_PART_H #define LIBTORRENT_DATA_STORAGE_CHUNK_PART_H #include "memory_chunk.h" namespace torrent { class File; class ChunkPart { public: typedef enum { MAPPED_MMAP, MAPPED_STATIC } mapped_type; ChunkPart(mapped_type mapped, const MemoryChunk& c, uint32_t pos) : m_mapped(mapped), m_chunk(c), m_position(pos), m_file(NULL), m_file_offset(0) {} bool is_valid() const { return m_chunk.is_valid(); } bool is_contained(uint32_t p) const { return p >= m_position && p < m_position + size(); } bool has_address(void* p) const { return (char*)p >= m_chunk.begin() && p < m_chunk.end(); } void clear(); mapped_type mapped() const { return m_mapped; } MemoryChunk& chunk() { return m_chunk; } const MemoryChunk& chunk() const { return m_chunk; } uint32_t size() const { return m_chunk.size(); } uint32_t position() const { return m_position; } uint32_t remaining_from(uint32_t pos) const { return size() - (pos - m_position); } File* file() const { return m_file; } uint64_t file_offset() const { return m_file_offset; } void set_file(File* f, uint64_t f_offset) { m_file = f; m_file_offset = f_offset; } bool is_incore(uint32_t pos, uint32_t length = ~uint32_t()); uint32_t incore_length(uint32_t pos, uint32_t length = ~uint32_t()); private: mapped_type m_mapped; MemoryChunk m_chunk; uint32_t m_position; // Currently used to figure out what file and where a SIGBUS // occurred. Can also be used in the future to indicate if a part is // temporary storage, etc. File* m_file; uint64_t m_file_offset; }; } #endif libtorrent-0.13.2/src/data/hash_check_queue.cc000644 000765 000024 00000007367 11716350717 022241 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "hash_check_queue.h" #include "data/hash_chunk.h" #include "torrent/hash_string.h" namespace torrent { HashCheckQueue::HashCheckQueue() { pthread_mutex_init(&m_lock, NULL); } HashCheckQueue::~HashCheckQueue() { pthread_mutex_destroy(&m_lock); } void HashCheckQueue::push_back(HashChunk* hash_chunk) { if (hash_chunk == NULL || !hash_chunk->chunk()->is_loaded() || !hash_chunk->chunk()->is_blocking()) throw internal_error("Invalid hash chunk passed to HashCheckQueue."); pthread_mutex_lock(&m_lock); // Set blocking...(? this needs to be possible to do after getting // the chunk) When doing this make sure we verify that the handle is // not previously blocked. base_type::push_back(hash_chunk); // TODO: Poke thread. pthread_mutex_unlock(&m_lock); } // erase... // // The erasing function should call slot, perhaps return a bool if we // deleted, or in the rare case it has already been hashed and will // arraive in the near future? // // We could handle this by polling the done chunks on false return // values. // Lock the chunk list and increment blocking only when starting the // checking. // No removal of entries, only clearing. bool HashCheckQueue::remove(HashChunk* hash_chunk) { pthread_mutex_lock(&m_lock); bool result; iterator itr = std::find(begin(), end(), hash_chunk); if (itr != end()) { base_type::erase(itr); result = true; } else { result = false; } pthread_mutex_unlock(&m_lock); return result; } void HashCheckQueue::perform() { pthread_mutex_lock(&m_lock); while (!empty()) { HashChunk* hash_chunk = base_type::front(); base_type::pop_front(); if (!hash_chunk->chunk()->is_loaded()) throw internal_error("HashCheckQueue::perform(): !entry.node->is_loaded()."); pthread_mutex_unlock(&m_lock); if (!hash_chunk->perform(~uint32_t(), true)) throw internal_error("HashCheckQueue::perform(): !hash_chunk->perform(~uint32_t(), true)."); HashString hash; hash_chunk->hash_c(hash.data()); m_slot_chunk_done(hash_chunk, hash); pthread_mutex_lock(&m_lock); } pthread_mutex_unlock(&m_lock); } } libtorrent-0.13.2/src/data/hash_check_queue.h000644 000765 000024 00000005305 11716350717 022071 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_HASH_CHECK_QUEUE_H #define LIBTORRENT_DATA_HASH_CHECK_QUEUE_H #include #include #include #include "rak/allocators.h" namespace torrent { class HashString; class HashChunk; class lt_cacheline_aligned HashCheckQueue : private std::deque > { public: typedef std::deque > base_type; typedef std::tr1::function slot_chunk_handle; using base_type::iterator; using base_type::empty; using base_type::size; using base_type::begin; using base_type::end; using base_type::front; using base_type::back; HashCheckQueue(); ~HashCheckQueue(); // Guarded functions for adding new... void push_back(HashChunk* node); void perform(); bool remove(HashChunk* node); slot_chunk_handle& slot_chunk_done() { return m_slot_chunk_done; } private: slot_chunk_handle m_slot_chunk_done; pthread_mutex_t m_lock; }; } #endif libtorrent-0.13.2/src/data/hash_chunk.cc000644 000765 000024 00000006077 11705767056 021073 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "hash_chunk.h" #include "chunk.h" #include "chunk_list_node.h" namespace torrent { bool HashChunk::perform(uint32_t length, bool force) { length = std::min(length, remaining()); if (m_position + length > m_chunk.chunk()->chunk_size()) throw internal_error("HashChunk::perform(...) received length out of range"); uint32_t l = force ? length : m_chunk.chunk()->incore_length(m_position); bool complete = l == length; while (l) { Chunk::iterator node = m_chunk.chunk()->at_position(m_position); l -= perform_part(node, l); } return complete; } void HashChunk::advise_willneed(uint32_t length) { if (!m_chunk.is_valid()) throw internal_error("HashChunk::willneed(...) called on an invalid chunk"); if (m_position + length > m_chunk.chunk()->chunk_size()) throw internal_error("HashChunk::willneed(...) received length out of range"); uint32_t pos = m_position; while (length) { Chunk::iterator itr = m_chunk.chunk()->at_position(pos); uint32_t l = std::min(length, remaining_part(itr, pos)); itr->chunk().advise(pos - itr->position(), l, MemoryChunk::advice_willneed); pos += l; length -= l; ++itr; } } uint32_t HashChunk::perform_part(Chunk::iterator itr, uint32_t length) { length = std::min(length, remaining_part(itr, m_position)); m_hash.update(itr->chunk().begin() + m_position - itr->position(), length); m_position += length; return length; } } libtorrent-0.13.2/src/data/hash_chunk.h000644 000765 000024 00000006433 11716350717 020723 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_HASH_CHUNK_H #define LIBTORRENT_HASH_CHUNK_H #include "torrent/exceptions.h" #include "utils/sha1.h" #include "chunk.h" #include "chunk_handle.h" namespace torrent { // This class interface assumes we're always going to check the whole // chunk. All we need is control of the (non-)blocking nature, and other // stuff related to performance and responsiveness. class ChunkListNode; class HashChunk { public: HashChunk() {} HashChunk(ChunkHandle h) { set_chunk(h); } void set_chunk(ChunkHandle h) { m_position = 0; m_chunk = h; m_hash.init(); } ChunkHandle* chunk() { return &m_chunk; } ChunkHandle& handle() { return m_chunk; } void hash_c(char* buffer) { m_hash.final_c(buffer); } // If force is true, then the return value is always true. bool perform(uint32_t length, bool force = true); void advise_willneed(uint32_t length); uint32_t remaining(); private: inline uint32_t remaining_part(Chunk::iterator itr, uint32_t pos); uint32_t perform_part(Chunk::iterator itr, uint32_t length); uint32_t m_position; ChunkHandle m_chunk; Sha1 m_hash; }; inline uint32_t HashChunk::remaining_part(Chunk::iterator itr, uint32_t pos) { return itr->size() - (pos - itr->position()); } inline uint32_t HashChunk::remaining() { if (!m_chunk.is_loaded()) throw internal_error("HashChunk::remaining(...) called on an invalid chunk"); return m_chunk.chunk()->chunk_size() - m_position; } } #endif libtorrent-0.13.2/src/data/hash_queue.cc000644 000765 000024 00000015527 11736247566 021112 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #define __STDC_FORMAT_MACROS #include #include #include #include "torrent/exceptions.h" #include "torrent/data/download_data.h" #include "torrent/utils/log.h" #include "torrent/utils/thread_base.h" #include "hash_queue.h" #include "hash_chunk.h" #include "chunk.h" #include "chunk_list_node.h" #include "globals.h" #include "thread_disk.h" #define LT_LOG_DATA(data, log_level, log_fmt, ...) \ lt_log_print_data(LOG_STORAGE_##log_level, data, "hash_queue", log_fmt, __VA_ARGS__); namespace tr1 { using namespace std::tr1; } namespace torrent { struct HashQueueEqual { HashQueueEqual(HashQueueNode::id_type id, uint32_t index) : m_id(id), m_index(index) {} bool operator () (const HashQueueNode& q) const { return m_id == q.id() && m_index == q.get_index(); } HashQueueNode::id_type m_id; uint32_t m_index; }; struct HashQueueWillneed { HashQueueWillneed(int bytes) : m_bytes(bytes) {} bool operator () (HashQueueNode& q) { return (m_bytes -= q.call_willneed()) <= 0; } int m_bytes; }; // If madvise is not available it will always mark the pages as being // in memory, thus we don't need to modify m_maxTries to have full // disk usage. But this may cause too much blocking as it will think // everything is in memory, thus we need to throttle. HashQueue::HashQueue(thread_disk* thread) : m_thread_disk(thread) { pthread_mutex_init(&m_done_chunks_lock, NULL); m_thread_disk->hash_queue()->slot_chunk_done() = tr1::bind(&HashQueue::chunk_done, this, tr1::placeholders::_1, tr1::placeholders::_2); } // If we're done immediately, move the chunk to the front of the list so // the next work cycle gets stuff done. void HashQueue::push_back(ChunkHandle handle, HashQueueNode::id_type id, slot_done_type d) { LT_LOG_DATA(id, DEBUG, "Adding index:%" PRIu32 " to queue.", handle.index()); if (!handle.is_loaded()) throw internal_error("HashQueue::add(...) received an invalid chunk"); HashChunk* hash_chunk = new HashChunk(handle); base_type::push_back(HashQueueNode(id, hash_chunk, d)); m_thread_disk->hash_queue()->push_back(hash_chunk); m_thread_disk->interrupt(); } bool HashQueue::has(HashQueueNode::id_type id) { return std::find_if(begin(), end(), rak::equal(id, std::mem_fun_ref(&HashQueueNode::id))) != end(); } bool HashQueue::has(HashQueueNode::id_type id, uint32_t index) { return std::find_if(begin(), end(), HashQueueEqual(id, index)) != end(); } void HashQueue::remove(HashQueueNode::id_type id) { iterator itr = begin(); while ((itr = std::find_if(itr, end(), rak::equal(id, std::mem_fun_ref(&HashQueueNode::id)))) != end()) { HashChunk *hash_chunk = itr->get_chunk(); LT_LOG_DATA(id, DEBUG, "Removing index:%" PRIu32 " from queue.", hash_chunk->handle().index()); thread_base::release_global_lock(); bool result = m_thread_disk->hash_queue()->remove(hash_chunk); thread_base::acquire_global_lock(); // The hash chunk was not found, so we need to wait until the hash // check finishes. if (!result) { pthread_mutex_lock(&m_done_chunks_lock); done_chunks_type::iterator done_itr; while ((done_itr = m_done_chunks.find(hash_chunk)) == m_done_chunks.end()) { pthread_mutex_unlock(&m_done_chunks_lock); usleep(100); pthread_mutex_lock(&m_done_chunks_lock); } m_done_chunks.erase(done_itr); pthread_mutex_unlock(&m_done_chunks_lock); } itr->slot_done()(*hash_chunk->chunk(), NULL); itr->clear(); itr = erase(itr); } } void HashQueue::clear() { if (!empty()) throw internal_error("HashQueue::clear() called but valid nodes were found."); // Replace with a dtor check to ensure it is empty? // std::for_each(begin(), end(), std::mem_fun_ref(&HashQueueNode::clear)); // base_type::clear(); } void HashQueue::work() { pthread_mutex_lock(&m_done_chunks_lock); while (!m_done_chunks.empty()) { HashChunk* hash_chunk = m_done_chunks.begin()->first; HashString hash_value = m_done_chunks.begin()->second; m_done_chunks.erase(m_done_chunks.begin()); // TODO: This is not optimal as we jump around... Check for front // of HashQueue in done_chunks instead. iterator itr = std::find_if(begin(), end(), tr1::bind(std::equal_to(), hash_chunk, tr1::bind(&HashQueueNode::get_chunk, tr1::placeholders::_1))); // TODO: Fix this... if (itr == end()) throw internal_error("Could not find done chunk's node."); LT_LOG_DATA(itr->id(), DEBUG, "Passing index:%" PRIu32 " to owner: %s.", hash_chunk->handle().index(), hash_string_to_hex_str(hash_value).c_str()); HashQueueNode::slot_done_type slotDone = itr->slot_done(); base_type::erase(itr); slotDone(hash_chunk->handle(), hash_value.c_str()); delete hash_chunk; } pthread_mutex_unlock(&m_done_chunks_lock); } void HashQueue::chunk_done(HashChunk* hash_chunk, const HashString& hash_value) { pthread_mutex_lock(&m_done_chunks_lock); m_done_chunks[hash_chunk] = hash_value; m_slot_has_work(m_done_chunks.empty()); pthread_mutex_unlock(&m_done_chunks_lock); } } libtorrent-0.13.2/src/data/hash_queue.h000644 000765 000024 00000006732 11717357372 020746 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_HASH_QUEUE_H #define LIBTORRENT_DATA_HASH_QUEUE_H #include #include #include #include #include "torrent/hash_string.h" #include "hash_queue_node.h" #include "chunk_handle.h" namespace torrent { class HashChunk; class thread_disk; // Calculating hash of incore memory is blindingly fast, it's always // the loading from swap/disk that takes time. So with the exception // of large resumed downloads, try to check the hash immediately. This // helps us in getting as much done as possible while the pages are in // memory. class HashQueue : private std::deque { public: typedef std::deque base_type; typedef std::map done_chunks_type; typedef HashQueueNode::slot_done_type slot_done_type; typedef std::tr1::function slot_bool; using base_type::iterator; using base_type::empty; using base_type::size; using base_type::begin; using base_type::end; using base_type::front; using base_type::back; HashQueue(thread_disk* thread); ~HashQueue() { clear(); pthread_mutex_destroy(&m_done_chunks_lock); } void push_back(ChunkHandle handle, HashQueueNode::id_type id, slot_done_type d); bool has(HashQueueNode::id_type id); bool has(HashQueueNode::id_type id, uint32_t index); void remove(HashQueueNode::id_type id); void clear(); void work(); slot_bool& slot_has_work() { return m_slot_has_work; } private: void chunk_done(HashChunk* hash_chunk, const HashString& hash_value); thread_disk* m_thread_disk; done_chunks_type m_done_chunks; pthread_mutex_t m_done_chunks_lock lt_cacheline_aligned; slot_bool m_slot_has_work; }; } #endif libtorrent-0.13.2/src/data/hash_queue_node.cc000644 000765 000024 00000004075 11705767056 022110 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "hash_chunk.h" #include "hash_queue_node.h" #include "chunk_list_node.h" namespace torrent { uint32_t HashQueueNode::get_index() const { return m_chunk->chunk()->index(); } void HashQueueNode::clear() { delete m_chunk; m_chunk = NULL; } uint32_t HashQueueNode::call_willneed() { if (!m_willneed) { m_willneed = true; m_chunk->advise_willneed(m_chunk->remaining()); } return m_chunk->remaining(); } } libtorrent-0.13.2/src/data/hash_queue_node.h000644 000765 000024 00000005733 11732116730 021737 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_HASH_QUEUE_NODE_H #define LIBTORRENT_DATA_HASH_QUEUE_NODE_H #include #include #include #include "chunk_handle.h" #include "hash_chunk.h" namespace torrent { class download_data; class HashQueueNode { public: typedef std::tr1::function slot_done_type; typedef download_data* id_type; HashQueueNode(id_type id, HashChunk* c, slot_done_type d) : m_id(id), m_chunk(c), m_willneed(false), m_slot_done(d) {} id_type id() const { return m_id; } ChunkHandle& handle() { return *m_chunk->chunk(); } uint32_t get_index() const; HashChunk* get_chunk() { return m_chunk; } bool get_willneed() const { return m_willneed; } bool perform_remaining(bool force) { return m_chunk->perform(m_chunk->remaining(), force); } void clear(); // Does not call multiple times on the same chunk. Returns the // number of bytes not checked in this chunk. uint32_t call_willneed(); slot_done_type& slot_done() { return m_slot_done; } private: id_type m_id; HashChunk* m_chunk; bool m_willneed; slot_done_type m_slot_done; }; } #endif libtorrent-0.13.2/src/data/hash_torrent.cc000644 000765 000024 00000017573 11721117103 021437 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #define __STDC_FORMAT_MACROS #include "data/chunk_list.h" #include "torrent/exceptions.h" #include "torrent/data/download_data.h" #include "torrent/utils/log.h" #include "hash_torrent.h" #include "hash_queue.h" #include "globals.h" #define LT_LOG_THIS(log_level, log_fmt, ...) \ lt_log_print_data(LOG_STORAGE_##log_level, m_chunk_list->data(), "hash_torrent", log_fmt, __VA_ARGS__); namespace torrent { HashTorrent::HashTorrent(ChunkList* c) : m_position(0), m_outstanding(-1), m_errno(0), m_chunk_list(c) { } bool HashTorrent::start(bool try_quick) { LT_LOG_THIS(INFO, "Start: position:%u size:%" PRIu64 " try_quick:%u.", m_position, m_chunk_list->size(), try_quick); if (m_position == m_chunk_list->size()) return true; if (m_position > 0 || m_chunk_list->empty()) throw internal_error("HashTorrent::start() call failed."); m_outstanding = 0; queue(try_quick); return m_position == m_chunk_list->size(); } void HashTorrent::clear() { LT_LOG_THIS(INFO, "Clear.", 0); m_outstanding = -1; m_position = 0; m_errno = 0; // Correct? rak::priority_queue_erase(&taskScheduler, &m_delayChecked); } bool HashTorrent::is_checked() { // When closed the chunk list is empty. Position can be equal to // chunk list for a short while as we have outstanding chunks, so // check the latter. return !m_chunk_list->empty() && m_position == m_chunk_list->size() && m_outstanding == -1; } // After all chunks are checked it won't show as is_checked until // after this function is called. This allows for the hash done signal // to be delayed. void HashTorrent::confirm_checked() { LT_LOG_THIS(INFO, "Confirm checked.", 0); if (m_outstanding != 0) throw internal_error("HashTorrent::confirm_checked() m_outstanding != 0."); m_outstanding = -1; } void HashTorrent::receive_chunkdone(uint32_t index) { LT_LOG_THIS(DEBUG, "Received chunk done: index:%" PRIu32 ".", index); if (m_outstanding <= 0) throw internal_error("HashTorrent::receive_chunkdone() m_outstanding <= 0."); // m_signalChunk will always point to // DownloadMain::receive_hash_done, so it will take care of cleanup. // // Make sure we call chunkdone before torrentDone has a chance to // trigger. m_outstanding--; queue(false); } // Mark unsuccessful checks so that if we have just stopped the // hash checker it will ensure those pieces get rechecked upon // restart. void HashTorrent::receive_chunk_cleared(uint32_t index) { LT_LOG_THIS(DEBUG, "Received chunk cleared: index:%" PRIu32 ".", index); if (m_outstanding <= 0) throw internal_error("HashTorrent::receive_chunk_cleared() m_outstanding < 0."); if (m_ranges.has(index)) throw internal_error("HashTorrent::receive_chunk_cleared() m_ranges.has(index)."); m_outstanding--; m_ranges.insert(index, index + 1); } void HashTorrent::queue(bool quick) { LT_LOG_THIS(DEBUG, "Queue: position:%u outstanding:%i try_quick:%u.", m_position, m_outstanding, quick); if (!is_checking()) throw internal_error("HashTorrent::queue() called but it's not running."); while (m_position < m_chunk_list->size()) { if (m_outstanding > 10 && m_outstanding * m_chunk_list->chunk_size() > (128 << 20)) return; // Not very efficient, but this is seldomly done. Ranges::iterator itr = m_ranges.find(m_position); if (itr == m_ranges.end()) { m_position = m_chunk_list->size(); break; } else if (m_position < itr->first) { m_position = itr->first; } // Need to do increment later if we're going to support resume // hashing a quick hashed torrent. ChunkHandle handle = m_chunk_list->get(m_position, ChunkList::get_dont_log); if (quick) { // We're not actually interested in doing any hashing, so just // skip what we know is not possible to hash. // // If the file does not exist then no valid error number is // returned. if (m_outstanding != 0) throw internal_error("HashTorrent::queue() quick hashing but m_outstanding != 0."); if (handle.is_valid()) { LT_LOG_THIS(DEBUG, "Return on handle.is_valid(): position:%u.", m_position); return m_chunk_list->release(&handle, ChunkList::get_dont_log); } if (handle.error_number().is_valid() && handle.error_number().value() != rak::error_number::e_noent) { LT_LOG_THIS(DEBUG, "Return on handle errno == E_NOENT: position:%u.", m_position); return; } m_position++; continue; } // If the error number is not valid, then we've just encountered a // file that hasn't be created/resized. Which means we ignore it // when doing initial hashing. if (handle.error_number().is_valid() && handle.error_number().value() != rak::error_number::e_noent) { if (handle.is_valid()) throw internal_error("HashTorrent::queue() error, but handle.is_valid()."); // We wait for all the outstanding chunks to be checked before // borking completely, else low-memory devices might not be able // to finish the hash check. if (m_outstanding != 0) return; // The rest of the outstanding chunks get ignored by // DownloadWrapper::receive_hash_done. Obsolete. clear(); m_errno = handle.error_number().value(); LT_LOG_THIS(INFO, "Completed (error): position:%u try_quick:%u errno:%i msg:'%s'.", m_position, quick, m_errno, handle.error_number().c_str()); rak::priority_queue_erase(&taskScheduler, &m_delayChecked); rak::priority_queue_insert(&taskScheduler, &m_delayChecked, cachedTime); return; } m_position++; if (!handle.is_valid() && !handle.error_number().is_valid()) throw internal_error("Hash torrent errno == 0."); // Missing file, skip the hash check. if (!handle.is_valid()) continue; m_slotCheck(handle); m_outstanding++; } if (m_outstanding == 0) { LT_LOG_THIS(INFO, "Completed (normal): position:%u try_quick:%u.", m_position, quick); // Erase the scheduled item just to make sure that if hashing is // started again during the delay it won't cause an exception. rak::priority_queue_erase(&taskScheduler, &m_delayChecked); rak::priority_queue_insert(&taskScheduler, &m_delayChecked, cachedTime); } } } libtorrent-0.13.2/src/data/hash_torrent.h000644 000765 000024 00000006765 11720140327 021305 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_HASH_TORRENT_H #define LIBTORRENT_DATA_HASH_TORRENT_H #include #include #include #include #include "data/chunk_handle.h" #include "torrent/utils/ranges.h" namespace torrent { class ChunkList; class DownloadWrapper; class HashTorrent { public: typedef ranges Ranges; typedef rak::mem_fun1 slot_check_type; typedef rak::mem_fun1 slot_error_type; HashTorrent(ChunkList* c); ~HashTorrent() { clear(); } bool start(bool try_quick); void clear(); bool is_checking() { return m_outstanding >= 0; } bool is_checked(); void confirm_checked(); Ranges& hashing_ranges() { return m_ranges; } uint32_t position() const { return m_position; } uint32_t outstanding() const { return m_outstanding; } int error_number() const { return m_errno; } void slot_check(slot_check_type s) { m_slotCheck = s; } // void slot_error(slot_error_type s) { m_slotError = s; } rak::priority_item& delay_checked() { return m_delayChecked; } void receive_chunkdone(uint32_t index); void receive_chunk_cleared(uint32_t index); private: void queue(bool quick); unsigned int m_position; int m_outstanding; Ranges m_ranges; int m_errno; ChunkList* m_chunk_list; slot_check_type m_slotCheck; slot_error_type m_slotError; rak::priority_item m_delayChecked; }; } #endif libtorrent-0.13.2/src/data/Makefile.am000644 000765 000024 00000001020 11716350717 020456 0ustar00rakshasastaff000000 000000 noinst_LTLIBRARIES = libsub_data.la libsub_data_la_SOURCES = \ chunk.cc \ chunk.h \ chunk_handle.h \ chunk_iterator.h \ chunk_list.cc \ chunk_list.h \ chunk_list_node.h \ chunk_part.cc \ chunk_part.h \ hash_check_queue.cc \ hash_check_queue.h \ hash_chunk.cc \ hash_chunk.h \ hash_queue.cc \ hash_queue.h \ hash_queue_node.cc \ hash_queue_node.h \ hash_torrent.cc \ hash_torrent.h \ memory_chunk.cc \ memory_chunk.h \ socket_file.cc \ socket_file.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) libtorrent-0.13.2/src/data/Makefile.in000644 000765 000024 00000041374 11744204216 020500 0ustar00rakshasastaff000000 000000 # Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/data DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ $(top_srcdir)/scripts/ax_pthread.m4 \ $(top_srcdir)/scripts/checks.m4 \ $(top_srcdir)/scripts/common.m4 \ $(top_srcdir)/scripts/libtool.m4 \ $(top_srcdir)/scripts/ltoptions.m4 \ $(top_srcdir)/scripts/ltsugar.m4 \ $(top_srcdir)/scripts/ltversion.m4 \ $(top_srcdir)/scripts/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsub_data_la_LIBADD = am_libsub_data_la_OBJECTS = chunk.lo chunk_list.lo chunk_part.lo \ hash_check_queue.lo hash_chunk.lo hash_queue.lo \ hash_queue_node.lo hash_torrent.lo memory_chunk.lo \ socket_file.lo libsub_data_la_OBJECTS = $(am_libsub_data_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libsub_data_la_SOURCES) DIST_SOURCES = $(libsub_data_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBTORRENT_CFLAGS = @LIBTORRENT_CFLAGS@ LIBTORRENT_CURRENT = @LIBTORRENT_CURRENT@ LIBTORRENT_INTERFACE_VERSION_INFO = @LIBTORRENT_INTERFACE_VERSION_INFO@ LIBTORRENT_INTERFACE_VERSION_NO = @LIBTORRENT_INTERFACE_VERSION_NO@ LIBTORRENT_LIBS = @LIBTORRENT_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ STUFF_CFLAGS = @STUFF_CFLAGS@ STUFF_LIBS = @STUFF_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libsub_data.la libsub_data_la_SOURCES = \ chunk.cc \ chunk.h \ chunk_handle.h \ chunk_iterator.h \ chunk_list.cc \ chunk_list.h \ chunk_list_node.h \ chunk_part.cc \ chunk_part.h \ hash_check_queue.cc \ hash_check_queue.h \ hash_chunk.cc \ hash_chunk.h \ hash_queue.cc \ hash_queue.h \ hash_queue_node.cc \ hash_queue_node.h \ hash_torrent.cc \ hash_torrent.h \ memory_chunk.cc \ memory_chunk.h \ socket_file.cc \ socket_file.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/data/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/data/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libsub_data.la: $(libsub_data_la_OBJECTS) $(libsub_data_la_DEPENDENCIES) $(EXTRA_libsub_data_la_DEPENDENCIES) $(CXXLINK) $(libsub_data_la_OBJECTS) $(libsub_data_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk_part.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash_check_queue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash_chunk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash_queue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash_queue_node.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash_torrent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory_chunk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_file.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libtorrent-0.13.2/src/data/memory_chunk.cc000644 000765 000024 00000011417 11735056603 021442 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include #include #include #include #include "torrent/exceptions.h" #include "memory_chunk.h" #ifdef __sun__ extern "C" int madvise(void *, size_t, int); //#include //Should be the include line instead, but Solaris //has an annoying bug wherein it doesn't declare //madvise for C++. #endif namespace torrent { uint32_t MemoryChunk::m_pagesize = getpagesize(); inline void MemoryChunk::align_pair(uint32_t* offset, uint32_t* length) const { *offset += page_align(); *length += *offset % m_pagesize; *offset -= *offset % m_pagesize; } MemoryChunk::MemoryChunk(char* ptr, char* begin, char* end, int prot, int flags) : m_ptr(ptr), m_begin(begin), m_end(end), m_prot(prot), m_flags(flags) { if (ptr == NULL) throw internal_error("MemoryChunk::MemoryChunk(...) received ptr == NULL"); if (page_align() >= m_pagesize) throw internal_error("MemoryChunk::MemoryChunk(...) received an page alignment >= page size"); if ((std::ptrdiff_t)ptr % m_pagesize) throw internal_error("MemoryChunk::MemoryChunk(...) is not aligned to a page"); } void MemoryChunk::unmap() { if (!is_valid()) throw internal_error("MemoryChunk::unmap() called on an invalid object"); if (munmap(m_ptr, m_end - m_ptr) != 0) throw internal_error("MemoryChunk::unmap() system call failed: " + std::string(rak::error_number::current().c_str())); } void MemoryChunk::incore(char* buf, uint32_t offset, uint32_t length) { if (!is_valid()) throw internal_error("Called MemoryChunk::incore(...) on an invalid object"); if (!is_valid_range(offset, length)) throw internal_error("MemoryChunk::incore(...) received out-of-range input"); align_pair(&offset, &length); #if USE_MINCORE #if USE_MINCORE_UNSIGNED if (mincore(m_ptr + offset, length, (unsigned char*)buf)) #else if (mincore(m_ptr + offset, length, (char*)buf)) #endif throw storage_error("System call mincore failed: " + std::string(rak::error_number::current().c_str())); #else // !USE_MINCORE // Pretend all pages are in memory. memset(buf, 1, pages_touched(offset, length)); #endif } bool MemoryChunk::advise(uint32_t offset, uint32_t length, int advice) { if (!is_valid()) throw internal_error("Called MemoryChunk::advise() on an invalid object"); if (!is_valid_range(offset, length)) throw internal_error("MemoryChunk::advise(...) received out-of-range input"); #if USE_MADVISE align_pair(&offset, &length); if (madvise(m_ptr + offset, length, advice) == 0) return true; else if (errno == EINVAL || (errno == ENOMEM && advice != advice_willneed) || errno == EBADF) throw internal_error("MemoryChunk::advise(...) " + std::string(strerror(errno))); else return false; #else return true; #endif } bool MemoryChunk::sync(uint32_t offset, uint32_t length, int flags) { if (!is_valid()) throw internal_error("Called MemoryChunk::sync() on an invalid object"); if (!is_valid_range(offset, length)) throw internal_error("MemoryChunk::sync(...) received out-of-range input"); align_pair(&offset, &length); return msync(m_ptr + offset, length, flags) == 0; } } libtorrent-0.13.2/src/data/memory_chunk.h000644 000765 000024 00000014413 11705767056 021313 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_DATA_MEMORY_CHUNK_H #define LIBTORRENT_DATA_MEMORY_CHUNK_H #include #include #include #include namespace torrent { class MemoryChunk { public: // Consider information about whetever the memory maps to a file or // not, since mincore etc can only be called on files. static const int prot_exec = PROT_EXEC; static const int prot_read = PROT_READ; static const int prot_write = PROT_WRITE; static const int prot_none = PROT_NONE; static const int map_shared = MAP_SHARED; #ifdef USE_MADVISE static const int advice_normal = MADV_NORMAL; static const int advice_random = MADV_RANDOM; static const int advice_sequential = MADV_SEQUENTIAL; static const int advice_willneed = MADV_WILLNEED; static const int advice_dontneed = MADV_DONTNEED; #else static const int advice_normal = 0; static const int advice_random = 1; static const int advice_sequential = 2; static const int advice_willneed = 3; static const int advice_dontneed = 4; #endif static const int sync_sync = MS_SYNC; static const int sync_async = MS_ASYNC; static const int sync_invalidate = MS_INVALIDATE; MemoryChunk() { clear(); } ~MemoryChunk() { clear(); } // Doesn't allow ptr == NULL, use the default ctor instead. MemoryChunk(char* ptr, char* begin, char* end, int prot, int flags); bool is_valid() const { return m_ptr; } bool is_readable() const { return m_prot & PROT_READ; } bool is_writable() const { return m_prot & PROT_WRITE; } bool is_exec() const { return m_prot & PROT_EXEC; } inline bool is_valid_range(uint32_t offset, uint32_t length) const; bool has_permissions(int prot) const { return !(prot & ~m_prot); } char* ptr() const { return m_ptr; } char* begin() const { return m_begin; } char* end() const { return m_end; } int get_prot() const { return m_prot; } uint32_t size() const { return m_end - m_begin; } uint32_t size_aligned() const; inline void clear(); void unmap(); // Use errno and strerror if you want to know why these failed. void incore(char* buf, uint32_t offset, uint32_t length); bool advise(uint32_t offset, uint32_t length, int advice); bool sync(uint32_t offset, uint32_t length, int flags); bool is_incore(uint32_t offset, uint32_t length); // Helper functions for aligning offsets and ranges to page boundaries. uint32_t page_align() const { return m_begin - m_ptr; } uint32_t page_align(uint32_t o) const { return (o + page_align()) % m_pagesize; } // This won't return correct values if length == 0. inline uint32_t pages_touched(uint32_t offset, uint32_t length) const; static uint32_t page_size() { return m_pagesize; } private: inline void align_pair(uint32_t* offset, uint32_t* length) const; static uint32_t m_pagesize; char* m_ptr; char* m_begin; char* m_end; int m_prot; int m_flags; }; inline bool MemoryChunk::is_valid_range(uint32_t offset, uint32_t length) const { return length != 0 && (uint64_t)offset + length <= size(); } inline void MemoryChunk::clear() { m_ptr = m_begin = m_end = NULL; m_flags = PROT_NONE; } inline uint32_t MemoryChunk::pages_touched(uint32_t offset, uint32_t length) const { if (length == 0) return 0; return (length + page_align(offset) + m_pagesize - 1) / m_pagesize; } // The size of the mapped memory. inline uint32_t MemoryChunk::size_aligned() const { return std::distance(m_ptr, m_end) + page_size() - ((std::distance(m_ptr, m_end) - 1) % page_size() + 1); } inline bool MemoryChunk::is_incore(uint32_t offset, uint32_t length) { uint32_t size = pages_touched(offset, length); char buf[size]; incore(buf, offset, length); return std::find(buf, buf + size, 0) == buf + size; } } #endif libtorrent-0.13.2/src/data/socket_file.cc000644 000765 000024 00000011644 11705767056 021243 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #include "config.h" #include "socket_file.h" #include "torrent/exceptions.h" #include #include #include #include #include #include #include #ifdef HAVE_FALLOCATE #include #endif namespace torrent { bool SocketFile::open(const std::string& path, int prot, int flags, mode_t mode) { close(); if (prot & MemoryChunk::prot_read && prot & MemoryChunk::prot_write) flags |= O_RDWR; else if (prot & MemoryChunk::prot_read) flags |= O_RDONLY; else if (prot & MemoryChunk::prot_write) flags |= O_WRONLY; else throw internal_error("torrent::SocketFile::open(...) Tried to open file with no protection flags"); #ifdef O_LARGEFILE fd_type fd = ::open(path.c_str(), flags | O_LARGEFILE, mode); #else fd_type fd = ::open(path.c_str(), flags, mode); #endif if (fd == invalid_fd) return false; m_fd = fd; return true; } void SocketFile::close() { if (!is_open()) return; ::close(m_fd); m_fd = invalid_fd; } uint64_t SocketFile::size() const { if (!is_open()) throw internal_error("SocketFile::size() called on a closed file"); rak::file_stat fs; return fs.update(m_fd) ? fs.size() : 0; } bool SocketFile::set_size(uint64_t size, int flags) const { if (!is_open()) throw internal_error("SocketFile::set_size() called on a closed file"); #ifdef HAVE_FALLOCATE if (flags & flag_fallocate && fallocate(m_fd, 0, 0, size) == 0) return true; #endif #ifdef USE_POSIX_FALLOCATE if (flags & flag_fallocate && flags & flag_fallocate_blocking && posix_fallocate(m_fd, 0, size) == 0) return true; #endif #ifdef SYS_DARWIN if (flags & flag_fallocate) { fstore_t fstore; fstore.fst_flags = F_ALLOCATECONTIG; fstore.fst_posmode = F_PEOFPOSMODE; fstore.fst_offset = 0; fstore.fst_length = size; fstore.fst_bytesalloc = 0; // Hmm... this shouldn't really be something we fail the set_size // on... // // Yet is somehow fails with ENOSPC... // if (fcntl(m_fd, F_PREALLOCATE, &fstore) == -1) // throw internal_error("hack: fcntl failed" + std::string(strerror(errno))); fcntl(m_fd, F_PREALLOCATE, &fstore); // Ignore result for now... } #endif if (ftruncate(m_fd, size) == 0) return true; // Use workaround to resize files on vfat. It causes the whole // client to block while it is resizing the files, this really // should be in a seperate thread. if (size != 0 && lseek(m_fd, size - 1, SEEK_SET) == (off_t)(size - 1) && write(m_fd, &size, 1) == 1) return true; return false; } MemoryChunk SocketFile::create_chunk(uint64_t offset, uint32_t length, int prot, int flags) const { if (!is_open()) throw internal_error("SocketFile::get_chunk() called on a closed file"); // For some reason mapping beyond the extent of the file does not // cause mmap to complain, so we need to check manually here. if (length == 0 || offset > size() || offset + length > size()) return MemoryChunk(); uint64_t align = offset % MemoryChunk::page_size(); char* ptr = (char*)mmap(NULL, length + align, prot, flags, m_fd, offset - align); if (ptr == MAP_FAILED) return MemoryChunk(); return MemoryChunk(ptr, ptr + align, ptr + align + length, prot, flags); } } libtorrent-0.13.2/src/data/socket_file.h000644 000765 000024 00000005752 11705767056 021110 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2011, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef LIBTORRENT_SOCKET_FILE_H #define LIBTORRENT_SOCKET_FILE_H #include #include #include #include #include "memory_chunk.h" namespace torrent { // Inherit from SocketBase? class SocketFile { public: typedef int fd_type; static const fd_type invalid_fd = -1; static const int o_create = O_CREAT; static const int o_truncate = O_TRUNC; static const int o_nonblock = O_NONBLOCK; static const int flag_fallocate = (1 << 0); static const int flag_fallocate_blocking = (1 << 1); SocketFile() : m_fd(invalid_fd) {} SocketFile(fd_type fd) : m_fd(fd) {} bool is_open() const { return m_fd != invalid_fd; } bool open(const std::string& path, int prot, int flags, mode_t mode = 0666); void close(); uint64_t size() const; bool set_size(uint64_t s, int flags = 0) const; MemoryChunk create_chunk(uint64_t offset, uint32_t length, int prot, int flags) const; fd_type fd() const { return m_fd; } private: // Use custom flags if stuff like file locking etc is implemented. SocketFile(const SocketFile&); void operator = (const SocketFile&); fd_type m_fd; }; } #endif libtorrent-0.13.2/scripts/attributes.m4000644 000765 000024 00000007650 11716350717 021060 0ustar00rakshasastaff000000 000000 # Functions to check for attributes support in compiler AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ AC_CACHE_CHECK([if compiler supports __attribute__((constructor))], [cc_cv_attribute_constructor], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void ctor() __attribute__((constructor)); void ctor() { }; ])], [cc_cv_attribute_constructor=yes], [cc_cv_attribute_constructor=no]) ]) if test "x$cc_cv_attribute_constructor" = "xyes"; then AC_DEFINE([SUPPORT_ATTRIBUTE_CONSTRUCTOR], 1, [Define this if the compiler supports the constructor attribute]) $1 else true $2 fi ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ AC_CACHE_CHECK([if compiler supports __attribute__((format(printf, n, n)))], [cc_cv_attribute_format], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { } ])], [cc_cv_attribute_format=yes], [cc_cv_attribute_format=no]) ]) if test "x$cc_cv_attribute_format" = "xyes"; then AC_DEFINE([SUPPORT_ATTRIBUTE_FORMAT], 1, [Define this if the compiler supports the format attribute]) $1 else true $2 fi ]) AC_DEFUN([CC_ATTRIBUTE_INTERNAL], [ AC_CACHE_CHECK([if compiler supports __attribute__((visibility("internal")))], [cc_cv_attribute_internal], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void __attribute__((visibility("internal"))) internal_function() { } ])], [cc_cv_attribute_internal=yes], [cc_cv_attribute_internal=no]) ]) if test "x$cc_cv_attribute_internal" = "xyes"; then AC_DEFINE([SUPPORT_ATTRIBUTE_INTERNAL], 1, [Define this if the compiler supports the internal visibility attribute]) $1 else true $2 fi ]) AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ AC_LANG_PUSH(C++) tmp_CXXFLAGS=$CXXFLAGS CXXFLAGS="$CXXFLAGS -fvisibility=hidden" AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))], [cc_cv_attribute_visibility], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void __attribute__((visibility("default"))) visibility_function() { } ])], [cc_cv_attribute_visibility=yes], [cc_cv_attribute_visibility=no]) ]) CXXFLAGS=$tmp_CXXFLAGS AC_LANG_POP(C++) if test "x$cc_cv_attribute_visibility" = "xyes"; then AC_DEFINE([SUPPORT_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attributes.]) CXXFLAGS="$CXXFLAGS -fvisibility=hidden" $1 else true $2 fi ]) AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ AC_CACHE_CHECK([if compiler supports __attribute__((nonnull()))], [cc_cv_attribute_nonnull], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void some_function(void *foo, void *bar) __attribute__((nonnull())); void some_function(void *foo, void *bar) { } ])], [cc_cv_attribute_nonnull=yes], [cc_cv_attribute_nonnull=no]) ]) if test "x$cc_cv_attribute_nonnull" = "xyes"; then AC_DEFINE([SUPPORT_ATTRIBUTE_NONNULL], 1, [Define this if the compiler supports the nonnull attribute]) $1 else true $2 fi ]) AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ AC_CACHE_CHECK([if compiler supports __attribute__((unused))], [cc_cv_attribute_unused], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void some_function(void *foo, __attribute__((unused)) void *bar); ])], [cc_cv_attribute_unused=yes], [cc_cv_attribute_unused=no]) ]) if test "x$cc_cv_attribute_unused" = "xyes"; then AC_DEFINE([SUPPORT_ATTRIBUTE_UNUSED], 1, [Define this if the compiler supports the unused attribute]) $1 else true $2 fi ]) AC_DEFUN([CC_FUNC_EXPECT], [ AC_CACHE_CHECK([if compiler has __builtin_expect function], [cc_cv_func_expect], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ int some_function() { int a = 3; return (int)__builtin_expect(a, 3); } ])], [cc_cv_func_expect=yes], [cc_cv_func_expect=no]) ]) if test "x$cc_cv_func_expect" = "xyes"; then AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function]) $1 else true $2 fi ]) libtorrent-0.13.2/scripts/ax_pthread.m4000644 000765 000024 00000030440 11727634354 021006 0ustar00rakshasastaff000000 000000 # =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS # # AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) # # DESCRIPTION # # This macro figures out how to build C programs using POSIX threads. It # sets the PTHREAD_LIBS output variable to the threads library and linker # flags, and the PTHREAD_CFLAGS output variable to any special C compiler # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # # Also sets PTHREAD_CC to any special C compiler that is needed for # multi-threaded programs (defaults to the value of CC otherwise). (This # is necessary on AIX to use the special cc_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also link it with them as well. e.g. you should link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threads programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name # (e.g. PTHREAD_CREATE_UNDETACHED on AIX). # # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the # PTHREAD_PRIO_INHERIT symbol is defined when compiling with # PTHREAD_CFLAGS. # # ACTION-IF-FOUND is a list of shell commands to run if a threads library # is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it # is not found. If ACTION-IF-FOUND is not specified, the default action # will define HAVE_PTHREAD. # # Please let the authors know if this macro fails on any platform, or if # you have any other suggestions or comments. This macro was based on work # by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help # from M. Frigo), as well as ac_pthread and hb_pthread macros posted by # Alejandro Forero Cuervo to the autoconf macro repository. We are also # grateful for the helpful feedback of numerous users. # # Updated for Autoconf 2.68 by Daniel Richard G. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 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, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 17 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_PUSH([C]) ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) AC_MSG_RESULT($ax_pthread_ok) if test x"$ax_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ;; *-darwin*) ax_pthread_flags="-pthread $ax_pthread_flags" ;; esac if test x"$ax_pthread_ok" = xno; then for flag in $ax_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) if test x"$ax_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; }], [pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */])], [ax_pthread_ok=yes], []) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($ax_pthread_ok) if test "x$ax_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [int attr = $attr; return attr /* ; */])], [attr_name=$attr; break], []) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *-osf* | *-hpux*) flag="-D_REENTRANT";; *solaris*) if test "$GCC" = "yes"; then flag="-D_REENTRANT" else flag="-mt -D_REENTRANT" fi ;; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], ax_cv_PTHREAD_PRIO_INHERIT, [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$ax_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else ax_pthread_ok=no $2 fi AC_LANG_POP ])dnl AX_PTHREAD libtorrent-0.13.2/scripts/checks.m4000644 000765 000024 00000032012 11741521767 020123 0ustar00rakshasastaff000000 000000 AC_DEFUN([TORRENT_CHECK_XFS], [ AC_MSG_CHECKING(for XFS support) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #include int main() { struct xfs_flock64 l; ioctl(0, XFS_IOC_RESVSP64, &l); return 0; } ])], [ AC_DEFINE(USE_XFS, 1, Use XFS filesystem stuff.) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_WITHOUT_XFS], [ AC_ARG_WITH(xfs, [ --without-xfs Do not check for XFS filesystem support], [ if test "$withval" = "yes"; then TORRENT_CHECK_XFS fi ], [ TORRENT_CHECK_XFS ]) ]) AC_DEFUN([TORRENT_WITH_XFS], [ AC_ARG_WITH(xfs, [ --with-xfs Check for XFS filesystem support], [ if test "$withval" = "yes"; then TORRENT_CHECK_XFS fi ]) ]) AC_DEFUN([TORRENT_CHECK_EPOLL], [ AC_MSG_CHECKING(for epoll support) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include int main() { int fd = epoll_create(100); return 0; } ])], [ AC_DEFINE(USE_EPOLL, 1, Use epoll.) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_WITHOUT_EPOLL], [ AC_ARG_WITH(epoll, [ --without-epoll Do not check for epoll support.], [ if test "$withval" = "yes"; then TORRENT_CHECK_EPOLL fi ], [ TORRENT_CHECK_EPOLL ]) ]) AC_DEFUN([TORRENT_CHECK_KQUEUE], [ AC_MSG_CHECKING(for kqueue support) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include /* Because OpenBSD's sys/event.h fails to compile otherwise. Yeah... */ #include int main() { int fd = kqueue(); return 0; } ])], [ AC_DEFINE(USE_KQUEUE, 1, Use kqueue.) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_CHECK_KQUEUE_SOCKET_ONLY], [ AC_MSG_CHECKING(whether kqueue supports pipes and ptys) AC_RUN_IFELSE([AC_LANG_SOURCE([ #include #include #include #include #include int main() { struct kevent ev[2], ev_out[2]; struct timespec ts = { 0, 0 }; int pfd[2], pty[2], kfd, n; char buffer[9001]; if (pipe(pfd) == -1) return 1; if (fcntl(pfd[1], F_SETFL, O_NONBLOCK) == -1) return 2; while ((n = write(pfd[1], buffer, sizeof(buffer))) == sizeof(buffer)); if ((pty[0]=posix_openpt(O_RDWR | O_NOCTTY)) == -1) return 3; if ((pty[1]=grantpt(pty[0])) == -1) return 4; EV_SET(ev+0, pfd[1], EVFILT_WRITE, EV_ADD | EV_ENABLE, 0, 0, NULL); EV_SET(ev+1, pty[1], EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL); if ((kfd = kqueue()) == -1) return 5; if ((n = kevent(kfd, ev, 2, NULL, 0, NULL)) == -1) return 6; if (ev_out[0].flags & EV_ERROR) return 7; if (ev_out[1].flags & EV_ERROR) return 8; read(pfd[0], buffer, sizeof(buffer)); if ((n = kevent(kfd, NULL, 0, ev_out, 2, &ts)) < 1) return 9; return 0; } ])], [ AC_MSG_RESULT(yes) ], [ AC_DEFINE(KQUEUE_SOCKET_ONLY, 1, kqueue only supports sockets.) AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_WITH_KQUEUE], [ AC_ARG_WITH(kqueue, [ --with-kqueue enable kqueue. [[default=no]]], [ if test "$withval" = "yes"; then TORRENT_CHECK_KQUEUE TORRENT_CHECK_KQUEUE_SOCKET_ONLY fi ]) ]) AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [ AC_ARG_WITH(kqueue, [ --without-kqueue Do not check for kqueue support.], [ if test "$withval" = "yes"; then TORRENT_CHECK_KQUEUE TORRENT_CHECK_KQUEUE_SOCKET_ONLY fi ], [ TORRENT_CHECK_KQUEUE TORRENT_CHECK_KQUEUE_SOCKET_ONLY ]) ]) AC_DEFUN([TORRENT_WITHOUT_VARIABLE_FDSET], [ AC_ARG_WITH(variable-fdset, [ --without-variable-fdset do not use non-portable variable sized fd_set's.], [ if test "$withval" = "yes"; then AC_DEFINE(USE_VARIABLE_FDSET, 1, defined when we allow the use of fd_set's of any size) fi ], [ AC_DEFINE(USE_VARIABLE_FDSET, 1, defined when we allow the use of fd_set's of any size) ]) ]) AC_DEFUN([TORRENT_CHECK_FALLOCATE], [ AC_MSG_CHECKING(for fallocate) AC_TRY_LINK([#include #include ],[ fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 0); return 0; ], [ AC_DEFINE(HAVE_FALLOCATE, 1, Linux's fallocate supported.) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_CHECK_POSIX_FALLOCATE], [ AC_MSG_CHECKING(for posix_fallocate) AC_TRY_LINK([#include ],[ posix_fallocate(0, 0, 0); ], [ AC_DEFINE(USE_POSIX_FALLOCATE, 1, posix_fallocate supported.) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_WITH_POSIX_FALLOCATE], [ AC_ARG_WITH(posix-fallocate, [ --with-posix-fallocate Check for and use posix_fallocate to allocate files.], [ if test "$withval" = "yes"; then TORRENT_CHECK_POSIX_FALLOCATE fi ]) ]) AC_DEFUN([TORRENT_CHECK_STATVFS], [ AC_CHECK_HEADERS(sys/vfs.h sys/statvfs.h sys/statfs.h) AC_MSG_CHECKING(for statvfs) AC_TRY_LINK( [ #if HAVE_SYS_VFS_H #include #endif #if HAVE_SYS_STATVFS_H #include #endif #if HAVE_SYS_STATFS_H #include #endif ],[ struct statvfs s; fsblkcnt_t c; statvfs("", &s); fstatvfs(0, &s); ], [ AC_DEFINE(FS_STAT_FD, [fstatvfs(fd, &m_stat) == 0], Function to determine filesystem stats from fd) AC_DEFINE(FS_STAT_FN, [statvfs(fn, &m_stat) == 0], Function to determine filesystem stats from filename) AC_DEFINE(FS_STAT_STRUCT, [struct statvfs], Type of second argument to statfs function) AC_DEFINE(FS_STAT_SIZE_TYPE, [unsigned long], Type of block size member in stat struct) AC_DEFINE(FS_STAT_COUNT_TYPE, [fsblkcnt_t], Type of block count member in stat struct) AC_DEFINE(FS_STAT_BLOCK_SIZE, [(m_stat.f_frsize)], Determine the block size) AC_MSG_RESULT(ok) have_stat_vfs=yes ], [ AC_MSG_RESULT(no) have_stat_vfs=no ]) ]) AC_DEFUN([TORRENT_CHECK_STATFS], [ AC_CHECK_HEADERS(sys/statfs.h sys/param.h sys/mount.h) AC_MSG_CHECKING(for statfs) AC_TRY_LINK( [ #if HAVE_SYS_STATFS_H #include #endif #if HAVE_SYS_PARAM_H #include #endif #if HAVE_SYS_MOUNT_H #include #endif ],[ struct statfs s; statfs("", &s); fstatfs(0, &s); ], [ AC_DEFINE(FS_STAT_FD, [fstatfs(fd, &m_stat) == 0], Function to determine filesystem stats from fd) AC_DEFINE(FS_STAT_FN, [statfs(fn, &m_stat) == 0], Function to determine filesystem stats from filename) AC_DEFINE(FS_STAT_STRUCT, [struct statfs], Type of second argument to statfs function) AC_DEFINE(FS_STAT_SIZE_TYPE, [long], Type of block size member in stat struct) AC_DEFINE(FS_STAT_COUNT_TYPE, [long], Type of block count member in stat struct) AC_DEFINE(FS_STAT_BLOCK_SIZE, [(m_stat.f_bsize)], Determine the block size) AC_MSG_RESULT(ok) have_stat_vfs=yes ], [ AC_MSG_RESULT(no) have_stat_vfs=no ]) ]) AC_DEFUN([TORRENT_DISABLED_STATFS], [ AC_DEFINE(FS_STAT_FD, [(errno = ENOSYS) == 0], Function to determine filesystem stats from fd) AC_DEFINE(FS_STAT_FN, [(errno = ENOSYS) == 0], Function to determine filesystem stats from filename) AC_DEFINE(FS_STAT_STRUCT, [struct {blocksize_type f_bsize; blockcount_type f_bavail;}], Type of second argument to statfs function) AC_DEFINE(FS_STAT_SIZE_TYPE, [int], Type of block size member in stat struct) AC_DEFINE(FS_STAT_COUNT_TYPE, [int], Type of block count member in stat struct) AC_DEFINE(FS_STAT_BLOCK_SIZE, [(4096)], Determine the block size) AC_MSG_RESULT(No filesystem stats available) ]) AC_DEFUN([TORRENT_WITHOUT_STATVFS], [ AC_ARG_WITH(statvfs, [ --without-statvfs Don't try to use statvfs to find free diskspace.], [ if test "$withval" = "yes"; then TORRENT_CHECK_STATVFS else have_stat_vfs=no fi ], [ TORRENT_CHECK_STATVFS ]) ]) AC_DEFUN([TORRENT_WITHOUT_STATFS], [ AC_ARG_WITH(statfs, [ --without-statfs Don't try to use statfs to find free diskspace.], [ if test "$have_stat_vfs" = "no"; then if test "$withval" = "yes"; then TORRENT_CHECK_STATFS else TORRENT_DISABLED_STATFS fi fi ], [ if test "$have_stat_vfs" = "no"; then TORRENT_CHECK_STATFS if test "$have_stat_vfs" = "no"; then TORRENT_DISABLED_STATFS fi fi ]) ]) AC_DEFUN([TORRENT_WITH_ADDRESS_SPACE], [ AC_ARG_WITH(address-space, AC_HELP_STRING([--with-address-space=MB], [Change the default address space size, default 1024 MB.]), [ if test ! -z $withval -a "$withval" != "yes" -a "$withval" != "no"; then AC_DEFINE_UNQUOTED(DEFAULT_ADDRESS_SPACE_SIZE, [$withval]) else AC_MSG_ERROR(--with-address-space requires a parameter.) fi ], [ AC_CHECK_SIZEOF(long) if test $ac_cv_sizeof_long = 8; then AC_DEFINE(DEFAULT_ADDRESS_SPACE_SIZE, 4096, Default address space size.) else AC_DEFINE(DEFAULT_ADDRESS_SPACE_SIZE, 1024, Default address space size.) fi ]) ]) AC_DEFUN([TORRENT_CHECK_TR1], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(for TR1 support) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include class Foo; typedef std::tr1::unordered_map Bar; ])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_TR1, 1, Define to 1 if your C++ library supports the extensions from Technical Report 1) ], [ AC_MSG_RESULT(no) ] ) AC_LANG_POP(C++) ]) AC_DEFUN([TORRENT_CHECK_CXX11], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(for C++11 support) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #include class Foo; typedef std::unordered_map Bar; union test { Bar b1; }; ])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_CXX11, 1, Define to 1 if your C++ compiler has support for C++11.) ], [ AC_MSG_RESULT(no) ] ) AC_LANG_POP(C++) ]) AC_DEFUN([TORRENT_WITH_FASTCGI], [ AC_ARG_WITH(fastcgi, [ --with-fastcgi=PATH Enable FastCGI RPC support. (DO NOT USE)], [ AC_MSG_CHECKING([for FastCGI (DO NOT USE)]) if test "$withval" = "no"; then AC_MSG_RESULT(no) elif test "$withval" = "yes"; then CXXFLAGS="$CXXFLAGS" LIBS="$LIBS -lfcgi" AC_TRY_LINK( [ #include ],[ FCGX_Init(); ], [ AC_MSG_RESULT(ok) ], [ AC_MSG_RESULT(not found) AC_MSG_ERROR(Could not compile FastCGI test.) ]) AC_DEFINE(HAVE_FASTCGI, 1, Support for FastCGI.) else CXXFLAGS="$CXXFLAGS -I$withval/include" LIBS="$LIBS -lfcgi -L$withval/lib" AC_TRY_LINK( [ #include ],[ FCGX_Init(); ], [ AC_MSG_RESULT(ok) ], [ AC_MSG_RESULT(not found) AC_MSG_ERROR(Could not compile FastCGI test.) ]) AC_DEFINE(HAVE_FASTCGI, 1, Support for FastCGI.) fi ]) ]) AC_DEFUN([TORRENT_WITH_XMLRPC_C], [ AC_MSG_CHECKING(for XMLRPC-C) AC_ARG_WITH(xmlrpc-c, [ --with-xmlrpc-c=PATH Enable XMLRPC-C support.], [ if test "$withval" = "no"; then AC_MSG_RESULT(no) else if test "$withval" = "yes"; then xmlrpc_cc_prg="xmlrpc-c-config" else xmlrpc_cc_prg="$withval" fi if eval $xmlrpc_cc_prg --version 2>/dev/null >/dev/null; then CXXFLAGS="$CXXFLAGS `$xmlrpc_cc_prg --cflags server-util`" LIBS="$LIBS `$xmlrpc_cc_prg server-util --libs`" AC_TRY_LINK( [ #include ],[ xmlrpc_registry_new(NULL); ], [ AC_MSG_RESULT(ok) ], [ AC_MSG_RESULT(failed) AC_MSG_ERROR(Could not compile XMLRPC-C test.) ]) AC_DEFINE(HAVE_XMLRPC_C, 1, Support for XMLRPC-C.) else AC_MSG_RESULT(failed) AC_MSG_ERROR(Could not compile XMLRPC-C test.) fi fi ],[ AC_MSG_RESULT(ignored) ]) ]) AC_DEFUN([TORRENT_WITH_INOTIFY], [ AC_LANG_PUSH(C++) AC_CHECK_HEADERS([sys/inotify.h mcheck.h]) AC_MSG_CHECKING([whether sys/inotify.h actually works]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include int main(int,const char**) { return (-1 == inotify_init()); }]) ],[ AC_DEFINE(HAVE_INOTIFY, 1, [sys/inotify.h exists and works correctly]) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(failed)] ) AC_LANG_POP(C++) ]) libtorrent-0.13.2/scripts/common.m4000644 000765 000024 00000017737 11735056603 020167 0ustar00rakshasastaff000000 000000 AC_DEFUN([TORRENT_CHECK_CXXFLAGS], [ AC_MSG_CHECKING([for user-defined CXXFLAGS]) if test -n "$CXXFLAGS"; then AC_MSG_RESULT([user-defined "$CXXFLAGS"]) else CXXFLAGS="-O2 -Wall" AC_MSG_RESULT([default "$CXXFLAGS"]) fi ]) AC_DEFUN([TORRENT_ENABLE_DEBUG], [ AC_ARG_ENABLE(debug, [ --enable-debug enable debug information [[default=yes]]], [ if test "$enableval" = "yes"; then CXXFLAGS="$CXXFLAGS -g -DDEBUG" else CXXFLAGS="$CXXFLAGS -DNDEBUG" fi ],[ CXXFLAGS="$CXXFLAGS -g -DDEBUG" ]) ]) AC_DEFUN([TORRENT_ENABLE_WERROR], [ AC_ARG_ENABLE(werror, [ --enable-werror enable the -Werror and -Wall flag [[default=no]]], [ if test "$enableval" = "yes"; then CXXFLAGS="$CXXFLAGS -Werror -Wall" fi ]) ]) AC_DEFUN([TORRENT_ENABLE_EXTRA_DEBUG], [ AC_ARG_ENABLE(extra-debug, [ --enable-extra-debug enable extra debugging checks. [[default=no]]], [ if test "$enableval" = "yes"; then AC_DEFINE(USE_EXTRA_DEBUG, 1, Enable extra debugging checks.) fi ]) ]) AC_DEFUN([TORRENT_WITH_SYSROOT], [ AC_ARG_WITH(sysroot, [ --with-sysroot=PATH compile and link with a specific sysroot.], [ AC_MSG_CHECKING(for sysroot) if test "$withval" = "no"; then AC_MSG_RESULT(no) elif test "$withval" = "yes"; then AC_MSG_RESULT(not a path) AC_MSG_ERROR(The sysroot option must point to a directory, like f.ex "/Developer/SDKs/MacOSX10.4u.sdk".) else AC_MSG_RESULT($withval) CXXFLAGS="$CXXFLAGS -isysroot $withval" LDFLAGS="$LDFLAGS -Wl,-syslibroot,$withval" fi ]) ]) AC_DEFUN([TORRENT_ENABLE_ARCH], [ AC_ARG_ENABLE(arch, [ --enable-arch=ARCH comma seprated list of architectures to compile for.], [ AC_MSG_CHECKING(for target architectures) if test "$enableval" = "yes"; then AC_MSG_ERROR(no arch supplied) elif test "$enableval" = "no"; then AC_MSG_RESULT(using default) else AC_MSG_RESULT($enableval) for i in `IFS=,; echo $enableval`; do CFLAGS="$CFLAGS -march=$i" CXXFLAGS="$CXXFLAGS -march=$i" LDFLAGS="$LDFLAGS -march=$i" done fi ]) ]) AC_DEFUN([TORRENT_OTFD], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(for proper overloaded template function disambiguation) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ template void f(T&) {} template void f(T*) {} int main() { int *i = 0; f(*i); f(i); } ])], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) AC_MSG_ERROR([your compiler does not properly handle overloaded template function disambiguation]) ]) AC_LANG_POP(C++) ]) AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(signedness of mincore parameter) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #include #include void f() { mincore((char*)0, 0, (unsigned char*)0); } ])], [ AC_DEFINE(USE_MINCORE, 1, Use mincore) AC_DEFINE(USE_MINCORE_UNSIGNED, 1, use unsigned char* in mincore) AC_MSG_RESULT(unsigned) ], [ AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #include #include void f() { mincore((char*)0, 0, (char*)0); } ])], [ AC_DEFINE(USE_MINCORE, 1, Use mincore) AC_DEFINE(USE_MINCORE_UNSIGNED, 0, use char* in mincore) AC_MSG_RESULT(signed) ], [ AC_MSG_ERROR([failed, do *not* attempt fix this with --disable-mincore unless you are running Win32.]) ]) ]) AC_LANG_POP(C++) ]) AC_DEFUN([TORRENT_MINCORE], [ AC_ARG_ENABLE(mincore, [ --disable-mincore disable mincore check [[default=enable]]], [ if test "$enableval" = "yes"; then TORRENT_MINCORE_SIGNEDNESS() else AC_MSG_CHECKING(for mincore) AC_MSG_RESULT(disabled) fi ],[ TORRENT_MINCORE_SIGNEDNESS() ]) ]) AC_DEFUN([TORRENT_CHECK_MADVISE], [ AC_MSG_CHECKING(for madvise) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #include void f() { static char test[1024]; madvise((void *)test, sizeof(test), MADV_NORMAL); } ])], [ AC_MSG_RESULT(yes) AC_DEFINE(USE_MADVISE, 1, Use madvise) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_CHECK_POPCOUNT], [ AC_MSG_CHECKING(for __builtin_popcount) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ int f() { return __builtin_popcount(0); } ])], [ AC_MSG_RESULT(yes) AC_DEFINE(USE_BUILTIN_POPCOUNT, 1, Use __builtin_popcount.) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_CHECK_CACHELINE], [ AC_MSG_CHECKING(for cacheline) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #include void* vptr __cacheline_aligned; void f() { posix_memalign(&vptr, SMP_CACHE_BYTES, 42); } ])], [ AC_MSG_RESULT(found builtin) dnl AC_DEFINE(LT_SMP_CACHE_BYTES, SMP_CACHE_BYTES, Largest L1 cache size we know of, should work on all archs.) dnl AC_DEFINE(lt_cacheline_aligned, __cacheline_aligned, LibTorrent defined cacheline aligned.) dnl Need to fix this so that it uses the stuff defined by the system. AC_DEFINE(LT_SMP_CACHE_BYTES, 128, Largest L1 cache size we know of should work on all archs.) AC_DEFINE(lt_cacheline_aligned, __attribute__((__aligned__(LT_SMP_CACHE_BYTES))), LibTorrent defined cacheline aligned.) ], [ AC_MSG_RESULT(using default 128 bytes) AC_DEFINE(LT_SMP_CACHE_BYTES, 128, Largest L1 cache size we know of should work on all archs.) AC_DEFINE(lt_cacheline_aligned, __attribute__((__aligned__(LT_SMP_CACHE_BYTES))), LibTorrent defined cacheline aligned.) ]) ]) AC_DEFUN([TORRENT_CHECK_EXECINFO], [ AC_MSG_CHECKING(for execinfo.h) AC_RUN_IFELSE([AC_LANG_SOURCE([ #include int main() { backtrace((void**)0, 0); backtrace_symbols((char**)0, 0); return 0;} ])], [ AC_MSG_RESULT(yes) AC_DEFINE(USE_EXECINFO, 1, Use execinfo.h) ], [ AC_MSG_RESULT(no) ]) ]) AC_DEFUN([TORRENT_CHECK_ALIGNED], [ AC_MSG_CHECKING(the byte alignment) AC_RUN_IFELSE([AC_LANG_SOURCE([ #include int main() { char buf[8] = { 0, 0, 0, 0, 1, 0, 0, 0 }; int i; for (i = 1; i < 4; ++i) if (*(uint32_t*)(buf + i) == 0) return -1; return 0; } ])], [ AC_MSG_RESULT(none needed) ], [ AC_DEFINE(USE_ALIGNED, 1, Require byte alignment) AC_MSG_RESULT(required) ]) ]) AC_DEFUN([TORRENT_ENABLE_ALIGNED], [ AC_ARG_ENABLE(aligned, [ --enable-aligned enable alignment safe code [[default=check]]], [ if test "$enableval" = "yes"; then AC_DEFINE(USE_ALIGNED, 1, Require byte alignment) fi ],[ TORRENT_CHECK_ALIGNED ]) ]) AC_DEFUN([TORRENT_DISABLE_IPV6], [ AC_ARG_ENABLE(ipv6, [ --enable-ipv6 disable ipv6 [[default=no]]], [ if test "$enableval" = "yes"; then AC_DEFINE(RAK_USE_INET6, 1, enable ipv6 stuff) fi ]) ]) AC_DEFUN([TORRENT_ENABLE_TR1], [ AC_ARG_ENABLE(std_tr1, [ --disable-std_tr1 disable check for support for TR1 [[default=enable]]], [ if test "$enableval" = "yes"; then TORRENT_CHECK_TR1() else AC_MSG_CHECKING(for TR1 support) AC_MSG_RESULT(disabled) fi ],[ TORRENT_CHECK_TR1() ]) ]) AC_DEFUN([TORRENT_ENABLE_CXX11], [ AC_ARG_ENABLE(std_c++11, [ --disable-std_c++11 disable check for support for C++11 [[default=enable]]], [ if test "$enableval" = "yes"; then TORRENT_CHECK_CXX11() else AC_MSG_CHECKING(for C++11 support) AC_MSG_RESULT(disabled) fi ],[ TORRENT_CHECK_CXX11() ] ) ]) libtorrent-0.13.2/scripts/libtool.m4000644 000765 000024 00001057216 11744204175 020337 0ustar00rakshasastaff000000 000000 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS libtorrent-0.13.2/scripts/ltoptions.m4000644 000765 000024 00000030073 11744204175 020715 0ustar00rakshasastaff000000 000000 # Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) libtorrent-0.13.2/scripts/ltsugar.m4000644 000765 000024 00000010424 11744204175 020341 0ustar00rakshasastaff000000 000000 # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) libtorrent-0.13.2/scripts/ltversion.m4000644 000765 000024 00000001262 11744204175 020705 0ustar00rakshasastaff000000 000000 # ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) libtorrent-0.13.2/scripts/lt~obsolete.m4000644 000765 000024 00000013756 11744204176 021246 0ustar00rakshasastaff000000 000000 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) libtorrent-0.13.2/rak/address_info.h000644 000765 000024 00000007504 11705767056 020333 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Wrapper for addrinfo with focus on zero-copy conversion to and from // the c-type and wrapper. // // Do use the wrapper on a pre-existing struct addrinfo, cast the // pointer rather than the base type. #ifndef RAK_ADDRESS_INFO_H #define RAK_ADDRESS_INFO_H #include #include namespace rak { class address_info { public: void clear() { std::memset(this, 0, sizeof(address_info)); } int flags() const { return m_addrinfo.ai_flags; } void set_flags(int f) { m_addrinfo.ai_flags = f; } int family() const { return m_addrinfo.ai_family; } void set_family(int f) { m_addrinfo.ai_family = f; } int socket_type() const { return m_addrinfo.ai_socktype; } void set_socket_type(int t) { m_addrinfo.ai_socktype = t; } int protocol() const { return m_addrinfo.ai_protocol; } void set_protocol(int p) { m_addrinfo.ai_protocol = p; } size_t length() const { return m_addrinfo.ai_addrlen; } socket_address* address() { return reinterpret_cast(m_addrinfo.ai_addr); } addrinfo* c_addrinfo() { return &m_addrinfo; } const addrinfo* c_addrinfo() const { return &m_addrinfo; } address_info* next() { return reinterpret_cast(m_addrinfo.ai_next); } static int get_address_info(const char* node, int domain, int type, address_info** ai); static void free_address_info(address_info* ai) { ::freeaddrinfo(ai->c_addrinfo()); } static const char* strerror(int err) { return gai_strerror(err); } private: addrinfo m_addrinfo; }; inline int address_info::get_address_info(const char* node, int pfamily, int stype, address_info** ai) { address_info hints; hints.clear(); hints.set_family(pfamily); hints.set_socket_type(stype); return ::getaddrinfo(node, NULL, hints.c_addrinfo(), reinterpret_cast(ai)); } } #endif libtorrent-0.13.2/rak/algorithm.h000644 000765 000024 00000011646 11705767056 017663 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_ALGORITHM_H #define RAK_ALGORITHM_H #include #include #include namespace rak { template _Function for_each_pre(_InputIter __first, _InputIter __last, _Function __f) { _InputIter __tmp; while (__first != __last) { __tmp = __first++; __f(*__tmp); } return __f; } // Return a range with a distance of no more than __distance and // between __first and __last, centered on __middle1. template std::pair<_InputIter, _InputIter> advance_bidirectional(_InputIter __first, _InputIter __middle1, _InputIter __last, _Distance __distance) { _InputIter __middle2 = __middle1; do { if (!__distance) break; if (__middle2 != __last) { ++__middle2; --__distance; } else if (__middle1 == __first) { break; } if (!__distance) break; if (__middle1 != __first) { --__middle1; --__distance; } else if (__middle2 == __last) { break; } } while (true); return std::make_pair(__middle1, __middle2); } template _InputIter advance_forward(_InputIter __first, _InputIter __last, _Distance __distance) { while (__first != __last && __distance != 0) { __first++; __distance--; } return __first; } template _InputIter advance_backward(_InputIter __first, _InputIter __last, _Distance __distance) { while (__first != __last && __distance != 0) { __first--; __distance--; } return __first; } template struct compare_base : public std::binary_function<_Value, _Value, bool> { bool operator () (const _Value& complete, const _Value& base) const { return !complete.compare(0, base.size(), base); } }; // Count the number of elements from the start of the containers to // the first inequal element. template typename std::iterator_traits<_InputIter1>::difference_type count_base(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2) { typename std::iterator_traits<_InputIter1>::difference_type __n = 0; for ( ;__first1 != __last1 && __first2 != __last2; ++__first1, ++__first2, ++__n) if (*__first1 != *__first2) return __n; return __n; } template _Return make_base(_InputIter __first, _InputIter __last, _Ftor __ftor) { if (__first == __last) return ""; _Return __base = __ftor(*__first++); for ( ;__first != __last; ++__first) { typename std::iterator_traits<_InputIter>::difference_type __pos = count_base(__base.begin(), __base.end(), __ftor(*__first).begin(), __ftor(*__first).end()); if (__pos < (typename std::iterator_traits<_InputIter>::difference_type)__base.size()) __base.resize(__pos); } return __base; } template inline int popcount_wrapper(T t) { #if USE_BUILTIN_POPCOUNT if (std::numeric_limits::digits <= std::numeric_limits::digits) return __builtin_popcount(t); else return __builtin_popcountll(t); #else #error __builtin_popcount not found. unsigned int count = 0; while (t) { count += t & 0x1; t >> 1; } return count; #endif } } #endif libtorrent-0.13.2/rak/allocators.h000644 000765 000024 00000007113 11705767056 020032 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Some allocators for cacheline aligned chunks of memory, etc. #ifndef RAK_ALLOCATORS_H #define RAK_ALLOCATORS_H #include #include #include #include namespace rak { template class cacheline_allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef const void* const_void_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; cacheline_allocator() throw() { } cacheline_allocator(const cacheline_allocator&) throw() { } template cacheline_allocator(const cacheline_allocator&) throw() { } ~cacheline_allocator() throw() { } template struct rebind { typedef cacheline_allocator other; }; // return address of values pointer address (reference value) const { return &value; } const_pointer address (const_reference value) const { return &value; } size_type max_size () const throw() { return std::numeric_limits::max() / sizeof(T); } pointer allocate(size_type num, const_void_pointer hint = 0) { return alloc_size(num*sizeof(T)); } static pointer alloc_size(size_type size) { pointer ptr = NULL; int __UNUSED result = posix_memalign((void**)&ptr, LT_SMP_CACHE_BYTES, size); return ptr; } void construct (pointer p, const T& value) { new((void*)p)T(value); } void destroy (pointer p) { p->~T(); } void deallocate (pointer p, size_type num) { free((void*)p); } }; template bool operator== (const cacheline_allocator&, const cacheline_allocator&) throw() { return true; } template bool operator!= (const cacheline_allocator&, const cacheline_allocator&) throw() { return false; } } // // Operator new with custom allocators: // template void* operator new(size_t s, rak::cacheline_allocator a) { return a.alloc_size(s); } #endif // namespace rak libtorrent-0.13.2/rak/error_number.h000644 000765 000024 00000006370 11744202446 020362 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_ERROR_NUMBER_H #define RAK_ERROR_NUMBER_H #include #include namespace rak { class error_number { public: static const int e_access = EACCES; static const int e_again = EAGAIN; static const int e_connreset = ECONNRESET; static const int e_connaborted = ECONNABORTED; static const int e_deadlk = EDEADLK; static const int e_noent = ENOENT; static const int e_nomem = ENOMEM; static const int e_notdir = ENOTDIR; static const int e_isdir = EISDIR; static const int e_intr = EINTR; error_number() : m_errno(0) {} error_number(int e) : m_errno(e) {} bool is_valid() const { return m_errno != 0; } int value() const { return m_errno; } const char* c_str() const { return std::strerror(m_errno); } bool is_blocked_momentary() const { return m_errno == e_again || m_errno == e_intr; } bool is_blocked_prolonged() const { return m_errno == e_deadlk; } bool is_closed() const { return m_errno == e_connreset || m_errno == e_connaborted; } bool is_bad_path() const { return m_errno == e_noent || m_errno == e_notdir || m_errno == e_access; } static error_number current() { return errno; } static void clear_global() { errno = 0; } static void set_global(error_number err) { errno = err.m_errno; } bool operator == (const error_number& e) const { return m_errno == e.m_errno; } private: int m_errno; }; } #endif libtorrent-0.13.2/rak/file_stat.h000644 000765 000024 00000006546 11705767056 017652 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_FILE_STAT_H #define RAK_FILE_STAT_H #include #include #include namespace rak { class file_stat { public: // Consider storing rak::error_number. bool update(int fd) { return fstat(fd, &m_stat) == 0; } bool update(const char* filename) { return stat(filename, &m_stat) == 0; } bool update(const std::string& filename) { return update(filename.c_str()); } bool update_link(const char* filename) { return lstat(filename, &m_stat) == 0; } bool update_link(const std::string& filename) { return update_link(filename.c_str()); } bool is_regular() const { return S_ISREG(m_stat.st_mode); } bool is_directory() const { return S_ISDIR(m_stat.st_mode); } bool is_character() const { return S_ISCHR(m_stat.st_mode); } bool is_block() const { return S_ISBLK(m_stat.st_mode); } bool is_fifo() const { return S_ISFIFO(m_stat.st_mode); } bool is_link() const { return S_ISLNK(m_stat.st_mode); } bool is_socket() const { return S_ISSOCK(m_stat.st_mode); } off_t size() const { return m_stat.st_size; } time_t access_time() const { return m_stat.st_atime; } time_t change_time() const { return m_stat.st_ctime; } time_t modified_time() const { return m_stat.st_mtime; } private: struct stat m_stat; }; } #endif libtorrent-0.13.2/rak/fs_stat.h000644 000765 000024 00000005442 11705767056 017335 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_FS_STAT_H #define RAK_FS_STAT_H #include #include #include #if HAVE_SYS_VFS_H #include #endif #if HAVE_SYS_STATVFS_H #include #endif #if HAVE_SYS_STATFS_H #include #endif #if HAVE_SYS_PARAM_H #include #endif #if HAVE_SYS_MOUNT_H #include #endif namespace rak { class fs_stat { public: typedef FS_STAT_SIZE_TYPE blocksize_type; typedef FS_STAT_COUNT_TYPE blockcount_type; typedef FS_STAT_STRUCT fs_stat_type; bool update(int fd) { return FS_STAT_FD; } bool update(const char* fn) { return FS_STAT_FN; } bool update(const std::string& filename) { return update(filename.c_str()); } blocksize_type blocksize() { return FS_STAT_BLOCK_SIZE; } blockcount_type blocks_avail() { return m_stat.f_bavail; } int64_t bytes_avail() { return (int64_t) blocksize() * m_stat.f_bavail; } private: fs_stat_type m_stat; }; } #endif libtorrent-0.13.2/rak/functional.h000644 000765 000024 00000040235 11744202530 020013 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_FUNCTIONAL_H #define RAK_FUNCTIONAL_H #include #include namespace rak { template struct reference_fix { typedef Type type; }; template struct reference_fix { typedef Type type; }; template struct value_t { value_t(Type v) : m_v(v) {} Type operator () () const { return m_v; } Type m_v; }; template inline value_t value(Type v) { return value_t(v); } template struct accumulate_t { accumulate_t(Type t, Ftor f) : result(t), m_f(f) {} template void operator () (const Arg& a) { result += m_f(a); } Type result; Ftor m_f; }; template inline accumulate_t accumulate(Type t, Ftor f) { return accumulate_t(t, f); } // Operators: template struct equal_t { typedef bool result_type; equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { return m_t == m_f(a); } Type m_t; Ftor m_f; }; template inline equal_t equal(Type t, Ftor f) { return equal_t(t, f); } template struct equal_ptr_t { typedef bool result_type; equal_ptr_t(Type* t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (const Arg& a) { return *m_t == *m_f(a); } Type* m_t; Ftor m_f; }; template inline equal_ptr_t equal_ptr(Type* t, Ftor f) { return equal_ptr_t(t, f); } template struct not_equal_t { typedef bool result_type; not_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { return m_t != m_f(a); } Type m_t; Ftor m_f; }; template inline not_equal_t not_equal(Type t, Ftor f) { return not_equal_t(t, f); } template struct less_t { typedef bool result_type; less_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { return m_t < m_f(a); } Type m_t; Ftor m_f; }; template inline less_t less(Type t, Ftor f) { return less_t(t, f); } template struct less2_t : public std::binary_function { less2_t(FtorA f_a, FtorB f_b) : m_f_a(f_a), m_f_b(f_b) {} bool operator () (typename FtorA::argument_type a, typename FtorB::argument_type b) { return m_f_a(a) < m_f_b(b); } FtorA m_f_a; FtorB m_f_b; }; template inline less2_t less2(FtorA f_a, FtorB f_b) { return less2_t(f_a,f_b); } template struct _greater { typedef bool result_type; _greater(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { return m_t > m_f(a); } Type m_t; Ftor m_f; }; template inline _greater greater(Type t, Ftor f) { return _greater(t, f); } template struct greater2_t : public std::binary_function { greater2_t(FtorA f_a, FtorB f_b) : m_f_a(f_a), m_f_b(f_b) {} bool operator () (typename FtorA::argument_type a, typename FtorB::argument_type b) { return m_f_a(a) > m_f_b(b); } FtorA m_f_a; FtorB m_f_b; }; template inline greater2_t greater2(FtorA f_a, FtorB f_b) { return greater2_t(f_a,f_b); } template struct less_equal_t { typedef bool result_type; less_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { return m_t <= m_f(a); } Type m_t; Ftor m_f; }; template inline less_equal_t less_equal(Type t, Ftor f) { return less_equal_t(t, f); } template struct greater_equal_t { typedef bool result_type; greater_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { return m_t >= m_f(a); } Type m_t; Ftor m_f; }; template inline greater_equal_t greater_equal(Type t, Ftor f) { return greater_equal_t(t, f); } template struct invert : public std::unary_function { Tp operator () (const Tp& x) const { return ~x; } }; template struct on_t : public std::unary_function { typedef typename Dest::result_type result_type; on_t(Src s, Dest d) : m_dest(d), m_src(s) {} result_type operator () (typename reference_fix::type arg) { return m_dest(m_src(arg)); } Dest m_dest; Src m_src; }; template inline on_t on(Src s, Dest d) { return on_t(s, d); } template struct on2_t : public std::binary_function { typedef typename Dest::result_type result_type; on2_t(Src s, Dest d) : m_dest(d), m_src(s) {} result_type operator () (typename reference_fix::type first, typename reference_fix::type second) { return m_dest(m_src(first), second); } Dest m_dest; Src m_src; }; template inline on2_t on2(Src s, Dest d) { return on2_t(s, d); } // Creates a functor for accessing a member. template struct mem_ptr_t : public std::unary_function { mem_ptr_t(Member Class::*m) : m_member(m) {} Member& operator () (Class* c) { return c->*m_member; } const Member& operator () (const Class* c) { return c->*m_member; } Member Class::*m_member; }; template inline mem_ptr_t mem_ptr(Member Class::*m) { return mem_ptr_t(m); } template struct mem_ref_t : public std::unary_function { mem_ref_t(Member Class::*m) : m_member(m) {} Member& operator () (Class& c) { return c.*m_member; } Member Class::*m_member; }; template struct const_mem_ref_t : public std::unary_function { const_mem_ref_t(const Member Class::*m) : m_member(m) {} const Member& operator () (const Class& c) { return c.*m_member; } const Member Class::*m_member; }; template inline mem_ref_t mem_ref(Member Class::*m) { return mem_ref_t(m); } template inline const_mem_ref_t const_mem_ref(const Member Class::*m) { return const_mem_ref_t(m); } template struct if_then_t { if_then_t(Cond c, Then t) : m_cond(c), m_then(t) {} template void operator () (Arg& a) { if (m_cond(a)) m_then(a); } Cond m_cond; Then m_then; }; template inline if_then_t if_then(Cond c, Then t) { return if_then_t(c, t); } template struct call_delete : public std::unary_function { void operator () (T* t) { delete t; } }; template inline void call_delete_func(T* t) { delete t; } template class bind1st_t : public std::unary_function { public: typedef typename reference_fix::type value_type; typedef typename reference_fix::type argument_type; bind1st_t(const Operation& op, const value_type v) : m_op(op), m_value(v) {} typename Operation::result_type operator () (const argument_type arg) { return m_op(m_value, arg); } protected: Operation m_op; value_type m_value; }; template inline bind1st_t bind1st(const Operation& op, const Type& val) { return bind1st_t(op, val); } template class bind2nd_t : public std::unary_function { public: typedef typename reference_fix::type argument_type; typedef typename reference_fix::type value_type; bind2nd_t(const Operation& op, const value_type v) : m_op(op), m_value(v) {} typename Operation::result_type operator () (argument_type arg) { return m_op(arg, m_value); } protected: Operation m_op; value_type m_value; }; template inline bind2nd_t bind2nd(const Operation& op, const Type& val) { return bind2nd_t(op, val); } // Lightweight callback function including pointer to object. Should // be replaced by TR1 stuff later. Requires an object to bind, instead // of using a seperate functor for that. template class ptr_fun0 { public: typedef Ret result_type; typedef Ret (*Function)(); ptr_fun0() {} ptr_fun0(Function f) : m_function(f) {} bool is_valid() const { return m_function; } Ret operator () () { return m_function(); } private: Function m_function; }; template class mem_fun0 { public: typedef Ret result_type; typedef Ret (Object::*Function)(); mem_fun0() : m_object(NULL) {} mem_fun0(Object* o, Function f) : m_object(o), m_function(f) {} bool is_valid() const { return m_object; } Ret operator () () { return (m_object->*m_function)(); } private: Object* m_object; Function m_function; }; template class const_mem_fun0 { public: typedef Ret result_type; typedef Ret (Object::*Function)() const; const_mem_fun0() : m_object(NULL) {} const_mem_fun0(const Object* o, Function f) : m_object(o), m_function(f) {} bool is_valid() const { return m_object; } Ret operator () () const { return (m_object->*m_function)(); } private: const Object* m_object; Function m_function; }; template class mem_fun1 { public: typedef Ret result_type; typedef Ret (Object::*Function)(Arg1); mem_fun1() : m_object(NULL) {} mem_fun1(Object* o, Function f) : m_object(o), m_function(f) {} bool is_valid() const { return m_object; } Ret operator () (Arg1 a1) { return (m_object->*m_function)(a1); } private: Object* m_object; Function m_function; }; template class const_mem_fun1 { public: typedef Ret result_type; typedef Ret (Object::*Function)(Arg1) const; const_mem_fun1() : m_object(NULL) {} const_mem_fun1(const Object* o, Function f) : m_object(o), m_function(f) {} bool is_valid() const { return m_object; } Ret operator () (Arg1 a1) const { return (m_object->*m_function)(a1); } private: const Object* m_object; Function m_function; }; template class mem_fun2 : public std::binary_function { public: typedef Ret result_type; typedef Ret (Object::*Function)(Arg1, Arg2); typedef Object object_type; mem_fun2() : m_object(NULL) {} mem_fun2(Object* o, Function f) : m_object(o), m_function(f) {} bool is_valid() const { return m_object; } object_type* object() { return m_object; } const object_type* object() const { return m_object; } Ret operator () (Arg1 a1, Arg2 a2) { return (m_object->*m_function)(a1, a2); } private: Object* m_object; Function m_function; }; template class mem_fun3 { public: typedef Ret result_type; typedef Ret (Object::*Function)(Arg1, Arg2, Arg3); mem_fun3() : m_object(NULL) {} mem_fun3(Object* o, Function f) : m_object(o), m_function(f) {} bool is_valid() const { return m_object; } Ret operator () (Arg1 a1, Arg2 a2, Arg3 a3) { return (m_object->*m_function)(a1, a2, a3); } private: Object* m_object; Function m_function; }; template inline ptr_fun0 ptr_fun(Ret (*f)()) { return ptr_fun0(f); } template inline mem_fun0 make_mem_fun(Object* o, Ret (Object::*f)()) { return mem_fun0(o, f); } template inline const_mem_fun0 make_mem_fun(const Object* o, Ret (Object::*f)() const) { return const_mem_fun0(o, f); } template inline mem_fun1 make_mem_fun(Object* o, Ret (Object::*f)(Arg1)) { return mem_fun1(o, f); } template inline const_mem_fun1 make_mem_fun(const Object* o, Ret (Object::*f)(Arg1) const) { return const_mem_fun1(o, f); } template inline mem_fun2 make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2)) { return mem_fun2(o, f); } template inline mem_fun3 make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) { return mem_fun3(o, f); } template inline void slot_list_call(const Container& slot_list) { if (slot_list.empty()) return; typename Container::const_iterator first = slot_list.begin(); typename Container::const_iterator next = slot_list.begin(); while (++next != slot_list.end()) { (*first)(); first = next; } (*first)(); } template inline void slot_list_call(const Container& slot_list, Arg1 arg1) { if (slot_list.empty()) return; typename Container::const_iterator first = slot_list.begin(); typename Container::const_iterator next = slot_list.begin(); while (++next != slot_list.end()) { (*first)(arg1); first = next; } (*first)(arg1); } } #endif libtorrent-0.13.2/rak/partial_queue.h000644 000765 000024 00000013673 11705767056 020537 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_PARTIAL_QUEUE_H #define RAK_PARTIAL_QUEUE_H #include #include #include namespace rak { // First step, don't allow overflowing to the next layer. Only disable // the above layers for now. // We also include 0 in a single layer as some chunk may be available // only through seeders. class partial_queue { public: typedef uint8_t key_type; typedef uint32_t mapped_type; typedef uint16_t size_type; typedef std::pair size_pair_type; static const size_type num_layers = 8; partial_queue() : m_data(NULL), m_maxLayerSize(0) {} ~partial_queue() { disable(); } bool is_full() const { return m_ceiling == 0; } bool is_layer_full(size_type l) const { return m_layers[l].second >= m_maxLayerSize; } bool is_enabled() const { return m_data != NULL; } // Add check to see if we can add more. Also make it possible to // check how full we are in the lower parts so the caller knows when // he can stop searching. // // Though propably not needed, as we must continue til the first // layer is full. size_type max_size() const { return m_maxLayerSize * num_layers; } size_type max_layer_size() const { return m_maxLayerSize; } // Must be less that or equal to (max size_type) / num_layers. void enable(size_type ls); void disable(); void clear(); // Safe to call while pop'ing and it will not reuse pop'ed indices // so it is guaranteed to reach max_size at some point. This will // ensure that the user needs to refill with new data at regular // intervals. bool insert(key_type key, mapped_type value); // Only call this when pop'ing as it moves the index. bool prepare_pop(); mapped_type pop(); private: partial_queue(const partial_queue&); void operator = (const partial_queue&); static size_type ceiling(size_type layer) { return (2 << layer) - 1; } void find_non_empty(); mapped_type* m_data; size_type m_maxLayerSize; size_type m_index; size_type m_ceiling; size_pair_type m_layers[num_layers]; }; inline void partial_queue::enable(size_type ls) { if (ls == 0) throw std::logic_error("partial_queue::enable(...) ls == 0."); delete [] m_data; m_data = new mapped_type[ls * num_layers]; m_maxLayerSize = ls; } inline void partial_queue::disable() { delete [] m_data; m_data = NULL; m_maxLayerSize = 0; } inline void partial_queue::clear() { if (m_data == NULL) return; m_index = 0; m_ceiling = ceiling(num_layers - 1); std::memset(m_layers, 0, num_layers * sizeof(size_pair_type)); } inline bool partial_queue::insert(key_type key, mapped_type value) { if (key >= m_ceiling) return false; size_type idx = 0; // Hmm... since we already check the 'm_ceiling' above, we only need // to find the target layer. Could this be calculated directly? while (key >= ceiling(idx)) ++idx; m_index = std::min(m_index, idx); // Currently don't allow overflow. if (is_layer_full(idx)) throw std::logic_error("partial_queue::insert(...) layer already full."); //return false; m_data[m_maxLayerSize * idx + m_layers[idx].second] = value; m_layers[idx].second++; if (is_layer_full(idx)) // Set the ceiling to 0 when layer 0 is full so no more values can // be inserted. m_ceiling = idx > 0 ? ceiling(idx - 1) : 0; return true; } // is_empty() will iterate to the first layer with un-popped elements // and return true, else return false when it reaches a overflowed or // the last layer. inline bool partial_queue::prepare_pop() { while (m_layers[m_index].first == m_layers[m_index].second) { if (is_layer_full(m_index) || m_index + 1 == num_layers) return false; m_index++; } return true; } inline partial_queue::mapped_type partial_queue::pop() { if (m_index >= num_layers || m_layers[m_index].first >= m_layers[m_index].second) throw std::logic_error("partial_queue::pop() bad state."); return m_data[m_index * m_maxLayerSize + m_layers[m_index].first++]; } } #endif libtorrent-0.13.2/rak/path.h000644 000765 000024 00000005432 11705767056 016625 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Various functions for manipulating file paths. Also consider making // a directory iterator. #ifndef RAK_PATH_H #define RAK_PATH_H #include #include namespace rak { inline std::string path_expand(const std::string& path) { if (path.empty() || path[0] != '~') return path; char* home = std::getenv("HOME"); if (home == NULL) return path; return home + path.substr(1); } // Don't inline this... // // Same strlcpy as found in *bsd. inline size_t strlcpy(char *dest, const char *src, size_t size) { size_t n = size; const char* first = src; if (n != 0) { while (--n != 0) if ((*dest++ = *src++) == '\0') break; } if (n == 0) { if (size != 0) *dest = '\0'; while (*src++) ; } return src - first - 1; } inline char* path_expand(const char* src, char* first, char* last) { if (*src == '~') { char* home = std::getenv("HOME"); if (home == NULL) return first; first += strlcpy(first, home, std::distance(first, last)); if (first > last) return last; src++; } return std::max(first + strlcpy(first, src, std::distance(first, last)), last); } } #endif libtorrent-0.13.2/rak/priority_queue.h000644 000765 000024 00000011253 11716350717 020746 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // priority_queue is a priority queue implemented using a binary // heap. It can contain multiple instances of a value. #ifndef RAK_PRIORITY_QUEUE_H #define RAK_PRIORITY_QUEUE_H #include #include #include namespace rak { template > class priority_queue : public std::vector { public: typedef std::vector base_type; typedef typename base_type::reference reference; typedef typename base_type::const_reference const_reference; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::value_type value_type; using base_type::begin; using base_type::end; using base_type::size; using base_type::empty; using base_type::clear; priority_queue(Compare l = Compare(), Equal e = Equal()) : m_compare(l), m_equal(e) {} const_reference top() const { return base_type::front(); } void pop() { std::pop_heap(begin(), end(), m_compare); base_type::pop_back(); } void push(const value_type& value) { base_type::push_back(value); std::push_heap(begin(), end(), m_compare); } template iterator find(const Key& key) { return std::find_if(begin(), end(), std::bind2nd(m_equal, key)); } template bool erase(const Key& key) { iterator itr = find(key); if (itr == end()) return false; erase(itr); return true; } // Removes 'itr' from the queue. This assumes 'itr' has been // modified such that it has a higher priority than any other // element in the queue. void erase(iterator itr) { // std::push_heap(begin(), ++itr, m_compare); // pop(); base_type::erase(itr); std::make_heap(begin(), end(), m_compare); } private: Compare m_compare; Equal m_equal; }; // Iterate while the top node has higher priority, as 'Compare' // returns false. template class queue_pop_iterator : public std::iterator { public: typedef Queue container_type; queue_pop_iterator() : m_queue(NULL) {} queue_pop_iterator(Queue* q, Compare c) : m_queue(q), m_compare(c) {} queue_pop_iterator& operator ++ () { m_queue->pop(); return *this; } queue_pop_iterator& operator ++ (int) { m_queue->pop(); return *this; } typename container_type::const_reference operator * () { return m_queue->top(); } bool operator != (const queue_pop_iterator& itr) { return !m_queue->empty() && !m_compare(m_queue->top()); } bool operator == (const queue_pop_iterator& itr) { return m_queue->empty() || m_compare(m_queue->top()); } private: Queue* m_queue; Compare m_compare; }; template inline queue_pop_iterator queue_popper(Queue& queue, Compare comp) { return queue_pop_iterator(&queue, comp); } } #endif libtorrent-0.13.2/rak/priority_queue_default.h000644 000765 000024 00000011137 11716350717 022453 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_PRIORITY_QUEUE_DEFAULT_H #define RAK_PRIORITY_QUEUE_DEFAULT_H #include #include #include #include #include namespace rak { class priority_item { public: typedef std::tr1::function slot_void; priority_item() {} ~priority_item() { if (is_queued()) throw std::logic_error("priority_item::~priority_item() called on a queued item."); m_time = timer(); m_slot = slot_void(); } bool is_valid() const { return (bool)m_slot; } bool is_queued() const { return m_time != timer(); } slot_void& slot() { return m_slot; } const timer& time() const { return m_time; } void clear_time() { m_time = timer(); } void set_time(const timer& t) { m_time = t; } bool compare(const timer& t) const { return m_time > t; } private: priority_item(const priority_item&); void operator = (const priority_item&); timer m_time; slot_void m_slot; }; struct priority_compare { bool operator () (const priority_item* const p1, const priority_item* const p2) const { return p1->time() > p2->time(); } }; typedef std::equal_to priority_equal; typedef priority_queue > priority_queue_default; inline void priority_queue_perform(priority_queue_default* queue, timer t) { while (!queue->empty() && queue->top()->time() <= t) { priority_item* v = queue->top(); queue->pop(); v->clear_time(); v->slot()(); } } inline void priority_queue_insert(priority_queue_default* queue, priority_item* item, timer t) { if (t == timer()) throw std::logic_error("priority_queue_insert(...) received a bad timer."); if (!item->is_valid()) throw std::logic_error("priority_queue_insert(...) called on an invalid item."); if (item->is_queued()) throw std::logic_error("priority_queue_insert(...) called on an already queued item."); if (queue->find(item) != queue->end()) throw std::logic_error("priority_queue_insert(...) item found in queue."); item->set_time(t); queue->push(item); } inline void priority_queue_erase(priority_queue_default* queue, priority_item* item) { if (!item->is_queued()) return; // Check is_valid() after is_queued() so that it is safe to call // erase on untouched instances. if (!item->is_valid()) throw std::logic_error("priority_queue_erase(...) called on an invalid item."); // Clear time before erasing to force it to the top. item->clear_time(); if (!queue->erase(item)) throw std::logic_error("priority_queue_erase(...) could not find item in queue."); if (queue->find(item) != queue->end()) throw std::logic_error("priority_queue_erase(...) item still in queue."); } } #endif libtorrent-0.13.2/rak/regex.h000644 000765 000024 00000006617 11705767056 017011 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // This is a hacked up whole string pattern matching. Replace with // TR1's regex when that becomes widely available. It is intended for // small strings. #ifndef RAK_REGEX_H #define RAK_REGEX_H #include #include #include #include #include namespace rak { class regex : public std::unary_function { public: regex() {} regex(const std::string& p) : m_pattern(p) {} const std::string& pattern() const { return m_pattern; } bool operator () (const std::string& p) const; private: std::string m_pattern; }; // This isn't optimized, or very clean. A simple hack that should work. inline bool regex::operator () (const std::string& text) const { if (m_pattern.empty() || text.empty() || (m_pattern[0] != '*' && m_pattern[0] != text[0])) return false; // Replace with unordered_vector? std::list paths; paths.push_front(0); for (std::string::const_iterator itrText = ++text.begin(), lastText = text.end(); itrText != lastText; ++itrText) { for (std::list::iterator itrPaths = paths.begin(), lastPaths = paths.end(); itrPaths != lastPaths; ) { unsigned int next = *itrPaths + 1; if (m_pattern[*itrPaths] != '*') itrPaths = paths.erase(itrPaths); else itrPaths++; // When we reach the end of 'm_pattern', we don't have a whole // match of 'text'. if (next == m_pattern.size()) continue; // Push to the back so that '*' will match zero length strings. if (m_pattern[next] == '*') paths.push_back(next); if (m_pattern[next] == *itrText) paths.push_front(next); } if (paths.empty()) return false; } return std::find(paths.begin(), paths.end(), m_pattern.size() - 1) != paths.end(); } } #endif libtorrent-0.13.2/rak/socket_address.h000644 000765 000024 00000032740 11705767056 020670 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY // Wrappers for the various sockaddr types with focus on zero-copy // casting between the original type and the wrapper class. // // The default ctor does not initialize any data. // // _n suffixes indicate that the argument or return value is in // network byte order, _h that they are in hardware byte order. // Add define for inet6 scope id? #ifndef RAK_SOCKET_ADDRESS_H #define RAK_SOCKET_ADDRESS_H #include #include #include #include #include #include #include namespace rak { class socket_address_inet; class socket_address_inet6; class socket_address { public: static const sa_family_t af_inet = AF_INET; static const int pf_inet = PF_INET; static const sa_family_t af_inet6 = AF_INET6; static const int pf_inet6 = PF_INET6; static const sa_family_t af_unspec = AF_UNSPEC; static const int pf_unspec = PF_UNSPEC; #ifdef AF_LOCAL static const sa_family_t af_local = AF_LOCAL; static const int pf_local = PF_LOCAL; #else static const sa_family_t af_local = AF_UNIX; static const int pf_local = PF_UNIX; #endif bool is_valid() const; bool is_bindable() const; bool is_address_any() const; // Should we need to set AF_UNSPEC? void clear() { std::memset(this, 0, sizeof(socket_address)); set_family(); } sa_family_t family() const { return m_sockaddr.sa_family; } void set_family() { m_sockaddr.sa_family = af_unspec; } uint16_t port() const; void set_port(uint16_t p); std::string address_str() const; bool address_c_str(char* buf, socklen_t size) const; // Attemts to set it as an inet, then an inet6 address. It will // never set anything but net addresses, no local/unix. bool set_address_str(const std::string& a) { return set_address_c_str(a.c_str()); } bool set_address_c_str(const char* a); uint32_t length() const; socket_address_inet* sa_inet() { return reinterpret_cast(this); } const socket_address_inet* sa_inet() const { return reinterpret_cast(this); } sockaddr* c_sockaddr() { return &m_sockaddr; } sockaddr_in* c_sockaddr_inet() { return &m_sockaddrInet; } const sockaddr* c_sockaddr() const { return &m_sockaddr; } const sockaddr_in* c_sockaddr_inet() const { return &m_sockaddrInet; } #ifdef RAK_USE_INET6 socket_address_inet6* sa_inet6() { return reinterpret_cast(this); } const socket_address_inet6* sa_inet6() const { return reinterpret_cast(this); } sockaddr_in6* c_sockaddr_inet6() { return &m_sockaddrInet6; } const sockaddr_in6* c_sockaddr_inet6() const { return &m_sockaddrInet6; } #endif // Copy a socket address which has the length 'length. Zero out any // extranous bytes and ensure it does not go beyond the size of this // struct. void copy(const socket_address& src, size_t length); static socket_address* cast_from(sockaddr* sa) { return reinterpret_cast(sa); } static const socket_address* cast_from(const sockaddr* sa) { return reinterpret_cast(sa); } // The different families will be sorted according to the // sa_family_t's numeric value. bool operator == (const socket_address& rhs) const; bool operator < (const socket_address& rhs) const; bool operator == (const sockaddr& rhs) const { return *this == *cast_from(&rhs); } bool operator == (const sockaddr* rhs) const { return *this == *cast_from(rhs); } bool operator < (const sockaddr& rhs) const { return *this == *cast_from(&rhs); } bool operator < (const sockaddr* rhs) const { return *this == *cast_from(rhs); } private: union { sockaddr m_sockaddr; sockaddr_in m_sockaddrInet; #ifdef RAK_USE_INET6 sockaddr_in6 m_sockaddrInet6; #endif }; }; // Remeber to set the AF_INET. class socket_address_inet { public: bool is_any() const { return is_port_any() && is_address_any(); } bool is_valid() const { return !is_port_any() && !is_address_any(); } bool is_port_any() const { return port() == 0; } bool is_address_any() const { return m_sockaddr.sin_addr.s_addr == htonl(INADDR_ANY); } void clear() { std::memset(this, 0, sizeof(socket_address_inet)); set_family(); } uint16_t port() const { return ntohs(m_sockaddr.sin_port); } uint16_t port_n() const { return m_sockaddr.sin_port; } void set_port(uint16_t p) { m_sockaddr.sin_port = htons(p); } void set_port_n(uint16_t p) { m_sockaddr.sin_port = p; } // Should address() return the uint32_t? in_addr address() const { return m_sockaddr.sin_addr; } uint32_t address_h() const { return ntohl(m_sockaddr.sin_addr.s_addr); } uint32_t address_n() const { return m_sockaddr.sin_addr.s_addr; } std::string address_str() const; bool address_c_str(char* buf, socklen_t size) const; void set_address(in_addr a) { m_sockaddr.sin_addr = a; } void set_address_h(uint32_t a) { m_sockaddr.sin_addr.s_addr = htonl(a); } void set_address_n(uint32_t a) { m_sockaddr.sin_addr.s_addr = a; } bool set_address_str(const std::string& a) { return set_address_c_str(a.c_str()); } bool set_address_c_str(const char* a); void set_address_any() { set_port(0); set_address_h(INADDR_ANY); } sa_family_t family() const { return m_sockaddr.sin_family; } void set_family() { m_sockaddr.sin_family = AF_INET; } sockaddr* c_sockaddr() { return reinterpret_cast(&m_sockaddr); } sockaddr_in* c_sockaddr_inet() { return &m_sockaddr; } const sockaddr* c_sockaddr() const { return reinterpret_cast(&m_sockaddr); } const sockaddr_in* c_sockaddr_inet() const { return &m_sockaddr; } bool operator == (const socket_address_inet& rhs) const; bool operator < (const socket_address_inet& rhs) const; private: struct sockaddr_in m_sockaddr; }; // Unique key for the address, excluding port numbers etc. class socket_address_key { public: // socket_address_host_key() {} socket_address_key(const socket_address& sa) { *this = sa; } socket_address_key& operator = (const socket_address& sa) { if (sa.family() == 0) { std::memset(this, 0, sizeof(socket_address_key)); } else if (sa.family() == socket_address::af_inet) { // Using hardware order as we use operator < to compare when // using inet only. m_addr.s_addr = sa.sa_inet()->address_h(); } else { // When we implement INET6 handling, embed the ipv4 address in // the ipv6 address. throw std::logic_error("socket_address_key(...) received an unsupported protocol family."); } return *this; } // socket_address_key& operator = (const socket_address_key& sa) { // } bool operator < (const socket_address_key& sa) const { // Compare the memory area instead. return m_addr.s_addr < sa.m_addr.s_addr; } private: union { in_addr m_addr; // #ifdef RAK_USE_INET6 // in_addr6 m_addr6; // #endif }; }; inline bool socket_address::is_valid() const { switch (family()) { case af_inet: return sa_inet()->is_valid(); // case af_inet6: // return sa_inet6().is_valid(); default: return false; } } inline bool socket_address::is_bindable() const { switch (family()) { case af_inet: return !sa_inet()->is_address_any(); default: return false; } } inline bool socket_address::is_address_any() const { switch (family()) { case af_inet: return sa_inet()->is_address_any(); default: return true; } } inline uint16_t socket_address::port() const { switch (family()) { case af_inet: return sa_inet()->port(); default: return 0; } } inline void socket_address::set_port(uint16_t p) { switch (family()) { case af_inet: return sa_inet()->set_port(p); default: break; } } inline std::string socket_address::address_str() const { switch (family()) { case af_inet: return sa_inet()->address_str(); default: return std::string(); } } inline bool socket_address::address_c_str(char* buf, socklen_t size) const { switch (family()) { case af_inet: return sa_inet()->address_c_str(buf, size); default: return false; } } inline bool socket_address::set_address_c_str(const char* a) { if (sa_inet()->set_address_c_str(a)) { sa_inet()->set_family(); return true; } else { return false; } } // Is the zero length really needed, should we require some length? inline uint32_t socket_address::length() const { switch(family()) { case af_inet: return sizeof(sockaddr_in); default: return 0; } } inline void socket_address::copy(const socket_address& src, size_t length) { length = std::min(length, sizeof(socket_address)); // Does this get properly optimized? std::memset(this, 0, sizeof(socket_address)); std::memcpy(this, &src, length); } // Should we be able to compare af_unspec? inline bool socket_address::operator == (const socket_address& rhs) const { if (family() != rhs.family()) return false; switch (family()) { case af_inet: return *sa_inet() == *rhs.sa_inet(); // case af_inet6: // return *sa_inet6() == *rhs.sa_inet6(); default: throw std::logic_error("socket_address::operator == (rhs) invalid type comparison."); } } inline bool socket_address::operator < (const socket_address& rhs) const { if (family() != rhs.family()) return family() < rhs.family(); switch (family()) { case af_inet: return *sa_inet() < *rhs.sa_inet(); // case af_inet6: // return *sa_inet6() < *rhs.sa_inet6(); default: throw std::logic_error("socket_address::operator < (rhs) invalid type comparison."); } } inline std::string socket_address_inet::address_str() const { char buf[INET_ADDRSTRLEN]; if (!address_c_str(buf, INET_ADDRSTRLEN)) return std::string(); return std::string(buf); } inline bool socket_address_inet::address_c_str(char* buf, socklen_t size) const { return inet_ntop(family(), &m_sockaddr.sin_addr, buf, size); } inline bool socket_address_inet::set_address_c_str(const char* a) { return inet_pton(AF_INET, a, &m_sockaddr.sin_addr); } inline bool socket_address_inet::operator == (const socket_address_inet& rhs) const { return m_sockaddr.sin_addr.s_addr == rhs.m_sockaddr.sin_addr.s_addr && m_sockaddr.sin_port == rhs.m_sockaddr.sin_port; } inline bool socket_address_inet::operator < (const socket_address_inet& rhs) const { return m_sockaddr.sin_addr.s_addr < rhs.m_sockaddr.sin_addr.s_addr || (m_sockaddr.sin_addr.s_addr == rhs.m_sockaddr.sin_addr.s_addr && m_sockaddr.sin_port < rhs.m_sockaddr.sin_port); } } #endif libtorrent-0.13.2/rak/string_manip.h000644 000765 000024 00000022440 11705767056 020361 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_STRING_MANIP_H #define RAK_STRING_MANIP_H #include #include #include #include #include namespace rak { // Use these trim functions until n1872 is widely supported. template Sequence trim_begin(const Sequence& seq) { if (seq.empty() || !std::isspace(*seq.begin())) return seq; typename Sequence::size_type pos = 0; while (pos != seq.length() && std::isspace(seq[pos])) pos++; return seq.substr(pos, seq.length() - pos); } template Sequence trim_end(const Sequence& seq) { if (seq.empty() || !std::isspace(*(--seq.end()))) return seq; typename Sequence::size_type pos = seq.size(); while (pos != 0 && std::isspace(seq[pos - 1])) pos--; return seq.substr(0, pos); } template Sequence trim(const Sequence& seq) { return trim_begin(trim_end(seq)); } template Sequence trim_begin_classic(const Sequence& seq) { if (seq.empty() || !std::isspace(*seq.begin(), std::locale::classic())) return seq; typename Sequence::size_type pos = 0; while (pos != seq.length() && std::isspace(seq[pos], std::locale::classic())) pos++; return seq.substr(pos, seq.length() - pos); } template Sequence trim_end_classic(const Sequence& seq) { if (seq.empty() || !std::isspace(*(--seq.end()), std::locale::classic())) return seq; typename Sequence::size_type pos = seq.size(); while (pos != 0 && std::isspace(seq[pos - 1], std::locale::classic())) pos--; return seq.substr(0, pos); } template Sequence trim_classic(const Sequence& seq) { return trim_begin_classic(trim_end_classic(seq)); } // Consider rewritting such that m_seq is replaced by first/last. template class split_iterator_t { public: typedef typename Sequence::const_iterator const_iterator; typedef typename Sequence::value_type value_type; split_iterator_t() {} split_iterator_t(const Sequence& seq, value_type delim) : m_seq(&seq), m_delim(delim), m_pos(seq.begin()), m_next(std::find(seq.begin(), seq.end(), delim)) { } Sequence operator * () { return Sequence(m_pos, m_next); } split_iterator_t& operator ++ () { m_pos = m_next; if (m_pos == m_seq->end()) return *this; m_pos++; m_next = std::find(m_pos, m_seq->end(), m_delim); return *this; } bool operator == (__UNUSED const split_iterator_t& itr) const { return m_pos == m_seq->end(); } bool operator != (__UNUSED const split_iterator_t& itr) const { return m_pos != m_seq->end(); } private: const Sequence* m_seq; value_type m_delim; const_iterator m_pos; const_iterator m_next; }; template inline split_iterator_t split_iterator(const Sequence& seq, typename Sequence::value_type delim) { return split_iterator_t(seq, delim); } template inline split_iterator_t split_iterator(__UNUSED const Sequence& seq) { return split_iterator_t(); } // Could optimize this abit. inline char hexchar_to_value(char c) { if (c >= '0' && c <= '9') return c - '0'; else if (c >= 'A' && c <= 'F') return 10 + c - 'A'; else return 10 + c - 'a'; } template inline char value_to_hexchar(Value v) { v >>= pos * 4; v &= 0xf; if (v < 0xA) return '0' + v; else return 'A' + v - 0xA; } template OutputIterator copy_escape_html(InputIterator first, InputIterator last, OutputIterator dest) { while (first != last) { if (std::isalpha(*first, std::locale::classic()) || std::isdigit(*first, std::locale::classic()) || *first == '-') { *(dest++) = *first; } else { *(dest++) = '%'; *(dest++) = value_to_hexchar<1>(*first); *(dest++) = value_to_hexchar<0>(*first); } ++first; } return dest; } template OutputIterator copy_escape_html(InputIterator first1, InputIterator last1, OutputIterator first2, OutputIterator last2) { while (first1 != last1) { if (std::isalpha(*first1, std::locale::classic()) || std::isdigit(*first1, std::locale::classic()) || *first1 == '-') { if (first2 == last2) break; else *(first2++) = *first1; } else { if (first2 == last2) break; else *(first2++) = '%'; if (first2 == last2) break; else *(first2++) = value_to_hexchar<1>(*first1); if (first2 == last2) break; else *(first2++) = value_to_hexchar<0>(*first1); } ++first1; } return first2; } template inline std::string copy_escape_html(Iterator first, Iterator last) { std::string dest; copy_escape_html(first, last, std::back_inserter(dest)); return dest; } template inline Sequence copy_escape_html(const Sequence& src) { Sequence dest; copy_escape_html(src.begin(), src.end(), std::back_inserter(dest)); return dest; } template inline std::string copy_escape_html_str(const Sequence& src) { std::string dest; copy_escape_html(src.begin(), src.end(), std::back_inserter(dest)); return dest; } // Consider support for larger than char type. template OutputIterator transform_hex(InputIterator first, InputIterator last, OutputIterator dest) { while (first != last) { *(dest++) = value_to_hexchar<1>(*first); *(dest++) = value_to_hexchar<0>(*first); ++first; } return dest; } template OutputIterator transform_hex(InputIterator first1, InputIterator last1, OutputIterator first2, OutputIterator last2) { while (first1 != last1) { if (first2 == last2) break; else *(first2++) = value_to_hexchar<1>(*first1); if (first2 == last2) break; else *(first2++) = value_to_hexchar<0>(*first1); ++first1; } return first2; } template inline Sequence transform_hex(const Sequence& src) { Sequence dest; transform_hex(src.begin(), src.end(), std::back_inserter(dest)); return dest; } template inline std::string transform_hex(Iterator first, Iterator last) { std::string dest; transform_hex(first, last, std::back_inserter(dest)); return dest; } template inline std::string transform_hex_str(const Sequence& seq) { std::string dest; transform_hex(seq.begin(), seq.end(), std::back_inserter(dest)); return dest; } template Sequence generate_random(size_t length) { Sequence s; s.reserve(length); std::generate_n(std::back_inserter(s), length, &::random); return s; } template inline bool is_all_alpha(Iterator first, Iterator last) { while (first != last) if (!std::isalpha(*first++, std::locale::classic())) return false; return true; } template inline bool is_all_alpha(const Sequence& src) { return is_all_alpha(src.begin(), src.end()); } template inline bool is_all_alnum(Iterator first, Iterator last) { while (first != last) if (!std::isalnum(*first++, std::locale::classic())) return false; return true; } template inline bool is_all_alnum(const Sequence& src) { return is_all_alnum(src.begin(), src.end()); } template inline bool is_all_name(Iterator first, Iterator last) { while (first != last) { if (!std::isalnum(*first, std::locale::classic()) && *first != '_') return false; first++; } return true; } template inline bool is_all_name(const Sequence& src) { return is_all_name(src.begin(), src.end()); } } #endif libtorrent-0.13.2/rak/timer.h000644 000765 000024 00000011153 11705767056 017006 0ustar00rakshasastaff000000 000000 // libTorrent - BitTorrent library // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_TIMER_H #define RAK_TIMER_H #include #include #include namespace rak { // Don't convert negative Timer to timeval and then back to Timer, that will bork. class timer { public: timer(int64_t usec = 0) : m_time(usec) {} timer(timeval tv) : m_time((int64_t)(uint32_t)tv.tv_sec * 1000000 + (int64_t)(uint32_t)tv.tv_usec % 1000000) {} int32_t seconds() const { return m_time / 1000000; } int32_t seconds_ceiling() const { return (m_time + 1000000 - 1) / 1000000; } int64_t usec() const { return m_time; } timer round_seconds() const { return (m_time / 1000000) * 1000000; } timer round_seconds_ceiling() const { return ((m_time + 1000000 - 1) / 1000000) * 1000000; } timeval tval() const { timeval val; val.tv_sec = m_time / 1000000; val.tv_usec = m_time % 1000000; return val; } static timer current(); static int64_t current_seconds() { return current().seconds(); } static int64_t current_usec() { return current().usec(); } static timer from_minutes(uint32_t minutes) { return rak::timer((uint64_t)minutes * 60 * 1000000); } static timer from_seconds(uint32_t seconds) { return rak::timer((uint64_t)seconds * 1000000); } static timer from_milliseconds(uint32_t msec) { return rak::timer((uint64_t)msec * 1000); } static timer max() { return std::numeric_limits::max(); } bool operator < (const timer& t) const { return m_time < t.m_time; } bool operator > (const timer& t) const { return m_time > t.m_time; } bool operator <= (const timer& t) const { return m_time <= t.m_time; } bool operator >= (const timer& t) const { return m_time >= t.m_time; } bool operator == (const timer& t) const { return m_time == t.m_time; } bool operator != (const timer& t) const { return m_time != t.m_time; } timer operator - (const timer& t) const { return timer(m_time - t.m_time); } timer operator + (const timer& t) const { return timer(m_time + t.m_time); } timer operator * (int64_t t) const { return timer(m_time * t); } timer operator / (int64_t t) const { return timer(m_time / t); } timer operator -= (int64_t t) { m_time -= t; return *this; } timer operator -= (const timer& t) { m_time -= t.m_time; return *this; } timer operator += (int64_t t) { m_time += t; return *this; } timer operator += (const timer& t) { m_time += t.m_time; return *this; } private: int64_t m_time; }; inline timer timer::current() { timeval t; gettimeofday(&t, 0); return timer(t); } } #endif libtorrent-0.13.2/rak/unordered_vector.h000644 000765 000024 00000006641 11705767056 021245 0ustar00rakshasastaff000000 000000 // rak - Rakshasa's toolbox // Copyright (C) 2005-2007, Jari Sundell // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. // // Contact: Jari Sundell // // Skomakerveien 33 // 3185 Skoppum, NORWAY #ifndef RAK_UNORDERED_VECTOR_H #define RAK_UNORDERED_VECTOR_H #include namespace rak { template class unordered_vector : private std::vector<_Tp> { public: typedef std::vector<_Tp> Base; typedef typename Base::value_type value_type; typedef typename Base::pointer pointer; typedef typename Base::const_pointer const_pointer; typedef typename Base::reference reference; typedef typename Base::const_reference const_reference; typedef typename Base::size_type size_type; typedef typename Base::difference_type difference_type; typedef typename Base::allocator_type allocator_type; typedef typename Base::iterator iterator; typedef typename Base::reverse_iterator reverse_iterator; typedef typename Base::const_iterator const_iterator; typedef typename Base::const_reverse_iterator const_reverse_iterator; using Base::clear; using Base::empty; using Base::size; using Base::reserve; using Base::front; using Base::back; using Base::begin; using Base::end; using Base::rbegin; using Base::rend; using Base::push_back; using Base::pop_back; // Use the range erase function, the single element erase gets // overloaded. using Base::erase; iterator insert(iterator position, const value_type& x); iterator erase(iterator position); private: }; template typename unordered_vector<_Tp>::iterator unordered_vector<_Tp>::insert(iterator position, const value_type& x) { Base::push_back(x); return --end(); } template typename unordered_vector<_Tp>::iterator unordered_vector<_Tp>::erase(iterator position) { // We don't need to check if position == end - 1 since we then copy // to the position we pop later. *position = Base::back(); Base::pop_back(); return position; } } #endif libtorrent-0.13.2/doc/http.xml000644 000765 000024 00000004771 11705767056 017216 0ustar00rakshasastaff000000 000000 Http handler
Introduction LibTorrent depends on the client to handle http downloads, thus the library does not have a dependency on any specific http library. The library provides a base class named torrent::Http with virtual member functions that the client must implement, and a sigc++ slot which must be set to create an instance of the derived torrent::Http class when called. The torrent::Http class and the factory slot related functions can be found in the header "torrent/http.h". The http handler should have reasonable connection timeouts, be non-blocking and not do reconnects on failed downloads.
Factory Slot The client registers the desired factory slot with the static torrent::Http::set_factory member function. Using sigc++ the client may bind values to the arguments of their function to avoid depending on globals. The factory slot must return a pointer to a new instance with the base type torrent::Http, and the caller takes responsibility of deleting the object. (Note: consider making the cleanup a slot)
Output Stream The data downloaded by the http handler is to be written to torrent::Http::m_stream which is a pointer to an std::iostream. The http handler must not change any of the flags on the stream.
Start Http::start is called by the library when it wishes to initiate a http download. Your Http derived class must implement this function. It must be non-blocking and thread-safe. This means that if a seperate thread is used for downloading then it must not emit any signal while the main thread is inside the library.
close Http::close is used bu the library to stop and close a download. No signals may be emited after this. Http::m_data should not be cleared. The library may clear the Http::m_data pointer after this.
Signals There are two mutually exclusive signals that are called when the download has stopped. The signal torrent::Http::m_signalDone is called if the download was successful and torrent::Http::m_stream contains the complete data. Or if the download was unsuccessful for some reason, then torrent::Http::m_signalFailed is called with an error message.
libtorrent-0.13.2/doc/main.xml000644 000765 000024 00000000354 11705767056 017154 0ustar00rakshasastaff000000 000000 ]> libTorrent Manual &torrent_section; &http_section; libtorrent-0.13.2/doc/torrent.xml000644 000765 000024 00000006365 11705767056 017735 0ustar00rakshasastaff000000 000000 Torrent
State
Closed This is the initial state of a download. When switching to this mode, all tracker requests are closed and the bitfield of completed chunks is cleared. File paths can only be changed in this state. Functions for getting information on bitfields, chunk count and various others will return size 0 in this state. (TODO: Check which)
torrent::Download::is_open() == false; torrent::Download::is_active() == false; torrent::Download::is_tracker_busy() == false;
Open This is the state after a successfull call to torrent::Download::open(). This function throws torrent::local_error if the download could not be opened. All files in the download have been created and are open. The initial hash check must be done to get a valid bitfield of completed chunks.
torrent::Download::is_open() == true; torrent::Download::is_active() == false;
Active A download is active after calling torrent::Download::start(). Only downloads that are in an open state and has a valid bitfield of completed chunks can be activated.
torrent::Download::is_open() == true; torrent::Download::is_active() == true; torrent::Download::is_hash_checked() == true;
A tracker request will be made when torrent::Download::stop() is called on an active download. It is not required to wait for the tracker request to finish before calling torrent::Download::close(), but it is recommened so the tracker knows this client is not available.
File Paths The paths of files in a Download consists of two parts, the root directory and the paths of each file. The file paths are read from the torrent file and the files usually reside in the root directory. The root directory is by default "./" for single file torrents and "./[torrent_name]/" for multi-file torrents.
// Get and set the root directory. std::string torrent::Download::get_root_dir(); void torrent::Download::set_root_dir(const std::string& dir); // Get the torrent::Entry class for each file in the download. torrent::Entry torrent::Download::get_entry(uint32_t index); uint32_t torrent::Download::get_entry_size(); typedef std::list<std::string> torrent::Entry::Path; // Get and set the file path. std::string torrent::Entry::get_path(); const Path& torrent::Entry::get_path_list(); void torrent::Entry::set_path_list(const Path& l);
The modifications can only be done while the download is in a closed state. Modifying the file paths will not change the "info hash" part of the bencode'd torrent associated with the download. (TODO: When exporting, save root directory and file paths to another section of the torrent)