btpd-0.16/0000755000175000001440000000000011426157674007403 500000000000000btpd-0.16/README0000644000175000001440000001600011425124720010161 00000000000000 The BitTorrent Protocol Daemon README btpd version 0.16 Contents 1 Introduction 1.a What is btpd? 1.b The programs 1.c The btcli commands 2 Using btpd 2.a Introduction 2.b Starting btpd 2.c Examples 2.d Troubleshooting 3 Building 3.a Requirements 3.b Standard build 4 Additional notes 4.a Upgrade form old versions 4.b Pre exit mode 4.c Using both IPv6 and IPv4 1. Introduction 1.a What is btpd? Btpd is a utility for sharing files over the BitTorrent network protocol. It runs in daemon mode, thus needing no controlling terminal or gui. Instead, the daemon is controlled by btcli, its command line utility, or other programs capable of sending commands and queries on the control socket. 1.b The programs btpd consists of the following programs: * btpd - The bittorrent client. * btcli - Command line interface to btpd. * btinfo - Shows information from a torrent file. All programs accept the "--help" option. 1.c The btcli commands The btcli utility has several different modes of operation. One of the following commands must be specified when running btcli: * add - Add torrents to btpd. * del - Remove torrents from btpd. * kill - Shut down btpd. * list - List torrents. * start - Activate torrents. * stat - Display stats for active torrents. * stop - Deactivate torrents. 2. Using btpd 2.a Introduction To start sharing a torrent with btpd, the torrent needs to be added to btpd. This is done with 'btcli add'. When you add a torrent btpd auto- matically (if you didn't specify otherwise) starts to share the torrent and download any missing data. The content directory you specify when adding a torrent doesn't need to exist; it will be created by btpd. You can see which torrents have been added to btpd with 'btcli list'. The list command also displays a number for each added torrent. This number can be used to specify the target torrent for the btcli commands, so you don't have to keep the torrent file once you've added it. The up- and download progress can be followed by using the 'btcli stat' command. Both the list and stat commands use the following indicators to display the state of a torrent: + the torrent is starting. This may take time if btpd needs to test the content of this torrent or one started before it. - the torrent is being stopped. I the torrent is inactive. S btpd is seeding the torrent. L btpd is leeching the torrent. You can stop an active torrent with 'btcli stop' and, of course, start an inactive torrent by using 'btcli start'. The 'btcli del' command should only be used when you're totally finished with sharing a torrent. The command will remove the torrent and its associated data from btpd. It's an escpecially bad idea to remove a not fully downloaded torrent and then adding it again, since btpd has lost information on the not fully downloaded pieces and will need to download the data again. To shut down btpd use 'btcli kill'. Don't forget to read the help for each of btcli's commands. 2.b Starting btpd NOTE: You should only need one instance of btpd regardless of how many torrents you want to share. To start btpd with default settings you only need to run it. However, there are many useful options you may want to use. To see a full list run 'btpd --help'. If you didn't specify otherwise, btpd starts with the same set of active torrents as it had the last time it was shut down. btdp will store information and write its log in $HOME/.btpd. Therefore it needs to be able to write there during its execution. You can specify another directory via the '-d' option or the $BTPD_HOME variable. I recommend specifiying the maximum number of uploads. Bittorrent employs a tit for tat algorithm, so uploading at good rates allows for downloading. Try to find a balance between uploads/outgoing bandwidth and the number of active torrents. 2.c Examples Start btpd with all options set to their default values. # btpd Start btpd and make it listen on port 12345, limit outgoing bandwidth to 200kB/s, limit the number of peers to 40 and not start any torrents that were active the last time btpd was shut down. # btpd -p 12345 --bw-out 200 --max-peers 40 --empty-start Display a list btpd's torrents and their number, size, status, etc. # btcli list Same as above, but only for torrent 12 and my.little.torrent. # btcli list 12 my.little.torrent Same as above but only for active torrents. # btcli list -a Same as above, but print using a custom format # btcli list -a -f "btcli list -f "%n\t%#\t%p%s\t%r\n" Add foo.torrent, with content dir foo.torrent.d, and start it. # btcli add -d foo.torrent.d foo.torrent Same as above without starting it. # btcli add --no-start -d foo.torrent.d foo.torrent Start bar.torrent and torrent number 7. # btcli start bar.torrent 7 Stop torrent number 7. # btcli stop 7 Stop all active torrents. # btcli stop -a Remove bar.torrent and it's associated information from btpd. # btcli del bar.torrent Display a summary of up/download stats for the active torrents. # btcli stat Display the summary once every five seconds. # btcli stat -w 5 Same as above, but also display individual stats for each active torrent. # btcli stat -w 5 -i Shut down btpd. # btcli kill 2.d Troubleshooting If btpd has shut down for some unknown reason, check the logfile for possible clues. 3. Building 3.a Requirements You should have a *BSD, Linux or sufficiently similar system. Make sure you have recent versions of the following software: * OpenSSL - Get at You also need a c99 compiler. A non antique GCC should do. 3.b Standard build # ./configure # make # make install See './configure --help' for available build options if the above fails. 4. Additional notes 4.a Upgrade from old version The layout of the torrents directory in the btpd directory has changed since btpd 0.11. Please remove the torrents directory before running later versions. 4.b Pre exit mode If btpd needs to send stop messages to trackers before shutting down, it will enter the pre exit mode. A btpd process in this mode can safely be ignored and will not interfere with any new btpd started in the same directory. 4.c Using both IPv6 and IPv4 Unfortunately enabling both IPv6 and IPv4 in btpd is less useful than it should be. The problem is that some sites have trackers for both versions and it's likely that the IPv6 one, which probably has less peers, will be used in favour of the IPv4 one. In order to fix this problem, the IP version options should be changed to be per torrent, in some future version of btpd. btpd-0.16/Makefile.am0000644000175000001440000000353511420522630011343 00000000000000AM_CFLAGS=-std=c99 -Wall @WARNNPS@ AM_CPPFLAGS=-D_FILE_OFFSET_BITS=64 -D@EVLOOP_METHOD@ -I$(top_srcdir)/misc -I$(top_srcdir)/evloop @openssl_CPPFLAGS@ AM_LDFLAGS=@openssl_LDFLAGS@ bin_PROGRAMS=btpd/btpd cli/btcli cli/btinfo noinst_LIBRARIES=misc/libmisc.a evloop/libevloop.a dist_man1_MANS=doc/btcli.1 doc/btinfo.1 doc/btpd.1 EXTRA_DIST=COPYRIGHT CHANGES # btpd btpd_btpd_SOURCES=\ btpd/active.c btpd/active.h btpd/addrinfo.c\ btpd/btpd.c btpd/btpd.h\ btpd/cli_if.c btpd/content.c btpd/content.h\ btpd/download.c btpd/download_subr.c btpd/download.h\ btpd/http_tr_if.c\ btpd/main.c\ btpd/nameconn.c btpd/net.c btpd/net.h btpd/net_types.h\ btpd/net_buf.c btpd/net_buf.h\ btpd/opts.c btpd/opts.h\ btpd/peer.c btpd/peer.h\ btpd/thread_cb.c btpd/tlib.c btpd/tlib.h btpd/torrent.c btpd/torrent.h\ btpd/tracker_req.c btpd/tracker_req.h\ btpd/upload.c btpd/upload.h\ btpd/util.c btpd_btpd_CFLAGS=@TD_CFLAGS@ $(AM_CFLAGS) btpd_btpd_LDADD=@TD_LIBS@ misc/libmisc.a evloop/libevloop.a -lcrypto -lm @CLOCKLIB@ @INETLIBS@ # btinfo cli_btinfo_SOURCES=cli/btinfo.c cli_btinfo_LDADD=misc/libmisc.a -lcrypto -lm # btcli cli_btcli_SOURCES=cli/btcli.c cli/btcli.h cli/add.c cli/del.c cli/list.c cli/kill.c cli/start.c cli/stop.c cli/stat.c cli_btcli_LDADD=misc/libmisc.a -lcrypto -lm @INETLIBS@ # libmisc misc_libmisc_a_SOURCES=\ misc/benc.c misc/benc.h\ misc/btpd_if.c misc/btpd_if.h misc/ipcdefs.h\ misc/metainfo.c misc/metainfo.h\ misc/hashtable.c misc/hashtable.h\ misc/http_client.c misc/http_client.h\ misc/iobuf.c misc/iobuf.h\ misc/queue.h\ misc/stream.c misc/stream.h\ misc/subr.c misc/subr.h # evloop EXTRA_evloop_libevloop_a_SOURCES=evloop/epoll.c evloop/kqueue.c evloop/poll.c evloop_libevloop_a_SOURCES=\ evloop/evloop.h\ evloop/timeheap.c evloop/timeheap.h evloop/timer.c evloop_libevloop_a_LIBADD=@EVLOOP_IMPL@ evloop_libevloop_a_DEPENDENCIES=@EVLOOP_IMPL@ btpd-0.16/aclocal.m40000644000175000001440000010602711426157640011162 00000000000000# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 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. # 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.66],, [m4_warning([this file was generated for autoconf 2.66. 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'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 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. # 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.1], [], [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.1])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 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. # 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 # 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 10 # 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'. 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 ;; 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='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])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"]) ]) # 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 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. # 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 ]) # Copyright (C) 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_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # 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 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. # 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 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_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 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. # 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 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_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 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. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} 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 btpd-0.16/Makefile.in0000644000175000001440000022013611426157640011365 00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 = : bin_PROGRAMS = btpd/btpd$(EXEEXT) cli/btcli$(EXEEXT) \ cli/btinfo$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(dist_man1_MANS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/configure compile depcomp install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(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_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru evloop_libevloop_a_AR = $(AR) $(ARFLAGS) am__dirstamp = $(am__leading_dot)dirstamp am_evloop_libevloop_a_OBJECTS = evloop/timeheap.$(OBJEXT) \ evloop/timer.$(OBJEXT) evloop_libevloop_a_OBJECTS = $(am_evloop_libevloop_a_OBJECTS) misc_libmisc_a_AR = $(AR) $(ARFLAGS) misc_libmisc_a_LIBADD = am_misc_libmisc_a_OBJECTS = misc/benc.$(OBJEXT) misc/btpd_if.$(OBJEXT) \ misc/metainfo.$(OBJEXT) misc/hashtable.$(OBJEXT) \ misc/http_client.$(OBJEXT) misc/iobuf.$(OBJEXT) \ misc/stream.$(OBJEXT) misc/subr.$(OBJEXT) misc_libmisc_a_OBJECTS = $(am_misc_libmisc_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) am_btpd_btpd_OBJECTS = btpd/btpd_btpd-active.$(OBJEXT) \ btpd/btpd_btpd-addrinfo.$(OBJEXT) \ btpd/btpd_btpd-btpd.$(OBJEXT) btpd/btpd_btpd-cli_if.$(OBJEXT) \ btpd/btpd_btpd-content.$(OBJEXT) \ btpd/btpd_btpd-download.$(OBJEXT) \ btpd/btpd_btpd-download_subr.$(OBJEXT) \ btpd/btpd_btpd-http_tr_if.$(OBJEXT) \ btpd/btpd_btpd-main.$(OBJEXT) \ btpd/btpd_btpd-nameconn.$(OBJEXT) btpd/btpd_btpd-net.$(OBJEXT) \ btpd/btpd_btpd-net_buf.$(OBJEXT) btpd/btpd_btpd-opts.$(OBJEXT) \ btpd/btpd_btpd-peer.$(OBJEXT) \ btpd/btpd_btpd-thread_cb.$(OBJEXT) \ btpd/btpd_btpd-tlib.$(OBJEXT) btpd/btpd_btpd-torrent.$(OBJEXT) \ btpd/btpd_btpd-tracker_req.$(OBJEXT) \ btpd/btpd_btpd-upload.$(OBJEXT) btpd/btpd_btpd-util.$(OBJEXT) btpd_btpd_OBJECTS = $(am_btpd_btpd_OBJECTS) btpd_btpd_DEPENDENCIES = misc/libmisc.a evloop/libevloop.a btpd_btpd_LINK = $(CCLD) $(btpd_btpd_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_cli_btcli_OBJECTS = cli/btcli.$(OBJEXT) cli/add.$(OBJEXT) \ cli/del.$(OBJEXT) cli/list.$(OBJEXT) cli/kill.$(OBJEXT) \ cli/start.$(OBJEXT) cli/stop.$(OBJEXT) cli/stat.$(OBJEXT) cli_btcli_OBJECTS = $(am_cli_btcli_OBJECTS) cli_btcli_DEPENDENCIES = misc/libmisc.a am_cli_btinfo_OBJECTS = cli/btinfo.$(OBJEXT) cli_btinfo_OBJECTS = $(am_cli_btinfo_OBJECTS) cli_btinfo_DEPENDENCIES = misc/libmisc.a DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(evloop_libevloop_a_SOURCES) \ $(EXTRA_evloop_libevloop_a_SOURCES) $(misc_libmisc_a_SOURCES) \ $(btpd_btpd_SOURCES) $(cli_btcli_SOURCES) \ $(cli_btinfo_SOURCES) DIST_SOURCES = $(evloop_libevloop_a_SOURCES) \ $(EXTRA_evloop_libevloop_a_SOURCES) $(misc_libmisc_a_SOURCES) \ $(btpd_btpd_SOURCES) $(cli_btcli_SOURCES) \ $(cli_btinfo_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' man1dir = $(mandir)/man1 NROFF = nroff MANS = $(dist_man1_MANS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CLOCKLIB = @CLOCKLIB@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EVLOOP_IMPL = @EVLOOP_IMPL@ EVLOOP_METHOD = @EVLOOP_METHOD@ EXEEXT = @EXEEXT@ GREP = @GREP@ INETLIBS = @INETLIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ 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@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TD_CFLAGS = @TD_CFLAGS@ TD_LIBS = @TD_LIBS@ VERSION = @VERSION@ WARNNPS = @WARNNPS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ 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@ openssl_CPPFLAGS = @openssl_CPPFLAGS@ openssl_LDFLAGS = @openssl_LDFLAGS@ 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@ AM_CFLAGS = -std=c99 -Wall @WARNNPS@ AM_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D@EVLOOP_METHOD@ -I$(top_srcdir)/misc -I$(top_srcdir)/evloop @openssl_CPPFLAGS@ AM_LDFLAGS = @openssl_LDFLAGS@ noinst_LIBRARIES = misc/libmisc.a evloop/libevloop.a dist_man1_MANS = doc/btcli.1 doc/btinfo.1 doc/btpd.1 EXTRA_DIST = COPYRIGHT CHANGES # btpd btpd_btpd_SOURCES = \ btpd/active.c btpd/active.h btpd/addrinfo.c\ btpd/btpd.c btpd/btpd.h\ btpd/cli_if.c btpd/content.c btpd/content.h\ btpd/download.c btpd/download_subr.c btpd/download.h\ btpd/http_tr_if.c\ btpd/main.c\ btpd/nameconn.c btpd/net.c btpd/net.h btpd/net_types.h\ btpd/net_buf.c btpd/net_buf.h\ btpd/opts.c btpd/opts.h\ btpd/peer.c btpd/peer.h\ btpd/thread_cb.c btpd/tlib.c btpd/tlib.h btpd/torrent.c btpd/torrent.h\ btpd/tracker_req.c btpd/tracker_req.h\ btpd/upload.c btpd/upload.h\ btpd/util.c btpd_btpd_CFLAGS = @TD_CFLAGS@ $(AM_CFLAGS) btpd_btpd_LDADD = @TD_LIBS@ misc/libmisc.a evloop/libevloop.a -lcrypto -lm @CLOCKLIB@ @INETLIBS@ # btinfo cli_btinfo_SOURCES = cli/btinfo.c cli_btinfo_LDADD = misc/libmisc.a -lcrypto -lm # btcli cli_btcli_SOURCES = cli/btcli.c cli/btcli.h cli/add.c cli/del.c cli/list.c cli/kill.c cli/start.c cli/stop.c cli/stat.c cli_btcli_LDADD = misc/libmisc.a -lcrypto -lm @INETLIBS@ # libmisc misc_libmisc_a_SOURCES = \ misc/benc.c misc/benc.h\ misc/btpd_if.c misc/btpd_if.h misc/ipcdefs.h\ misc/metainfo.c misc/metainfo.h\ misc/hashtable.c misc/hashtable.h\ misc/http_client.c misc/http_client.h\ misc/iobuf.c misc/iobuf.h\ misc/queue.h\ misc/stream.c misc/stream.h\ misc/subr.c misc/subr.h # evloop EXTRA_evloop_libevloop_a_SOURCES = evloop/epoll.c evloop/kqueue.c evloop/poll.c evloop_libevloop_a_SOURCES = \ evloop/evloop.h\ evloop/timeheap.c evloop/timeheap.h evloop/timer.c evloop_libevloop_a_LIBADD = @EVLOOP_IMPL@ evloop_libevloop_a_DEPENDENCIES = @EVLOOP_IMPL@ all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign 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): clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) evloop/$(am__dirstamp): @$(MKDIR_P) evloop @: > evloop/$(am__dirstamp) evloop/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) evloop/$(DEPDIR) @: > evloop/$(DEPDIR)/$(am__dirstamp) evloop/timeheap.$(OBJEXT): evloop/$(am__dirstamp) \ evloop/$(DEPDIR)/$(am__dirstamp) evloop/timer.$(OBJEXT): evloop/$(am__dirstamp) \ evloop/$(DEPDIR)/$(am__dirstamp) evloop/epoll.$(OBJEXT): evloop/$(am__dirstamp) \ evloop/$(DEPDIR)/$(am__dirstamp) evloop/kqueue.$(OBJEXT): evloop/$(am__dirstamp) \ evloop/$(DEPDIR)/$(am__dirstamp) evloop/poll.$(OBJEXT): evloop/$(am__dirstamp) \ evloop/$(DEPDIR)/$(am__dirstamp) evloop/libevloop.a: $(evloop_libevloop_a_OBJECTS) $(evloop_libevloop_a_DEPENDENCIES) evloop/$(am__dirstamp) -rm -f evloop/libevloop.a $(evloop_libevloop_a_AR) evloop/libevloop.a $(evloop_libevloop_a_OBJECTS) $(evloop_libevloop_a_LIBADD) $(RANLIB) evloop/libevloop.a misc/$(am__dirstamp): @$(MKDIR_P) misc @: > misc/$(am__dirstamp) misc/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) misc/$(DEPDIR) @: > misc/$(DEPDIR)/$(am__dirstamp) misc/benc.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/btpd_if.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/metainfo.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/hashtable.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/http_client.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/iobuf.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/stream.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/subr.$(OBJEXT): misc/$(am__dirstamp) \ misc/$(DEPDIR)/$(am__dirstamp) misc/libmisc.a: $(misc_libmisc_a_OBJECTS) $(misc_libmisc_a_DEPENDENCIES) misc/$(am__dirstamp) -rm -f misc/libmisc.a $(misc_libmisc_a_AR) misc/libmisc.a $(misc_libmisc_a_OBJECTS) $(misc_libmisc_a_LIBADD) $(RANLIB) misc/libmisc.a install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) btpd/$(am__dirstamp): @$(MKDIR_P) btpd @: > btpd/$(am__dirstamp) btpd/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) btpd/$(DEPDIR) @: > btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-active.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-addrinfo.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-btpd.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-cli_if.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-content.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-download.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-download_subr.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-http_tr_if.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-main.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-nameconn.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-net.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-net_buf.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-opts.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-peer.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-thread_cb.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-tlib.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-torrent.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-tracker_req.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-upload.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd_btpd-util.$(OBJEXT): btpd/$(am__dirstamp) \ btpd/$(DEPDIR)/$(am__dirstamp) btpd/btpd$(EXEEXT): $(btpd_btpd_OBJECTS) $(btpd_btpd_DEPENDENCIES) btpd/$(am__dirstamp) @rm -f btpd/btpd$(EXEEXT) $(btpd_btpd_LINK) $(btpd_btpd_OBJECTS) $(btpd_btpd_LDADD) $(LIBS) cli/$(am__dirstamp): @$(MKDIR_P) cli @: > cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) cli/$(DEPDIR) @: > cli/$(DEPDIR)/$(am__dirstamp) cli/btcli.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/add.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/del.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/list.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/kill.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/start.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/stop.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/stat.$(OBJEXT): cli/$(am__dirstamp) cli/$(DEPDIR)/$(am__dirstamp) cli/btcli$(EXEEXT): $(cli_btcli_OBJECTS) $(cli_btcli_DEPENDENCIES) cli/$(am__dirstamp) @rm -f cli/btcli$(EXEEXT) $(LINK) $(cli_btcli_OBJECTS) $(cli_btcli_LDADD) $(LIBS) cli/btinfo.$(OBJEXT): cli/$(am__dirstamp) \ cli/$(DEPDIR)/$(am__dirstamp) cli/btinfo$(EXEEXT): $(cli_btinfo_OBJECTS) $(cli_btinfo_DEPENDENCIES) cli/$(am__dirstamp) @rm -f cli/btinfo$(EXEEXT) $(LINK) $(cli_btinfo_OBJECTS) $(cli_btinfo_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f btpd/btpd_btpd-active.$(OBJEXT) -rm -f btpd/btpd_btpd-addrinfo.$(OBJEXT) -rm -f btpd/btpd_btpd-btpd.$(OBJEXT) -rm -f btpd/btpd_btpd-cli_if.$(OBJEXT) -rm -f btpd/btpd_btpd-content.$(OBJEXT) -rm -f btpd/btpd_btpd-download.$(OBJEXT) -rm -f btpd/btpd_btpd-download_subr.$(OBJEXT) -rm -f btpd/btpd_btpd-http_tr_if.$(OBJEXT) -rm -f btpd/btpd_btpd-main.$(OBJEXT) -rm -f btpd/btpd_btpd-nameconn.$(OBJEXT) -rm -f btpd/btpd_btpd-net.$(OBJEXT) -rm -f btpd/btpd_btpd-net_buf.$(OBJEXT) -rm -f btpd/btpd_btpd-opts.$(OBJEXT) -rm -f btpd/btpd_btpd-peer.$(OBJEXT) -rm -f btpd/btpd_btpd-thread_cb.$(OBJEXT) -rm -f btpd/btpd_btpd-tlib.$(OBJEXT) -rm -f btpd/btpd_btpd-torrent.$(OBJEXT) -rm -f btpd/btpd_btpd-tracker_req.$(OBJEXT) -rm -f btpd/btpd_btpd-upload.$(OBJEXT) -rm -f btpd/btpd_btpd-util.$(OBJEXT) -rm -f cli/add.$(OBJEXT) -rm -f cli/btcli.$(OBJEXT) -rm -f cli/btinfo.$(OBJEXT) -rm -f cli/del.$(OBJEXT) -rm -f cli/kill.$(OBJEXT) -rm -f cli/list.$(OBJEXT) -rm -f cli/start.$(OBJEXT) -rm -f cli/stat.$(OBJEXT) -rm -f cli/stop.$(OBJEXT) -rm -f evloop/epoll.$(OBJEXT) -rm -f evloop/kqueue.$(OBJEXT) -rm -f evloop/poll.$(OBJEXT) -rm -f evloop/timeheap.$(OBJEXT) -rm -f evloop/timer.$(OBJEXT) -rm -f misc/benc.$(OBJEXT) -rm -f misc/btpd_if.$(OBJEXT) -rm -f misc/hashtable.$(OBJEXT) -rm -f misc/http_client.$(OBJEXT) -rm -f misc/iobuf.$(OBJEXT) -rm -f misc/metainfo.$(OBJEXT) -rm -f misc/stream.$(OBJEXT) -rm -f misc/subr.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-active.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-addrinfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-btpd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-cli_if.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-content.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-download.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-download_subr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-http_tr_if.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-nameconn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-net.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-net_buf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-opts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-peer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-thread_cb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-tlib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-torrent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-tracker_req.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-upload.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@btpd/$(DEPDIR)/btpd_btpd-util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/add.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/btcli.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/btinfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/del.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/kill.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/start.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/stat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cli/$(DEPDIR)/stop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evloop/$(DEPDIR)/epoll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evloop/$(DEPDIR)/kqueue.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evloop/$(DEPDIR)/poll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evloop/$(DEPDIR)/timeheap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evloop/$(DEPDIR)/timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/benc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/btpd_if.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/hashtable.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/http_client.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/iobuf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/metainfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/stream.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/subr.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` btpd/btpd_btpd-active.o: btpd/active.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-active.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-active.Tpo -c -o btpd/btpd_btpd-active.o `test -f 'btpd/active.c' || echo '$(srcdir)/'`btpd/active.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-active.Tpo btpd/$(DEPDIR)/btpd_btpd-active.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/active.c' object='btpd/btpd_btpd-active.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-active.o `test -f 'btpd/active.c' || echo '$(srcdir)/'`btpd/active.c btpd/btpd_btpd-active.obj: btpd/active.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-active.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-active.Tpo -c -o btpd/btpd_btpd-active.obj `if test -f 'btpd/active.c'; then $(CYGPATH_W) 'btpd/active.c'; else $(CYGPATH_W) '$(srcdir)/btpd/active.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-active.Tpo btpd/$(DEPDIR)/btpd_btpd-active.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/active.c' object='btpd/btpd_btpd-active.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-active.obj `if test -f 'btpd/active.c'; then $(CYGPATH_W) 'btpd/active.c'; else $(CYGPATH_W) '$(srcdir)/btpd/active.c'; fi` btpd/btpd_btpd-addrinfo.o: btpd/addrinfo.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-addrinfo.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-addrinfo.Tpo -c -o btpd/btpd_btpd-addrinfo.o `test -f 'btpd/addrinfo.c' || echo '$(srcdir)/'`btpd/addrinfo.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-addrinfo.Tpo btpd/$(DEPDIR)/btpd_btpd-addrinfo.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/addrinfo.c' object='btpd/btpd_btpd-addrinfo.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-addrinfo.o `test -f 'btpd/addrinfo.c' || echo '$(srcdir)/'`btpd/addrinfo.c btpd/btpd_btpd-addrinfo.obj: btpd/addrinfo.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-addrinfo.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-addrinfo.Tpo -c -o btpd/btpd_btpd-addrinfo.obj `if test -f 'btpd/addrinfo.c'; then $(CYGPATH_W) 'btpd/addrinfo.c'; else $(CYGPATH_W) '$(srcdir)/btpd/addrinfo.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-addrinfo.Tpo btpd/$(DEPDIR)/btpd_btpd-addrinfo.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/addrinfo.c' object='btpd/btpd_btpd-addrinfo.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-addrinfo.obj `if test -f 'btpd/addrinfo.c'; then $(CYGPATH_W) 'btpd/addrinfo.c'; else $(CYGPATH_W) '$(srcdir)/btpd/addrinfo.c'; fi` btpd/btpd_btpd-btpd.o: btpd/btpd.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-btpd.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-btpd.Tpo -c -o btpd/btpd_btpd-btpd.o `test -f 'btpd/btpd.c' || echo '$(srcdir)/'`btpd/btpd.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-btpd.Tpo btpd/$(DEPDIR)/btpd_btpd-btpd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/btpd.c' object='btpd/btpd_btpd-btpd.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-btpd.o `test -f 'btpd/btpd.c' || echo '$(srcdir)/'`btpd/btpd.c btpd/btpd_btpd-btpd.obj: btpd/btpd.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-btpd.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-btpd.Tpo -c -o btpd/btpd_btpd-btpd.obj `if test -f 'btpd/btpd.c'; then $(CYGPATH_W) 'btpd/btpd.c'; else $(CYGPATH_W) '$(srcdir)/btpd/btpd.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-btpd.Tpo btpd/$(DEPDIR)/btpd_btpd-btpd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/btpd.c' object='btpd/btpd_btpd-btpd.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-btpd.obj `if test -f 'btpd/btpd.c'; then $(CYGPATH_W) 'btpd/btpd.c'; else $(CYGPATH_W) '$(srcdir)/btpd/btpd.c'; fi` btpd/btpd_btpd-cli_if.o: btpd/cli_if.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-cli_if.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-cli_if.Tpo -c -o btpd/btpd_btpd-cli_if.o `test -f 'btpd/cli_if.c' || echo '$(srcdir)/'`btpd/cli_if.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-cli_if.Tpo btpd/$(DEPDIR)/btpd_btpd-cli_if.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/cli_if.c' object='btpd/btpd_btpd-cli_if.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-cli_if.o `test -f 'btpd/cli_if.c' || echo '$(srcdir)/'`btpd/cli_if.c btpd/btpd_btpd-cli_if.obj: btpd/cli_if.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-cli_if.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-cli_if.Tpo -c -o btpd/btpd_btpd-cli_if.obj `if test -f 'btpd/cli_if.c'; then $(CYGPATH_W) 'btpd/cli_if.c'; else $(CYGPATH_W) '$(srcdir)/btpd/cli_if.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-cli_if.Tpo btpd/$(DEPDIR)/btpd_btpd-cli_if.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/cli_if.c' object='btpd/btpd_btpd-cli_if.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-cli_if.obj `if test -f 'btpd/cli_if.c'; then $(CYGPATH_W) 'btpd/cli_if.c'; else $(CYGPATH_W) '$(srcdir)/btpd/cli_if.c'; fi` btpd/btpd_btpd-content.o: btpd/content.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-content.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-content.Tpo -c -o btpd/btpd_btpd-content.o `test -f 'btpd/content.c' || echo '$(srcdir)/'`btpd/content.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-content.Tpo btpd/$(DEPDIR)/btpd_btpd-content.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/content.c' object='btpd/btpd_btpd-content.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-content.o `test -f 'btpd/content.c' || echo '$(srcdir)/'`btpd/content.c btpd/btpd_btpd-content.obj: btpd/content.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-content.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-content.Tpo -c -o btpd/btpd_btpd-content.obj `if test -f 'btpd/content.c'; then $(CYGPATH_W) 'btpd/content.c'; else $(CYGPATH_W) '$(srcdir)/btpd/content.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-content.Tpo btpd/$(DEPDIR)/btpd_btpd-content.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/content.c' object='btpd/btpd_btpd-content.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-content.obj `if test -f 'btpd/content.c'; then $(CYGPATH_W) 'btpd/content.c'; else $(CYGPATH_W) '$(srcdir)/btpd/content.c'; fi` btpd/btpd_btpd-download.o: btpd/download.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-download.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-download.Tpo -c -o btpd/btpd_btpd-download.o `test -f 'btpd/download.c' || echo '$(srcdir)/'`btpd/download.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-download.Tpo btpd/$(DEPDIR)/btpd_btpd-download.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/download.c' object='btpd/btpd_btpd-download.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-download.o `test -f 'btpd/download.c' || echo '$(srcdir)/'`btpd/download.c btpd/btpd_btpd-download.obj: btpd/download.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-download.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-download.Tpo -c -o btpd/btpd_btpd-download.obj `if test -f 'btpd/download.c'; then $(CYGPATH_W) 'btpd/download.c'; else $(CYGPATH_W) '$(srcdir)/btpd/download.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-download.Tpo btpd/$(DEPDIR)/btpd_btpd-download.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/download.c' object='btpd/btpd_btpd-download.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-download.obj `if test -f 'btpd/download.c'; then $(CYGPATH_W) 'btpd/download.c'; else $(CYGPATH_W) '$(srcdir)/btpd/download.c'; fi` btpd/btpd_btpd-download_subr.o: btpd/download_subr.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-download_subr.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-download_subr.Tpo -c -o btpd/btpd_btpd-download_subr.o `test -f 'btpd/download_subr.c' || echo '$(srcdir)/'`btpd/download_subr.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-download_subr.Tpo btpd/$(DEPDIR)/btpd_btpd-download_subr.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/download_subr.c' object='btpd/btpd_btpd-download_subr.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-download_subr.o `test -f 'btpd/download_subr.c' || echo '$(srcdir)/'`btpd/download_subr.c btpd/btpd_btpd-download_subr.obj: btpd/download_subr.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-download_subr.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-download_subr.Tpo -c -o btpd/btpd_btpd-download_subr.obj `if test -f 'btpd/download_subr.c'; then $(CYGPATH_W) 'btpd/download_subr.c'; else $(CYGPATH_W) '$(srcdir)/btpd/download_subr.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-download_subr.Tpo btpd/$(DEPDIR)/btpd_btpd-download_subr.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/download_subr.c' object='btpd/btpd_btpd-download_subr.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-download_subr.obj `if test -f 'btpd/download_subr.c'; then $(CYGPATH_W) 'btpd/download_subr.c'; else $(CYGPATH_W) '$(srcdir)/btpd/download_subr.c'; fi` btpd/btpd_btpd-http_tr_if.o: btpd/http_tr_if.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-http_tr_if.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-http_tr_if.Tpo -c -o btpd/btpd_btpd-http_tr_if.o `test -f 'btpd/http_tr_if.c' || echo '$(srcdir)/'`btpd/http_tr_if.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-http_tr_if.Tpo btpd/$(DEPDIR)/btpd_btpd-http_tr_if.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/http_tr_if.c' object='btpd/btpd_btpd-http_tr_if.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-http_tr_if.o `test -f 'btpd/http_tr_if.c' || echo '$(srcdir)/'`btpd/http_tr_if.c btpd/btpd_btpd-http_tr_if.obj: btpd/http_tr_if.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-http_tr_if.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-http_tr_if.Tpo -c -o btpd/btpd_btpd-http_tr_if.obj `if test -f 'btpd/http_tr_if.c'; then $(CYGPATH_W) 'btpd/http_tr_if.c'; else $(CYGPATH_W) '$(srcdir)/btpd/http_tr_if.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-http_tr_if.Tpo btpd/$(DEPDIR)/btpd_btpd-http_tr_if.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/http_tr_if.c' object='btpd/btpd_btpd-http_tr_if.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-http_tr_if.obj `if test -f 'btpd/http_tr_if.c'; then $(CYGPATH_W) 'btpd/http_tr_if.c'; else $(CYGPATH_W) '$(srcdir)/btpd/http_tr_if.c'; fi` btpd/btpd_btpd-main.o: btpd/main.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-main.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-main.Tpo -c -o btpd/btpd_btpd-main.o `test -f 'btpd/main.c' || echo '$(srcdir)/'`btpd/main.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-main.Tpo btpd/$(DEPDIR)/btpd_btpd-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/main.c' object='btpd/btpd_btpd-main.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-main.o `test -f 'btpd/main.c' || echo '$(srcdir)/'`btpd/main.c btpd/btpd_btpd-main.obj: btpd/main.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-main.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-main.Tpo -c -o btpd/btpd_btpd-main.obj `if test -f 'btpd/main.c'; then $(CYGPATH_W) 'btpd/main.c'; else $(CYGPATH_W) '$(srcdir)/btpd/main.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-main.Tpo btpd/$(DEPDIR)/btpd_btpd-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/main.c' object='btpd/btpd_btpd-main.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-main.obj `if test -f 'btpd/main.c'; then $(CYGPATH_W) 'btpd/main.c'; else $(CYGPATH_W) '$(srcdir)/btpd/main.c'; fi` btpd/btpd_btpd-nameconn.o: btpd/nameconn.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-nameconn.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-nameconn.Tpo -c -o btpd/btpd_btpd-nameconn.o `test -f 'btpd/nameconn.c' || echo '$(srcdir)/'`btpd/nameconn.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-nameconn.Tpo btpd/$(DEPDIR)/btpd_btpd-nameconn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/nameconn.c' object='btpd/btpd_btpd-nameconn.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-nameconn.o `test -f 'btpd/nameconn.c' || echo '$(srcdir)/'`btpd/nameconn.c btpd/btpd_btpd-nameconn.obj: btpd/nameconn.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-nameconn.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-nameconn.Tpo -c -o btpd/btpd_btpd-nameconn.obj `if test -f 'btpd/nameconn.c'; then $(CYGPATH_W) 'btpd/nameconn.c'; else $(CYGPATH_W) '$(srcdir)/btpd/nameconn.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-nameconn.Tpo btpd/$(DEPDIR)/btpd_btpd-nameconn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/nameconn.c' object='btpd/btpd_btpd-nameconn.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-nameconn.obj `if test -f 'btpd/nameconn.c'; then $(CYGPATH_W) 'btpd/nameconn.c'; else $(CYGPATH_W) '$(srcdir)/btpd/nameconn.c'; fi` btpd/btpd_btpd-net.o: btpd/net.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-net.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-net.Tpo -c -o btpd/btpd_btpd-net.o `test -f 'btpd/net.c' || echo '$(srcdir)/'`btpd/net.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-net.Tpo btpd/$(DEPDIR)/btpd_btpd-net.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/net.c' object='btpd/btpd_btpd-net.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-net.o `test -f 'btpd/net.c' || echo '$(srcdir)/'`btpd/net.c btpd/btpd_btpd-net.obj: btpd/net.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-net.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-net.Tpo -c -o btpd/btpd_btpd-net.obj `if test -f 'btpd/net.c'; then $(CYGPATH_W) 'btpd/net.c'; else $(CYGPATH_W) '$(srcdir)/btpd/net.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-net.Tpo btpd/$(DEPDIR)/btpd_btpd-net.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/net.c' object='btpd/btpd_btpd-net.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-net.obj `if test -f 'btpd/net.c'; then $(CYGPATH_W) 'btpd/net.c'; else $(CYGPATH_W) '$(srcdir)/btpd/net.c'; fi` btpd/btpd_btpd-net_buf.o: btpd/net_buf.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-net_buf.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-net_buf.Tpo -c -o btpd/btpd_btpd-net_buf.o `test -f 'btpd/net_buf.c' || echo '$(srcdir)/'`btpd/net_buf.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-net_buf.Tpo btpd/$(DEPDIR)/btpd_btpd-net_buf.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/net_buf.c' object='btpd/btpd_btpd-net_buf.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-net_buf.o `test -f 'btpd/net_buf.c' || echo '$(srcdir)/'`btpd/net_buf.c btpd/btpd_btpd-net_buf.obj: btpd/net_buf.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-net_buf.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-net_buf.Tpo -c -o btpd/btpd_btpd-net_buf.obj `if test -f 'btpd/net_buf.c'; then $(CYGPATH_W) 'btpd/net_buf.c'; else $(CYGPATH_W) '$(srcdir)/btpd/net_buf.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-net_buf.Tpo btpd/$(DEPDIR)/btpd_btpd-net_buf.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/net_buf.c' object='btpd/btpd_btpd-net_buf.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-net_buf.obj `if test -f 'btpd/net_buf.c'; then $(CYGPATH_W) 'btpd/net_buf.c'; else $(CYGPATH_W) '$(srcdir)/btpd/net_buf.c'; fi` btpd/btpd_btpd-opts.o: btpd/opts.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-opts.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-opts.Tpo -c -o btpd/btpd_btpd-opts.o `test -f 'btpd/opts.c' || echo '$(srcdir)/'`btpd/opts.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-opts.Tpo btpd/$(DEPDIR)/btpd_btpd-opts.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/opts.c' object='btpd/btpd_btpd-opts.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-opts.o `test -f 'btpd/opts.c' || echo '$(srcdir)/'`btpd/opts.c btpd/btpd_btpd-opts.obj: btpd/opts.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-opts.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-opts.Tpo -c -o btpd/btpd_btpd-opts.obj `if test -f 'btpd/opts.c'; then $(CYGPATH_W) 'btpd/opts.c'; else $(CYGPATH_W) '$(srcdir)/btpd/opts.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-opts.Tpo btpd/$(DEPDIR)/btpd_btpd-opts.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/opts.c' object='btpd/btpd_btpd-opts.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-opts.obj `if test -f 'btpd/opts.c'; then $(CYGPATH_W) 'btpd/opts.c'; else $(CYGPATH_W) '$(srcdir)/btpd/opts.c'; fi` btpd/btpd_btpd-peer.o: btpd/peer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-peer.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-peer.Tpo -c -o btpd/btpd_btpd-peer.o `test -f 'btpd/peer.c' || echo '$(srcdir)/'`btpd/peer.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-peer.Tpo btpd/$(DEPDIR)/btpd_btpd-peer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/peer.c' object='btpd/btpd_btpd-peer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-peer.o `test -f 'btpd/peer.c' || echo '$(srcdir)/'`btpd/peer.c btpd/btpd_btpd-peer.obj: btpd/peer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-peer.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-peer.Tpo -c -o btpd/btpd_btpd-peer.obj `if test -f 'btpd/peer.c'; then $(CYGPATH_W) 'btpd/peer.c'; else $(CYGPATH_W) '$(srcdir)/btpd/peer.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-peer.Tpo btpd/$(DEPDIR)/btpd_btpd-peer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/peer.c' object='btpd/btpd_btpd-peer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-peer.obj `if test -f 'btpd/peer.c'; then $(CYGPATH_W) 'btpd/peer.c'; else $(CYGPATH_W) '$(srcdir)/btpd/peer.c'; fi` btpd/btpd_btpd-thread_cb.o: btpd/thread_cb.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-thread_cb.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-thread_cb.Tpo -c -o btpd/btpd_btpd-thread_cb.o `test -f 'btpd/thread_cb.c' || echo '$(srcdir)/'`btpd/thread_cb.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-thread_cb.Tpo btpd/$(DEPDIR)/btpd_btpd-thread_cb.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/thread_cb.c' object='btpd/btpd_btpd-thread_cb.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-thread_cb.o `test -f 'btpd/thread_cb.c' || echo '$(srcdir)/'`btpd/thread_cb.c btpd/btpd_btpd-thread_cb.obj: btpd/thread_cb.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-thread_cb.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-thread_cb.Tpo -c -o btpd/btpd_btpd-thread_cb.obj `if test -f 'btpd/thread_cb.c'; then $(CYGPATH_W) 'btpd/thread_cb.c'; else $(CYGPATH_W) '$(srcdir)/btpd/thread_cb.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-thread_cb.Tpo btpd/$(DEPDIR)/btpd_btpd-thread_cb.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/thread_cb.c' object='btpd/btpd_btpd-thread_cb.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-thread_cb.obj `if test -f 'btpd/thread_cb.c'; then $(CYGPATH_W) 'btpd/thread_cb.c'; else $(CYGPATH_W) '$(srcdir)/btpd/thread_cb.c'; fi` btpd/btpd_btpd-tlib.o: btpd/tlib.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-tlib.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-tlib.Tpo -c -o btpd/btpd_btpd-tlib.o `test -f 'btpd/tlib.c' || echo '$(srcdir)/'`btpd/tlib.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-tlib.Tpo btpd/$(DEPDIR)/btpd_btpd-tlib.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/tlib.c' object='btpd/btpd_btpd-tlib.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-tlib.o `test -f 'btpd/tlib.c' || echo '$(srcdir)/'`btpd/tlib.c btpd/btpd_btpd-tlib.obj: btpd/tlib.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-tlib.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-tlib.Tpo -c -o btpd/btpd_btpd-tlib.obj `if test -f 'btpd/tlib.c'; then $(CYGPATH_W) 'btpd/tlib.c'; else $(CYGPATH_W) '$(srcdir)/btpd/tlib.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-tlib.Tpo btpd/$(DEPDIR)/btpd_btpd-tlib.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/tlib.c' object='btpd/btpd_btpd-tlib.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-tlib.obj `if test -f 'btpd/tlib.c'; then $(CYGPATH_W) 'btpd/tlib.c'; else $(CYGPATH_W) '$(srcdir)/btpd/tlib.c'; fi` btpd/btpd_btpd-torrent.o: btpd/torrent.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-torrent.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-torrent.Tpo -c -o btpd/btpd_btpd-torrent.o `test -f 'btpd/torrent.c' || echo '$(srcdir)/'`btpd/torrent.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-torrent.Tpo btpd/$(DEPDIR)/btpd_btpd-torrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/torrent.c' object='btpd/btpd_btpd-torrent.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-torrent.o `test -f 'btpd/torrent.c' || echo '$(srcdir)/'`btpd/torrent.c btpd/btpd_btpd-torrent.obj: btpd/torrent.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-torrent.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-torrent.Tpo -c -o btpd/btpd_btpd-torrent.obj `if test -f 'btpd/torrent.c'; then $(CYGPATH_W) 'btpd/torrent.c'; else $(CYGPATH_W) '$(srcdir)/btpd/torrent.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-torrent.Tpo btpd/$(DEPDIR)/btpd_btpd-torrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/torrent.c' object='btpd/btpd_btpd-torrent.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-torrent.obj `if test -f 'btpd/torrent.c'; then $(CYGPATH_W) 'btpd/torrent.c'; else $(CYGPATH_W) '$(srcdir)/btpd/torrent.c'; fi` btpd/btpd_btpd-tracker_req.o: btpd/tracker_req.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-tracker_req.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-tracker_req.Tpo -c -o btpd/btpd_btpd-tracker_req.o `test -f 'btpd/tracker_req.c' || echo '$(srcdir)/'`btpd/tracker_req.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-tracker_req.Tpo btpd/$(DEPDIR)/btpd_btpd-tracker_req.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/tracker_req.c' object='btpd/btpd_btpd-tracker_req.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-tracker_req.o `test -f 'btpd/tracker_req.c' || echo '$(srcdir)/'`btpd/tracker_req.c btpd/btpd_btpd-tracker_req.obj: btpd/tracker_req.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-tracker_req.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-tracker_req.Tpo -c -o btpd/btpd_btpd-tracker_req.obj `if test -f 'btpd/tracker_req.c'; then $(CYGPATH_W) 'btpd/tracker_req.c'; else $(CYGPATH_W) '$(srcdir)/btpd/tracker_req.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-tracker_req.Tpo btpd/$(DEPDIR)/btpd_btpd-tracker_req.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/tracker_req.c' object='btpd/btpd_btpd-tracker_req.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-tracker_req.obj `if test -f 'btpd/tracker_req.c'; then $(CYGPATH_W) 'btpd/tracker_req.c'; else $(CYGPATH_W) '$(srcdir)/btpd/tracker_req.c'; fi` btpd/btpd_btpd-upload.o: btpd/upload.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-upload.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-upload.Tpo -c -o btpd/btpd_btpd-upload.o `test -f 'btpd/upload.c' || echo '$(srcdir)/'`btpd/upload.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-upload.Tpo btpd/$(DEPDIR)/btpd_btpd-upload.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/upload.c' object='btpd/btpd_btpd-upload.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-upload.o `test -f 'btpd/upload.c' || echo '$(srcdir)/'`btpd/upload.c btpd/btpd_btpd-upload.obj: btpd/upload.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-upload.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-upload.Tpo -c -o btpd/btpd_btpd-upload.obj `if test -f 'btpd/upload.c'; then $(CYGPATH_W) 'btpd/upload.c'; else $(CYGPATH_W) '$(srcdir)/btpd/upload.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-upload.Tpo btpd/$(DEPDIR)/btpd_btpd-upload.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/upload.c' object='btpd/btpd_btpd-upload.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-upload.obj `if test -f 'btpd/upload.c'; then $(CYGPATH_W) 'btpd/upload.c'; else $(CYGPATH_W) '$(srcdir)/btpd/upload.c'; fi` btpd/btpd_btpd-util.o: btpd/util.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-util.o -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-util.Tpo -c -o btpd/btpd_btpd-util.o `test -f 'btpd/util.c' || echo '$(srcdir)/'`btpd/util.c @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-util.Tpo btpd/$(DEPDIR)/btpd_btpd-util.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/util.c' object='btpd/btpd_btpd-util.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-util.o `test -f 'btpd/util.c' || echo '$(srcdir)/'`btpd/util.c btpd/btpd_btpd-util.obj: btpd/util.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -MT btpd/btpd_btpd-util.obj -MD -MP -MF btpd/$(DEPDIR)/btpd_btpd-util.Tpo -c -o btpd/btpd_btpd-util.obj `if test -f 'btpd/util.c'; then $(CYGPATH_W) 'btpd/util.c'; else $(CYGPATH_W) '$(srcdir)/btpd/util.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) btpd/$(DEPDIR)/btpd_btpd-util.Tpo btpd/$(DEPDIR)/btpd_btpd-util.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='btpd/util.c' object='btpd/btpd_btpd-util.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btpd_btpd_CFLAGS) $(CFLAGS) -c -o btpd/btpd_btpd-util.obj `if test -f 'btpd/util.c'; then $(CYGPATH_W) 'btpd/util.c'; else $(CYGPATH_W) '$(srcdir)/btpd/util.c'; fi` install-man1: $(dist_man1_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } 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) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi $(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 -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 -9 -c >$(distdir).tar.bz2 $(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 -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.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" \ $(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: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { 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-am all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(MANS) installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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) -rm -f btpd/$(DEPDIR)/$(am__dirstamp) -rm -f btpd/$(am__dirstamp) -rm -f cli/$(DEPDIR)/$(am__dirstamp) -rm -f cli/$(am__dirstamp) -rm -f evloop/$(DEPDIR)/$(am__dirstamp) -rm -f evloop/$(am__dirstamp) -rm -f misc/$(DEPDIR)/$(am__dirstamp) -rm -f misc/$(am__dirstamp) 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-binPROGRAMS clean-generic clean-noinstLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf btpd/$(DEPDIR) cli/$(DEPDIR) evloop/$(DEPDIR) misc/$(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-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf btpd/$(DEPDIR) cli/$(DEPDIR) evloop/$(DEPDIR) misc/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-man uninstall-man: uninstall-man1 .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ clean-binPROGRAMS clean-generic clean-noinstLIBRARIES ctags \ dist dist-all dist-bzip2 dist-gzip dist-lzma dist-shar \ dist-tarZ dist-xz dist-zip distcheck distclean \ distclean-compile distclean-generic distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ 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-man1 \ 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 pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-man uninstall-man1 # 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: btpd-0.16/install-sh0000755000175000001440000003253711426157640011332 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.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 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 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 trap '(exit $?); exit' 1 2 13 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 starting with `-'. 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 # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # 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 -z "$d" && 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: btpd-0.16/doc/0000755000175000001440000000000011426157674010150 500000000000000btpd-0.16/doc/btcli.10000644000175000001440000001356711425124761011251 00000000000000.TH BTCLI "1" "2010\-07\-31" "BitTorrent Protocol Daemon 0.16" "User Commands" .\" disable hyphenation .nh .\" adjust text to left margin only .ad l .\" ----------------------------------------------------------------- .\" MAIN CONTENT .\" ----------------------------------------------------------------- .SH "NAME" btcli \- command line interface to btpd .SH "SYNOPSIS" .B btcli \fIOPERATION\fR [\fIOPERATION_OPTIONS\fR] .SH "DESCRIPTION" .PP \fBbtcli\fR is a utility that interacts with a running btpd daemon. It has several different modes of operation. .SH "OPERATIONS" .PP One of the following operations must be specified when running btcli: .TP \fBadd\fR \- Add torrents to btpd. .TP \fBdel\fR \- Remove torrents from btpd. .TP \fBkill\fR \- Shut down btpd. .TP \fBlist\fR \- List torrents. .TP \fBstart\fR \- Activate torrents. .TP \fBstat\fR \- Display stats for active torrents. .TP \fBstop\fR \- Deactivate torrents. .TP \fB\-\-help\fR \fIOPERATION\fR Show help for the specified operation. .SH "ADD OPTIONS" .TP \fB\-d\fR dir Specifies the directory in which the files in the torrent will be downloaded; It does not specify \fBbtpd\fR's "work" directory. That is gathered from the environment variable \fI$HOME\fR. .TP \fB\-N, \-\-nostart\fR Do not start the torrent immediately after adding it. .TP \fB\-T, \-\-topdir\fR Append the torrent top directory (if any) to the content path. .TP \fB\-n\fR name Specifies the name to be displayed for this torrent. .SH "LIST OPTIONS" .TP \fB\-a\fR List active torrents. .TP \fB\-i\fR List inactive torrents. .TP \fB\-f\fR format Specifies a custom format to use while displaying torrents. The following is a list of the characters that can be used: .RS 8 .PP \fB%n\fR - torrent name .br \fB%#\fR - torrent number .br \fB%h\fR - torrent hash .br \fB%d\fR - download directory .br \fB%t\fR - state .br \fB%P\fR - peer count .PP \fB%^\fR - upload rate .br \fB%v\fR - download rate .PP \fB%D\fR - downloaded bytes .br \fB%U\fR - uploaded bytes .br \fB%g\fR - bytes got .br \fB%u\fR - bytes uploaded .br \fB%s\fR - total size, (formatted: prints K, M, G) .br \fB%S\fR - total size, in bytes .PP \fB%A\fR - available pieces .br \fB%T\fR - total pieces .br \fB%H\fR - have pieces .PP \fB%p\fR - percent have (formatted) .br \fB%r\fR - ratio .PP \fB%%\fR - a percent symbol: '%' .RE .SH "STAT OPTIONS" .TP \fB\-i\fR Display individual lines for each torrent. .TP \fB\-n\fR Display the name of each torrent. Implies '-i'. .SH "START OPTIONS" .TP \fB\-a\fR Activate all non-active torrents. .SH "STOP OPTIONS" .TP \fB\-a\fR Deactivate all torrents. .SH "USAGE" .PP btpd must be started before btcli can be used. See \fBbtpd\fR(1) for help with starting btpd. .PP To start sharing a torrent with btpd, the torrent needs to be added to btpd. This is done with \fBbtcli add\fR. Unless otherwise specified, btpd automatically starts to share the torrent and download any missing data. If the content directory you specify when adding a torrent does not exist, btpd will create it. .PP You can see which torrents have been added to btpd with \fBbtcli list\fR. The list mode also displays a number for each added torrent. This number can be used to specify the target torrent for the btcli modes, so you don't have to keep the torrent file after adding it. .PP The up\- and download progress can be followed by using the \fBbtcli stat\fR mode. Both the list and stat modes use the following indicators to display the state of a torrent: .RS 4 .TP 4 \fB+\fR The torrent is starting. This may take time if btpd needs to test the content of this torrent or one started before it. .TP 4 \fB\-\fR The torrent is being stopped. .TP 4 \fBI\fR The torrent is inactive. .TP 4 \fBS\fR btpd is seeding the torrent. .TP 4 \fBL\fR btpd is leeching the torrent. .RE .PP You can stop an active torrent with \fBbtcli stop\fR. You can start an inactive torrent by using \fBbtcli start\fR. .PP .B Note: Torrents can be specified either with its number or its file. .PP The \fBbtcli del\fR mode should only be used when you're totally finished with sharing a torrent. The mode will remove the torrent and its associated data from btpd. It is a bad idea to remove a not fully downloaded torrent and then add it again, since btpd has lost information on the not fully downloaded pieces and will need to download the data again. .PP To shut down btpd use \fBbtcli kill\fR. .SH "EXAMPLES" Display a list btpd's torrents and their number, size, status, etc. .RS 4 .B $ btcli list .RE .PP Same as above, but only for torrent 12 and my.little.torrent. .br .RS 4 .B $ btcli list 12 my.little.torrent .RE .PP Same as above but only for active torrents. .br .RS 4 .B $ btcli list \-a .RE .PP Add foo.torrent, with content dir foo.torrent.d, and start it. .br .RS 4 .B $ btcli add \-d foo.torrent.d foo.torrent .RE .PP Same as above without starting it. .br .RS 4 .B $ btcli add \-\-no\-start \-d foo.torrent.d foo.torrent .RE .PP Start bar.torrent and torrent number 7. .br .RS 4 .B $ btcli start bar.torrent 7 .RE .PP Stop torrent number 7. .br .RS 4 .B $ btcli stop 7 .RE .PP Stop all active torrents. .br .RS 4 .B $ btcli stop \-a .RE .PP Remove bar.torrent and it's associated information from btpd. .br .RS 4 .B $ btcli del bar.torrent .RE .PP Display a summary of up/download stats for the active torrents. .br .RS 4 .B $ btcli stat .RE .PP Display the summary once every five seconds. .br .RS 4 .B $ btcli stat \-w 5 .RE .PP Same as above, but also display individual stats for each active torrent. .br .RS 4 .B $ btcli stat \-w 5 \-i .RE .PP Shut down btpd. .br .RS 4 .B $ btcli kill .RE .SH "BUGS" Known bugs are listed at \fIhttp://github.com/queueRAM/btpd/issues\fR .sp Before submitting a bug report, please verify that you are running the latest version of btpd. .SH "AUTHORS" .sp Current maintainers: .sp \- Marq Schneider <\fIqueueRAM@gmail.com\fR> .sp Past contributors: .sp \- Richard Nyberg <\fIbtpd@murmeldjur.se\fR> .SH "SEE ALSO" .BR \fBbtpd\fR(1) .BR \fBbtinfo\fR(1) btpd-0.16/doc/btpd.10000644000175000001440000001160711425124777011105 00000000000000.TH BTPD "1" "2010\-07\-31" "BitTorrent Protocol Daemon 0.16" "User Commands" .\" disable hyphenation .nh .\" adjust text to left margin only .ad l .\" ----------------------------------------------------------------- .\" MAIN CONTENT .\" ----------------------------------------------------------------- .SH "NAME" btpd \- BitTorrent Protocol Daemon .SH "SYNOPSIS" .B btpd [\fB\-d\fR \fIdir\fR] [\fB\-p\fR \fIport\fR] [\fBOPTIONS\fR...] .SH "DESCRIPTION" Btpd is a utility for sharing files over the BitTorrent network protocol. It runs in daemon mode, thus needing no controlling terminal or gui. Instead, the daemon is controlled by \fBbtcli\fR, its control utility, or other programs capable of sending commands and queries on the control socket. .PP btpd consists of the following programs: .RS 4 \fBbtpd\fR \- The bittorrent client. .br \fBbtcli\fR \- Command line interface to btpd. .br \fBbtinfo\fR \- Shows information from a torrent file. .RE .PP All programs accept the \fB\-\-help\fR option. .SH "OPTIONS" .TP \fB\-d\fR \fIdir\fR The path for the btpd directory. Default is \fI$HOME/.btpd\fR. .TP \fB\-p\fR \fIn\fR, \fB\-\-port\fR \fIn\fR Listen at port \fIn\fR. Default is 6881. .TP \fB\-\-help\fR [\fImode\fR] Show this text or help for the specified mode. .TP .B \-4 Use IPv4. If given in conjunction with \fB\-6\fR, both versions are used. .TP .B \-6 Use IPv6. By default IPv4 is used. Unfortunately enabling both IPv6 and IPv4 in btpd is less useful than it should be. The problem is that some sites have trackers for both versions and it's likely that the IPv6 one, which probably has less peers, will be used in favour of the IPv4 one. .TP .B \-\-bw\-in \fIn\fR Limit incoming BitTorrent traffic to \fIn\fR kB/s. Default is 0 which means unlimited. .TP .B \-\-bw\-out \fIn\fR Limit outgoing BitTorrent traffic to \fIn\fR kB/s. Default is 0 which means unlimited. .TP .B \-\-empty\-start Start btpd without any active torrents. .TP .B \-\-ip \fIaddr\fR Let the tracker distribute the given address instead of the one it sees btpd connect from. .TP .B \-\-ipcprot \fImode\fR Set the protection mode of the command socket. The mode is specified by an octal number. Default is 0600. .TP .B \-\-logfile \fIfile\fR Where to put the logfile. By default it's put in the btpd dir. .TP .B \-\-max-peers \fIn\fR Limit the amount of peers to \fIn\fR. .TP .B \-\-max\-uploads n Controls the number of simultaneous uploads. The possible values are: .RS \fIn\fR < \-1 : Choose \fIn\fR >= 2 based on \fB\-\-bw\-out\fR (default). .br \fIn\fR = \-1 : Upload to every interested peer. .br \fIn\fR = 0 : Dont't upload to anyone. .br \fIn\fR > 0 : Upload to at most n peers simultaneously. .RE .TP .B \-\-no\-daemon Keep the btpd process in the foregorund and log to std{out,err}. This option is intended for debugging purposes. .TP .B \-\-prealloc \fIn\fR Preallocate disk space in chunks of \fIn\fR kB. Default is 2048. Note that \fIn\fR will be rounded up to the closest multiple of the torrent piece size. If \fIn\fR is zero no preallocation will be done. .SH "STARTING BTPD" To start btpd with default settings you only need to run it. However, there are many useful options you may want to use. To see a full list run \fBbtpd \-\-help\fR. If you didn't specify otherwise, btpd starts with the same set of active torrents as it had the last time it was shut down. .PP \fBbtdp\fR will store information and write its log in \fI$HOME/.btpd\fR. Therefore it needs to be able to write there during its execution. You can specify another directory via the \fB\-d\fR option or the \fI$BTPD_HOME\fR variable. .PP It is recommended to specifiy the maximum number of uploads. Bittorrent employs a tit for tat algorithm, so uploading at good rates allows for downloading. Try to find a balance between uploads/outgoing bandwidth and the number of active torrents. .PP .B Note: You should only need one instance of btpd regardless of how many torrents you want to share. .SH "EXAMPLES" Start btpd with all options set to their default values. .RS 4 .nf .B $ btpd .fi .RE .PP Start btpd as above, but with torrent data in the directory /var/torrents .RS 4 .nf .B $ btpd \-d /var/torrents .fi .RE .PP Start btpd and make it listen on port 12345, limit outgoing bandwidth to 200kB/s, limit the number of peers to 40 and not start any torrents that were active the last time btpd was shut down. .RS 4 .nf .B $ btpd \-p 12345 \-\-bw\-out 200 \-\-max\-peers 40 \-\-empty\-start .fi .RE .SH "TROUBLESHOOTING" If \fBbtpd\fR has shut down for some unknown reason, check the logfile for possible clues. .SH "BUGS" Known bugs are listed at \fIhttp://github.com/queueRAM/btpd/issues\fR .sp Before submitting a bug report, please verify that you are running the latest version of btpd. .SH "AUTHORS" .sp Current maintainers: .sp \- Marq Schneider <\fIqueueRAM@gmail.com\fR> .sp Past contributors: .sp \- Richard Nyberg <\fIbtpd@murmeldjur.se\fR> .SH "SEE ALSO" .BR \fBbtcli\fR(1) .BR \fBbtinfo\fR(1) btpd-0.16/doc/btinfo.10000644000175000001440000000250411425125016011414 00000000000000.TH BTINFO "1" "2010\-07\-31" "BitTorrent Protocol Daemon 0.16" "User Commands" .\" disable hyphenation .nh .\" adjust text to left margin only .ad l .\" ----------------------------------------------------------------- .\" MAIN CONTENT .\" ----------------------------------------------------------------- .SH "NAME" btinfo \- BitTorrent Protocol Daemon information .SH "SYNOPSIS" .B btinfo \fIfile\fR .SH "EXAMPLE" List the torrent information for \fBosol\-0906\-x86.iso.torrent\fR .PP .nf .B $ btinfo /var/torrents/osol\-0906\-x86.iso.torrent Name: osol\-0906\-x86.iso Info hash: 58aca632a9f68427a8ac8f58cafa7a72ca067dba Tracker URLs: [ [ http://dlc.sun.com:6969/announce ] [ http://dlc.sun.com:16969/announce ] ] Number of pieces: 1354 Piece size: 524288 Total size: 709871616 Number of files: 1 Files: osol-0906-x86.iso (709871616) .fi .SH "TROUBLESHOOTING" If \fBbtpd\fR has shut down for some unknown reason, check the logfile for possible clues. .SH "BUGS" Known bugs are listed at \fIhttp://github.com/queueRAM/btpd/issues\fR .sp Before submitting a bug report, please verify that you are running the latest version of btpd. .SH "AUTHORS" .sp Current maintainers: .sp \- Marq Schneider <\fIqueueRAM@gmail.com\fR> .sp Past contributors: .sp \- Richard Nyberg <\fIbtpd@murmeldjur.se\fR> .SH "SEE ALSO" .BR \fBbtpd\fR(1) .BR \fBbtcli\fR(1) btpd-0.16/compile0000755000175000001440000000727111426157640010701 00000000000000#! /bin/sh # Wrapper for compilers which do not understand `-c -o'. scriptversion=2009-10-06.20; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software # Foundation, Inc. # Written by Tom Tromey . # # 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. # This file is maintained in Automake, please report # bugs to or send patches to # . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand `-c -o'. Remove `-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file `INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; esac ofile= cfile= eat= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as `compile cc -o foo foo.c'. # So we strip `-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no `-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use `[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # 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: btpd-0.16/COPYRIGHT0000644000175000001440000000600111425123756010604 00000000000000The btpd software is distributed under the following terms: Copyright (c) 2005-2009 Richard Nyberg . All rights reserved. Copyright (c) 2010 Marq Schneider . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Additionally, the part of the btpd code contained in misc/queue.h is covered by the following license: Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. btpd-0.16/evloop/0000755000175000001440000000000011426157674010707 500000000000000btpd-0.16/evloop/epoll.c0000644000175000001440000000553711417473677012124 00000000000000#include #include #include #include #include "evloop.h" static int m_epfd; static struct epoll_event m_evs[100]; static uint8_t m_valid[100]; int evloop_init(void) { if (timeheap_init() != 0) return -1; m_epfd = epoll_create(getdtablesize()); return m_epfd >= 0 ? 0 : -1; } int fdev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb, void *arg) { ev->fd = fd; ev->cb = cb; ev->arg = arg; ev->flags = 0; ev->index = -1; return fdev_enable(ev, flags); } int fdev_enable(struct fdev *ev, uint16_t flags) { struct epoll_event epev; int err = 0; uint16_t sf = ev->flags; ev->flags |= flags; if (sf != ev->flags) { epev.data.ptr = ev; epev.events = ((ev->flags & EV_READ) ? EPOLLIN : 0) | ((ev->flags & EV_WRITE) ? EPOLLOUT : 0); if (sf == 0) err = epoll_ctl(m_epfd, EPOLL_CTL_ADD, ev->fd, &epev); else err = epoll_ctl(m_epfd, EPOLL_CTL_MOD, ev->fd, &epev); } return err; } int fdev_disable(struct fdev *ev, uint16_t flags) { struct epoll_event epev; int err = 0; uint16_t sf = ev->flags; ev->flags &= ~flags; if (sf != ev->flags) { epev.data.ptr = ev; epev.events = ((ev->flags & EV_READ) ? EPOLLIN : 0) | ((ev->flags & EV_WRITE) ? EPOLLOUT : 0); if (ev->flags == 0) err = epoll_ctl(m_epfd, EPOLL_CTL_DEL, ev->fd, &epev); else err = epoll_ctl(m_epfd, EPOLL_CTL_MOD, ev->fd, &epev); } return err; } int fdev_del(struct fdev *ev) { if (ev->index >= 0) m_valid[ev->index] = 0; return fdev_disable(ev, EV_READ|EV_WRITE); } int evloop(void) { int nev, i, millisecs; struct timespec delay; while (1) { evtimers_run(); delay = evtimer_delay(); if (delay.tv_sec >= 0) millisecs = delay.tv_sec * 1000 + delay.tv_nsec / 1000000; else millisecs = -1; if ((nev = epoll_wait(m_epfd, m_evs, 100, millisecs)) < 0) { if (errno == EINTR) continue; else return -1; } memset(m_valid, 1, nev); for (i = 0; i < nev; i++) { struct fdev *ev = m_evs[i].data.ptr; ev->index = i; } for (i = 0; i < nev; i++) { struct fdev *ev = m_evs[i].data.ptr; if ((m_valid[i] && ev->flags & EV_READ && m_evs[i].events & (EPOLLIN|EPOLLERR|EPOLLHUP))) ev->cb(ev->fd, EV_READ, ev->arg); if ((m_valid[i] && ev->flags & EV_WRITE && m_evs[i].events & (EPOLLOUT|EPOLLERR|EPOLLHUP))) ev->cb(ev->fd, EV_WRITE, ev->arg); if (m_valid[i]) ev->index = -1; } } } btpd-0.16/evloop/evloop.h0000644000175000001440000000222111417473677012305 00000000000000#ifndef BTPD_EVLOOP_H #define BTPD_EVLOOP_H #include #include #include "timeheap.h" #define EV_READ 1 #define EV_WRITE 2 #define EV_TIMEOUT 3 typedef void (*evloop_cb_t)(int fd, short type, void *arg); #if defined(EVLOOP_EPOLL) || defined(EVLOOP_KQUEUE) struct fdev { evloop_cb_t cb; void *arg; int fd; uint16_t flags; #ifdef EVLOOP_EPOLL int16_t index; #else int16_t rdidx; int16_t wridx; #endif }; #elif defined(EVLOOP_POLL) struct fdev { int i; }; #else #error No evloop method defined. #endif struct timeout { evloop_cb_t cb; void *arg; struct th_handle th; }; int evloop_init(void); int evloop(void); int fdev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb, void *arg); int fdev_del(struct fdev *ev); int fdev_enable(struct fdev *ev, uint16_t flags); int fdev_disable(struct fdev *ev, uint16_t flags); void evtimer_init(struct timeout *, evloop_cb_t, void *); int evtimer_add(struct timeout *, struct timespec *); void evtimer_del(struct timeout *); void evtimers_run(void); struct timespec evtimer_delay(void); int evtimer_gettime(struct timespec *); #endif btpd-0.16/evloop/timer.c0000644000175000001440000000532211417473677012121 00000000000000#include #include "evloop.h" #include "timeheap.h" #if defined(HAVE_CLOCK_MONOTONIC) #ifdef CLOCK_MONOTONIC_FAST #define TIMER_CLOCK CLOCK_MONOTONIC_FAST #else #define TIMER_CLOCK CLOCK_MONOTONIC #endif int evtimer_gettime(struct timespec *ts) { return clock_gettime(TIMER_CLOCK, ts); } #elif defined(HAVE_MACH_ABSOLUTE_TIME) #include int evtimer_gettime(struct timespec *ts) { uint64_t nsecs; static double nsmul; static mach_timebase_info_data_t nsratio = { 0, 0 }; if (nsratio.denom == 0) { mach_timebase_info(&nsratio); nsmul = (double)nsratio.numer / nsratio.denom; } nsecs = mach_absolute_time() * nsmul; ts->tv_sec = nsecs / 1000000000ULL; ts->tv_nsec = nsecs - ts->tv_sec * 1000000000ULL; return 0; } #else #error No supported time mechanism #endif static struct timespec addtime(struct timespec a, struct timespec b) { struct timespec ret; ret.tv_sec = a.tv_sec + b.tv_sec; ret.tv_nsec = a.tv_nsec + b.tv_nsec; if (ret.tv_nsec >= 1000000000) { ret.tv_sec += 1; ret.tv_nsec -= 1000000000; } return ret; } static struct timespec subtime(struct timespec a, struct timespec b) { struct timespec ret; ret.tv_sec = a.tv_sec - b.tv_sec; ret.tv_nsec = a.tv_nsec - b.tv_nsec; if (ret.tv_nsec < 0) { ret.tv_sec -= 1; ret.tv_nsec += 1000000000; } return ret; } void evtimer_init(struct timeout *h, evloop_cb_t cb, void *arg) { h->cb = cb; h->arg = arg; h->th.i = -1; h->th.data = h; } int evtimer_add(struct timeout *h, struct timespec *t) { struct timespec now, sum; evtimer_gettime(&now); sum = addtime(now, *t); if (h->th.i == -1) return timeheap_insert(&h->th, &sum); else { timeheap_change(&h->th, &sum); return 0; } } void evtimer_del(struct timeout *h) { if (h->th.i >= 0) { timeheap_remove(&h->th); h->th.i = -1; } } void evtimers_run(void) { struct timespec now; evtimer_gettime(&now); while (timeheap_size() > 0) { struct timespec diff = subtime(timeheap_top(), now); if (diff.tv_sec < 0 || (diff.tv_sec == 0 && diff.tv_nsec < 1000000)) { struct timeout *t = timeheap_remove_top(); t->th.i = -1; t->cb(-1, EV_TIMEOUT, t->arg); } else break; } } struct timespec evtimer_delay(void) { struct timespec now, diff; if (timeheap_size() == 0) { diff.tv_sec = -1; diff.tv_nsec = 0; } else { evtimer_gettime(&now); diff = subtime(timeheap_top(), now); if (diff.tv_sec < 0) { diff.tv_sec = 0; diff.tv_nsec = 0; } } return diff; } btpd-0.16/evloop/timeheap.h0000644000175000001440000000061511417473677012602 00000000000000#ifndef BTPD_TIMEHEAP_H #define BTPD_TIMEHEAP_H struct th_handle { int i; void *data; }; int timeheap_init(void); int timeheap_size(void); int timeheap_insert(struct th_handle *h, struct timespec *t); void timeheap_remove(struct th_handle *h); void timeheap_change(struct th_handle *h, struct timespec *t); void *timeheap_remove_top(void); struct timespec timeheap_top(void); #endif btpd-0.16/evloop/kqueue.c0000644000175000001440000000656011417473677012305 00000000000000#include #include #include #include #include #include #include "evloop.h" static int m_kq; static struct kevent m_evs[100]; static uint8_t m_valid[100]; int evloop_init(void) { if (timeheap_init() != 0) return -1; m_kq = kqueue(); return m_kq >= 0 ? 0 : -1; } int fdev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb, void *arg) { ev->fd = fd; ev->cb = cb; ev->arg = arg; ev->flags = 0; ev->rdidx = -1; ev->wridx = -1; return fdev_enable(ev, flags); } int fdev_enable(struct fdev *ev, uint16_t flags) { struct kevent kev[2], *kp = NULL; int count = 0; uint16_t sf = ev->flags; ev->flags |= flags; if ((sf & EV_READ) == 0 && (flags & EV_READ) != 0) { EV_SET(&kev[0], ev->fd, EVFILT_READ, EV_ADD, 0, 0, ev); kp = kev; count = 1; } if ((sf & EV_WRITE) == 0 && (flags & EV_WRITE) != 0) { EV_SET(&kev[1], ev->fd, EVFILT_WRITE, EV_ADD, 0, 0, ev); if (count == 0) kp = &kev[1]; count++; } return count > 0 ? kevent(m_kq, kp, count, NULL, 0, NULL) : 0; } int fdev_disable(struct fdev *ev, uint16_t flags) { struct kevent kev[2], *kp = NULL; int count = 0; uint16_t sf = ev->flags; ev->flags &= ~flags; if ((sf & EV_READ) != 0 && (flags & EV_READ) != 0) { EV_SET(&kev[0], ev->fd, EVFILT_READ, EV_DELETE, 0, 0, ev); kp = kev; count = 1; } if ((sf & EV_WRITE) != 0 && (flags & EV_WRITE) != 0) { EV_SET(&kev[1], ev->fd, EVFILT_WRITE, EV_DELETE, 0, 0, ev); if (count == 0) kp = &kev[1]; count++; } return count > 0 ? kevent(m_kq, kp, count, NULL, 0, NULL) : 0; } int fdev_del(struct fdev *ev) { if (ev->rdidx >= 0) m_valid[ev->rdidx] = 0; if (ev->wridx >= 0) m_valid[ev->wridx] = 0; return fdev_disable(ev, EV_READ|EV_WRITE); } int evloop(void) { int nev, i; struct timespec delay; while (1) { evtimers_run(); delay = evtimer_delay(); if ((nev = kevent(m_kq, NULL, 0, m_evs, 100, &delay)) < 0) { if (errno == EINTR) continue; else return -1; } memset(m_valid, 1, nev); for (i = 0; i < nev; i++) { if (m_evs[i].flags & EV_ERROR) { errno = m_evs[i].data; return -1; } struct fdev *ev = (struct fdev *)m_evs[i].udata; switch (m_evs[i].filter) { case EVFILT_READ: ev->rdidx = i; break; case EVFILT_WRITE: ev->wridx = i; break; } } for (i = 0; i < nev; i++) { if (!m_valid[i]) continue; struct fdev *ev = (struct fdev *)m_evs[i].udata; switch (m_evs[i].filter) { case EVFILT_READ: if (ev->flags & EV_READ) ev->cb(ev->fd, EV_READ, ev->arg); if (m_valid[i]) ev->rdidx = -1; break; case EVFILT_WRITE: if (ev->flags & EV_WRITE) ev->cb(ev->fd, EV_WRITE, ev->arg); if (m_valid[i]) ev->wridx = -1; break; } } } } btpd-0.16/evloop/timeheap.c0000644000175000001440000000514711417473677012602 00000000000000#include #include #include #include "timeheap.h" struct th_entry { struct timespec t; struct th_handle *h; }; static struct th_entry *heap; static int heap_cap; static int heap_use; static int cmptime_lt(struct timespec a, struct timespec b) { if (a.tv_sec == b.tv_sec) return a.tv_nsec < b.tv_nsec; else return a.tv_sec < b.tv_sec; } static int cmpentry_lt(int a, int b) { return cmptime_lt(heap[a].t, heap[b].t); } static void swap(int i, int j) { struct th_entry tmp = heap[i]; heap[i] = heap[j]; heap[i].h->i = i; heap[j] = tmp; heap[j].h->i = j; } static void bubble_up(int i) { while (i != 0) { int p = (i-1)/2; if (cmpentry_lt(i, p)) { swap(i, p); i = p; } else return; } } static void bubble_down(int i) { int li, ri, ci; loop: li = 2*i+1; ri = 2*i+2; if (ri < heap_use) ci = cmpentry_lt(li, ri) ? li : ri; else if (li < heap_use) ci = li; else return; if (cmpentry_lt(ci, i)) { swap(i, ci); i = ci; goto loop; } } int timeheap_init(void) { heap_cap = 10; heap_use = 0; if ((heap = malloc(sizeof(struct th_entry) * heap_cap)) == NULL) return -1; else return 0; } int timeheap_size(void) { return heap_use; } int timeheap_insert(struct th_handle *h, struct timespec *t) { if (heap_use == heap_cap) { int ncap = heap_cap * 2; struct th_entry *nheap = realloc(heap, ncap * sizeof(struct th_entry)); if (nheap == NULL) return -1; heap_cap = ncap; heap = nheap; } heap[heap_use].t = *t; heap[heap_use].h = h; h->i = heap_use; heap_use++; bubble_up(h->i); return 0; } void timeheap_remove(struct th_handle *h) { assert(h->i >= 0 && h->i < heap_use); heap_use--; if (heap_use > 0) { int i = h->i; int earlier = cmpentry_lt(heap_use, i); heap[i] = heap[heap_use]; heap[i].h->i = i; if (earlier) bubble_up(i); else bubble_down(i); } } void timeheap_change(struct th_handle *h, struct timespec *t) { assert(h->i >= 0 && h->i < heap_use); int earlier = cmptime_lt(*t, heap[h->i].t); heap[h->i].t = *t; if (earlier) bubble_up(h->i); else bubble_down(h->i); } struct timespec timeheap_top(void) { return heap[0].t; } void * timeheap_remove_top(void) { void *ret = heap[0].h->data; struct th_handle h = { 0, NULL }; timeheap_remove(&h); return ret; } btpd-0.16/evloop/poll.c0000644000175000001440000000616611417473677011756 00000000000000#include #include #include #include #include #include "evloop.h" #define POLL_INIT_SIZE 64 struct poll_ev { struct fdev *ev; evloop_cb_t cb; void *arg; }; static struct pollfd *m_pfds; static struct poll_ev *m_pevs; static int m_cap, m_size; static int m_cur = -1, m_curdel; static int poll_grow(void) { int ncap = m_cap * 2; struct pollfd *nm_pfds = realloc(m_pfds, ncap * sizeof(*m_pfds)); struct poll_ev *nm_pevs = realloc(m_pevs, ncap * sizeof(*m_pevs)); if (nm_pfds != NULL) m_pfds = nm_pfds; if (nm_pevs != NULL) m_pevs = nm_pevs; if (nm_pfds == NULL || nm_pevs == NULL) return errno; m_cap = ncap; return 0; } int evloop_init(void) { if (timeheap_init() != 0) return -1; m_cap = POLL_INIT_SIZE; m_size = 0; if ((m_pfds = calloc(m_cap, sizeof(*m_pfds))) == NULL) return -1; if ((m_pevs = calloc(m_cap, sizeof(*m_pevs))) == NULL) { free(m_pfds); return -1; } return 0; } int fdev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb, void *arg) { if (m_size == m_cap && poll_grow() != 0) return errno; ev->i = m_size; m_size++; m_pfds[ev->i].fd = fd; m_pfds[ev->i].events = ((flags & EV_READ) ? POLLIN : 0) | ((flags & EV_WRITE) ? POLLOUT : 0); m_pevs[ev->i].ev = ev; m_pevs[ev->i].cb = cb; m_pevs[ev->i].arg = arg; return 0; } int fdev_enable(struct fdev *ev, uint16_t flags) { m_pfds[ev->i].events |= ((flags & EV_READ) ? POLLIN : 0) | ((flags & EV_WRITE) ? POLLOUT : 0); return 0; } int fdev_disable(struct fdev *ev, uint16_t flags) { short pflags = ((flags & EV_READ) ? POLLIN : 0) | ((flags & EV_WRITE) ? POLLOUT : 0); m_pfds[ev->i].events &= ~pflags; return 0; } int fdev_del(struct fdev *ev) { assert(ev->i < m_size); m_size--; m_pfds[ev->i] = m_pfds[m_size]; m_pevs[ev->i] = m_pevs[m_size]; m_pevs[ev->i].ev->i = ev->i; if (ev->i == m_cur) m_curdel = 1; return 0; } int evloop(void) { int millisecs; struct timespec delay; while (1) { evtimers_run(); delay = evtimer_delay(); if (delay.tv_sec >= 0) millisecs = delay.tv_sec * 1000 + delay.tv_nsec / 1000000; else millisecs = -1; if (poll(m_pfds, m_size, millisecs) < 0) { if (errno == EINTR) continue; else return -1; } m_cur = 0; while (m_cur < m_size) { struct pollfd *pfd = &m_pfds[m_cur]; struct poll_ev *pev = &m_pevs[m_cur]; if ((pfd->events & POLLIN && pfd->revents & (POLLIN|POLLERR|POLLHUP))) pev->cb(pfd->fd, EV_READ, pev->arg); if ((!m_curdel && pfd->events & POLLOUT && pfd->revents & (POLLOUT|POLLERR|POLLHUP))) pev->cb(pfd->fd, EV_WRITE, pev->arg); if (!m_curdel) m_cur++; else m_curdel = 0; } m_cur = -1; } } btpd-0.16/btpd/0000755000175000001440000000000011426157674010334 500000000000000btpd-0.16/btpd/upload.h0000644000175000001440000000041011417473677011710 00000000000000#ifndef BTPD_UPLOAD_H #define BTPD_UPLOAD_H void ul_on_new_peer(struct peer *p); void ul_on_lost_peer(struct peer *p); void ul_on_lost_torrent(struct net *n); void ul_on_interest(struct peer *p); void ul_on_uninterest(struct peer *p); void ul_init(void); #endif btpd-0.16/btpd/net.h0000644000175000001440000000175511417473677011227 00000000000000#ifndef BTPD_NET_H #define BTPD_NET_H #define MSG_CHOKE 0 #define MSG_UNCHOKE 1 #define MSG_INTEREST 2 #define MSG_UNINTEREST 3 #define MSG_HAVE 4 #define MSG_BITFIELD 5 #define MSG_REQUEST 6 #define MSG_PIECE 7 #define MSG_CANCEL 8 #define RATEHISTORY 20 extern struct peer_tq net_unattached; extern struct peer_tq net_bw_readq; extern struct peer_tq net_bw_writeq; extern unsigned net_npeers; void net_init(void); void net_on_tick(void); void net_create(struct torrent *tp); void net_kill(struct torrent *tp); void net_start(struct torrent *tp); void net_stop(struct torrent *tp); int net_active(struct torrent *tp); void net_ban_peer(struct net *n, struct meta_peer *mp); int net_torrent_has_peer(struct net *n, const uint8_t *id); void net_io_cb(int sd, short type, void *arg); int net_connect_addr(int family, struct sockaddr *sa, socklen_t salen, int *sd); int net_connect_name(const char *ip, int port, int *sd); int net_af_spec(void); #endif btpd-0.16/btpd/torrent.c0000644000175000001440000001355211417473677012127 00000000000000#include "btpd.h" #include #define SAVE_INTERVAL 300 static unsigned m_nghosts; static unsigned m_ntorrents; static struct torrent_tq m_torrents = BTPDQ_HEAD_INITIALIZER(m_torrents); static unsigned m_tsave; static struct torrent *m_savetp; const struct torrent_tq * torrent_get_all(void) { return &m_torrents; } unsigned torrent_count(void) { return m_ntorrents; } unsigned torrent_ghosts(void) { return m_nghosts; } struct torrent * torrent_by_num(unsigned num) { struct tlib *tl = tlib_by_num(num); return tl != NULL ? tl->tp : NULL; } struct torrent * torrent_by_hash(const uint8_t *hash) { struct tlib *tl = tlib_by_hash(hash); return tl != NULL ? tl->tp : NULL; } const char * torrent_name(struct torrent *tp) { return tp->tl->name; } off_t torrent_piece_size(struct torrent *tp, uint32_t index) { if (index < tp->npieces - 1) return tp->piece_length; else { off_t allbutlast = tp->piece_length * (tp->npieces - 1); return tp->total_length - allbutlast; } } uint32_t torrent_piece_blocks(struct torrent *tp, uint32_t piece) { return ceil(torrent_piece_size(tp, piece) / (double)PIECE_BLOCKLEN); } uint32_t torrent_block_size(struct torrent *tp, uint32_t piece, uint32_t nblocks, uint32_t block) { if (block < nblocks - 1) return PIECE_BLOCKLEN; else { uint32_t allbutlast = PIECE_BLOCKLEN * (nblocks - 1); return torrent_piece_size(tp, piece) - allbutlast; } } static void torrent_kill(struct torrent *tp) { assert(m_ntorrents > 0); assert(!(net_active(tp) || cm_active(tp))); if (tp->state == T_GHOST) m_nghosts--; m_ntorrents--; BTPDQ_REMOVE(&m_torrents, tp, entry); if (tp->delete) tlib_kill(tp->tl); else tp->tl->tp = NULL; tr_kill(tp); net_kill(tp); cm_kill(tp); mi_free_files(tp->nfiles, tp->files); if (m_savetp == tp) if ((m_savetp = BTPDQ_NEXT(tp, entry)) == NULL) m_savetp = BTPDQ_FIRST(&m_torrents); free(tp); } enum ipc_err torrent_start(struct tlib *tl) { struct torrent *tp; char *mi; if (tl->tp != NULL) { assert(torrent_startable(tl)); torrent_kill(tl->tp); tl->tp = NULL; } if (tl->dir == NULL) return IPC_EBADTENT; if (tlib_load_mi(tl, &mi) != 0) return IPC_EBADTENT; tp = btpd_calloc(1, sizeof(*tp)); tp->tl = tl; tp->files = mi_files(mi); tp->nfiles = mi_nfiles(mi); if (tp->files == NULL) btpd_err("out of memory.\n"); tp->total_length = mi_total_length(mi); tp->piece_length = mi_piece_length(mi); tp->npieces = mi_npieces(mi); tp->pieces_off = benc_dget_mem(benc_dget_dct(mi, "info"), "pieces", NULL) - mi; btpd_log(BTPD_L_BTPD, "Starting torrent '%s'.\n", torrent_name(tp)); tr_create(tp, mi); tl->tp = tp; net_create(tp); cm_create(tp, mi); BTPDQ_INSERT_TAIL(&m_torrents, tp, entry); m_ntorrents++; cm_start(tp, 0); free(mi); if (m_ntorrents == 1) { m_tsave = btpd_seconds + SAVE_INTERVAL; m_savetp = tp; } return IPC_OK; } static void become_ghost(struct torrent *tp) { btpd_log(BTPD_L_BTPD, "Stopped torrent '%s'.\n", torrent_name(tp)); tp->state = T_GHOST; if (tp->delete) tlib_del(tp->tl); else tlib_update_info(tp->tl, 0); m_nghosts++; } void torrent_stop(struct torrent *tp, int delete) { if (delete) tp->delete = 1; switch (tp->state) { case T_LEECH: case T_SEED: case T_STARTING: tp->state = T_STOPPING; if (net_active(tp)) net_stop(tp); if (tr_active(tp)) tr_stop(tp); if (cm_active(tp)) cm_stop(tp); if (!cm_active(tp)) { become_ghost(tp); if (!tr_active(tp)) torrent_kill(tp); } break; default: break; } } void torrent_on_tick(struct torrent *tp) { if (tp->state != T_STOPPING && cm_error(tp)) torrent_stop(tp, 0); switch (tp->state) { case T_STARTING: if (cm_started(tp)) { if (cm_full(tp)) tp->state = T_SEED; else tp->state = T_LEECH; net_start(tp); tr_start(tp); } break; case T_LEECH: if (cm_full(tp)) { struct peer *p, *next; tp->state = T_SEED; btpd_log(BTPD_L_BTPD, "Finished downloading '%s'.\n", torrent_name(tp)); tr_complete(tp); BTPDQ_FOREACH_MUTABLE(p, &tp->net->peers, p_entry, next) { assert(p->nwant == 0); if (peer_full(p)) peer_kill(p); } } break; case T_STOPPING: if (cm_active(tp)) break; become_ghost(tp); case T_GHOST: if (!tr_active(tp)) torrent_kill(tp); break; default: break; } } void torrent_on_tick_all(void) { struct torrent *tp, *next; BTPDQ_FOREACH_MUTABLE(tp, &m_torrents, entry, next) torrent_on_tick(tp); if (m_savetp != NULL && m_tsave <= btpd_seconds) { if (m_savetp->state == T_LEECH || m_savetp->state == T_SEED) { tlib_update_info(m_savetp->tl, 1); if ((m_savetp = BTPDQ_NEXT(m_savetp, entry)) == NULL) m_savetp = BTPDQ_FIRST(&m_torrents); if (m_ntorrents > 0) m_tsave = btpd_seconds + max(m_ntorrents, SAVE_INTERVAL) / m_ntorrents; } } } int torrent_active(struct tlib *tl) { return tl->tp != NULL && tl->tp->state != T_GHOST; } int torrent_startable(struct tlib *tl) { return tl->tp == NULL || (tl->tp->state == T_GHOST && !tl->tp->delete); } int torrent_haunting(struct tlib *tl) { return tl->tp != NULL && tl->tp->delete && tl->tp->state == T_GHOST; } btpd-0.16/btpd/content.c0000644000175000001440000003312111417473677012076 00000000000000#include "btpd.h" #include #include struct content { enum { CM_INACTIVE, CM_STARTING, CM_ACTIVE } state; int error; uint32_t npieces_got; off_t ncontent_bytes; size_t bppbf; // bytes per piece block field uint8_t *piece_field; uint8_t *block_field; uint8_t *pos_field; struct bt_stream *rds; struct bt_stream *wrs; struct resume_data *resd; }; #define ZEROBUFLEN (1 << 14) static const uint8_t m_zerobuf[ZEROBUFLEN]; static int fd_cb_rd(const char *path, int *fd, void *arg) { struct torrent *tp = arg; return vopen(fd, O_RDONLY, "%s/%s", tp->tl->dir, path); } static int fd_cb_wr(const char *path, int *fd, void *arg) { struct torrent *tp = arg; return vopen(fd, O_RDWR, "%s/%s", tp->tl->dir, path); } struct start_test_data { struct torrent *tp; struct file_time_size *fts; uint32_t start; BTPDQ_ENTRY(start_test_data) entry; }; BTPDQ_HEAD(std_tq, start_test_data); static struct std_tq m_startq = BTPDQ_HEAD_INITIALIZER(m_startq); static struct timeout m_workev; #define READBUFLEN (1 << 14) static int test_hash(struct torrent *tp, uint8_t *hash, uint32_t piece) { char piece_hash[SHA_DIGEST_LENGTH]; tlib_read_hash(tp->tl, tp->pieces_off, piece, piece_hash); return bcmp(hash, piece_hash, SHA_DIGEST_LENGTH); } static int test_piece(struct torrent *tp, uint32_t piece, int *ok) { int err; uint8_t hash[SHA_DIGEST_LENGTH]; if ((err = bts_sha(tp->cm->rds, piece * tp->piece_length, torrent_piece_size(tp, piece), hash)) != 0) { btpd_log(BTPD_L_ERROR, "io error on '%s' (%s).\n", bts_filename(tp->cm->rds), strerror(err)); return err;; } *ok = test_hash(tp, hash, piece) == 0; return 0; } static int test_hash(struct torrent *tp, uint8_t *hash, uint32_t piece); static void startup_test_run(void); void worker_cb(int fd, short type, void *arg) { startup_test_run(); } void cm_kill(struct torrent *tp) { struct content *cm = tp->cm; tlib_close_resume(cm->resd); free(cm->pos_field); free(cm); tp->cm = NULL; } static int stat_and_adjust(struct torrent *tp, struct file_time_size ret[]); void cm_save(struct torrent *tp) { struct file_time_size fts[tp->nfiles]; stat_and_adjust(tp, fts); for (int i = 0; i < tp->nfiles; i++) resume_set_fts(tp->cm->resd, i, fts + i); } static void cm_on_error(struct torrent *tp) { if (!tp->cm->error) { tp->cm->error = 1; cm_stop(tp); } } static void cm_write_done(struct torrent *tp) { int err; struct content *cm = tp->cm; err = bts_close(cm->wrs); cm->wrs = NULL; if (err && !cm->error) { btpd_log(BTPD_L_ERROR, "error closing write stream for '%s' (%s).\n", torrent_name(tp), strerror(err)); cm_on_error(tp); } if (!cm->error) cm_save(tp); } void cm_stop(struct torrent *tp) { struct content *cm = tp->cm; if (cm->state != CM_STARTING && cm->state != CM_ACTIVE) return; if (cm->state == CM_STARTING) { struct start_test_data *std; BTPDQ_FOREACH(std, &m_startq, entry) if (std->tp == tp) { BTPDQ_REMOVE(&m_startq, std, entry); free(std->fts); free(std); break; } } if (cm->rds != NULL) bts_close(cm->rds); if (cm->wrs != NULL) cm_write_done(tp); cm->state = CM_INACTIVE; } int cm_active(struct torrent *tp) { struct content *cm = tp->cm; return cm->state != CM_INACTIVE; } int cm_error(struct torrent *tp) { return tp->cm->error; } int cm_started(struct torrent *tp) { struct content *cm = tp->cm; return cm->state == CM_ACTIVE; } void cm_create(struct torrent *tp, const char *mi) { size_t pfield_size = ceil(tp->npieces / 8.0); struct content *cm = btpd_calloc(1, sizeof(*cm)); cm->bppbf = ceil((double)tp->piece_length / (1 << 17)); cm->pos_field = btpd_calloc(pfield_size, 1); cm->resd = tlib_open_resume(tp->tl, tp->nfiles, pfield_size, cm->bppbf * tp->npieces); cm->piece_field = resume_piece_field(cm->resd); cm->block_field = resume_block_field(cm->resd); tp->cm = cm; } int cm_get_bytes(struct torrent *tp, uint32_t piece, uint32_t begin, size_t len, uint8_t **buf) { if (tp->cm->error) return EIO; *buf = btpd_malloc(len); int err = bts_get(tp->cm->rds, piece * tp->piece_length + begin, *buf, len); if (err != 0) { btpd_log(BTPD_L_ERROR, "io error on '%s' (%s).\n", bts_filename(tp->cm->rds), strerror(err)); cm_on_error(tp); } return err; } void cm_prealloc(struct torrent *tp, uint32_t piece) { struct content *cm = tp->cm; if (cm_alloc_size <= 0) set_bit(cm->pos_field, piece); } void cm_test_piece(struct torrent *tp, uint32_t piece) { int ok; struct content *cm = tp->cm; if ((errno = test_piece(tp, piece, &ok)) != 0) cm_on_error(tp); else if (ok) { assert(cm->npieces_got < tp->npieces); cm->npieces_got++; set_bit(cm->piece_field, piece); if (net_active(tp)) dl_on_ok_piece(tp->net,piece); if (cm_full(tp)) cm_write_done(tp); } else { cm->ncontent_bytes -= torrent_piece_size(tp,piece); bzero(cm->block_field + piece * cm->bppbf, cm->bppbf); if (net_active(tp)) dl_on_bad_piece(tp->net, piece); } } int cm_put_bytes(struct torrent *tp, uint32_t piece, uint32_t begin, const uint8_t *buf, size_t len) { int err; struct content *cm = tp->cm; if (cm->error) return EIO; uint8_t *bf = cm->block_field + piece * cm->bppbf; assert(!has_bit(bf, begin / PIECE_BLOCKLEN)); assert(!has_bit(cm->piece_field, piece)); if (!has_bit(cm->pos_field, piece)) { unsigned npieces = ceil((double)cm_alloc_size / tp->piece_length); uint32_t start = piece - piece % npieces; uint32_t end = min(start + npieces, tp->npieces); while (start < end) { if (!has_bit(cm->pos_field, start)) { assert(!has_bit(cm->piece_field, start)); off_t len = torrent_piece_size(tp, start); off_t off = tp->piece_length * start; while (len > 0) { size_t wlen = min(ZEROBUFLEN, len); if ((err = bts_put(cm->wrs, off, m_zerobuf, wlen)) != 0) { btpd_log(BTPD_L_ERROR, "io error on '%s' (%s).\n", bts_filename(cm->wrs), strerror(errno)); cm_on_error(tp); return err; } len -= wlen; off += wlen; } set_bit(cm->pos_field, start); } start++; } } err = bts_put(cm->wrs, piece * tp->piece_length + begin, buf, len); if (err != 0) { btpd_log(BTPD_L_ERROR, "io error on '%s' (%s)\n", bts_filename(cm->wrs), strerror(err)); cm_on_error(tp); return err; } cm->ncontent_bytes += len; set_bit(bf, begin / PIECE_BLOCKLEN); return 0; } int cm_full(struct torrent *tp) { return tp->cm->npieces_got == tp->npieces; } off_t cm_content(struct torrent *tp) { return tp->cm->ncontent_bytes; } uint32_t cm_pieces(struct torrent *tp) { return tp->cm->npieces_got; } uint8_t * cm_get_piece_field(struct torrent *tp) { return tp->cm->piece_field; } uint8_t * cm_get_block_field(struct torrent *tp, uint32_t piece) { return tp->cm->block_field + piece * tp->cm->bppbf; } int cm_has_piece(struct torrent *tp, uint32_t piece) { return has_bit(tp->cm->piece_field, piece); } int stat_and_adjust(struct torrent *tp, struct file_time_size ret[]) { int fd; char path[PATH_MAX]; struct stat sb; for (int i = 0; i < tp->nfiles; i++) { snprintf(path, PATH_MAX, "%s/%s", tp->tl->dir, tp->files[i].path); again: if (stat(path, &sb) == -1) { if (errno == ENOENT) { errno = vopen(&fd, O_CREAT|O_RDWR, "%s", path); if (errno != 0 || close(fd) != 0) { btpd_log(BTPD_L_ERROR, "failed to create '%s' (%s).\n", path, strerror(errno)); return errno; } goto again; } else { btpd_log(BTPD_L_ERROR, "failed to stat '%s' (%s).\n", path, strerror(errno)); return errno; } } else if (sb.st_size > tp->files[i].length) { if (truncate(path, tp->files[i].length) != 0) { btpd_log(BTPD_L_ERROR, "failed to truncate '%s' (%s).\n", path, strerror(errno)); return errno; } goto again; } else { ret[i].mtime = sb.st_mtime; ret[i].size = sb.st_size; } } return 0; } void startup_test_end(struct torrent *tp, int unclean) { struct content *cm = tp->cm; bzero(cm->pos_field, ceil(tp->npieces / 8.0)); for (uint32_t piece = 0; piece < tp->npieces; piece++) { if (cm_has_piece(tp, piece)) { cm->ncontent_bytes += torrent_piece_size(tp, piece); cm->npieces_got++; set_bit(cm->pos_field, piece); continue; } uint8_t *bf = cm->block_field + cm->bppbf * piece; uint32_t nblocks = torrent_piece_blocks(tp, piece); uint32_t nblocks_got = 0; for (uint32_t i = 0; i < nblocks; i++) { if (has_bit(bf, i)) { nblocks_got++; cm->ncontent_bytes += torrent_block_size(tp, piece, nblocks, i); } } if (nblocks_got == nblocks) { bzero(bf, cm->bppbf); cm->ncontent_bytes -= torrent_piece_size(tp, piece); } else if (nblocks_got > 0) set_bit(cm->pos_field, piece); } if (unclean) { struct start_test_data *std = BTPDQ_FIRST(&m_startq); BTPDQ_REMOVE(&m_startq, std, entry); for (int i = 0; i < tp->nfiles; i++) resume_set_fts(cm->resd, i, std->fts + i); free(std->fts); free(std); } if (!cm_full(tp)) { int err; if ((err = bts_open(&cm->wrs, tp->nfiles, tp->files, fd_cb_wr, tp)) != 0) { btpd_log(BTPD_L_ERROR, "failed to open write stream for '%s' (%s).\n", torrent_name(tp), strerror(err)); cm_on_error(tp); return; } } cm->state = CM_ACTIVE; } void startup_test_run(void) { int ok; struct torrent *tp; struct content *cm; struct start_test_data * std = BTPDQ_FIRST(&m_startq); uint32_t this; if (std == NULL) return; tp = std->tp; cm = tp->cm; if (test_piece(std->tp, std->start, &ok) != 0) { cm_on_error(std->tp); return; } if (ok) set_bit(cm->piece_field, std->start); else clear_bit(cm->piece_field, std->start); this = std->start; do std->start++; while (std->start < tp->npieces && !has_bit(cm->pos_field, std->start)); if (std->start >= tp->npieces) startup_test_end(tp, 1); if (!BTPDQ_EMPTY(&m_startq)) btpd_timer_add(&m_workev, (& (struct timespec) { 0, 0 })); } void startup_test_begin(struct torrent *tp, struct file_time_size *fts) { uint32_t piece = 0; struct content *cm = tp->cm; while (piece < tp->npieces && !has_bit(cm->pos_field, piece)) piece++; if (piece < tp->npieces) { struct start_test_data *std = btpd_calloc(1, sizeof(*std)); std->tp = tp; std->start = piece; std->fts = fts; BTPDQ_INSERT_TAIL(&m_startq, std, entry); if (std == BTPDQ_FIRST(&m_startq)) btpd_timer_add(&m_workev, (& (struct timespec) { 0, 0 })); } else { free(fts); startup_test_end(tp, 0); } } void cm_start(struct torrent *tp, int force_test) { int err, run_test = force_test; struct file_time_size *fts; struct content *cm = tp->cm; cm->state = CM_STARTING; if ((errno = bts_open(&cm->rds, tp->nfiles, tp->files, fd_cb_rd, tp)) != 0) { btpd_log(BTPD_L_ERROR, "failed to open stream for '%s' (%s).\n", torrent_name(tp), strerror(errno)); cm_on_error(tp); return; } fts = btpd_calloc(tp->nfiles, sizeof(*fts)); if ((err = stat_and_adjust(tp, fts)) != 0) { free(fts); cm_on_error(tp); return; } for (int i = 0; i < tp->nfiles; i++) { struct file_time_size rfts; resume_get_fts(cm->resd, i, &rfts); if ((fts[i].mtime != rfts.mtime || fts[i].size != rfts.size)) { run_test = 1; break; } } if (run_test) { memset(cm->pos_field, 0xff, ceil(tp->npieces / 8.0)); off_t off = 0; for (int i = 0; i < tp->nfiles; i++) { if (fts[i].size != tp->files[i].length) { uint32_t start, end; end = (off + tp->files[i].length - 1) / tp->piece_length; start = (off + fts[i].size) / tp->piece_length; while (start <= end) { clear_bit(cm->pos_field, start); clear_bit(cm->piece_field, start); bzero(cm->block_field + start * cm->bppbf, cm->bppbf); start++; } } off += tp->files[i].length; } } startup_test_begin(tp, fts); } void cm_init(void) { evtimer_init(&m_workev, worker_cb, NULL); } btpd-0.16/btpd/net_types.h0000644000175000001440000000465511417473677012455 00000000000000#ifndef BTPD_NET_TYPES_H #define BTPD_NET_TYPES_H BTPDQ_HEAD(peer_tq, peer); BTPDQ_HEAD(piece_tq, piece); BTPDQ_HEAD(block_request_tq, block_request); BTPDQ_HEAD(blog_tq, blog); BTPDQ_HEAD(blog_record_tq, blog_record); struct net { struct torrent *tp; int active; int endgame; uint8_t *busy_field; uint32_t npcs_busy; unsigned *piece_count; struct piece_tq getlst; unsigned long rate_up, rate_dwn; unsigned long long uploaded, downloaded; unsigned npeers; struct peer_tq peers; struct mptbl *mptbl; }; enum input_state { SHAKE_PSTR, SHAKE_INFO, SHAKE_ID, BTP_MSGSIZE, BTP_MSGHEAD, BTP_PIECEMETA, BTP_MSGBODY }; struct meta_peer { struct peer *p; HTBL_ENTRY(chain); uint16_t flags; uint16_t refs; uint8_t id[20]; }; HTBL_TYPE(mptbl, meta_peer, uint8_t, id, chain); struct peer { int sd; uint8_t *piece_field; uint8_t *bad_field; uint32_t npieces; uint32_t nwant; uint32_t npcs_bad; int suspicion; struct net *n; struct meta_peer *mp; struct block_request_tq my_reqs; unsigned nreqs_out; unsigned npiece_msgs; size_t outq_off; struct nb_tq outq; struct fdev ioev; unsigned long rate_up, rate_dwn; unsigned long count_up, count_dwn; long t_created; long t_lastwrite; long t_wantwrite; long t_nointerest; struct { uint32_t msg_len; uint8_t msg_num; uint32_t pc_index; uint32_t pc_begin; enum input_state state; size_t st_bytes; char *buf; size_t off; } in; BTPDQ_ENTRY(peer) p_entry; BTPDQ_ENTRY(peer) ul_entry; BTPDQ_ENTRY(peer) rq_entry; BTPDQ_ENTRY(peer) wq_entry; }; struct piece { struct net *n; uint32_t index; unsigned nreqs; unsigned nblocks; unsigned ngot; unsigned nbusy; unsigned next_block; struct net_buf **eg_reqs; struct block_request_tq reqs; struct blog_tq logs; const uint8_t *have_field; uint8_t *down_field; BTPDQ_ENTRY(piece) entry; }; struct blog { BTPDQ_ENTRY(blog) entry; struct blog_record_tq records; uint8_t *hashes; }; struct blog_record { BTPDQ_ENTRY(blog_record) entry; struct meta_peer *mp; uint8_t down_field[]; }; struct block_request { struct peer *p; struct net_buf *msg; BTPDQ_ENTRY(block_request) p_entry; BTPDQ_ENTRY(block_request) blk_entry; }; #endif btpd-0.16/btpd/active.c0000644000175000001440000000365511417473677011710 00000000000000#include "btpd.h" void active_add(const uint8_t *hash) { FILE *fp; if ((fp = fopen("active", "a")) == NULL) { btpd_log(BTPD_L_ERROR, "couldn't open file 'active' (%s).\n", strerror(errno)); return; } fwrite(hash, 20, 1, fp); fclose(fp); } static void active_del_pos(FILE *fp, long pos, off_t *size) { uint8_t ehash[20]; fseek(fp, -20, SEEK_END); fread(ehash, 20, 1, fp); fseek(fp, pos, SEEK_SET); fwrite(ehash, 20, 1, fp); fflush(fp); *size -= 20; ftruncate(fileno(fp), *size); } void active_del(const uint8_t *hash) { FILE *fp; long pos; struct stat sb; uint8_t buf[20]; if ((fp = fopen("active", "r+")) == NULL) { btpd_log(BTPD_L_ERROR, "couldn't open file 'active' (%s).\n", strerror(errno)); return; } if (fstat(fileno(fp), &sb) != 0) { btpd_log(BTPD_L_ERROR, "couldn't stat file 'active' (%s).\n", strerror(errno)); goto close; } pos = 0; while (fread(buf, 20, 1, fp) == 1) { if (bcmp(buf, hash, 20) == 0) { active_del_pos(fp, pos, &sb.st_size); break; } pos += 20; } close: fclose(fp); } void active_start(void) { FILE *fp; long pos; struct stat sb; uint8_t hash[20]; if ((fp = fopen("active", "r+")) == NULL) return; if (fstat(fileno(fp), &sb) != 0) { btpd_log(BTPD_L_ERROR, "Couldn't stat file 'active' (%s).\n", strerror(errno)); goto close; } pos = 0; while (fread(hash, sizeof(hash), 1, fp) == 1) { struct tlib *tl = tlib_by_hash(hash); if (tl != NULL && tl->tp == NULL) if (torrent_start(tl) != 0) { active_del_pos(fp, pos, &sb.st_size); fseek(fp, pos, SEEK_SET); } pos += 20; } close: fclose(fp); } void active_clear(void) { unlink("active"); } btpd-0.16/btpd/download.h0000644000175000001440000000240511417473677012241 00000000000000#ifndef BTPD_DOWNLOAD_H #define BTPD_DOWNLOAD_H // download_subr.c int piece_full(struct piece *pc); void piece_free(struct piece *pc); void piece_log_bad(struct piece *pc); void piece_log_good(struct piece *pc); void piece_log_block(struct piece *pc, struct peer *p, uint32_t begin); void dl_on_piece_unfull(struct piece *pc); struct piece *dl_new_piece(struct net *n, uint32_t index); struct piece *dl_find_piece(struct net *n, uint32_t index); unsigned dl_piece_assign_requests(struct piece *pc, struct peer *p); unsigned dl_assign_requests(struct peer *p); void dl_assign_requests_eg(struct peer *p); void dl_unassign_requests(struct peer *p); void dl_unassign_requests_eg(struct peer *p); void dl_piece_reorder_eg(struct piece *pc); // download.c void dl_on_new_peer(struct peer *p); void dl_on_lost_peer(struct peer *p); void dl_on_choke(struct peer *p); void dl_on_unchoke(struct peer *p); void dl_on_download(struct peer *p); void dl_on_undownload(struct peer *p); void dl_on_piece_ann(struct peer *p, uint32_t index); void dl_on_block(struct peer *p, struct block_request *req, uint32_t index, uint32_t begin, uint32_t length, const uint8_t *data); void dl_on_ok_piece(struct net *n, uint32_t piece); void dl_on_bad_piece(struct net *n, uint32_t piece); #endif btpd-0.16/btpd/btpd.c0000644000175000001440000000527611417473677011367 00000000000000#include "btpd.h" #include #include static uint8_t m_peer_id[20]; static struct timeout m_heartbeat; static int m_signal; static int m_shutdown; static int m_ghost; long btpd_seconds; void btpd_exit(int code) { btpd_log(BTPD_L_BTPD, "Exiting.\n"); exit(code); } extern int pidfd; void ipc_shutdown(void); void net_shutdown(void); static void death_procedure(void) { assert(m_shutdown); if (torrent_count() == 0) btpd_exit(0); if (!m_ghost && torrent_count() == torrent_ghosts()) { btpd_log(BTPD_L_BTPD, "Entering pre exit mode. Bye!\n"); fclose(stderr); fclose(stdout); net_shutdown(); ipc_shutdown(); close(pidfd); m_ghost = 1; } } void btpd_shutdown(void) { m_shutdown = 1; struct torrent *tp, *next; BTPDQ_FOREACH_MUTABLE(tp, torrent_get_all(), entry, next) torrent_stop(tp, 0); death_procedure(); } int btpd_is_stopping(void) { return m_shutdown; } const uint8_t * btpd_get_peer_id(void) { return m_peer_id; } static void signal_handler(int signal) { m_signal = signal; } static void heartbeat_cb(int fd, short type, void *arg) { btpd_timer_add(&m_heartbeat, (& (struct timespec) { 1, 0 })); btpd_seconds++; net_on_tick(); torrent_on_tick_all(); if (m_signal) { btpd_log(BTPD_L_BTPD, "Got signal %d.\n", m_signal); m_signal = 0; if (!m_shutdown) btpd_shutdown(); } if (m_shutdown) death_procedure(); } void tr_init(void); void ipc_init(void); void td_init(void); void addrinfo_init(void); void btpd_init(void) { struct sigaction sa; unsigned long seed; uint8_t idcon[1024]; struct timeval now; int n; bzero(&sa, sizeof(sa)); sa.sa_handler = SIG_IGN; sa.sa_flags = SA_RESTART; sigfillset(&sa.sa_mask); sigaction(SIGPIPE, &sa, NULL); sa.sa_handler = signal_handler; sigaction(SIGTERM, &sa, NULL); sigaction(SIGINT, &sa, NULL); gettimeofday(&now, NULL); n = snprintf(idcon, sizeof(idcon), "%ld%ld%d", (long)now.tv_sec, (long)now.tv_usec, net_port); if (n < sizeof(idcon)) gethostname(idcon + n, sizeof(idcon) - n); idcon[sizeof(idcon) - 1] = '\0'; n = strlen(idcon); SHA1(idcon, n, m_peer_id); bcopy(m_peer_id, &seed, sizeof(seed)); bcopy(BTPD_VERSION, m_peer_id, sizeof(BTPD_VERSION) - 1); m_peer_id[sizeof(BTPD_VERSION) - 1] = '|'; srandom(seed); td_init(); addrinfo_init(); net_init(); ipc_init(); ul_init(); cm_init(); tr_init(); tlib_init(); evtimer_init(&m_heartbeat, heartbeat_cb, NULL); btpd_timer_add(&m_heartbeat, (& (struct timespec) { 1, 0 })); } btpd-0.16/btpd/net_buf.h0000644000175000001440000000336411417473677012061 00000000000000#ifndef BTPD_NET_BUF_H #define BTPD_NET_BUF_H #define NB_CHOKE 0 #define NB_UNCHOKE 1 #define NB_INTEREST 2 #define NB_UNINTEREST 3 #define NB_HAVE 4 #define NB_BITFIELD 5 #define NB_REQUEST 6 #define NB_PIECE 7 #define NB_CANCEL 8 #define NB_TORRENTDATA 10 #define NB_MULTIHAVE 11 #define NB_BITDATA 12 #define NB_SHAKE 13 #define NB_KEEPALIVE 14 struct net_buf { short type; unsigned refs; char *buf; size_t len; void (*kill_buf)(char *, size_t); }; struct nb_link { struct net_buf *nb; BTPDQ_ENTRY(nb_link) entry; }; BTPDQ_HEAD(nb_tq, nb_link); struct torrent; struct peer; struct net_buf *nb_create_keepalive(void); struct net_buf *nb_create_piece(uint32_t index, uint32_t begin, size_t blen); struct net_buf *nb_create_torrentdata(void); struct net_buf *nb_create_request(uint32_t index, uint32_t begin, uint32_t length); struct net_buf *nb_create_cancel(uint32_t index, uint32_t begin, uint32_t length); struct net_buf *nb_create_have(uint32_t index); struct net_buf *nb_create_multihave(struct torrent *tp); struct net_buf *nb_create_unchoke(void); struct net_buf *nb_create_choke(void); struct net_buf *nb_create_uninterest(void); struct net_buf *nb_create_interest(void); struct net_buf *nb_create_bitfield(struct torrent *tp); struct net_buf *nb_create_bitdata(struct torrent *tp); struct net_buf *nb_create_shake(struct torrent *tp); int nb_torrentdata_fill(struct net_buf *nb, struct torrent *tp, uint32_t index, uint32_t begin, uint32_t length); int nb_drop(struct net_buf *nb); void nb_hold(struct net_buf *nb); uint32_t nb_get_index(struct net_buf *nb); uint32_t nb_get_begin(struct net_buf *nb); uint32_t nb_get_length(struct net_buf *nb); #endif btpd-0.16/btpd/tlib.h0000644000175000001440000000300211417473677011356 00000000000000#ifndef BTPD_TLIB_H #define BTPD_TLIB_H struct tlib { unsigned num; uint8_t hash[20]; struct torrent *tp; char *name; char *dir; unsigned long long tot_up, tot_down; off_t content_size, content_have; HTBL_ENTRY(nchain); HTBL_ENTRY(hchain); }; struct file_time_size { off_t size; time_t mtime; }; void tlib_init(void); struct tlib *tlib_iter_first(struct htbl_iter *it); struct tlib *tlib_iter_next(struct htbl_iter *it); struct tlib *tlib_add(const uint8_t *hash, const char *mi, size_t mi_size, const char *content, char *name); struct tlib *tlib_readd(struct tlib *tl, const uint8_t *hash, const char *mi, size_t mi_size, const char *content, char *name); int tlib_del(struct tlib *tl); void tlib_kill(struct tlib *tl); void tlib_update_info(struct tlib *tl, int only_file); struct tlib *tlib_by_hash(const uint8_t *hash); struct tlib *tlib_by_num(unsigned num); unsigned tlib_count(void); int tlib_load_mi(struct tlib *tl, char **res); void tlib_read_hash(struct tlib *tl, size_t off, uint32_t piece, uint8_t *hash); struct resume_data *tlib_open_resume(struct tlib *tl, unsigned nfiles, size_t pfsize, size_t bfsize); void tlib_close_resume(struct resume_data *resume); uint8_t *resume_piece_field(struct resume_data *resd); uint8_t *resume_block_field(struct resume_data *resd); void resume_set_fts(struct resume_data *resd, int i, struct file_time_size *fts); void resume_get_fts(struct resume_data *resd, int i, struct file_time_size *fts); #endif btpd-0.16/btpd/torrent.h0000644000175000001440000000244711417473677012135 00000000000000#ifndef BTPD_TORRENT_H #define BTPD_TORRENT_H #define PIECE_BLOCKLEN (1 << 14) #define RELPATH_SIZE SHAHEXSIZE enum torrent_state { T_STARTING, T_LEECH, T_SEED, T_STOPPING, T_GHOST }; struct torrent { struct tlib *tl; enum torrent_state state; int delete; struct content *cm; struct trackers *tr; struct net *net; off_t total_length; off_t piece_length; uint32_t npieces; unsigned nfiles; struct mi_file *files; size_t pieces_off; BTPDQ_ENTRY(torrent) entry; }; BTPDQ_HEAD(torrent_tq, torrent); unsigned torrent_count(void); unsigned torrent_ghosts(void); const struct torrent_tq *torrent_get_all(void); struct torrent *torrent_by_num(unsigned num); struct torrent *torrent_by_hash(const uint8_t *hash); enum ipc_err torrent_start(struct tlib *tl); void torrent_stop(struct torrent *tp, int delete); int torrent_active(struct tlib *tl); int torrent_haunting(struct tlib *tl); int torrent_startable(struct tlib *tl); off_t torrent_piece_size(struct torrent *tp, uint32_t piece); uint32_t torrent_piece_blocks(struct torrent *tp, uint32_t piece); uint32_t torrent_block_size(struct torrent *tp, uint32_t piece, uint32_t nblocks, uint32_t block); const char *torrent_name(struct torrent *tp); void torrent_on_tick_all(void); #endif btpd-0.16/btpd/upload.c0000644000175000001440000001153211417473677011712 00000000000000#include "btpd.h" #define CHOKE_INTERVAL (& (struct timespec) { 10, 0 }) static struct timeout m_choke_timer; static unsigned m_npeers; static struct peer_tq m_peerq = BTPDQ_HEAD_INITIALIZER(m_peerq); static int m_max_uploads; struct peer_sort { struct peer *p; unsigned i; }; static int rate_cmp(const void *arg1, const void *arg2) { struct peer *p1 = ((struct peer_sort *)arg1)->p; struct peer *p2 = ((struct peer_sort *)arg2)->p; unsigned long rate1 = cm_full(p1->n->tp) ? p1->rate_up / 2: p1->rate_dwn; unsigned long rate2 = cm_full(p2->n->tp) ? p2->rate_up / 2: p2->rate_dwn; if (rate1 < rate2) return -1; else if (rate1 == rate2) return 0; else return 1; } static void choke_do(void) { if (m_max_uploads < 0) { struct peer *p; BTPDQ_FOREACH(p, &m_peerq, ul_entry) if (p->mp->flags & PF_I_CHOKE) peer_unchoke(p); } else if (m_max_uploads == 0) { struct peer *p; BTPDQ_FOREACH(p, &m_peerq, ul_entry) if ((p->mp->flags & PF_I_CHOKE) == 0) peer_choke(p); } else { struct peer_sort worthy[m_npeers]; int nworthy = 0; int i = 0; int found = 0; struct peer *p; int unchoked[m_npeers]; BTPDQ_FOREACH(p, &m_peerq, ul_entry) { int ok = 0; if (!peer_full(p)) { if (cm_full(p->n->tp)) { if (p->rate_up > 0) ok = 1; } else if (peer_active_down(p) && p->rate_dwn > 0) ok = 1; } if (ok) { worthy[nworthy].p = p; worthy[nworthy].i = i; nworthy++; } i++; } qsort(worthy, nworthy, sizeof(worthy[0]), rate_cmp); bzero(unchoked, sizeof(unchoked)); for (i = nworthy - 1; i >= 0 && found < m_max_uploads - 1; i--) { if ((worthy[i].p->mp->flags & PF_P_WANT) != 0) found++; if ((worthy[i].p->mp->flags & PF_I_CHOKE) != 0) peer_unchoke(worthy[i].p); unchoked[worthy[i].i] = 1; } i = 0; BTPDQ_FOREACH(p, &m_peerq, ul_entry) { if (!unchoked[i]) { if (found < m_max_uploads && !peer_full(p)) { if (p->mp->flags & PF_P_WANT) found++; if (p->mp->flags & PF_I_CHOKE) peer_unchoke(p); } else { if ((p->mp->flags & PF_I_CHOKE) == 0) peer_choke(p); } } i++; } } } static void shuffle_optimists(void) { for (int i = 0; i < m_npeers; i++) { struct peer *p = BTPDQ_FIRST(&m_peerq); if ((p->mp->flags & (PF_P_WANT|PF_I_CHOKE)) == (PF_P_WANT|PF_I_CHOKE)) { break; } else { BTPDQ_REMOVE(&m_peerq, p, ul_entry); BTPDQ_INSERT_TAIL(&m_peerq, p, ul_entry); } } } static void choke_cb(int sd, short type, void *arg) { btpd_timer_add(&m_choke_timer, CHOKE_INTERVAL); static int cb_count = 0; cb_count++; if (cb_count % 3 == 0) shuffle_optimists(); choke_do(); } void ul_on_new_peer(struct peer *p) { long where = rand_between(-2, m_npeers); if (where < 1) BTPDQ_INSERT_HEAD(&m_peerq, p, ul_entry); else { struct peer *it = BTPDQ_FIRST(&m_peerq); where--; while (where > 0) { it = BTPDQ_NEXT(it, ul_entry); where--; } BTPDQ_INSERT_AFTER(&m_peerq, it, p, ul_entry); } m_npeers++; choke_do(); } void ul_on_lost_peer(struct peer *p) { assert(m_npeers > 0); BTPDQ_REMOVE(&m_peerq, p, ul_entry); m_npeers--; if ((p->mp->flags & (PF_P_WANT|PF_I_CHOKE)) == PF_P_WANT) choke_do(); } void ul_on_lost_torrent(struct net *n) { struct peer *p; BTPDQ_FOREACH(p, &n->peers, p_entry) { BTPDQ_REMOVE(&m_peerq, p, ul_entry); m_npeers--; } choke_do(); } void ul_on_interest(struct peer *p) { if ((p->mp->flags & PF_I_CHOKE) == 0) choke_do(); } void ul_on_uninterest(struct peer *p) { if ((p->mp->flags & PF_I_CHOKE) == 0) choke_do(); } void ul_init(void) { if (net_max_uploads >= -1) m_max_uploads = net_max_uploads; else { if (net_bw_limit_out == 0) m_max_uploads = 8; else if (net_bw_limit_out < (10 << 10)) m_max_uploads = 2; else if (net_bw_limit_out < (20 << 10)) m_max_uploads = 3; else if (net_bw_limit_out < (40 << 10)) m_max_uploads = 4; else m_max_uploads = 5 + (net_bw_limit_out / (100 << 10)); } evtimer_init(&m_choke_timer, choke_cb, NULL); btpd_timer_add(&m_choke_timer, CHOKE_INTERVAL); } btpd-0.16/btpd/tracker_req.c0000644000175000001440000002024411417473677012730 00000000000000#include "btpd.h" #include "http_client.h" #define REQ_DELAY 1 #define DEFAULT_INTERVAL rand_between(25 * 60, 30 * 60) #define RETRY1_TIMEOUT (& (struct timespec) {240 + rand_between(0, 120), 0}) #define RETRY2_TIMEOUT (& (struct timespec) {900 + rand_between(0, 300), 0}) long tr_key; static long m_tlast_req, m_tnext_req; struct tr_entry { BTPDQ_ENTRY(tr_entry) entry; char *failure; char *url; enum tr_type type; }; BTPDQ_HEAD(tr_entry_tq, tr_entry); struct tr_tier { struct torrent *tp; struct tr_entry *cur; struct tr_entry_tq trackers; struct timeout timer; BTPDQ_ENTRY(tr_tier) entry; void *req; int interval; int bad_conns; int active; int has_responded; enum tr_event event; }; BTPDQ_HEAD(tr_tier_tq, tr_tier); struct trackers { struct tr_tier_tq trackers; }; static struct tr_entry * first_nonfailed(struct tr_tier *t) { struct tr_entry *e; BTPDQ_FOREACH(e, &t->trackers, entry) if (e->failure == NULL) return e; abort(); } static int all_failed(struct tr_tier *t) { struct tr_entry *e; BTPDQ_FOREACH(e, &t->trackers, entry) if (e->failure == NULL) return 0; return 1; } static void * req_send(struct tr_tier *t) { btpd_log(BTPD_L_TR, "sending event %d to '%s' for '%s'.\n", t->event, t->cur->url, torrent_name(t->tp)); switch (t->cur->type) { case TR_HTTP: return httptr_req(t->tp, t, t->cur->url, t->event); default: abort(); } } static void req_cancel(struct tr_tier *t) { switch (t->cur->type) { case TR_HTTP: httptr_cancel(t->req); break; default: abort(); } t->req = NULL; } static void entry_send(struct tr_tier *t, struct tr_entry *e, enum tr_event event) { if (t->req != NULL) req_cancel(t); t->event = event; t->cur = e; if (m_tlast_req > btpd_seconds - REQ_DELAY) { m_tnext_req = max(m_tnext_req, m_tlast_req) + REQ_DELAY; btpd_timer_add(&t->timer, (& (struct timespec) { m_tnext_req - btpd_seconds, 0 })); return; } btpd_timer_del(&t->timer); if ((t->req = req_send(t)) == NULL) btpd_err("failed to create tracker message to '%s' (%s).", e->url, strerror(errno)); m_tlast_req = btpd_seconds; } static int tier_active(struct tr_tier *t) { return t->active; } static void tier_timer_cb(int fd, short type, void *arg) { struct tr_tier *t = arg; assert(tier_active(t) && !all_failed(t)); entry_send(t, first_nonfailed(t), t->event); } static void tier_start(struct tr_tier *t) { struct tr_entry *e; assert(!tier_active(t) || t->event == TR_EV_STOPPED); BTPDQ_FOREACH(e, &t->trackers, entry) if (e->failure != NULL) { free(e->failure); e->failure = NULL; } t->has_responded = 0; t->bad_conns = 0; t->active = 1; entry_send(t, BTPDQ_FIRST(&t->trackers), TR_EV_STARTED); } static void tier_stop(struct tr_tier *t) { if (!tier_active(t) || t->event == TR_EV_STOPPED) return; if (!t->has_responded && t->bad_conns > 1) { btpd_timer_del(&t->timer); if (t->req != NULL) req_cancel(t); t->active = 0; } else entry_send(t, first_nonfailed(t), TR_EV_STOPPED); } static void tier_complete(struct tr_tier *t) { if (tier_active(t) && t->event == TR_EV_EMPTY) entry_send(t, BTPDQ_FIRST(&t->trackers), TR_EV_COMPLETED); } static void add_tracker(struct tr_tier *t, const char *url) { struct tr_entry *e; struct http_url *hu; if ((hu = http_url_parse(url)) != NULL) { http_url_free(hu); e = btpd_calloc(1, sizeof(*e)); if ((e->url = strdup(url)) == NULL) btpd_err("Out of memory.\n"); e->type = TR_HTTP; } else { btpd_log(BTPD_L_TR, "skipping unsupported tracker '%s' for '%s'.\n", url, torrent_name(t->tp)); return; } BTPDQ_INSERT_TAIL(&t->trackers, e, entry); } static struct tr_tier * tier_create(struct torrent *tp, struct mi_tier *tier) { struct tr_tier *t = btpd_calloc(1, sizeof(*t)); t->tp = tp; BTPDQ_INIT(&t->trackers); for (int i = 0; i < tier->nurls; i++) add_tracker(t, tier->urls[i]); if (!BTPDQ_EMPTY(&t->trackers)) { t->interval = -1; t->event = TR_EV_STOPPED; evtimer_init(&t->timer, tier_timer_cb, t); return t; } else { free(t); return NULL; } } static void tier_kill(struct tr_tier *t) { struct tr_entry *e, *next; btpd_timer_del(&t->timer); if (t->req != NULL) req_cancel(t); BTPDQ_FOREACH_MUTABLE(e, &t->trackers, entry , next) { if (e->failure != NULL) free(e->failure); free(e->url); free(e); } free(t); } void tr_create(struct torrent *tp, const char *mi) { int i; struct tr_tier *t; struct mi_announce *ann; tp->tr = btpd_calloc(1, sizeof(*tp->tr)); BTPDQ_INIT(&tp->tr->trackers); if ((ann = mi_announce(mi)) == NULL) btpd_err("Out of memory.\n"); for (i = 0; i < ann->ntiers; i++) if ((t = tier_create(tp, &ann->tiers[i])) != NULL) BTPDQ_INSERT_TAIL(&tp->tr->trackers, t, entry); mi_free_announce(ann); } void tr_kill(struct torrent *tp) { struct tr_tier *t, *next; BTPDQ_FOREACH_MUTABLE(t, &tp->tr->trackers, entry, next) tier_kill(t); free(tp->tr); tp->tr = NULL; } void tr_start(struct torrent *tp) { struct tr_tier *t; BTPDQ_FOREACH(t, &tp->tr->trackers, entry) tier_start(t); } void tr_stop(struct torrent *tp) { struct tr_tier *t; BTPDQ_FOREACH(t, &tp->tr->trackers, entry) tier_stop(t); } void tr_complete(struct torrent *tp) { struct tr_tier *t; BTPDQ_FOREACH(t, &tp->tr->trackers, entry) tier_complete(t); } int tr_active(struct torrent *tp) { struct tr_tier *t; BTPDQ_FOREACH(t, &tp->tr->trackers, entry) if (tier_active(t)) return 1; return 0; } int tr_good_count(struct torrent *tp) { int count = 0; struct tr_tier *t; BTPDQ_FOREACH(t, &tp->tr->trackers, entry) if (tier_active(t) && t->bad_conns == 0) count++; return count; } void tr_result(struct tr_tier *t, struct tr_response *res) { struct tr_entry *e; t->req = NULL; switch (res->type) { case TR_RES_FAIL: t->cur->failure = benc_str(res->mi_failure, NULL, NULL); btpd_log(BTPD_L_ERROR, "tracker at '%s' failed (%s).\n", t->cur->url, t->cur->failure); if (all_failed(t)) { t->active = 0; break; } case TR_RES_CONN: btpd_log(BTPD_L_TR, "connection to '%s' failed for '%s'.\n", t->cur->url, torrent_name(t->tp)); e = t->cur; while ((e = BTPDQ_NEXT(e, entry)) != NULL && e->failure != NULL) ; if (e != NULL) { entry_send(t, e, t->event); break; } t->bad_conns++; if (t->event == TR_EV_STOPPED && t->bad_conns > 1) t->active = 0; else if (t->bad_conns == 1) entry_send(t, BTPDQ_FIRST(&t->trackers), t->event); else if (t->bad_conns == 2) btpd_timer_add(&t->timer, RETRY1_TIMEOUT); else btpd_timer_add(&t->timer, RETRY2_TIMEOUT); break; case TR_RES_BAD: btpd_log(BTPD_L_ERROR, "bad data from tracker '%s' for '%s'.\n", t->cur->url, torrent_name(t->tp)); case TR_RES_OK: if (TR_RES_OK) btpd_log(BTPD_L_TR, "response from '%s' for '%s'.\n", t->cur->url, torrent_name(t->tp)); if (t->event == TR_EV_STOPPED) t->active = 0; else { t->event = TR_EV_EMPTY; if (res->interval > 0) t->interval = res->interval; btpd_timer_add(&t->timer, (& (struct timespec) { t->interval > 0 ? t->interval : DEFAULT_INTERVAL, 0 })); } t->bad_conns = 0; t->has_responded = 1; BTPDQ_REMOVE(&t->trackers, t->cur, entry); BTPDQ_INSERT_HEAD(&t->trackers, t->cur, entry); break; default: abort(); } } void tr_init(void) { tr_key = random(); } btpd-0.16/btpd/download.c0000644000175000001440000001076111417473677012240 00000000000000#include "btpd.h" /* * Called when a peer announces it's got a new piece. * * If the piece is missing or unfull we increase the peer's * wanted level and if possible call dl_on_download. */ void dl_on_piece_ann(struct peer *p, uint32_t index) { struct net *n = p->n; n->piece_count[index]++; if (cm_has_piece(n->tp, index)) return; struct piece *pc = dl_find_piece(n, index); if (n->endgame) { assert(pc != NULL); peer_want(p, index); if (peer_leech_ok(p)) dl_assign_requests_eg(p); } else if (pc == NULL) { peer_want(p, index); if (peer_leech_ok(p)) { pc = dl_new_piece(n, index); dl_piece_assign_requests(pc, p); } } else if (!piece_full(pc)) { peer_want(p, index); if (peer_leech_ok(p)) dl_piece_assign_requests(pc, p); } } void dl_on_download(struct peer *p) { struct net *n = p->n; if (n->endgame) dl_assign_requests_eg(p); else dl_assign_requests(p); } void dl_on_unchoke(struct peer *p) { if (peer_leech_ok(p)) dl_on_download(p); } void dl_on_undownload(struct peer *p) { if (!p->n->endgame) dl_unassign_requests(p); else dl_unassign_requests_eg(p); } void dl_on_choke(struct peer *p) { if (p->nreqs_out > 0) dl_on_undownload(p); } /** * Called when a piece has been tested positively. */ void dl_on_ok_piece(struct net *n, uint32_t piece) { struct peer *p; struct piece *pc = dl_find_piece(n, piece); btpd_log(BTPD_L_POL, "Got piece: %u.\n", pc->index); struct net_buf *have = nb_create_have(pc->index); nb_hold(have); BTPDQ_FOREACH(p, &n->peers, p_entry) if (!peer_has(p, pc->index)) peer_send(p, have); nb_drop(have); if (n->endgame) BTPDQ_FOREACH(p, &n->peers, p_entry) peer_unwant(p, pc->index); piece_log_good(pc); assert(pc->nreqs == 0); piece_free(pc); } /* * Called when a piece has been tested negatively. */ void dl_on_bad_piece(struct net *n, uint32_t piece) { struct piece *pc = dl_find_piece(n, piece); btpd_log(BTPD_L_ERROR, "Bad hash for piece %u of '%s'.\n", pc->index, torrent_name(n->tp)); for (uint32_t i = 0; i < pc->nblocks; i++) clear_bit(pc->down_field, i); pc->ngot = 0; pc->nbusy = 0; piece_log_bad(pc); if (n->endgame) { struct peer *p; BTPDQ_FOREACH(p, &n->peers, p_entry) { if (peer_leech_ok(p) && peer_requestable(p, pc->index)) dl_assign_requests_eg(p); } } else dl_on_piece_unfull(pc); } void dl_on_new_peer(struct peer *p) { } void dl_on_lost_peer(struct peer *p) { struct net *n = p->n; for (uint32_t i = 0; i < n->tp->npieces; i++) if (peer_has(p, i)) n->piece_count[i]--; if (p->nreqs_out > 0) dl_on_undownload(p); } void dl_on_block(struct peer *p, struct block_request *req, uint32_t index, uint32_t begin, uint32_t length, const uint8_t *data) { struct net *n = p->n; struct piece *pc = dl_find_piece(n, index); piece_log_block(pc, p, begin); cm_put_bytes(p->n->tp, index, begin, data, length); pc->ngot++; if (n->endgame) { struct block_request *req, *next; struct net_buf *cancel = nb_create_cancel(index, begin, length); nb_hold(cancel); BTPDQ_FOREACH(req, &pc->reqs, blk_entry) { if (nb_get_begin(req->msg) == begin) { if (req->p != p) peer_cancel(req->p, req, cancel); pc->nreqs--; } } nb_drop(cancel); dl_piece_reorder_eg(pc); BTPDQ_FOREACH_MUTABLE(req, &pc->reqs, blk_entry, next) { if (nb_get_begin(req->msg) != begin) continue; BTPDQ_REMOVE(&pc->reqs, req, blk_entry); nb_drop(req->msg); if (peer_leech_ok(req->p)) dl_assign_requests_eg(req->p); free(req); } if (pc->ngot == pc->nblocks) cm_test_piece(pc->n->tp, pc->index); } else { BTPDQ_REMOVE(&pc->reqs, req, blk_entry); nb_drop(req->msg); free(req); pc->nreqs--; // XXX: Needs to be looked at if we introduce snubbing. clear_bit(pc->down_field, begin / PIECE_BLOCKLEN); pc->nbusy--; if (pc->ngot == pc->nblocks) cm_test_piece(pc->n->tp, pc->index); if (peer_leech_ok(p)) dl_assign_requests(p); } } btpd-0.16/btpd/net.c0000644000175000001440000004576311417473677011231 00000000000000#include "btpd.h" #include #include static unsigned long m_bw_bytes_in; static unsigned long m_bw_bytes_out; static unsigned long m_rate_up; static unsigned long m_rate_dwn; struct net_listener { int sd; struct fdev ev; }; static int m_nlisteners; static struct net_listener *m_net_listeners; unsigned net_npeers; struct peer_tq net_bw_readq = BTPDQ_HEAD_INITIALIZER(net_bw_readq); struct peer_tq net_bw_writeq = BTPDQ_HEAD_INITIALIZER(net_bw_writeq); struct peer_tq net_unattached = BTPDQ_HEAD_INITIALIZER(net_unattached); void net_ban_peer(struct net *n, struct meta_peer *mp) { if (mp->flags & PF_BANNED) return; mp_hold(mp); // Keep the meta peer alive mp->flags |= PF_BANNED; btpd_log(BTPD_L_BAD, "banned peer %p.\n", mp); } int net_torrent_has_peer(struct net *n, const uint8_t *id) { return mptbl_find(n->mptbl, id) != NULL; } void net_create(struct torrent *tp) { struct net *n = btpd_calloc(1, sizeof(*n)); n->tp = tp; tp->net = n; if ((n->mptbl = mptbl_create(3, btpd_id_eq, btpd_id_hash)) == NULL) btpd_err("Out of memory.\n"); BTPDQ_INIT(&n->getlst); n->busy_field = btpd_calloc(ceil(tp->npieces / 8.0), 1); n->piece_count = btpd_calloc(tp->npieces, sizeof(*n->piece_count)); } void net_kill(struct torrent *tp) { struct htbl_iter it; struct meta_peer *mp = mptbl_iter_first(tp->net->mptbl, &it); while (mp != NULL) { struct meta_peer *mps = mp; mp = mptbl_iter_del(&it); mp_kill(mps); } mptbl_free(tp->net->mptbl); free(tp->net->piece_count); free(tp->net->busy_field); free(tp->net); tp->net = NULL; } void net_start(struct torrent *tp) { struct net *n = tp->net; n->active = 1; } void net_stop(struct torrent *tp) { struct net *n = tp->net; n->active = 0; n->rate_up = 0; n->rate_dwn = 0; ul_on_lost_torrent(n); struct piece *pc; while ((pc = BTPDQ_FIRST(&n->getlst)) != NULL) piece_free(pc); BTPDQ_INIT(&n->getlst); struct peer *p = BTPDQ_FIRST(&net_unattached); while (p != NULL) { struct peer *next = BTPDQ_NEXT(p, p_entry); if (p->n == n) peer_kill(p); p = next; } p = BTPDQ_FIRST(&n->peers); while (p != NULL) { struct peer *next = BTPDQ_NEXT(p, p_entry); peer_kill(p); p = next; } } int net_active(struct torrent *tp) { return tp->net->active; } #define BLOCK_MEM_COUNT 1 static unsigned long net_write(struct peer *p, unsigned long wmax) { struct nb_link *nl; struct iovec iov[IOV_MAX]; int niov; int limited; ssize_t nwritten; unsigned long bcount; int block_count = 0; limited = wmax > 0; niov = 0; assert((nl = BTPDQ_FIRST(&p->outq)) != NULL); if (nl->nb->type == NB_TORRENTDATA) block_count = 1; while ((niov < IOV_MAX && nl != NULL && (!limited || (limited && wmax > 0)))) { if (nl->nb->type == NB_PIECE) { if (block_count >= BLOCK_MEM_COUNT) break; struct net_buf *tdata = BTPDQ_NEXT(nl, entry)->nb; if (tdata->buf == NULL) { if (nb_torrentdata_fill(tdata, p->n->tp, nb_get_index(nl->nb), nb_get_begin(nl->nb), nb_get_length(nl->nb)) != 0) { peer_kill(p); return 0; } } block_count++; } if (niov > 0) { iov[niov].iov_base = nl->nb->buf; iov[niov].iov_len = nl->nb->len; } else { iov[niov].iov_base = nl->nb->buf + p->outq_off; iov[niov].iov_len = nl->nb->len - p->outq_off; } if (limited) { if (iov[niov].iov_len > wmax) iov[niov].iov_len = wmax; wmax -= iov[niov].iov_len; } niov++; nl = BTPDQ_NEXT(nl, entry); } nwritten = writev(p->sd, iov, niov); if (nwritten < 0) { if (errno == EAGAIN) { p->t_wantwrite = btpd_seconds; return 0; } else { btpd_log(BTPD_L_CONN, "write error: %s\n", strerror(errno)); peer_kill(p); return 0; } } else if (nwritten == 0) { btpd_log(BTPD_L_CONN, "connection closed by peer.\n"); peer_kill(p); return 0; } bcount = nwritten; nl = BTPDQ_FIRST(&p->outq); while (bcount > 0) { unsigned long bufdelta = nl->nb->len - p->outq_off; if (bcount >= bufdelta) { peer_sent(p, nl->nb); if (nl->nb->type == NB_TORRENTDATA) { p->n->uploaded += bufdelta; p->count_up += bufdelta; } bcount -= bufdelta; BTPDQ_REMOVE(&p->outq, nl, entry); nb_drop(nl->nb); free(nl); p->outq_off = 0; nl = BTPDQ_FIRST(&p->outq); } else { if (nl->nb->type == NB_TORRENTDATA) { p->n->uploaded += bcount; p->count_up += bcount; } p->outq_off += bcount; bcount = 0; } } if (!BTPDQ_EMPTY(&p->outq)) p->t_wantwrite = btpd_seconds; else btpd_ev_disable(&p->ioev, EV_WRITE); p->t_lastwrite = btpd_seconds; return nwritten; } static int net_dispatch_msg(struct peer *p, const char *buf) { uint32_t index, begin, length; int res = 0; switch (p->in.msg_num) { case MSG_CHOKE: peer_on_choke(p); break; case MSG_UNCHOKE: peer_on_unchoke(p); break; case MSG_INTEREST: peer_on_interest(p); break; case MSG_UNINTEREST: peer_on_uninterest(p); break; case MSG_HAVE: peer_on_have(p, dec_be32(buf)); break; case MSG_BITFIELD: if (p->npieces == 0) peer_on_bitfield(p, buf); else res = 1; break; case MSG_REQUEST: if ((p->mp->flags & (PF_P_WANT|PF_I_CHOKE)) == PF_P_WANT) { index = dec_be32(buf); begin = dec_be32(buf + 4); length = dec_be32(buf + 8); if ((length > PIECE_BLOCKLEN || index >= p->n->tp->npieces || !cm_has_piece(p->n->tp, index) || begin + length > torrent_piece_size(p->n->tp, index))) { btpd_log(BTPD_L_MSG, "bad request: (%u, %u, %u) from %p\n", index, begin, length, p); res = 1; break; } peer_on_request(p, index, begin, length); } break; case MSG_CANCEL: index = dec_be32(buf); begin = dec_be32(buf + 4); length = dec_be32(buf + 8); peer_on_cancel(p, index, begin, length); break; case MSG_PIECE: length = p->in.msg_len - 9; peer_on_piece(p, p->in.pc_index, p->in.pc_begin, length, buf); break; default: abort(); } return res; } static int net_mh_ok(struct peer *p) { uint32_t mlen = p->in.msg_len; switch (p->in.msg_num) { case MSG_CHOKE: case MSG_UNCHOKE: case MSG_INTEREST: case MSG_UNINTEREST: return mlen == 1; case MSG_HAVE: return mlen == 5; case MSG_BITFIELD: return mlen == (uint32_t)ceil(p->n->tp->npieces / 8.0) + 1; case MSG_REQUEST: case MSG_CANCEL: return mlen == 13; case MSG_PIECE: return mlen <= PIECE_BLOCKLEN + 9; default: return 0; } } static void net_progress(struct peer *p, size_t length) { if (p->in.state == BTP_MSGBODY && p->in.msg_num == MSG_PIECE) { p->n->downloaded += length; p->count_dwn += length; } } static int net_state(struct peer *p, const char *buf) { switch (p->in.state) { case SHAKE_PSTR: if (bcmp(buf, "\x13""BitTorrent protocol", 20) != 0) goto bad; peer_set_in_state(p, SHAKE_INFO, 20); break; case SHAKE_INFO: if (p->mp->flags & PF_INCOMING) { struct torrent *tp = torrent_by_hash(buf); if (tp == NULL || !net_active(tp)) goto bad; p->n = tp->net; peer_send(p, nb_create_shake(tp)); } else if (bcmp(buf, p->n->tp->tl->hash, 20) != 0) goto bad; peer_set_in_state(p, SHAKE_ID, 20); break; case SHAKE_ID: if ((net_torrent_has_peer(p->n, buf) || bcmp(buf, btpd_get_peer_id(), 20) == 0)) goto bad; bcopy(buf, p->mp->id, 20); peer_on_shake(p); peer_set_in_state(p, BTP_MSGSIZE, 4); break; case BTP_MSGSIZE: p->in.msg_len = dec_be32(buf); if (p->in.msg_len == 0) peer_on_keepalive(p); else peer_set_in_state(p, BTP_MSGHEAD, 1); break; case BTP_MSGHEAD: p->in.msg_num = buf[0]; if (!net_mh_ok(p)) goto bad; else if (p->in.msg_len == 1) { if (net_dispatch_msg(p, buf) != 0) goto bad; peer_set_in_state(p, BTP_MSGSIZE, 4); } else if (p->in.msg_num == MSG_PIECE) peer_set_in_state(p, BTP_PIECEMETA, 8); else peer_set_in_state(p, BTP_MSGBODY, p->in.msg_len - 1); break; case BTP_PIECEMETA: p->in.pc_index = dec_be32(buf); p->in.pc_begin = dec_be32(buf + 4); peer_set_in_state(p, BTP_MSGBODY, p->in.msg_len - 9); break; case BTP_MSGBODY: if (net_dispatch_msg(p, buf) != 0) goto bad; peer_set_in_state(p, BTP_MSGSIZE, 4); break; default: abort(); } return 0; bad: btpd_log(BTPD_L_CONN, "bad data from %p (%u, %u, %u).\n", p, p->in.state, p->in.msg_len, p->in.msg_num); peer_kill(p); return -1; } #define GRBUFLEN (1 << 15) static unsigned long net_read(struct peer *p, unsigned long rmax) { size_t rest = p->in.buf != NULL ? p->in.st_bytes - p->in.off : 0; char buf[GRBUFLEN]; struct iovec iov[2] = { { p->in.buf + p->in.off, rest }, { buf, sizeof(buf) } }; if (rmax > 0) { if (iov[0].iov_len > rmax) iov[0].iov_len = rmax; iov[1].iov_len = min(rmax - iov[0].iov_len, iov[1].iov_len); } ssize_t nread = readv(p->sd, iov, 2); if (nread < 0 && errno == EAGAIN) goto out; else if (nread < 0) { btpd_log(BTPD_L_CONN, "Read error (%s) on %p.\n", strerror(errno), p); peer_kill(p); return 0; } else if (nread == 0) { btpd_log(BTPD_L_CONN, "Connection closed by %p.\n", p); peer_kill(p); return 0; } if (rest > 0) { if (nread < rest) { p->in.off += nread; net_progress(p, nread); goto out; } net_progress(p, rest); if (net_state(p, p->in.buf) != 0) return nread; free(p->in.buf); p->in.buf = NULL; p->in.off = 0; } iov[1].iov_len = nread - rest; while (p->in.st_bytes <= iov[1].iov_len) { size_t consumed = p->in.st_bytes; net_progress(p, consumed); if (net_state(p, iov[1].iov_base) != 0) return nread; iov[1].iov_base += consumed; iov[1].iov_len -= consumed; } if (iov[1].iov_len > 0) { net_progress(p, iov[1].iov_len); p->in.off = iov[1].iov_len; p->in.buf = btpd_malloc(p->in.st_bytes); bcopy(iov[1].iov_base, p->in.buf, iov[1].iov_len); } out: return nread > 0 ? nread : 0; } int net_connect_addr(int family, struct sockaddr *sa, socklen_t salen, int *sd) { if ((*sd = socket(family, SOCK_STREAM, 0)) == -1) return errno; set_nonblocking(*sd); if (connect(*sd, sa, salen) == -1 && errno != EINPROGRESS) { int err = errno; btpd_log(BTPD_L_CONN, "Botched connection %s.\n", strerror(errno)); close(*sd); return err; } return 0; } int net_connect_name(const char *ip, int port, int *sd) { struct addrinfo hints, *res; char portstr[6]; assert(net_npeers < net_max_peers); if (snprintf(portstr, sizeof(portstr), "%d", port) >= sizeof(portstr)) return EINVAL; bzero(&hints, sizeof(hints)); hints.ai_family = net_af_spec(); hints.ai_flags = AI_NUMERICHOST; hints.ai_socktype = SOCK_STREAM; if (getaddrinfo(ip, portstr, &hints, &res) != 0) return errno; int error = net_connect_addr(res->ai_family, res->ai_addr, res->ai_addrlen, sd); freeaddrinfo(res); return error; } void net_connection_cb(int sd, short type, void *arg) { int nsd; nsd = accept(sd, NULL, NULL); if (nsd < 0) { if (errno == EWOULDBLOCK || errno == ECONNABORTED) return; else btpd_err("accept: %s\n", strerror(errno)); } if (set_nonblocking(nsd) != 0) { close(nsd); return; } assert(net_npeers <= net_max_peers); if (net_npeers == net_max_peers) { close(nsd); return; } peer_create_in(nsd); btpd_log(BTPD_L_CONN, "got connection.\n"); } static unsigned long compute_rate_sub(unsigned long rate) { if (rate > 256 * RATEHISTORY) return rate / RATEHISTORY; else return min(256, rate); } static void compute_rates(void) { unsigned long tot_up = 0, tot_dwn = 0; struct torrent *tp; BTPDQ_FOREACH(tp, torrent_get_all(), entry) { unsigned long tp_up = 0, tp_dwn = 0; struct net *n = tp->net; struct peer *p; BTPDQ_FOREACH(p, &n->peers, p_entry) { if (p->count_up > 0 || peer_active_up(p)) { tp_up += p->count_up; p->rate_up += p->count_up - compute_rate_sub(p->rate_up); p->count_up = 0; } if (p->count_dwn > 0 || peer_active_down(p)) { tp_dwn += p->count_dwn; p->rate_dwn += p->count_dwn - compute_rate_sub(p->rate_dwn); p->count_dwn = 0; } } n->rate_up += tp_up - compute_rate_sub(n->rate_up); n->rate_dwn += tp_dwn - compute_rate_sub(n->rate_dwn); tot_up += tp_up; tot_dwn += tp_dwn; } m_rate_up += tot_up - compute_rate_sub(m_rate_up); m_rate_dwn += tot_dwn - compute_rate_sub(m_rate_dwn); } static void net_bw_tick(void) { struct peer *p; m_bw_bytes_out = net_bw_limit_out; m_bw_bytes_in = net_bw_limit_in; if (net_bw_limit_in > 0) { while ((p = BTPDQ_FIRST(&net_bw_readq)) != NULL && m_bw_bytes_in > 0) { BTPDQ_REMOVE(&net_bw_readq, p, rq_entry); btpd_ev_enable(&p->ioev, EV_READ); p->mp->flags &= ~PF_ON_READQ; m_bw_bytes_in -= net_read(p, m_bw_bytes_in); } } else { while ((p = BTPDQ_FIRST(&net_bw_readq)) != NULL) { BTPDQ_REMOVE(&net_bw_readq, p, rq_entry); btpd_ev_enable(&p->ioev, EV_READ); p->mp->flags &= ~PF_ON_READQ; net_read(p, 0); } } if (net_bw_limit_out) { while (((p = BTPDQ_FIRST(&net_bw_writeq)) != NULL && m_bw_bytes_out > 0)) { BTPDQ_REMOVE(&net_bw_writeq, p, wq_entry); btpd_ev_enable(&p->ioev, EV_WRITE); p->mp->flags &= ~PF_ON_WRITEQ; m_bw_bytes_out -= net_write(p, m_bw_bytes_out); } } else { while ((p = BTPDQ_FIRST(&net_bw_writeq)) != NULL) { BTPDQ_REMOVE(&net_bw_writeq, p, wq_entry); btpd_ev_enable(&p->ioev, EV_WRITE); p->mp->flags &= ~PF_ON_WRITEQ; net_write(p, 0); } } } static void run_peer_ticks(void) { struct torrent *tp; struct peer *p, *next; BTPDQ_FOREACH_MUTABLE(p, &net_unattached, p_entry, next) peer_on_tick(p); BTPDQ_FOREACH(tp, torrent_get_all(), entry) BTPDQ_FOREACH_MUTABLE(p, &tp->net->peers, p_entry, next) peer_on_tick(p); } void net_on_tick(void) { run_peer_ticks(); compute_rates(); net_bw_tick(); } static void net_read_cb(struct peer *p) { if (net_bw_limit_in == 0) net_read(p, 0); else if (m_bw_bytes_in > 0) m_bw_bytes_in -= net_read(p, m_bw_bytes_in); else { btpd_ev_disable(&p->ioev, EV_READ); p->mp->flags |= PF_ON_READQ; BTPDQ_INSERT_TAIL(&net_bw_readq, p, rq_entry); } } static void net_write_cb(struct peer *p) { if (net_bw_limit_out == 0) net_write(p, 0); else if (m_bw_bytes_out > 0) m_bw_bytes_out -= net_write(p, m_bw_bytes_out); else { btpd_ev_disable(&p->ioev, EV_WRITE); p->mp->flags |= PF_ON_WRITEQ; BTPDQ_INSERT_TAIL(&net_bw_writeq, p, wq_entry); } } void net_io_cb(int sd, short type, void *arg) { switch (type) { case EV_READ: net_read_cb(arg); break; case EV_WRITE: net_write_cb(arg); break; default: abort(); } } int net_af_spec(void) { if (net_ipv4 && net_ipv6) return AF_UNSPEC; else if (net_ipv4) return AF_INET; else return AF_INET6; } void net_shutdown(void) { for (int i = 0; i < m_nlisteners; i++) { btpd_ev_del(&m_net_listeners[i].ev); close(m_net_listeners[i].sd); } } void net_init(void) { m_bw_bytes_out = net_bw_limit_out; m_bw_bytes_in = net_bw_limit_in; int safe_fds = getdtablesize() * 4 / 5; if (net_max_peers == 0 || net_max_peers > safe_fds) net_max_peers = safe_fds; int count = 0, flag = 1, found_ipv4 = 0, found_ipv6 = 0, sd; char portstr[6]; struct addrinfo hints, *res, *ai; bzero(&hints, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; hints.ai_family = net_af_spec(); hints.ai_socktype = SOCK_STREAM; snprintf(portstr, sizeof(portstr), "%hu", net_port); if ((errno = getaddrinfo(NULL, portstr, &hints, &res)) != 0) btpd_err("getaddrinfo failed (%s).\n", gai_strerror(errno)); for (ai = res; ai != NULL; ai = ai->ai_next) { count++; if (ai->ai_family == AF_INET) found_ipv4 = 1; else found_ipv6 = 1; } net_ipv4 = found_ipv4; net_ipv6 = found_ipv6; if (!net_ipv4 && !net_ipv6) btpd_err("no usable address found. wrong use of -4/-6 perhaps.\n"); m_nlisteners = count; m_net_listeners = btpd_calloc(count, sizeof(*m_net_listeners)); for (ai = res; ai != NULL; ai = ai->ai_next) { count--; if ((sd = socket(ai->ai_family, ai->ai_socktype, 0)) == -1) btpd_err("failed to create socket (%s).\n", strerror(errno)); setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)); #ifdef IPV6_V6ONLY if (ai->ai_family == AF_INET6) setsockopt(sd, IPPROTO_IPV6, IPV6_V6ONLY, &flag, sizeof(flag)); #endif if (bind(sd, ai->ai_addr, ai->ai_addrlen) == -1) btpd_err("bind failed (%s).\n", strerror(errno)); listen(sd, 10); set_nonblocking(sd); m_net_listeners[count].sd = sd; btpd_ev_new(&m_net_listeners[count].ev, sd, EV_READ, net_connection_cb, NULL); } freeaddrinfo(res); } btpd-0.16/btpd/net_buf.c0000644000175000001440000001372511417473677012056 00000000000000#include "btpd.h" static struct net_buf *m_choke; static struct net_buf *m_unchoke; static struct net_buf *m_interest; static struct net_buf *m_uninterest; static struct net_buf *m_keepalive; static void kill_buf_no(char *buf, size_t len) { } static void kill_buf_free(char *buf, size_t len) { free(buf); } static void kill_buf_abort(char *buf, size_t len) { abort(); } static struct net_buf * nb_create_alloc(short type, size_t len) { struct net_buf *nb = btpd_calloc(1, sizeof(*nb) + len); nb->type = type; nb->buf = (char *)(nb + 1); nb->len = len; nb->kill_buf = kill_buf_no; return nb; } static struct net_buf * nb_create_set(short type, char *buf, size_t len, void (*kill_buf)(char *, size_t)) { struct net_buf *nb = btpd_calloc(1, sizeof(*nb)); nb->type = type; nb->buf = buf; nb->len = len; nb->kill_buf = kill_buf; return nb; } static struct net_buf * nb_create_onesized(char mtype, int btype) { struct net_buf *out = nb_create_alloc(btype, 5); enc_be32(out->buf, 1); out->buf[4] = mtype; return out; } static struct net_buf * nb_singleton(struct net_buf *nb) { nb_hold(nb); nb->kill_buf = kill_buf_abort; return nb; } struct net_buf * nb_create_keepalive(void) { if (m_keepalive == NULL) { m_keepalive = nb_create_alloc(NB_KEEPALIVE, 4); enc_be32(m_keepalive->buf, 0); nb_singleton(m_keepalive); } return m_keepalive; } struct net_buf * nb_create_piece(uint32_t index, uint32_t begin, size_t blen) { struct net_buf *out; out = nb_create_alloc(NB_PIECE, 13); enc_be32(out->buf, 9 + blen); out->buf[4] = MSG_PIECE; enc_be32(out->buf + 5, index); enc_be32(out->buf + 9, begin); return out; } struct net_buf * nb_create_torrentdata(void) { struct net_buf *out; out = nb_create_set(NB_TORRENTDATA, NULL, 0, kill_buf_no); return out; } int nb_torrentdata_fill(struct net_buf *nb, struct torrent *tp, uint32_t index, uint32_t begin, uint32_t length) { int err; uint8_t *content; assert(nb->type == NB_TORRENTDATA && nb->buf == NULL); if ((err = cm_get_bytes(tp, index, begin, length, &content)) != 0) return err; nb->buf = content; nb->len = length; nb->kill_buf = kill_buf_free; return 0; } struct net_buf * nb_create_request(uint32_t index, uint32_t begin, uint32_t length) { struct net_buf *out = nb_create_alloc(NB_REQUEST, 17); enc_be32(out->buf, 13); out->buf[4] = MSG_REQUEST; enc_be32(out->buf + 5, index); enc_be32(out->buf + 9, begin); enc_be32(out->buf + 13, length); return out; } struct net_buf * nb_create_cancel(uint32_t index, uint32_t begin, uint32_t length) { struct net_buf *out = nb_create_alloc(NB_CANCEL, 17); enc_be32(out->buf, 13); out->buf[4] = MSG_CANCEL; enc_be32(out->buf + 5, index); enc_be32(out->buf + 9, begin); enc_be32(out->buf + 13, length); return out; } struct net_buf * nb_create_have(uint32_t index) { struct net_buf *out = nb_create_alloc(NB_HAVE, 9); enc_be32(out->buf, 5); out->buf[4] = MSG_HAVE; enc_be32(out->buf + 5, index); return out; } struct net_buf * nb_create_multihave(struct torrent *tp) { uint32_t have_npieces = cm_pieces(tp); struct net_buf *out = nb_create_alloc(NB_MULTIHAVE, 9 * have_npieces); for (uint32_t i = 0, count = 0; count < have_npieces; i++) { if (cm_has_piece(tp, i)) { enc_be32(out->buf + count * 9, 5); out->buf[count * 9 + 4] = MSG_HAVE; enc_be32(out->buf + count * 9 + 5, i); count++; } } return out; } struct net_buf * nb_create_unchoke(void) { if (m_unchoke == NULL) m_unchoke = nb_singleton(nb_create_onesized(MSG_UNCHOKE, NB_UNCHOKE)); return m_unchoke; } struct net_buf * nb_create_choke(void) { if (m_choke == NULL) m_choke = nb_singleton(nb_create_onesized(MSG_CHOKE, NB_CHOKE)); return m_choke; } struct net_buf * nb_create_uninterest(void) { if (m_uninterest == NULL) m_uninterest = nb_singleton(nb_create_onesized(MSG_UNINTEREST, NB_UNINTEREST)); return m_uninterest; } struct net_buf * nb_create_interest(void) { if (m_interest == NULL) m_interest = nb_singleton(nb_create_onesized(MSG_INTEREST, NB_INTEREST)); return m_interest; } struct net_buf * nb_create_bitfield(struct torrent *tp) { uint32_t plen = ceil(tp->npieces / 8.0); struct net_buf *out = nb_create_alloc(NB_BITFIELD, 5); enc_be32(out->buf, plen + 1); out->buf[4] = MSG_BITFIELD; return out; } struct net_buf * nb_create_bitdata(struct torrent *tp) { uint32_t plen = ceil(tp->npieces / 8.0); struct net_buf *out = nb_create_set(NB_BITDATA, cm_get_piece_field(tp), plen, kill_buf_no); return out; } struct net_buf * nb_create_shake(struct torrent *tp) { struct net_buf *out = nb_create_alloc(NB_SHAKE, 68); bcopy("\x13""BitTorrent protocol\0\0\0\0\0\0\0\0", out->buf, 28); bcopy(tp->tl->hash, out->buf + 28, 20); bcopy(btpd_get_peer_id(), out->buf + 48, 20); return out; } uint32_t nb_get_index(struct net_buf *nb) { switch (nb->type) { case NB_CANCEL: case NB_HAVE: case NB_PIECE: case NB_REQUEST: return dec_be32(nb->buf + 5); default: abort(); } } uint32_t nb_get_begin(struct net_buf *nb) { switch (nb->type) { case NB_CANCEL: case NB_PIECE: case NB_REQUEST: return dec_be32(nb->buf + 9); default: abort(); } } uint32_t nb_get_length(struct net_buf *nb) { switch (nb->type) { case NB_CANCEL: case NB_REQUEST: return dec_be32(nb->buf + 13); case NB_PIECE: return dec_be32(nb->buf) - 9; default: abort(); } } int nb_drop(struct net_buf *nb) { assert(nb->refs > 0); nb->refs--; if (nb->refs == 0) { nb->kill_buf(nb->buf, nb->len); free(nb); return 1; } else return 0; } void nb_hold(struct net_buf *nb) { nb->refs++; } btpd-0.16/btpd/nameconn.c0000644000175000001440000000510111417473677012217 00000000000000#include "btpd.h" struct nameconn { struct fdev write_ev; void (*cb)(void *, int, int); void *arg; aictx_t ai_handle; struct addrinfo *ai_res, *ai_cur; int sd; enum { NC_AI, NC_CONN } state; }; static void nc_connect(struct nameconn *nc); static void nc_free(struct nameconn *nc) { if (nc->ai_res != NULL) freeaddrinfo(nc->ai_res); free(nc); } static void nc_done(struct nameconn *nc, int error) { nc->cb(nc->arg, error, nc->sd); nc_free(nc); } static void nc_write_cb(int sd, short type, void *arg) { struct nameconn *nc = arg; int error; socklen_t errsiz = sizeof(int); if (getsockopt(nc->sd, SOL_SOCKET, SO_ERROR, &error, &errsiz) < 0) btpd_err("getsockopt error (%s).\n", strerror(errno)); if (error == 0) { btpd_ev_del(&nc->write_ev); nc_done(nc, 0); } else { btpd_ev_del(&nc->write_ev); close(nc->sd); nc->ai_cur = nc->ai_cur->ai_next; nc_connect(nc); } } static void nc_connect(struct nameconn *nc) { struct addrinfo *ai; int err; again: if ((ai = nc->ai_cur) == NULL) { nc_done(nc, ENOTCONN); return; } if ((nc->sd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) btpd_err("Failed to create socket (%s).\n", strerror(errno)); set_nonblocking(nc->sd); err = connect(nc->sd, ai->ai_addr, ai->ai_addrlen); if (err == 0) nc_done(nc, 0); else if (err < 0 && errno == EINPROGRESS) btpd_ev_new(&nc->write_ev, nc->sd, EV_WRITE, nc_write_cb, nc); else { close(nc->sd); nc->ai_cur = ai->ai_next; goto again; } } static void nc_ai_cb(void *arg, int error, struct addrinfo *ai) { struct nameconn *nc = arg; if (error == 0) { nc->ai_cur = nc->ai_res = ai; nc->state = NC_CONN; nc_connect(nc); } else nc_done(nc, error); } nameconn_t btpd_name_connect(const char *name, short port, void (*cb)(void *, int, int), void *arg) { struct addrinfo hints; struct nameconn *nc = btpd_calloc(1, sizeof(*nc)); nc->cb = cb; nc->arg = arg; nc->sd = -1; bzero(&hints, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_family = net_af_spec(); hints.ai_socktype = SOCK_STREAM; nc->ai_handle = btpd_addrinfo(name, port, &hints, nc_ai_cb, nc); return nc; } void btpd_name_connect_cancel(struct nameconn *nc) { if (nc->state == NC_AI) btpd_addrinfo_cancel(nc->ai_handle); else { btpd_ev_del(&nc->write_ev); close(nc->sd); } nc_free(nc); } btpd-0.16/btpd/active.h0000644000175000001440000000026311417473677011705 00000000000000#ifndef BTPD_ACTIVE_H #define BTPD_ACTIVE_H void active_add(const uint8_t *hash); void active_del(const uint8_t *hash); void active_clear(void); void active_start(void); #endif btpd-0.16/btpd/http_tr_if.c0000644000175000001440000001544311417473677012575 00000000000000#include "btpd.h" #include #include #define MAX_DOWNLOAD (1 << 18) // 256kB static const char *m_tr_events[] = { "started", "stopped", "completed", "" }; struct httptr_req { struct torrent *tp; struct tr_tier *tr; struct http_req *req; struct iobuf buf; struct fdev ioev; struct timeout timer; nameconn_t nc; int sd; enum tr_event event; }; static void httptr_free(struct httptr_req *treq) { if (treq->sd != -1) { btpd_ev_del(&treq->ioev); close(treq->sd); } btpd_timer_del(&treq->timer); iobuf_free(&treq->buf); free(treq); } static void maybe_connect_to(struct torrent *tp, const char *pinfo) { const char *pid; char *ip; int port; size_t len; if ((pid = benc_dget_mem(pinfo, "peer id", &len)) == NULL || len != 20) return; if (bcmp(btpd_get_peer_id(), pid, 20) == 0) return; if (net_torrent_has_peer(tp->net, pid)) return; if ((ip = benc_dget_str(pinfo, "ip", NULL)) == NULL) return; port = benc_dget_int(pinfo, "port"); peer_create_out(tp->net, pid, ip, port); if (ip != NULL) free(ip); } static void parse_reply(struct torrent *tp, struct tr_response *res, const char *content, size_t size) { const char *buf; size_t len; const char *peers; const char *v6key[] = {"peers6", "peers_ipv6"}; if (benc_validate(content, size) != 0) goto bad_data; if ((buf = benc_dget_any(content, "failure reason")) != NULL) { if (!benc_isstr(buf)) goto bad_data; res->type = TR_RES_FAIL; res->mi_failure = buf; return; } buf = benc_dget_any(content, "interval"); if (buf != NULL && benc_isint(buf)) res->interval = benc_int(buf, NULL); if ((peers = benc_dget_any(content, "peers")) == NULL) goto after_peers; if (benc_islst(peers)) { for (peers = benc_first(peers); peers != NULL && net_npeers < net_max_peers; peers = benc_next(peers)) maybe_connect_to(tp, peers); } else if (benc_isstr(peers)) { if (net_ipv4) { peers = benc_dget_mem(content, "peers", &len); for (size_t i = 0; i < len && net_npeers < net_max_peers; i += 6) peer_create_out_compact(tp->net, AF_INET, peers + i); } } else goto bad_data; after_peers: if (!net_ipv6) goto after_peers6; for (int k = 0; k < 2; k++) { peers = benc_dget_any(content, v6key[k]); if (peers != NULL && benc_isstr(peers)) { peers = benc_dget_mem(content, v6key[k], &len); for (size_t i = 0; i < len && net_npeers < net_max_peers; i += 18) peer_create_out_compact(tp->net, AF_INET6, peers + i); } } after_peers6: res->type = TR_RES_OK; return; bad_data: res->type = TR_RES_BAD; } static void http_cb(struct http_req *req, struct http_response *res, void *arg) { struct httptr_req *treq = arg; struct tr_response tres = {0, NULL, -1 }; switch (res->type) { case HTTP_T_ERR: tres.type = TR_RES_BAD; tr_result(treq->tr, &tres); httptr_free(treq); break; case HTTP_T_DATA: if (treq->buf.off + res->v.data.l > MAX_DOWNLOAD) { tres.type = TR_RES_BAD; tr_result(treq->tr, &tres); httptr_cancel(treq); break; } if (!iobuf_write(&treq->buf, res->v.data.p, res->v.data.l)) btpd_err("Out of memory.\n"); break; case HTTP_T_DONE: if (treq->event == TR_EV_STOPPED) { tres.type = TR_RES_OK; tr_result(treq->tr, &tres); } else { parse_reply(treq->tp, &tres, treq->buf.buf, treq->buf.off); tr_result(treq->tr, &tres); } httptr_free(treq); break; default: break; } } static void httptr_io_cb(int sd, short type, void *arg) { struct tr_response res; struct httptr_req *treq = arg; switch (type) { case EV_READ: if (http_read(treq->req, sd) && !http_want_read(treq->req)) btpd_ev_disable(&treq->ioev, EV_READ); break; case EV_WRITE: if (http_write(treq->req, sd) && !http_want_write(treq->req)) btpd_ev_disable(&treq->ioev, EV_WRITE); break; case EV_TIMEOUT: res.type = TR_RES_CONN; tr_result(treq->tr, &res); httptr_cancel(treq); break; default: abort(); } } static void httptr_nc_cb(void *arg, int error, int sd) { struct tr_response res; struct httptr_req *treq = arg; if (error) { res.type = TR_RES_CONN; tr_result(treq->tr, &res); http_cancel(treq->req); httptr_free(treq); } else { treq->sd = sd; uint16_t flags = (http_want_read(treq->req) ? EV_READ : 0) | (http_want_write(treq->req) ? EV_WRITE : 0); btpd_ev_new(&treq->ioev, sd, flags, httptr_io_cb, treq); btpd_timer_add(&treq->timer, (& (struct timespec) { 30, 0 })); } } struct httptr_req * httptr_req(struct torrent *tp, struct tr_tier *tr, const char *aurl, enum tr_event event) { char e_hash[61], e_id[61], url[512], qc; const uint8_t *peer_id = btpd_get_peer_id(); struct http_url *http_url; qc = (strchr(aurl, '?') == NULL) ? '?' : '&'; for (int i = 0; i < 20; i++) snprintf(e_hash + i * 3, 4, "%%%.2x", tp->tl->hash[i]); for (int i = 0; i < 20; i++) snprintf(e_id + i * 3, 4, "%%%.2x", peer_id[i]); snprintf(url, sizeof(url), "%s%cinfo_hash=%s&peer_id=%s&key=%ld%s%s&port=%d&uploaded=%llu" "&downloaded=%llu&left=%llu&compact=1%s%s", aurl, qc, e_hash, e_id, tr_key, tr_ip_arg == NULL ? "" : "&ip=", tr_ip_arg == NULL ? "" : tr_ip_arg, net_port, tp->net->uploaded, tp->net->downloaded, (long long)tp->total_length - cm_content(tp), event == TR_EV_EMPTY ? "" : "&event=", m_tr_events[event]); struct httptr_req *treq = btpd_calloc(1, sizeof(*treq)); if (!http_get(&treq->req, url, "User-Agent: " BTPD_VERSION "\r\n", http_cb, treq)) { free(treq); return NULL; } treq->tp = tp; treq->tr = tr; treq->event = event; treq->buf = iobuf_init(4096); if (treq->buf.error) btpd_err("Out of memory.\n"); treq->tr = tr; treq->sd = -1; http_url = http_url_get(treq->req); treq->nc = btpd_name_connect(http_url->host, http_url->port, httptr_nc_cb, treq); evtimer_init(&treq->timer, httptr_io_cb, treq); btpd_timer_add(&treq->timer, (& (struct timespec) { 60, 0 })); return treq; } void httptr_cancel(struct httptr_req *treq) { if (treq->sd == -1) btpd_name_connect_cancel(treq->nc); http_cancel(treq->req); httptr_free(treq); } btpd-0.16/btpd/opts.c0000644000175000001440000000054111417473677011411 00000000000000#include "btpd.h" const char *btpd_dir; uint32_t btpd_logmask = BTPD_L_BTPD | BTPD_L_ERROR; int net_max_uploads = -2; unsigned net_max_peers; unsigned net_bw_limit_in; unsigned net_bw_limit_out; int net_port = 6881; off_t cm_alloc_size = 2048 * 1024; int ipcprot = 0600; int empty_start = 0; const char *tr_ip_arg; int net_ipv4 = 1; int net_ipv6 = 0; btpd-0.16/btpd/cli_if.c0000644000175000001440000003505211423447207011641 00000000000000#include "btpd.h" #include #include struct cli { int sd; struct fdev read; }; static int m_listen_sd; static struct fdev m_cli_incoming; static int write_buffer(struct cli *cli, struct iobuf *iob) { int err = 0; if (!iob->error) { uint32_t len = iob->off; write_fully(cli->sd, &len, sizeof(len)); err = write_fully(cli->sd, iob->buf, iob->off); } else btpd_err("Out of memory.\n"); iobuf_free(iob); return err; } static int write_code_buffer(struct cli *cli, enum ipc_err code) { struct iobuf iob = iobuf_init(16); iobuf_print(&iob, "d4:codei%uee", code); return write_buffer(cli, &iob); } static int write_add_buffer(struct cli *cli, unsigned num) { struct iobuf iob = iobuf_init(32); iobuf_print(&iob, "d4:codei%ue3:numi%uee", IPC_OK, num); return write_buffer(cli, &iob); } static void write_ans(struct iobuf *iob, struct tlib *tl, enum ipc_tval val) { enum ipc_tstate ts = IPC_TSTATE_INACTIVE; switch (val) { case IPC_TVAL_CGOT: iobuf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tp == NULL ? tl->content_have : (long long)cm_content(tl->tp)); return; case IPC_TVAL_CSIZE: iobuf_print(iob, "i%dei%llde", IPC_TYPE_NUM, (long long)tl->content_size); return; case IPC_TVAL_PCCOUNT: if (tl->tp == NULL) iobuf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); else iobuf_print(iob, "i%dei%lue", IPC_TYPE_NUM, (unsigned long)tl->tp->npieces); return; case IPC_TVAL_PCGOT: if (tl->tp == NULL) iobuf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); else iobuf_print(iob, "i%dei%lue", IPC_TYPE_NUM, (unsigned long)cm_pieces(tl->tp)); return; case IPC_TVAL_PCSEEN: if (tl->tp == NULL) iobuf_print(iob, "i%dei%de", IPC_TYPE_NUM, 0); else { unsigned long pcseen = 0; for (unsigned long i = 0; i < tl->tp->npieces; i++) if (tl->tp->net->piece_count[i] > 0) pcseen++; iobuf_print(iob, "i%dei%lue", IPC_TYPE_NUM, pcseen); } return; case IPC_TVAL_RATEDWN: iobuf_print(iob, "i%dei%lue", IPC_TYPE_NUM, tl->tp == NULL ? 0UL : tl->tp->net->rate_dwn / RATEHISTORY); return; case IPC_TVAL_RATEUP: iobuf_print(iob, "i%dei%lue", IPC_TYPE_NUM, tl->tp == NULL ? 0UL : tl->tp->net->rate_up / RATEHISTORY); return; case IPC_TVAL_SESSDWN: iobuf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tp == NULL ? 0LL : tl->tp->net->downloaded); return; case IPC_TVAL_SESSUP: iobuf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tp == NULL ? 0LL : tl->tp->net->uploaded); return; case IPC_TVAL_DIR: if (tl->dir != NULL) iobuf_print(iob, "i%de%d:%s", IPC_TYPE_STR, (int)strlen(tl->dir), tl->dir); else iobuf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_EBADTENT); return; case IPC_TVAL_NAME: if (tl->name != NULL) iobuf_print(iob, "i%de%d:%s", IPC_TYPE_STR, (int)strlen(tl->name), tl->name); else iobuf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_EBADTENT); return; case IPC_TVAL_IHASH: iobuf_print(iob, "i%de20:", IPC_TYPE_BIN); iobuf_write(iob, tl->hash, 20); return; case IPC_TVAL_NUM: iobuf_print(iob, "i%dei%ue", IPC_TYPE_NUM, tl->num); return; case IPC_TVAL_PCOUNT: iobuf_print(iob, "i%dei%ue", IPC_TYPE_NUM, tl->tp == NULL ? 0 : tl->tp->net->npeers); return; case IPC_TVAL_STATE: iobuf_print(iob, "i%de", IPC_TYPE_NUM); if (tl->tp != NULL) { switch (tl->tp->state) { case T_STARTING: ts = IPC_TSTATE_START; break; case T_STOPPING: ts = IPC_TSTATE_STOP; break; case T_SEED: ts = IPC_TSTATE_SEED; break; case T_LEECH: ts = IPC_TSTATE_LEECH; break; case T_GHOST: break; } } iobuf_print(iob, "i%de", ts); return; case IPC_TVAL_TOTDWN: iobuf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tot_down + (tl->tp == NULL ? 0 : tl->tp->net->downloaded)); return; case IPC_TVAL_TOTUP: iobuf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tot_up + (tl->tp == NULL ? 0 : tl->tp->net->uploaded)); return; case IPC_TVAL_TRERR: iobuf_print(iob, "i%dei%ue", IPC_TYPE_NUM, 0); return; case IPC_TVAL_TRGOOD: iobuf_print(iob, "i%dei%de", IPC_TYPE_NUM, tl->tp == NULL ? 0 : tr_good_count(tl->tp)); return; case IPC_TVALCOUNT: break; } iobuf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ENOKEY); } static int cmd_tget(struct cli *cli, int argc, const char *args) { if (argc != 1 || !benc_isdct(args)) return IPC_COMMERR; size_t nkeys; const char *keys, *p; enum ipc_tval *opts; struct iobuf iob; if ((keys = benc_dget_lst(args, "keys")) == NULL) return IPC_COMMERR; nkeys = benc_nelems(keys); opts = btpd_calloc(nkeys, sizeof(*opts)); p = benc_first(keys); for (int i = 0; i < nkeys; i++) opts[i] = benc_int(p, &p); iob = iobuf_init(1 << 15); iobuf_swrite(&iob, "d4:codei0e6:resultl"); p = benc_dget_any(args, "from"); if (benc_isint(p)) { enum ipc_twc from = benc_int(p, NULL); struct htbl_iter it; struct tlib *tl; for (tl = tlib_iter_first(&it); tl != NULL; tl = tlib_iter_next(&it)) { if (!torrent_haunting(tl) && ( from == IPC_TWC_ALL || (!torrent_active(tl) && from == IPC_TWC_INACTIVE) || (torrent_active(tl) && from == IPC_TWC_ACTIVE))) { iobuf_swrite(&iob, "l"); for (int k = 0; k < nkeys; k++) write_ans(&iob, tl, opts[k]); iobuf_swrite(&iob, "e"); } } } else if (benc_islst(p)) { for (p = benc_first(p); p != NULL; p = benc_next(p)) { struct tlib *tl = NULL; if (benc_isint(p)) tl = tlib_by_num(benc_int(p, NULL)); else if (benc_isstr(p) && benc_strlen(p) == 20) tl = tlib_by_hash(benc_mem(p, NULL, NULL)); else { iobuf_free(&iob); free(opts); return IPC_COMMERR; } if (tl != NULL && !torrent_haunting(tl)) { iobuf_swrite(&iob, "l"); for (int i = 0; i < nkeys; i++) write_ans(&iob, tl, opts[i]); iobuf_swrite(&iob, "e"); } else iobuf_print(&iob, "i%de", IPC_ENOTENT); } } iobuf_swrite(&iob, "ee"); free(opts); return write_buffer(cli, &iob); } static int cmd_add(struct cli *cli, int argc, const char *args) { if (argc != 1 || !benc_isdct(args)) return IPC_COMMERR; struct tlib *tl; size_t mi_size = 0, csize = 0; const char *mi, *cp; char content[PATH_MAX]; uint8_t hash[20]; if ((mi = benc_dget_mem(args, "torrent", &mi_size)) == NULL) return IPC_COMMERR; if (!mi_test(mi, mi_size)) return write_code_buffer(cli, IPC_EBADT); if ((cp = benc_dget_mem(args, "content", &csize)) == NULL || csize >= PATH_MAX || csize == 0) return write_code_buffer(cli, IPC_EBADCDIR); if (cp[0] != '/') return write_code_buffer(cli, IPC_EBADCDIR); bcopy(cp, content, csize); content[csize] = '\0'; tl = tlib_by_hash(mi_info_hash(mi, hash)); if (tl != NULL && !torrent_haunting(tl)) return write_code_buffer(cli, IPC_ETENTEXIST); if (tl != NULL) { tl = tlib_readd(tl, hash, mi, mi_size, content, benc_dget_str(args, "name", NULL)); } else { tl = tlib_add(hash, mi, mi_size, content, benc_dget_str(args, "name", NULL)); } return write_add_buffer(cli, tl->num); } static int cmd_del(struct cli *cli, int argc, const char *args) { if (argc != 1) return IPC_COMMERR; int ret; struct tlib *tl; if (benc_isstr(args) && benc_strlen(args) == 20) tl = tlib_by_hash(benc_mem(args, NULL, NULL)); else if (benc_isint(args)) tl = tlib_by_num(benc_int(args, NULL)); else return IPC_COMMERR; if (tl == NULL || torrent_haunting(tl)) ret = write_code_buffer(cli, IPC_ENOTENT); else { ret = write_code_buffer(cli, IPC_OK); if (tl->tp != NULL) torrent_stop(tl->tp, 1); else tlib_del(tl); } return ret; } static int cmd_start(struct cli *cli, int argc, const char *args) { if (argc != 1) return IPC_COMMERR; if (btpd_is_stopping()) return write_code_buffer(cli, IPC_ESHUTDOWN); struct tlib *tl; enum ipc_err code = IPC_OK; if (benc_isstr(args) && benc_strlen(args) == 20) tl = tlib_by_hash(benc_mem(args, NULL, NULL)); else if (benc_isint(args)) tl = tlib_by_num(benc_int(args, NULL)); else return IPC_COMMERR; if (tl == NULL || torrent_haunting(tl)) code = IPC_ENOTENT; else if (!torrent_startable(tl)) code = IPC_ETACTIVE; else if ((code = torrent_start(tl)) == IPC_OK) active_add(tl->hash); return write_code_buffer(cli, code); } static int cmd_start_all(struct cli *cli, int argc, const char *args) { struct htbl_iter it; struct tlib *tl; enum ipc_err last_code, ret_code= IPC_OK; if (btpd_is_stopping()) return write_code_buffer(cli, IPC_ESHUTDOWN); for (tl = tlib_iter_first(&it); tl != NULL; tl = tlib_iter_next(&it)) { if (torrent_startable(tl)) { if ((last_code = torrent_start(tl)) == IPC_OK) { active_add(tl->hash); } else { btpd_err("torrent_start(%d) failed.\n", tl->num); ret_code = last_code; } } } return write_code_buffer(cli, ret_code); } static int cmd_stop(struct cli *cli, int argc, const char *args) { if (argc != 1) return IPC_COMMERR; struct tlib *tl; if (benc_isstr(args) && benc_strlen(args) == 20) tl = tlib_by_hash(benc_mem(args, NULL, NULL)); else if (benc_isint(args)) tl = tlib_by_num(benc_int(args, NULL)); else return IPC_COMMERR; if (tl == NULL || torrent_haunting(tl)) return write_code_buffer(cli, IPC_ENOTENT); else if (!torrent_active(tl)) return write_code_buffer(cli, IPC_ETINACTIVE); else { // Stopping a torrent may trigger exit so we need to reply before. int ret = write_code_buffer(cli, IPC_OK); active_del(tl->hash); torrent_stop(tl->tp, 0); return ret; } } static int cmd_stop_all(struct cli *cli, int argc, const char *args) { struct torrent *tp, *next; int ret = write_code_buffer(cli, IPC_OK); active_clear(); BTPDQ_FOREACH_MUTABLE(tp, torrent_get_all(), entry, next) torrent_stop(tp, 0); return ret; } static int cmd_die(struct cli *cli, int argc, const char *args) { int err = write_code_buffer(cli, IPC_OK); if (!btpd_is_stopping()) { btpd_log(BTPD_L_BTPD, "Someone wants me dead.\n"); btpd_shutdown(); } return err; } static struct { const char *name; int nlen; int (*fun)(struct cli *cli, int, const char *); } cmd_table[] = { { "add", 3, cmd_add }, { "del", 3, cmd_del }, { "die", 3, cmd_die }, { "start", 5, cmd_start }, { "start-all", 9, cmd_start_all}, { "stop", 4, cmd_stop }, { "stop-all", 8, cmd_stop_all}, { "tget", 4, cmd_tget } }; static int ncmds = sizeof(cmd_table) / sizeof(cmd_table[0]); static int cmd_dispatch(struct cli *cli, const char *buf) { size_t cmdlen; const char *cmd; const char *args; cmd = benc_mem(benc_first(buf), &cmdlen, &args); for (int i = 0; i < ncmds; i++) { if ((cmdlen == cmd_table[i].nlen && strncmp(cmd_table[i].name, cmd, cmdlen) == 0)) { return cmd_table[i].fun(cli, benc_nelems(buf) - 1, args); } } return ENOENT; } static void cli_read_cb(int sd, short type, void *arg) { struct cli *cli = arg; uint32_t cmdlen; uint8_t *msg = NULL; if (read_fully(sd, &cmdlen, sizeof(cmdlen)) != 0) goto error; msg = btpd_malloc(cmdlen); if (read_fully(sd, msg, cmdlen) != 0) goto error; if (!(benc_validate(msg, cmdlen) == 0 && benc_islst(msg) && benc_first(msg) != NULL && benc_isstr(benc_first(msg)))) goto error; if (cmd_dispatch(cli, msg) != 0) goto error; free(msg); return; error: btpd_ev_del(&cli->read); close(cli->sd); free(cli); if (msg != NULL) free(msg); } void client_connection_cb(int sd, short type, void *arg) { int nsd; if ((nsd = accept(sd, NULL, NULL)) < 0) { if (errno == EWOULDBLOCK || errno == ECONNABORTED) return; else btpd_err("client accept: %s\n", strerror(errno)); } if ((errno = set_blocking(nsd)) != 0) btpd_err("set_blocking: %s.\n", strerror(errno)); struct cli *cli = btpd_calloc(1, sizeof(*cli)); cli->sd = nsd; btpd_ev_new(&cli->read, cli->sd, EV_READ, cli_read_cb, cli); } void ipc_shutdown(void) { btpd_ev_del(&m_cli_incoming); close(m_listen_sd); } void ipc_init(void) { int sd; struct sockaddr_un addr; size_t psiz = sizeof(addr.sun_path); addr.sun_family = PF_UNIX; if (snprintf(addr.sun_path, psiz, "%s/sock", btpd_dir) >= psiz) btpd_err("'%s/sock' is too long.\n", btpd_dir); if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) btpd_err("sock: %s\n", strerror(errno)); if (bind(sd, (struct sockaddr *)&addr, sizeof(addr)) != 0) { if (errno == EADDRINUSE) { unlink(addr.sun_path); if (bind(sd, (struct sockaddr *)&addr, sizeof(addr)) != 0) btpd_err("bind: %s\n", strerror(errno)); } else btpd_err("bind: %s\n", strerror(errno)); } if (chmod(addr.sun_path, ipcprot) == -1) btpd_err("chmod: %s (%s).\n", addr.sun_path, strerror(errno)); listen(sd, 4); set_nonblocking(sd); btpd_ev_new(&m_cli_incoming, sd, EV_READ, client_connection_cb, NULL); m_listen_sd = sd; } btpd-0.16/btpd/peer.h0000644000175000001440000000537311417473677011374 00000000000000#ifndef BTPD_PEER_H #define BTPD_PEER_H #define PF_I_WANT 0x1 /* We want to download from the peer */ #define PF_I_CHOKE 0x2 /* We choke the peer */ #define PF_P_WANT 0x4 /* The peer wants to download from us */ #define PF_P_CHOKE 0x8 /* The peer is choking us */ #define PF_ON_READQ 0x10 #define PF_ON_WRITEQ 0x20 #define PF_ATTACHED 0x40 #define PF_NO_REQUESTS 0x80 #define PF_INCOMING 0x100 #define PF_DO_UNWANT 0x200 #define PF_SUSPECT 0x400 #define PF_BANNED 0x800 #define MAXPIECEMSGS 128 #define MAXPIPEDREQUESTS 10 void peer_set_in_state(struct peer *p, enum input_state state, size_t size); void peer_send(struct peer *p, struct net_buf *nb); int peer_unsend(struct peer *p, struct nb_link *nl); void peer_sent(struct peer *p, struct net_buf *nb); void peer_keepalive(struct peer *p); void peer_unchoke(struct peer *p); void peer_choke(struct peer *p); void peer_unwant(struct peer *p, uint32_t index); void peer_want(struct peer *p, uint32_t index); void peer_request(struct peer *p, struct block_request *req); void peer_cancel(struct peer *p, struct block_request *req, struct net_buf *nb); int peer_requested(struct peer *p, uint32_t piece, uint32_t block); void peer_create_in(int sd); void peer_create_out(struct net *n, const uint8_t *id, const char *ip, int port); void peer_create_out_compact(struct net *n, int family, const char *compact); void peer_kill(struct peer *p); void peer_on_no_reqs(struct peer *p); void peer_on_keepalive(struct peer *p); void peer_on_shake(struct peer *p); void peer_on_interest(struct peer *p); void peer_on_uninterest(struct peer *p); void peer_on_choke(struct peer *p); void peer_on_unchoke(struct peer *p); void peer_on_have(struct peer *p, uint32_t index); void peer_on_bitfield(struct peer *p, const uint8_t *field); void peer_on_piece(struct peer *p, uint32_t index, uint32_t begin, uint32_t length, const char *data); void peer_on_request(struct peer *p, uint32_t index, uint32_t begin, uint32_t length); void peer_on_cancel(struct peer *p, uint32_t index, uint32_t begin, uint32_t length); void peer_on_tick(struct peer *p); int peer_active_down(struct peer *p); int peer_active_up(struct peer *p); int peer_chokes(struct peer *p); int peer_wanted(struct peer *p); int peer_laden(struct peer *p); int peer_has(struct peer *p, uint32_t index); int peer_has_bad(struct peer *p, uint32_t index); int peer_leech_ok(struct peer *p); int peer_full(struct peer *p); void peer_bad_piece(struct peer *p, uint32_t index); void peer_good_piece(struct peer *p, uint32_t index); int peer_requestable(struct peer *p, uint32_t index); void mp_hold(struct meta_peer *mp); void mp_drop(struct meta_peer *mp, struct net *n); void mp_kill(struct meta_peer *mp); #endif btpd-0.16/btpd/peer.c0000644000175000001440000004247511417473677011373 00000000000000#include "btpd.h" #include struct meta_peer * mp_create(void) { return btpd_calloc(1, sizeof(struct meta_peer)); } void mp_kill(struct meta_peer *mp) { free(mp); } void mp_hold(struct meta_peer *mp) { mp->refs++; } void mp_drop(struct meta_peer *mp, struct net *n) { assert(mp->refs > 0); mp->refs--; if (mp->refs == 0) { assert(mp->p == NULL); if (mp->flags & PF_ATTACHED) assert(mptbl_remove(n->mptbl, mp->id) == mp); mp_kill(mp); } } void peer_kill(struct peer *p) { struct nb_link *nl; btpd_log(BTPD_L_CONN, "killed peer %p\n", p); if (p->mp->flags & PF_ATTACHED) { BTPDQ_REMOVE(&p->n->peers, p, p_entry); p->n->npeers--; if (p->n->active) { ul_on_lost_peer(p); dl_on_lost_peer(p); } } else BTPDQ_REMOVE(&net_unattached, p, p_entry); if (p->mp->flags & PF_ON_READQ) BTPDQ_REMOVE(&net_bw_readq, p, rq_entry); if (p->mp->flags & PF_ON_WRITEQ) BTPDQ_REMOVE(&net_bw_writeq, p, wq_entry); btpd_ev_del(&p->ioev); close(p->sd); nl = BTPDQ_FIRST(&p->outq); while (nl != NULL) { struct nb_link *next = BTPDQ_NEXT(nl, entry); nb_drop(nl->nb); free(nl); nl = next; } p->mp->p = NULL; mp_drop(p->mp, p->n); if (p->in.buf != NULL) free(p->in.buf); if (p->piece_field != NULL) free(p->piece_field); if (p->bad_field != NULL) free(p->bad_field); free(p); net_npeers--; } void peer_set_in_state(struct peer *p, enum input_state state, size_t size) { p->in.state = state; p->in.st_bytes = size; } void peer_send(struct peer *p, struct net_buf *nb) { struct nb_link *nl = btpd_calloc(1, sizeof(*nl)); nl->nb = nb; nb_hold(nb); if (BTPDQ_EMPTY(&p->outq)) { assert(p->outq_off == 0); btpd_ev_enable(&p->ioev, EV_WRITE); p->t_wantwrite = btpd_seconds; } BTPDQ_INSERT_TAIL(&p->outq, nl, entry); } /* * Remove a network buffer from the peer's outq. * If a part of the buffer already have been written * to the network it cannot be removed. * * Returns 1 if the buffer is removed, 0 if not. */ int peer_unsend(struct peer *p, struct nb_link *nl) { if (!(nl == BTPDQ_FIRST(&p->outq) && p->outq_off > 0)) { BTPDQ_REMOVE(&p->outq, nl, entry); if (nl->nb->type == NB_TORRENTDATA) { assert(p->npiece_msgs > 0); p->npiece_msgs--; } nb_drop(nl->nb); free(nl); if (BTPDQ_EMPTY(&p->outq)) { if (p->mp->flags & PF_ON_WRITEQ) { BTPDQ_REMOVE(&net_bw_writeq, p, wq_entry); p->mp->flags &= ~PF_ON_WRITEQ; } else btpd_ev_disable(&p->ioev, EV_WRITE); } return 1; } else return 0; } void peer_sent(struct peer *p, struct net_buf *nb) { switch (nb->type) { case NB_KEEPALIVE: btpd_log(BTPD_L_MSG, "sent keepalive to %p\n", p); break; case NB_CHOKE: btpd_log(BTPD_L_MSG, "sent choke to %p\n", p); break; case NB_UNCHOKE: btpd_log(BTPD_L_MSG, "sent unchoke to %p\n", p); p->mp->flags &= ~PF_NO_REQUESTS; break; case NB_INTEREST: btpd_log(BTPD_L_MSG, "sent interest to %p\n", p); break; case NB_UNINTEREST: btpd_log(BTPD_L_MSG, "sent uninterest to %p\n", p); break; case NB_HAVE: btpd_log(BTPD_L_MSG, "sent have(%u) to %p\n", nb_get_index(nb), p); break; case NB_BITFIELD: btpd_log(BTPD_L_MSG, "sent bitfield to %p\n", p); break; case NB_REQUEST: btpd_log(BTPD_L_MSG, "sent request(%u,%u,%u) to %p\n", nb_get_index(nb), nb_get_begin(nb), nb_get_length(nb), p); break; case NB_PIECE: btpd_log(BTPD_L_MSG, "sent piece(%u,%u,%u) to %p\n", nb_get_index(nb), nb_get_begin(nb), nb_get_length(nb), p); break; case NB_CANCEL: btpd_log(BTPD_L_MSG, "sent cancel(%u,%u,%u) to %p\n", nb_get_index(nb), nb_get_begin(nb), nb_get_length(nb), p); break; case NB_TORRENTDATA: btpd_log(BTPD_L_MSG, "sent data to %p\n", p); assert(p->npiece_msgs > 0); p->npiece_msgs--; break; case NB_MULTIHAVE: btpd_log(BTPD_L_MSG, "sent multihave to %p\n", p); break; case NB_BITDATA: btpd_log(BTPD_L_MSG, "sent bitdata to %p\n", p); break; case NB_SHAKE: btpd_log(BTPD_L_MSG, "sent shake to %p\n", p); break; } } void peer_request(struct peer *p, struct block_request *req) { assert(p->nreqs_out < MAXPIPEDREQUESTS); p->nreqs_out++; BTPDQ_INSERT_TAIL(&p->my_reqs, req, p_entry); peer_send(p, req->msg); } int peer_requested(struct peer *p, uint32_t piece, uint32_t block) { uint32_t begin = block * PIECE_BLOCKLEN; struct block_request *req; BTPDQ_FOREACH(req, &p->my_reqs, p_entry) if (nb_get_index(req->msg) == piece && nb_get_begin(req->msg) == begin) return 1; return 0; } void peer_keepalive(struct peer *p) { peer_send(p, nb_create_keepalive()); } void peer_cancel(struct peer *p, struct block_request *req, struct net_buf *nb) { BTPDQ_REMOVE(&p->my_reqs, req, p_entry); p->nreqs_out--; int removed = 0; struct nb_link *nl; BTPDQ_FOREACH(nl, &p->outq, entry) { if (nl->nb == req->msg) { removed = peer_unsend(p, nl); break; } } if (!removed) peer_send(p, nb); if (p->nreqs_out == 0) peer_on_no_reqs(p); } void peer_unchoke(struct peer *p) { p->mp->flags &= ~PF_I_CHOKE; peer_send(p, nb_create_unchoke()); } void peer_choke(struct peer *p) { struct nb_link *nl = BTPDQ_FIRST(&p->outq); while (nl != NULL) { struct nb_link *next = BTPDQ_NEXT(nl, entry); if (nl->nb->type == NB_PIECE) { struct nb_link *data = next; next = BTPDQ_NEXT(next, entry); if (peer_unsend(p, nl)) peer_unsend(p, data); } nl = next; } p->mp->flags |= PF_I_CHOKE; peer_send(p, nb_create_choke()); } void peer_want(struct peer *p, uint32_t index) { if (!has_bit(p->piece_field, index) || peer_has_bad(p, index)) return; assert(p->nwant < p->npieces); p->nwant++; if (p->nwant == 1) { p->mp->flags |= PF_I_WANT; if (p->mp->flags & PF_SUSPECT) return; if (p->nreqs_out == 0) { assert((p->mp->flags & PF_DO_UNWANT) == 0); int unsent = 0; struct nb_link *nl = BTPDQ_LAST(&p->outq, nb_tq); if (nl != NULL && nl->nb->type == NB_UNINTEREST) unsent = peer_unsend(p, nl); if (!unsent) peer_send(p, nb_create_interest()); } else { assert((p->mp->flags & PF_DO_UNWANT) != 0); p->mp->flags &= ~PF_DO_UNWANT; } } } void peer_unwant(struct peer *p, uint32_t index) { if (!has_bit(p->piece_field, index) || peer_has_bad(p, index)) return; assert(p->nwant > 0); p->nwant--; if (p->nwant == 0) { p->mp->flags &= ~PF_I_WANT; if (p->mp->flags & PF_SUSPECT) return; p->t_nointerest = btpd_seconds; if (p->nreqs_out == 0) peer_send(p, nb_create_uninterest()); else p->mp->flags |= PF_DO_UNWANT; } } static struct peer * peer_create_common(int sd) { struct peer *p = btpd_calloc(1, sizeof(*p)); p->mp = mp_create(); mp_hold(p->mp); p->mp->p = p; p->sd = sd; p->mp->flags = PF_I_CHOKE | PF_P_CHOKE; p->t_created = btpd_seconds; p->t_lastwrite = btpd_seconds; p->t_nointerest = btpd_seconds; BTPDQ_INIT(&p->my_reqs); BTPDQ_INIT(&p->outq); peer_set_in_state(p, SHAKE_PSTR, 28); btpd_ev_new(&p->ioev, p->sd, EV_READ, net_io_cb, p); BTPDQ_INSERT_TAIL(&net_unattached, p, p_entry); net_npeers++; return p; } void peer_create_in(int sd) { struct peer *p = peer_create_common(sd); p->mp->flags |= PF_INCOMING; } void peer_create_out(struct net *n, const uint8_t *id, const char *ip, int port) { int sd; struct peer *p; if (net_connect_name(ip, port, &sd) != 0) return; p = peer_create_common(sd); p->n = n; peer_send(p, nb_create_shake(n->tp)); } void peer_create_out_compact(struct net *n, int family, const char *compact) { int sd; struct peer *p; struct sockaddr_storage addr; struct sockaddr_in *a4; struct sockaddr_in6 *a6; socklen_t addrlen; switch (family) { case AF_INET: if (!net_ipv4) return; a4 = (struct sockaddr_in *)&addr; a4->sin_family = AF_INET; addrlen = sizeof(*a4); bcopy(compact, &a4->sin_addr.s_addr, 4); bcopy(compact + 4, &a4->sin_port, 2); break; case AF_INET6: if (!net_ipv6) return; a6 = (struct sockaddr_in6 *)&addr; a6->sin6_family = AF_INET6; addrlen = sizeof(*a6); bcopy(compact, &a6->sin6_addr, 16); bcopy(compact + 16, &a6->sin6_port, 2); break; default: abort(); } if (net_connect_addr(family, (struct sockaddr *)&addr, addrlen, &sd) != 0) return; p = peer_create_common(sd); p->n = n; peer_send(p, nb_create_shake(n->tp)); } void peer_on_no_reqs(struct peer *p) { if ((p->mp->flags & PF_DO_UNWANT) != 0) { assert(p->nwant == 0); p->mp->flags &= ~PF_DO_UNWANT; peer_send(p, nb_create_uninterest()); } } void peer_on_keepalive(struct peer *p) { btpd_log(BTPD_L_MSG, "received keep alive from %p\n", p); } void peer_on_shake(struct peer *p) { uint8_t printid[21]; int i; for (i = 0; i < 20 && isprint(p->mp->id[i]); i++) printid[i] = p->mp->id[i]; printid[i] = '\0'; btpd_log(BTPD_L_MSG, "received shake(%s) from %p\n", printid, p); p->piece_field = btpd_calloc(1, (int)ceil(p->n->tp->npieces / 8.0)); if (cm_pieces(p->n->tp) > 0) { if ((cm_pieces(p->n->tp) * 9 < 5 + ceil(p->n->tp->npieces / 8.0))) peer_send(p, nb_create_multihave(p->n->tp)); else { peer_send(p, nb_create_bitfield(p->n->tp)); peer_send(p, nb_create_bitdata(p->n->tp)); } } mptbl_insert(p->n->mptbl, p->mp); BTPDQ_REMOVE(&net_unattached, p, p_entry); BTPDQ_INSERT_HEAD(&p->n->peers, p, p_entry); p->mp->flags |= PF_ATTACHED; p->n->npeers++; ul_on_new_peer(p); dl_on_new_peer(p); } void peer_on_choke(struct peer *p) { btpd_log(BTPD_L_MSG, "received choke from %p\n", p); if ((p->mp->flags & PF_P_CHOKE) != 0) return; else { p->mp->flags |= PF_P_CHOKE; dl_on_choke(p); struct nb_link *nl = BTPDQ_FIRST(&p->outq); while (nl != NULL) { struct nb_link *next = BTPDQ_NEXT(nl, entry); if (nl->nb->type == NB_REQUEST) peer_unsend(p, nl); nl = next; } } } void peer_on_unchoke(struct peer *p) { btpd_log(BTPD_L_MSG, "received unchoke from %p\n", p); if ((p->mp->flags & PF_P_CHOKE) == 0) return; else { p->mp->flags &= ~PF_P_CHOKE; dl_on_unchoke(p); } } void peer_on_interest(struct peer *p) { btpd_log(BTPD_L_MSG, "received interest from %p\n", p); if ((p->mp->flags & PF_P_WANT) != 0) return; else { p->mp->flags |= PF_P_WANT; ul_on_interest(p); } } void peer_on_uninterest(struct peer *p) { btpd_log(BTPD_L_MSG, "received uninterest from %p\n", p); if ((p->mp->flags & PF_P_WANT) == 0) return; else { p->mp->flags &= ~PF_P_WANT; p->t_nointerest = btpd_seconds; ul_on_uninterest(p); } } void peer_on_have(struct peer *p, uint32_t index) { btpd_log(BTPD_L_MSG, "received have(%u) from %p\n", index, p); if (!has_bit(p->piece_field, index)) { set_bit(p->piece_field, index); p->npieces++; dl_on_piece_ann(p, index); } } void peer_on_bitfield(struct peer *p, const uint8_t *field) { btpd_log(BTPD_L_MSG, "received bitfield from %p\n", p); assert(p->npieces == 0); bcopy(field, p->piece_field, (size_t)ceil(p->n->tp->npieces / 8.0)); for (uint32_t i = 0; i < p->n->tp->npieces; i++) { if (has_bit(p->piece_field, i)) { p->npieces++; dl_on_piece_ann(p, i); } } } void peer_on_piece(struct peer *p, uint32_t index, uint32_t begin, uint32_t length, const char *data) { struct block_request *req; BTPDQ_FOREACH(req, &p->my_reqs, p_entry) if ((nb_get_begin(req->msg) == begin && nb_get_index(req->msg) == index && nb_get_length(req->msg) == length)) break; if (req != NULL) { btpd_log(BTPD_L_MSG, "received piece(%u,%u,%u) from %p\n", index, begin, length, p); assert(p->nreqs_out > 0); p->nreqs_out--; BTPDQ_REMOVE(&p->my_reqs, req, p_entry); if (p->nreqs_out == 0) peer_on_no_reqs(p); dl_on_block(p, req, index, begin, length, data); } else btpd_log(BTPD_L_MSG, "discarded piece(%u,%u,%u) from %p\n", index, begin, length, p); } void peer_on_request(struct peer *p, uint32_t index, uint32_t begin, uint32_t length) { btpd_log(BTPD_L_MSG, "received request(%u,%u,%u) from %p\n", index, begin, length, p); if ((p->mp->flags & PF_NO_REQUESTS) == 0) { peer_send(p, nb_create_piece(index, begin, length)); peer_send(p, nb_create_torrentdata()); p->npiece_msgs++; if (p->npiece_msgs >= MAXPIECEMSGS) { peer_send(p, nb_create_choke()); peer_send(p, nb_create_unchoke()); p->mp->flags |= PF_NO_REQUESTS; } } } void peer_on_cancel(struct peer *p, uint32_t index, uint32_t begin, uint32_t length) { btpd_log(BTPD_L_MSG, "received cancel(%u,%u,%u) from %p\n", index, begin, length, p); struct nb_link *nl; BTPDQ_FOREACH(nl, &p->outq, entry) if (nl->nb->type == NB_PIECE && nb_get_begin(nl->nb) == begin && nb_get_index(nl->nb) == index && nb_get_length(nl->nb) == length) { struct nb_link *data = BTPDQ_NEXT(nl, entry); if (peer_unsend(p, nl)) peer_unsend(p, data); break; } } void peer_on_tick(struct peer *p) { if (p->mp->flags & PF_BANNED) goto kill; if (p->mp->flags & PF_ATTACHED) { if (BTPDQ_EMPTY(&p->outq)) { if (btpd_seconds - p->t_lastwrite >= 120) peer_keepalive(p); } else if (btpd_seconds - p->t_wantwrite >= 60) { btpd_log(BTPD_L_CONN, "write attempt timed out.\n"); goto kill; } if ((cm_full(p->n->tp) && !(p->mp->flags & PF_P_WANT) && btpd_seconds - p->t_nointerest >= 600)) { btpd_log(BTPD_L_CONN, "no interest for 10 minutes.\n"); goto kill; } } else if (btpd_seconds - p->t_created >= 60) { btpd_log(BTPD_L_CONN, "hand shake timed out.\n"); goto kill; } return; kill: peer_kill(p); } void peer_bad_piece(struct peer *p, uint32_t index) { if (p->npcs_bad == 0) { assert(p->bad_field == NULL); p->bad_field = btpd_calloc(ceil(p->n->tp->npieces / 8.0), 1); } assert(!has_bit(p->bad_field, index)); set_bit(p->bad_field, index); p->npcs_bad++; p->suspicion++; if (p->suspicion == 3) { btpd_log(BTPD_L_BAD, "suspect peer %p.\n", p); p->mp->flags |= PF_SUSPECT; if (p->nwant > 0) { p->mp->flags &= ~PF_DO_UNWANT; peer_send(p, nb_create_uninterest()); } } } void peer_good_piece(struct peer *p, uint32_t index) { if (peer_has_bad(p, index)) { assert(p->npcs_bad > 0); p->npcs_bad--; if (p->npcs_bad == 0) { free(p->bad_field); p->bad_field = NULL; } else clear_bit(p->bad_field, index); } p->suspicion = 0; if (p->mp->flags & PF_SUSPECT) { btpd_log(BTPD_L_BAD, "unsuspect peer %p.\n", p); p->mp->flags &= ~PF_SUSPECT; if (p->nwant > 0) { assert(p->mp->flags & PF_I_WANT); peer_send(p, nb_create_interest()); } if (peer_leech_ok(p)) dl_on_download(p); } } int peer_chokes(struct peer *p) { return p->mp->flags & PF_P_CHOKE; } int peer_has(struct peer *p, uint32_t index) { return has_bit(p->piece_field, index); } int peer_has_bad(struct peer *p, uint32_t index) { return p->bad_field != NULL && has_bit(p->bad_field, index); } int peer_laden(struct peer *p) { return p->nreqs_out >= MAXPIPEDREQUESTS; } int peer_wanted(struct peer *p) { return (p->mp->flags & PF_I_WANT) == PF_I_WANT; } int peer_leech_ok(struct peer *p) { return (p->mp->flags & (PF_BANNED|PF_SUSPECT|PF_I_WANT|PF_P_CHOKE)) == PF_I_WANT && !peer_laden(p); } int peer_active_down(struct peer *p) { return peer_leech_ok(p) || p->nreqs_out > 0; } int peer_active_up(struct peer *p) { return (p->mp->flags & (PF_P_WANT|PF_I_CHOKE)) == PF_P_WANT || p->npiece_msgs > 0; } int peer_full(struct peer *p) { return p->npieces == p->n->tp->npieces; } int peer_requestable(struct peer *p, uint32_t index) { return peer_has(p, index) && !peer_has_bad(p, index); } btpd-0.16/btpd/addrinfo.c0000644000175000001440000000436311423447207012203 00000000000000#include "btpd.h" #include struct ai_ctx { BTPDQ_ENTRY(ai_ctx) entry; struct addrinfo hints; struct addrinfo *res; char node[255], service[6]; void (*cb)(void *, int, struct addrinfo *); void *arg; int cancel; int error; uint16_t port; }; BTPDQ_HEAD(ai_ctx_tq, ai_ctx); static struct ai_ctx_tq m_aiq = BTPDQ_HEAD_INITIALIZER(m_aiq); static pthread_mutex_t m_aiq_lock; static pthread_cond_t m_aiq_cond; struct ai_ctx * btpd_addrinfo(const char *node, uint16_t port, struct addrinfo *hints, void (*cb)(void *, int, struct addrinfo *), void *arg) { struct ai_ctx *ctx = btpd_calloc(1, sizeof(*ctx)); ctx->hints = *hints; ctx->cb = cb; ctx->arg = arg; snprintf(ctx->node, sizeof(ctx->node), "%s", node); ctx->port = port; snprintf(ctx->service, sizeof(ctx->service), "%hu", port); pthread_mutex_lock(&m_aiq_lock); BTPDQ_INSERT_TAIL(&m_aiq, ctx, entry); pthread_mutex_unlock(&m_aiq_lock); pthread_cond_signal(&m_aiq_cond); return ctx; } void btpd_addrinfo_cancel(struct ai_ctx *ctx) { ctx->cancel = 1; } static void addrinfo_td_cb(void *arg) { struct ai_ctx *ctx = arg; if (!ctx->cancel) ctx->cb(ctx->arg, ctx->error, ctx->res); else if (ctx->res != NULL) freeaddrinfo(ctx->res); free(ctx); } static void * addrinfo_td(void *arg) { struct ai_ctx *ctx; while (1) { pthread_mutex_lock(&m_aiq_lock); while (BTPDQ_EMPTY(&m_aiq)) pthread_cond_wait(&m_aiq_cond, &m_aiq_lock); ctx = BTPDQ_FIRST(&m_aiq); BTPDQ_REMOVE(&m_aiq, ctx, entry); pthread_mutex_unlock(&m_aiq_lock); ctx->error = getaddrinfo(ctx->node, ctx->service, &ctx->hints, &ctx->res); td_post_begin(); td_post(addrinfo_td_cb, ctx); td_post_end(); } pthread_exit(NULL); } static void errdie(int err, const char *str) { if (err != 0) btpd_err("addrinfo_init: %s (%s).\n", str, strerror(errno)); } void addrinfo_init(void) { pthread_t td; errdie(pthread_mutex_init(&m_aiq_lock, NULL), "pthread_mutex_init"); errdie(pthread_cond_init(&m_aiq_cond, NULL), "pthread_cond_init"); errdie(pthread_create(&td, NULL, addrinfo_td, NULL), "pthread_create"); } btpd-0.16/btpd/opts.h0000644000175000001440000000060411417473677011416 00000000000000#ifndef BTPD_OPTS_H #define BTPD_OPTS_H extern const char *btpd_dir; extern uint32_t btpd_logmask; extern int net_max_uploads; extern unsigned net_max_peers; extern unsigned net_bw_limit_in; extern unsigned net_bw_limit_out; extern int net_port; extern off_t cm_alloc_size; extern int ipcprot; extern int empty_start; extern const char *tr_ip_arg; extern int net_ipv4, net_ipv6; #endif btpd-0.16/btpd/tracker_req.h0000644000175000001440000000152011417473677012731 00000000000000#ifndef TRACKER_REQ_H #define TRACKER_REQ_H enum tr_event { TR_EV_STARTED, TR_EV_STOPPED, TR_EV_COMPLETED, TR_EV_EMPTY }; extern long tr_key; enum tr_type { TR_HTTP }; struct tr_response { enum { TR_RES_FAIL, TR_RES_CONN, TR_RES_BAD, TR_RES_OK } type; const char *mi_failure; int interval; }; struct tr_tier; void tr_create(struct torrent *tp, const char *mi); void tr_kill(struct torrent *tp); void tr_start(struct torrent *tp); void tr_stop(struct torrent *tp); void tr_complete(struct torrent *tp); int tr_active(struct torrent *tp); void tr_result(struct tr_tier *t, struct tr_response *res); int tr_good_count(struct torrent *tp); struct httptr_req *httptr_req(struct torrent *tp, struct tr_tier *tr, const char *url, enum tr_event event); void httptr_cancel(struct httptr_req *req); #endif btpd-0.16/btpd/btpd.h0000644000175000001440000000532411417473677011366 00000000000000#ifndef BTPD_H #define BTPD_H #include #include #include #include #include #include #include #ifndef AI_ADDRCONFIG #define AI_ADDRCONFIG 0 #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #define DAEMON #include #undef DAEMON #include #include #include #include #include "active.h" #include "hashtable.h" #include "net_buf.h" #include "net_types.h" #include "net.h" #include "peer.h" #include "tlib.h" #include "torrent.h" #include "download.h" #include "upload.h" #include "content.h" #include "opts.h" #include "tracker_req.h" #define BTPD_VERSION PACKAGE_NAME "/" PACKAGE_VERSION #define BTPD_L_ALL 0xffffffff #define BTPD_L_ERROR 0x00000001 #define BTPD_L_TR 0x00000002 #define BTPD_L_CONN 0x00000004 #define BTPD_L_MSG 0x00000008 #define BTPD_L_BTPD 0x00000010 #define BTPD_L_POL 0x00000020 #define BTPD_L_BAD 0x00000040 extern long btpd_seconds; void btpd_init(void); __attribute__((format (printf, 2, 3))) void btpd_log(uint32_t type, const char *fmt, ...); __attribute__((format (printf, 1, 2), noreturn)) void btpd_err(const char *fmt, ...); __attribute__((malloc)) void *btpd_malloc(size_t size); __attribute__((malloc)) void *btpd_calloc(size_t nmemb, size_t size); void btpd_ev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb, void *arg); void btpd_ev_del(struct fdev *ev); void btpd_ev_enable(struct fdev *ev, uint16_t flags); void btpd_ev_disable(struct fdev *ev, uint16_t flags); void btpd_timer_add(struct timeout *to, struct timespec *ts); void btpd_timer_del(struct timeout *to); void btpd_shutdown(void); int btpd_is_stopping(void); int btpd_id_eq(const void *k1, const void *k2); uint32_t btpd_id_hash(const void *k); const uint8_t *btpd_get_peer_id(void); int btpd_id_eq(const void *id1, const void *id2); uint32_t btpd_id_hash(const void *id); void td_acquire_lock(void); void td_release_lock(void); void td_post(void (*cb)(void *), void *arg); void td_post_end(); #define td_post_begin td_acquire_lock typedef struct ai_ctx * aictx_t; aictx_t btpd_addrinfo(const char *node, uint16_t port, struct addrinfo *hints, void (*cb)(void *, int, struct addrinfo *), void *arg); void btpd_addrinfo_cancel(aictx_t ctx); typedef struct nameconn *nameconn_t; nameconn_t btpd_name_connect(const char *name, short port, void (*cb)(void *, int, int), void *arg); void btpd_name_connect_cancel(nameconn_t nc); #endif btpd-0.16/btpd/download_subr.c0000644000175000001440000004172211417473677013274 00000000000000/* * The commandments: * * A peer is wanted except when it only has pieces we've already * downloaded or fully requested. Thus, a peer's wanted count is * increased for each missing or unfull piece it announces, or * when a piece it has becomes unfull. * * When a peer we want unchokes us, requests will primarily * be put on pieces we're already downloading and then on * possible new pieces. * * When choosing between several different new pieces to start * downloading, the rarest piece will be chosen. * * End game mode sets in when all missing blocks are requested. * In end game mode no piece is counted as full unless it's * downloaded. * */ #include "btpd.h" #include #include static void piece_new_log(struct piece *pc) { struct blog *log = btpd_calloc(1, sizeof(*log)); BTPDQ_INIT(&log->records); BTPDQ_INSERT_HEAD(&pc->logs, log, entry); } static void piece_log_hashes(struct piece *pc) { uint8_t *buf; struct torrent *tp = pc->n->tp; struct blog *log = BTPDQ_FIRST(&pc->logs); log->hashes = btpd_malloc(20 * pc->nblocks); for (unsigned i = 0; i < pc->nblocks; i++) { uint32_t bsize = torrent_block_size(tp, pc->index, pc->nblocks, i); cm_get_bytes(tp, pc->index, i * PIECE_BLOCKLEN, bsize, &buf); SHA1(buf, bsize, &log->hashes[i * 20]); free(buf); } } static void piece_log_free(struct piece *pc, struct blog *log) { struct blog_record *r, *rnext; BTPDQ_FOREACH_MUTABLE(r, &log->records, entry, rnext) { mp_drop(r->mp, pc->n); free(r); } if (log->hashes != NULL) free(log->hashes); free(log); } static void piece_kill_logs(struct piece *pc) { struct blog *log, *lnext; BTPDQ_FOREACH_MUTABLE(log, &pc->logs, entry, lnext) piece_log_free(pc, log); BTPDQ_INIT(&pc->logs); } void piece_log_bad(struct piece *pc) { struct blog *log = BTPDQ_FIRST(&pc->logs); struct blog_record *r = BTPDQ_FIRST(&log->records); struct meta_peer *culprit = NULL; if (r == BTPDQ_LAST(&log->records, blog_record_tq)) { unsigned i; for (i = 0; i < pc->nblocks; i++) if (!has_bit(r->down_field, i)) break; if (i == pc->nblocks) culprit = r->mp; } if (culprit != NULL) { if (pc->n->endgame && culprit->p != NULL) peer_unwant(culprit->p, pc->index); net_ban_peer(pc->n, culprit); BTPDQ_REMOVE(&pc->logs, log, entry); piece_log_free(pc, log); } else { BTPDQ_FOREACH(r, &log->records, entry) { if (r->mp->p != NULL) { if (pc->n->endgame) peer_unwant(r->mp->p, pc->index); peer_bad_piece(r->mp->p, pc->index); } } piece_log_hashes(pc); } piece_new_log(pc); } void piece_log_good(struct piece *pc) { struct blog_record *r; struct blog *log = BTPDQ_FIRST(&pc->logs), *bad = BTPDQ_NEXT(log, entry); BTPDQ_FOREACH(r, &log->records, entry) if (r->mp->p != NULL) peer_good_piece(r->mp->p, pc->index); if (bad != NULL) piece_log_hashes(pc); while (bad != NULL) { BTPDQ_FOREACH(r, &bad->records, entry) { int culprit = 0; for (unsigned i = 0; i < pc->nblocks && !culprit; i++) if (has_bit(r->down_field, i) && ( bcmp(&log->hashes[i*20], &bad->hashes[i*20], 20) != 0)) culprit = 1; if (culprit) net_ban_peer(pc->n, r->mp); else if (r->mp->p != NULL) peer_good_piece(r->mp->p, pc->index); } bad = BTPDQ_NEXT(bad, entry); } } void piece_log_block(struct piece *pc, struct peer *p, uint32_t begin) { struct blog_record *r; struct blog *log = BTPDQ_FIRST(&pc->logs); BTPDQ_FOREACH(r, &log->records, entry) if (r->mp == p->mp) break; if (r == NULL) { r = btpd_calloc(1, sizeof(*r) + ceil(pc->nblocks / 8.0)); r->mp = p->mp; mp_hold(r->mp); BTPDQ_INSERT_HEAD(&log->records, r, entry); } else { BTPDQ_REMOVE(&log->records, r, entry); BTPDQ_INSERT_HEAD(&log->records, r, entry); } set_bit(r->down_field, begin / PIECE_BLOCKLEN); } static struct piece * piece_alloc(struct net *n, uint32_t index) { assert(!has_bit(n->busy_field, index) && n->npcs_busy < n->tp->npieces); struct piece *pc; size_t mem, field; unsigned nblocks; nblocks = torrent_piece_blocks(n->tp, index); field = (size_t)ceil(nblocks / 8.0); mem = sizeof(*pc) + field; pc = btpd_calloc(1, mem); pc->n = n; pc->down_field = (uint8_t *)(pc + 1); pc->have_field = cm_get_block_field(n->tp, index); pc->index = index; pc->nblocks = nblocks; pc->nreqs = 0; pc->next_block = 0; for (unsigned i = 0; i < nblocks; i++) if (has_bit(pc->have_field, i)) pc->ngot++; assert(pc->ngot < pc->nblocks); BTPDQ_INIT(&pc->reqs); BTPDQ_INIT(&pc->logs); piece_new_log(pc); n->npcs_busy++; set_bit(n->busy_field, index); BTPDQ_INSERT_TAIL(&n->getlst, pc, entry); return pc; } void piece_free(struct piece *pc) { struct net *n = pc->n; struct block_request *req, *next; assert(n->npcs_busy > 0); n->npcs_busy--; clear_bit(n->busy_field, pc->index); BTPDQ_REMOVE(&pc->n->getlst, pc, entry); BTPDQ_FOREACH_MUTABLE(req, &pc->reqs, blk_entry, next) { nb_drop(req->msg); free(req); } piece_kill_logs(pc); if (pc->eg_reqs != NULL) { for (uint32_t i = 0; i < pc->nblocks; i++) if (pc->eg_reqs[i] != NULL) nb_drop(pc->eg_reqs[i]); free(pc->eg_reqs); } free(pc); } int piece_full(struct piece *pc) { return pc->ngot + pc->nbusy == pc->nblocks; } static int dl_should_enter_endgame(struct net *n) { int should; if (cm_pieces(n->tp) + n->npcs_busy == n->tp->npieces) { should = 1; struct piece *pc; BTPDQ_FOREACH(pc, &n->getlst, entry) { if (!piece_full(pc)) { should = 0; break; } } } else should = 0; return should; } static void dl_piece_insert_eg(struct piece *pc) { struct piece_tq *getlst = &pc->n->getlst; if (pc->nblocks == pc->ngot) BTPDQ_INSERT_TAIL(getlst, pc, entry); else { unsigned r = pc->nreqs / (pc->nblocks - pc->ngot); struct piece *it; BTPDQ_FOREACH(it, getlst, entry) { if ((it->nblocks == it->ngot || r < it->nreqs / (it->nblocks - it->ngot))) { BTPDQ_INSERT_BEFORE(it, pc, entry); break; } } if (it == NULL) BTPDQ_INSERT_TAIL(getlst, pc, entry); } } void dl_piece_reorder_eg(struct piece *pc) { BTPDQ_REMOVE(&pc->n->getlst, pc, entry); dl_piece_insert_eg(pc); } static void dl_enter_endgame(struct net *n) { struct peer *p; struct piece *pc; struct piece *pcs[n->npcs_busy]; unsigned pi; btpd_log(BTPD_L_POL, "Entering end game\n"); n->endgame = 1; pi = 0; BTPDQ_FOREACH(pc, &n->getlst, entry) { struct block_request *req; for (unsigned i = 0; i < pc->nblocks; i++) clear_bit(pc->down_field, i); pc->nbusy = 0; pc->eg_reqs = btpd_calloc(pc->nblocks, sizeof(struct net_buf *)); BTPDQ_FOREACH(req, &pc->reqs, blk_entry) { uint32_t blki = nb_get_begin(req->msg) / PIECE_BLOCKLEN; if (pc->eg_reqs[blki] == NULL) { pc->eg_reqs[blki] = req->msg; nb_hold(req->msg); } } pcs[pi] = pc; pi++; } BTPDQ_INIT(&n->getlst); while (pi > 0) { pi--; dl_piece_insert_eg(pcs[pi]); } BTPDQ_FOREACH(p, &n->peers, p_entry) { assert(p->nwant == 0); BTPDQ_FOREACH(pc, &n->getlst, entry) peer_want(p, pc->index); if (peer_leech_ok(p)) dl_assign_requests_eg(p); } } struct piece * dl_find_piece(struct net *n, uint32_t index) { struct piece *pc; BTPDQ_FOREACH(pc, &n->getlst, entry) if (pc->index == index) break; return pc; } static int dl_piece_startable(struct peer *p, uint32_t index) { return peer_requestable(p, index) && !cm_has_piece(p->n->tp, index) && !has_bit(p->n->busy_field, index); } /* * Find the rarest piece the peer has, that isn't already allocated * for download or already downloaded. If no such piece can be found * return ENOENT. * * Return 0 or ENOENT, index in res. */ static int dl_choose_rarest(struct peer *p, uint32_t *res) { uint32_t i; struct net *n = p->n; assert(n->endgame == 0); for (i = 0; i < n->tp->npieces && !dl_piece_startable(p, i); i++) ; if (i == n->tp->npieces) return ENOENT; uint32_t min_i = i; uint32_t min_c = 1; for(i++; i < n->tp->npieces; i++) { if (dl_piece_startable(p, i)) { if (n->piece_count[i] == n->piece_count[min_i]) min_c++; else if (n->piece_count[i] < n->piece_count[min_i]) { min_i = i; min_c = 1; } } } if (min_c > 1) { min_c = rand_between(1, min_c); for (i = min_i; min_c > 0; i++) { if (dl_piece_startable(p, i) && n->piece_count[i] == n->piece_count[min_i]) { min_c--; min_i = i; } } } *res = min_i; return 0; } /* * Called from dl_piece_assign_requests when a piece becomes full. * The wanted level of the peers that has this piece will be decreased. * This function is the only one that may trigger end game. */ static void dl_on_piece_full(struct piece *pc) { struct peer *p; BTPDQ_FOREACH(p, &pc->n->peers, p_entry) peer_unwant(p, pc->index); if (dl_should_enter_endgame(pc->n)) dl_enter_endgame(pc->n); } struct piece * dl_new_piece(struct net *n, uint32_t index) { btpd_log(BTPD_L_POL, "Started on piece %u.\n", index); cm_prealloc(n->tp, index); return piece_alloc(n, index); } /* * Called when a previously full piece loses a peer. * This is needed because we have decreased the wanted * level for the peers that have this piece when it got * full. Thus we have to increase the wanted level and * try to assign requests for this piece. */ void dl_on_piece_unfull(struct piece *pc) { struct net *n = pc->n; struct peer *p; assert(!piece_full(pc) && n->endgame == 0); BTPDQ_FOREACH(p, &n->peers, p_entry) peer_want(p, pc->index); p = BTPDQ_FIRST(&n->peers); while (p != NULL && !piece_full(pc)) { if (peer_leech_ok(p) && peer_requestable(p, pc->index)) dl_piece_assign_requests(pc, p); // Cannot provoke end game here. p = BTPDQ_NEXT(p, p_entry); } } #define INCNEXTBLOCK(pc) \ (pc)->next_block = ((pc)->next_block + 1) % (pc)->nblocks static struct block_request * dl_new_request(struct peer *p, struct piece *pc, struct net_buf *msg) { if (msg == NULL) { uint32_t block = pc->next_block; uint32_t start = block * PIECE_BLOCKLEN; uint32_t length = torrent_block_size(pc->n->tp, pc->index, pc->nblocks, block); msg = nb_create_request(pc->index, start, length); } struct block_request *req = btpd_malloc(sizeof(*req)); req->p = p; req->msg = msg; nb_hold(req->msg); BTPDQ_INSERT_TAIL(&pc->reqs, req, blk_entry); pc->nreqs++; if (!pc->n->endgame) { set_bit(pc->down_field, pc->next_block); pc->nbusy++; } peer_request(p, req); return req; } /* * Request as many blocks as possible on this piece from * the peer. If the piece becomes full we call dl_on_piece_full. * * Return the number of requests sent. */ unsigned dl_piece_assign_requests(struct piece *pc, struct peer *p) { assert(!piece_full(pc) && !peer_laden(p)); unsigned count = 0; do { while ((has_bit(pc->have_field, pc->next_block) || has_bit(pc->down_field, pc->next_block))) INCNEXTBLOCK(pc); dl_new_request(p, pc, NULL); INCNEXTBLOCK(pc); count++; } while (!piece_full(pc) && !peer_laden(p)); if (piece_full(pc)) dl_on_piece_full(pc); return count; } /* * Request as many blocks as possible from the peer. Puts * requests on already active pieces before starting on new * ones. Care must be taken since end game mode may be triggered * by the calls to dl_piece_assign_requests. * * Returns number of requests sent. * * XXX: should do something smart when deciding on which * already started piece to put requests on. */ unsigned dl_assign_requests(struct peer *p) { assert(!p->n->endgame && peer_leech_ok(p)); struct piece *pc; struct net *n = p->n; unsigned count = 0; BTPDQ_FOREACH(pc, &n->getlst, entry) { if (piece_full(pc) || !peer_requestable(p, pc->index)) continue; count += dl_piece_assign_requests(pc, p); if (n->endgame) break; if (!piece_full(pc)) assert(peer_laden(p)); if (peer_laden(p)) break; } while (!peer_laden(p) && !n->endgame) { uint32_t index; if (dl_choose_rarest(p, &index) == 0) { pc = dl_new_piece(n, index); if (pc != NULL) count += dl_piece_assign_requests(pc, p); } else break; } return count; } void dl_unassign_requests(struct peer *p) { while (p->nreqs_out > 0) { struct block_request *req = BTPDQ_FIRST(&p->my_reqs); struct piece *pc = dl_find_piece(p->n, nb_get_index(req->msg)); int was_full = piece_full(pc); while (req != NULL) { struct block_request *next = BTPDQ_NEXT(req, p_entry); uint32_t blki = nb_get_begin(req->msg) / PIECE_BLOCKLEN; // XXX: Needs to be looked at if we introduce snubbing. assert(has_bit(pc->down_field, blki)); clear_bit(pc->down_field, blki); pc->nbusy--; BTPDQ_REMOVE(&p->my_reqs, req, p_entry); p->nreqs_out--; BTPDQ_REMOVE(&pc->reqs, req, blk_entry); nb_drop(req->msg); free(req); pc->nreqs--; while (next != NULL && nb_get_index(next->msg) != pc->index) next = BTPDQ_NEXT(next, p_entry); req = next; } if (p->nreqs_out == 0) peer_on_no_reqs(p); if (was_full && !piece_full(pc)) dl_on_piece_unfull(pc); } assert(BTPDQ_EMPTY(&p->my_reqs)); } static void dl_piece_assign_requests_eg(struct piece *pc, struct peer *p) { unsigned first_block = pc->next_block; do { if ((has_bit(pc->have_field, pc->next_block) || peer_requested(p, pc->index, pc->next_block))) { INCNEXTBLOCK(pc); continue; } struct block_request *req = dl_new_request(p, pc, pc->eg_reqs[pc->next_block]); if (pc->eg_reqs[pc->next_block] == NULL) { pc->eg_reqs[pc->next_block] = req->msg; nb_hold(req->msg); } INCNEXTBLOCK(pc); } while (!peer_laden(p) && pc->next_block != first_block); } void dl_assign_requests_eg(struct peer *p) { assert(peer_leech_ok(p)); struct net *n = p->n; struct piece_tq tmp; BTPDQ_INIT(&tmp); struct piece *pc = BTPDQ_FIRST(&n->getlst); while (!peer_laden(p) && pc != NULL) { struct piece *next = BTPDQ_NEXT(pc, entry); if (peer_requestable(p, pc->index) && pc->nblocks != pc->ngot) { dl_piece_assign_requests_eg(pc, p); BTPDQ_REMOVE(&n->getlst, pc, entry); BTPDQ_INSERT_HEAD(&tmp, pc, entry); } pc = next; } pc = BTPDQ_FIRST(&tmp); while (pc != NULL) { struct piece *next = BTPDQ_NEXT(pc, entry); dl_piece_insert_eg(pc); pc = next; } } void dl_unassign_requests_eg(struct peer *p) { struct block_request *req; struct piece *pc; struct piece_tq tmp; BTPDQ_INIT(&tmp); while (p->nreqs_out > 0) { req = BTPDQ_FIRST(&p->my_reqs); pc = dl_find_piece(p->n, nb_get_index(req->msg)); BTPDQ_REMOVE(&pc->n->getlst, pc, entry); BTPDQ_INSERT_HEAD(&tmp, pc, entry); while (req != NULL) { struct block_request *next = BTPDQ_NEXT(req, p_entry); BTPDQ_REMOVE(&p->my_reqs, req, p_entry); p->nreqs_out--; BTPDQ_REMOVE(&pc->reqs, req, blk_entry); nb_drop(req->msg); free(req); pc->nreqs--; while (next != NULL && nb_get_index(next->msg) != pc->index) next = BTPDQ_NEXT(next, p_entry); req = next; } } assert(BTPDQ_EMPTY(&p->my_reqs)); peer_on_no_reqs(p); pc = BTPDQ_FIRST(&tmp); while (pc != NULL) { struct piece *next = BTPDQ_NEXT(pc, entry); dl_piece_insert_eg(pc); pc = next; } } btpd-0.16/btpd/tlib.c0000644000175000001440000002765511417473677011375 00000000000000#include "btpd.h" #include #include #include HTBL_TYPE(numtbl, tlib, unsigned, num, nchain); HTBL_TYPE(hashtbl, tlib, uint8_t, hash, hchain); static unsigned m_nextnum; static unsigned m_ntlibs; static struct numtbl *m_numtbl; static struct hashtbl *m_hashtbl; unsigned tlib_count(void) { return m_ntlibs; } struct tlib * tlib_by_num(unsigned num) { return numtbl_find(m_numtbl, &num); } struct tlib * tlib_by_hash(const uint8_t *hash) { return hashtbl_find(m_hashtbl, hash); } struct tlib * tlib_iter_first(struct htbl_iter *it) { return numtbl_iter_first(m_numtbl, it); } struct tlib * tlib_iter_next(struct htbl_iter *it) { return numtbl_iter_next(it); } void tlib_kill(struct tlib *tl) { numtbl_remove(m_numtbl, &tl->num); hashtbl_remove(m_hashtbl, tl->hash); if (tl->name != NULL) free(tl->name); if (tl->dir != NULL) free(tl->dir); free(tl); m_ntlibs--; } struct tlib * tlib_create(const uint8_t *hash) { struct tlib *tl = btpd_calloc(1, sizeof(*tl)); char hex[SHAHEXSIZE]; bin2hex(hash, hex, 20); tl->num = m_nextnum; bcopy(hash, tl->hash, 20); m_nextnum++; m_ntlibs++; numtbl_insert(m_numtbl, tl); hashtbl_insert(m_hashtbl, tl); return tl; } int tlib_del(struct tlib *tl) { char relpath[RELPATH_SIZE]; char path[PATH_MAX]; DIR *dir; struct dirent *de; assert(tl->tp == NULL || tl->tp->state == T_GHOST); snprintf(path, PATH_MAX, "torrents/%s", bin2hex(tl->hash, relpath, 20)); if ((dir = opendir(path)) != NULL) { while ((de = readdir(dir)) != NULL) { if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) continue; snprintf(path, PATH_MAX, "torrents/%s/%s", relpath, de->d_name); remove(path); } closedir(dir); } snprintf(path, PATH_MAX, "torrents/%s", relpath); remove(path); if (tl->tp == NULL) tlib_kill(tl); return 0; } static void dct_subst_save(FILE *fp, const char *dct1, const char *dct2) { fprintf(fp, "d"); const char *k1 = benc_first(dct1), *k2 = benc_first(dct2); const char *val, *str, *rest; size_t len; while (k1 != NULL && k2 != NULL) { int test = benc_strcmp(k1, k2); if (test < 0) { str = benc_mem(k1, &len, &val); fprintf(fp, "%d:%.*s", (int)len, (int)len, str); fwrite(val, 1, benc_length(val), fp); k1 = benc_next(val); } else { str = benc_mem(k2, &len, &val); fprintf(fp, "%d:%.*s", (int)len, (int)len, str); fwrite(val, 1, benc_length(val), fp); k2 = benc_next(val); if (test == 0) k1 = benc_next(benc_next(k1)); } } rest = k1 != NULL ? k1 : k2; while (rest != NULL) { str = benc_mem(rest, &len, &val); fprintf(fp, "%d:%.*s", (int)len, (int)len, str); fwrite(val, 1, benc_length(val), fp); rest = benc_next(val); } fprintf(fp, "e"); } static int valid_info(char *buf, size_t len) { size_t slen; const char *info; if (benc_validate(buf, len) != 0) return 0; if ((info = benc_dget_dct(buf, "info")) == NULL) return 0; if (benc_dget_mem(info, "name", &slen) == NULL || slen == 0) return 0; if ((benc_dget_mem(info, "dir", &slen) == NULL || (slen == 0 || slen >= PATH_MAX))) return 0; return 1; } static void load_info(struct tlib *tl, const char *path) { size_t size = 1 << 14; char buf[size]; const char *info; if (read_file(path, buf, &size) == NULL) { btpd_log(BTPD_L_ERROR, "couldn't load '%s' (%s).\n", path, strerror(errno)); return; } if (!valid_info(buf, size)) { btpd_log(BTPD_L_ERROR, "bad info file '%s'.\n", path); return; } info = benc_dget_dct(buf, "info"); tl->name = benc_dget_str(info, "name", NULL); tl->dir = benc_dget_str(info, "dir", NULL); tl->tot_up = benc_dget_int(info, "total upload"); tl->tot_down = benc_dget_int(info, "total download"); tl->content_size = benc_dget_int(info, "content size"); tl->content_have = benc_dget_int(info, "content have"); if (tl->name == NULL || tl->dir == NULL) btpd_err("Out of memory.\n"); } static void save_info(struct tlib *tl) { FILE *fp; char relpath[SHAHEXSIZE], path[PATH_MAX], wpath[PATH_MAX]; struct iobuf iob = iobuf_init(1 << 10); iobuf_print(&iob, "d4:infod" "12:content havei%llde12:content sizei%llde" "3:dir%d:%s4:name%d:%s" "14:total downloadi%llde12:total uploadi%llde" "ee", (long long)tl->content_have, (long long)tl->content_size, (int)strlen(tl->dir), tl->dir, (int)strlen(tl->name), tl->name, tl->tot_down, tl->tot_up); if (iob.error) btpd_err("Out of memory.\n"); bin2hex(tl->hash, relpath, 20); snprintf(path, PATH_MAX, "torrents/%s/info", relpath); snprintf(wpath, PATH_MAX, "%s.write", path); if ((fp = fopen(wpath, "w")) == NULL) btpd_err("failed to open '%s' (%s).\n", wpath, strerror(errno)); dct_subst_save(fp, "de", iob.buf); iobuf_free(&iob); if ((fflush(fp) == EOF || fsync(fileno(fp)) != 0 || ferror(fp) || fclose(fp) != 0)) btpd_err("failed to write '%s'.\n", wpath); if (rename(wpath, path) != 0) btpd_err("failed to rename: '%s' -> '%s' (%s).\n", wpath, path, strerror(errno)); } void tlib_update_info(struct tlib *tl, int only_file) { struct tlib tmp; assert(tl->tp != NULL); if (only_file) { tmp = *tl; tl = &tmp; } tl->tot_down += tl->tp->net->downloaded; tl->tot_up += tl->tp->net->uploaded; tl->content_have = cm_content(tl->tp); tl->content_size = tl->tp->total_length; save_info(tl); } static void write_torrent(const char *mi, size_t mi_size, const char *path) { FILE *fp; if ((fp = fopen(path, "w")) == NULL) goto err; if (fwrite(mi, mi_size, 1, fp) != 1) { errno = EIO; goto err; } if (fclose(fp) != 0) goto err; return; err: btpd_err("failed to write metainfo '%s' (%s).\n", path, strerror(errno)); } struct tlib * tlib_add(const uint8_t *hash, const char *mi, size_t mi_size, const char *content, char *name) { struct tlib *tl = tlib_create(hash); char relpath[RELPATH_SIZE], file[PATH_MAX]; bin2hex(hash, relpath, 20); if (name == NULL) if ((name = mi_name(mi)) == NULL) btpd_err("out of memory.\n"); tl->content_size = mi_total_length(mi); tl->name = name; tl->dir = strdup(content); if (tl->name == NULL || tl->dir == NULL) btpd_err("out of memory.\n"); snprintf(file, PATH_MAX, "torrents/%s", relpath); if (mkdir(file, 0777) != 0) btpd_err("failed to create dir '%s' (%s).\n", file, strerror(errno)); snprintf(file, PATH_MAX, "torrents/%s/torrent", relpath); write_torrent(mi, mi_size, file); save_info(tl); return tl; } struct tlib * tlib_readd(struct tlib *tl, const uint8_t *hash, const char *mi, size_t mi_size, const char *content, char *name) { struct tlib *tln; struct torrent *tp = tl->tp; tp->delete = 0; tlib_kill(tl); tln = tlib_add(hash, mi, mi_size, content, name); tln->tp = tp; return tln; } static int num_test(const void *k1, const void *k2) { return *(const unsigned *)k1 == *(const unsigned *)k2; } static uint32_t num_hash(const void *k) { return *(const unsigned *)k; } void tlib_init(void) { DIR *dirp; struct dirent *dp; uint8_t hash[20]; char file[PATH_MAX]; m_numtbl = numtbl_create(1, num_test, num_hash); m_hashtbl = hashtbl_create(1, btpd_id_eq, btpd_id_hash); if (m_numtbl == NULL || m_hashtbl == NULL) btpd_err("Out of memory.\n"); if ((dirp = opendir("torrents")) == NULL) btpd_err("couldn't open the torrents directory.\n"); while ((dp = readdir(dirp)) != NULL) { if (strlen(dp->d_name) == 40 && ishex(dp->d_name)) { struct tlib * tl = tlib_create(hex2bin(dp->d_name, hash, 20)); snprintf(file, PATH_MAX, "torrents/%s/info", dp->d_name); load_info(tl, file); } } closedir(dirp); } void tlib_read_hash(struct tlib *tl, size_t off, uint32_t piece, uint8_t *hash) { int fd; ssize_t nread; char relpath[RELPATH_SIZE]; bin2hex(tl->hash, relpath, 20); if ((errno = vopen(&fd, O_RDONLY, "torrents/%s/torrent", relpath)) != 0) btpd_err("failed to open 'torrents/%s/torrent' (%s).\n", relpath, strerror(errno)); lseek(fd, off + piece * 20, SEEK_SET); if ((nread = read(fd, hash, 20)) != 20) { if (nread == -1) btpd_err("failed to read 'torrents/%s/torrent' (%s).\n", relpath, strerror(errno)); else btpd_err("corrupt file: 'torrents/%s/torrent'.\n", relpath); } close(fd); } int tlib_load_mi(struct tlib *tl, char **res) { char file[PATH_MAX]; char relpath[RELPATH_SIZE]; char *mi; bin2hex(tl->hash, relpath, 20); snprintf(file, sizeof(file), "torrents/%s/torrent", relpath); if ((mi = mi_load(file, NULL)) == NULL) { btpd_log(BTPD_L_ERROR, "torrent '%s': failed to load metainfo (%s).\n", tl->name, strerror(errno)); return errno; } *res = mi; return 0; } struct resume_data { void *base; size_t size; uint8_t *pc_field; uint8_t *blk_field; }; static void * resume_file_size(struct resume_data *resd, int i) { return resd->base + 8 + 16 * i; } static void * resume_file_time(struct resume_data *resd, int i) { return resd->base + 16 + 16 * i; } static void init_resume(int fd, size_t size) { char buf[1024]; uint32_t ver; bzero(buf, sizeof(buf)); enc_be32(&ver, 2); if (write(fd, "RESD", 4) == -1 || write(fd, &ver, 4) == -1) goto fatal; size -= 8; while (size > 0) { ssize_t nw = write(fd, buf, min(sizeof(buf), size)); if (nw < 1) goto fatal; size -= nw; } return; fatal: btpd_err("failed to initialize resume file (%s).\n", strerror(errno)); } struct resume_data * tlib_open_resume(struct tlib *tl, unsigned nfiles, size_t pfsize, size_t bfsize) { int fd; char relpath[RELPATH_SIZE]; struct stat sb; struct resume_data *resd = btpd_calloc(1, sizeof(*resd)); bin2hex(tl->hash, relpath, 20); resd->size = 8 + nfiles * 16 + pfsize + bfsize; if ((errno = vopen(&fd, O_RDWR|O_CREAT, "torrents/%s/resume", relpath)) != 0) goto fatal; if (fstat(fd, &sb) != 0) goto fatal; if (sb.st_size != resd->size) { if (sb.st_size != 0 && ftruncate(fd, 0) != 0) goto fatal; init_resume(fd, resd->size); } resd->base = mmap(NULL, resd->size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (resd->base == MAP_FAILED) goto fatal; if (bcmp(resd->base, "RESD", 4) != 0 || dec_be32(resd->base + 4) != 2) init_resume(fd, resd->size); close(fd); resd->pc_field = resd->base + 8 + nfiles * 16; resd->blk_field = resd->pc_field + pfsize; return resd; fatal: btpd_err("file operation failed on 'torrents/%s/resume' (%s).\n", relpath, strerror(errno)); } uint8_t * resume_piece_field(struct resume_data *resd) { return resd->pc_field; } uint8_t * resume_block_field(struct resume_data *resd) { return resd->blk_field; } void resume_set_fts(struct resume_data *resd, int i, struct file_time_size *fts) { enc_be64(resume_file_size(resd, i), (uint64_t)fts->size); enc_be64(resume_file_time(resd, i), (uint64_t)fts->mtime); } void resume_get_fts(struct resume_data *resd, int i, struct file_time_size *fts) { fts->size = dec_be64(resume_file_size(resd, i)); fts->mtime = dec_be64(resume_file_time(resd, i)); } void tlib_close_resume(struct resume_data *resd) { munmap(resd->base, resd->size); free(resd); } btpd-0.16/btpd/content.h0000644000175000001440000000167411417473677012113 00000000000000#ifndef BTPD_CONTENT_H #define BTPD_CONTENT_H void cm_init(void); void cm_create(struct torrent *tp, const char *mi); void cm_kill(struct torrent *tp); void cm_start(struct torrent *tp, int force_test); void cm_stop(struct torrent * tp); int cm_active(struct torrent *tp); int cm_error(struct torrent *tp); int cm_started(struct torrent *tp); int cm_full(struct torrent *tp); off_t cm_content(struct torrent *tp); uint32_t cm_pieces(struct torrent *tp); uint8_t *cm_get_piece_field(struct torrent *tp); uint8_t *cm_get_block_field(struct torrent *tp, uint32_t piece); int cm_has_piece(struct torrent *tp, uint32_t piece); int cm_put_bytes(struct torrent *tp, uint32_t piece, uint32_t begin, const uint8_t *buf, size_t len); int cm_get_bytes(struct torrent *tp, uint32_t piece, uint32_t begin, size_t len, uint8_t **buf); void cm_prealloc(struct torrent *tp, uint32_t piece); void cm_test_piece(struct torrent *tp, uint32_t piece); #endif btpd-0.16/btpd/thread_cb.c0000644000175000001440000000322511417473677012341 00000000000000#include #include #include #include #include "btpd.h" struct td_cb { void (*cb)(void *); void *arg; BTPDQ_ENTRY(td_cb) entry; }; BTPDQ_HEAD(td_cb_tq, td_cb); static int m_td_rd, m_td_wr; static struct fdev m_td_ev; static struct td_cb_tq m_td_cbs = BTPDQ_HEAD_INITIALIZER(m_td_cbs); static pthread_mutex_t m_td_lock; void td_acquire_lock(void) { pthread_mutex_lock(&m_td_lock); } void td_release_lock(void) { pthread_mutex_unlock(&m_td_lock); } void td_post(void (*fun)(void *), void *arg) { struct td_cb *cb = btpd_calloc(1, sizeof(*cb)); cb->cb = fun; cb->arg = arg; BTPDQ_INSERT_TAIL(&m_td_cbs, cb, entry); } void td_post_end(void) { char c = '1'; td_release_lock(); write(m_td_wr, &c, sizeof(c)); } static void td_cb(int fd, short type, void *arg) { char buf[1024]; struct td_cb_tq tmpq = BTPDQ_HEAD_INITIALIZER(tmpq); struct td_cb *cb, *next; read(fd, buf, sizeof(buf)); td_acquire_lock(); BTPDQ_FOREACH_MUTABLE(cb, &m_td_cbs, entry, next) BTPDQ_INSERT_TAIL(&tmpq, cb, entry); BTPDQ_INIT(&m_td_cbs); td_release_lock(); BTPDQ_FOREACH_MUTABLE(cb, &tmpq, entry, next) { cb->cb(cb->arg); free(cb); } } void td_init(void) { int err; int fds[2]; if (pipe(fds) == -1) { btpd_err("Couldn't create thread callback pipe (%s).\n", strerror(errno)); } m_td_rd = fds[0]; m_td_wr = fds[1]; if ((err = pthread_mutex_init(&m_td_lock, NULL)) != 0) btpd_err("Couldn't create mutex (%s).\n", strerror(err)); btpd_ev_new(&m_td_ev, m_td_rd, EV_READ, td_cb, NULL); } btpd-0.16/btpd/main.c0000644000175000001440000002063611417473677011357 00000000000000#include "btpd.h" #include #include int btpd_daemon_phase = 2; int first_btpd_comm[2]; int pidfd; void first_btpd_exit(char code) { write(first_btpd_comm[1], &code, 1); close(first_btpd_comm[0]); close(first_btpd_comm[1]); } static void writepid(void) { int nw; char pidtxt[100]; nw = snprintf(pidtxt, sizeof(pidtxt), "%ld", (long)getpid()); ftruncate(pidfd, 0); write(pidfd, pidtxt, nw); } static void setup_daemon(int daemonize, const char *dir) { char c; pid_t pid; struct timespec ts; if (snprintf(NULL, 0, "btpd") != 4) btpd_err("snprintf doesn't work.\n"); if (evtimer_gettime(&ts) != 0) btpd_err("evtimer_gettime failed (%s).\n", strerror(errno)); if (dir == NULL) { if ((dir = find_btpd_dir()) == NULL) btpd_err("Cannot find the btpd directory.\n"); if (dir[0] != '/') btpd_err("Got non absolute path '%s' from system environment.\n", dir); btpd_dir = dir; } if (mkdir(dir, 0777) == -1 && errno != EEXIST) btpd_err("Couldn't create home '%s' (%s).\n", dir, strerror(errno)); if (chdir(dir) != 0) btpd_err("Couldn't change working directory to '%s' (%s).\n", dir, strerror(errno)); if (mkdir("torrents", 0777) == -1 && errno != EEXIST) btpd_err("Couldn't create torrents subdir (%s).\n", strerror(errno)); if (btpd_dir == NULL) { char wd[PATH_MAX]; if (getcwd(wd, PATH_MAX) == NULL) btpd_err("Couldn't get working directory (%s).\n", strerror(errno)); if ((btpd_dir = strdup(wd)) == NULL) btpd_err("Out of memory.\n"); } if (daemonize) { if (pipe(first_btpd_comm) < 0) btpd_err("Failed to create pipe (%s).\n", strerror(errno)); if ((pid = fork()) < 0) btpd_err("fork() failed (%s).\n", strerror(errno)); if (pid != 0) { read(first_btpd_comm[0], &c, 1); exit(c); } btpd_daemon_phase--; if (setsid() < 0) btpd_err("setsid() failed (%s).\n", strerror(errno)); if ((pid = fork()) < 0) btpd_err("fork() failed (%s).\n", strerror(errno)); if (pid != 0) exit(0); } if ((pidfd = open("pid", O_CREAT|O_WRONLY, 0666)) == -1) btpd_err("Couldn't open 'pid' (%s).\n", strerror(errno)); if (lockf(pidfd, F_TLOCK, 0) == -1) btpd_err("Another instance of btpd is probably running in %s.\n", dir); writepid(); } static void usage(void) { printf( "btpd is the BitTorrent Protocol Daemon.\n" "\n" "Usage: btpd [-d dir] [-p port] [more options...]\n" "\n" "Options:\n" "-4\n" "\tUse IPv4. If given in conjunction with -6, " "both versions are used.\n" "\n" "-6\n" "\tUse IPv6. By default IPv4 is used.\n" "\n" "--bw-in n\n" "\tLimit incoming BitTorrent traffic to n kB/s.\n" "\tDefault is 0 which means unlimited.\n" "\n" "--bw-out n\n" "\tLimit outgoing BitTorrent traffic to n kB/s.\n" "\tDefault is 0 which means unlimited.\n" "\n" "-d dir\n" "\tThe directory in which to run btpd. Default is '$HOME/.btpd'.\n" "\n" "--empty-start\n" "\tStart btpd without any active torrents.\n" "\n" "--help\n" "\tShow this text.\n" "\n" "--ip addr\n" "\tLet the tracker distribute the given address instead of the one\n" "\tit sees btpd connect from.\n" "\n" "--ipcprot mode\n" "\tSet the protection mode of the command socket.\n" "\tThe mode is specified by an octal number. Default is 0600.\n" "\n" "--logfile file\n" "\tWhere to put the logfile. By default it's put in the btpd dir.\n" "\n" "--max-peers n\n" "\tLimit the amount of peers to n.\n" "\n" "--max-uploads n\n" "\tControls the number of simultaneous uploads.\n" "\tThe possible values are:\n" "\t\tn < -1 : Choose n >= 2 based on --bw-out (default).\n" "\t\tn = -1 : Upload to every interested peer.\n" "\t\tn = 0 : Dont't upload to anyone.\n" "\t\tn > 0 : Upload to at most n peers simultaneously.\n" "\n" "--no-daemon\n" "\tKeep the btpd process in the foregorund and log to std{out,err}.\n" "\tThis option is intended for debugging purposes.\n" "\n" "-p n, --port n\n" "\tListen at port n. Default is 6881.\n" "\n" "--prealloc n\n" "\tPreallocate disk space in chunks of n kB. Default is 2048.\n" "\tNote that n will be rounded up to the closest multiple of the\n" "\ttorrent piece size. If n is zero no preallocation will be done.\n" "\n"); exit(1); } static int longval = 0; static struct option longopts[] = { { "port", required_argument, NULL, 'p' }, { "bw-in", required_argument, &longval, 1 }, { "bw-out", required_argument, &longval, 2 }, { "prealloc", required_argument, &longval, 3 }, { "max-uploads", required_argument, &longval, 4 }, { "max-peers", required_argument, &longval, 5 }, { "no-daemon", no_argument, &longval, 6 }, { "logfile", required_argument, &longval, 7 }, { "ipcprot", required_argument, &longval, 8 }, { "empty-start", no_argument, &longval, 9 }, { "ip", required_argument, &longval, 10 }, { "logmask", required_argument, &longval, 11 }, { "help", no_argument, &longval, 128 }, { NULL, 0, NULL, 0 } }; int main(int argc, char **argv) { char *dir = NULL, *log = NULL; int daemonize = 1, opt4 = 0, opt6 = 0; for (;;) { switch (getopt_long(argc, argv, "46d:p:", longopts, NULL)) { case -1: goto args_done; case '4': opt4 = 1; break; case '6': opt6 = 1; break; case 'd': dir = optarg; break; case 'p': net_port = atoi(optarg); break; case 0: switch (longval) { case 1: net_bw_limit_in = atoi(optarg) * 1024; break; case 2: net_bw_limit_out = atoi(optarg) * 1024; break; case 3: cm_alloc_size = atoi(optarg) * 1024; break; case 4: net_max_uploads = atoi(optarg); break; case 5: net_max_peers = atoi(optarg); break; case 6: daemonize = 0; break; case 7: log = optarg; break; case 8: ipcprot = strtol(optarg, NULL, 8); break; case 9: empty_start = 1; break; case 10: tr_ip_arg = optarg; break; case 11: btpd_logmask = atoi(optarg); break; default: usage(); } break; case '?': default: usage(); } } args_done: argc -= optind; argv += optind; if (opt6) { net_ipv6 = 1; if (!opt4) net_ipv4 = 0; } if (argc > 0) usage(); setup_daemon(daemonize, dir); if (evloop_init() != 0) btpd_err("Failed to initialize evloop (%s).\n", strerror(errno)); btpd_init(); if (daemonize) { if (freopen("/dev/null", "r", stdin) == NULL) btpd_err("freopen of stdin failed (%s).\n", strerror(errno)); if (freopen(log == NULL ? "log" : log, "a", stderr) == NULL) btpd_err("Couldn't open '%s' (%s).\n", log, strerror(errno)); if (dup2(fileno(stderr), fileno(stdout)) < 0) btpd_err("dup2 failed (%s).\n", strerror(errno)); first_btpd_exit(0); } setlinebuf(stdout); setlinebuf(stderr); btpd_daemon_phase = 0; if (!empty_start) active_start(); else active_clear(); evloop(); btpd_err("Exit from evloop with error (%s).\n", strerror(errno)); return 1; } btpd-0.16/btpd/util.c0000644000175000001440000000512611417473677011405 00000000000000#include "btpd.h" #include #include int btpd_id_eq(const void *k1, const void *k2) { return bcmp(k1, k2, 20) == 0; } uint32_t btpd_id_hash(const void *k) { return dec_be32(k + 16); } void * btpd_malloc(size_t size) { void *a; if ((a = malloc(size)) == NULL) btpd_err("Failed to allocate %d bytes.\n", (int)size); return a; } void * btpd_calloc(size_t nmemb, size_t size) { void *a; if ((a = calloc(nmemb, size)) == NULL) btpd_err("Failed to allocate %d bytes.\n", (int)(nmemb * size)); return a; } void btpd_ev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb, void *arg) { if (fdev_new(ev, fd, flags, cb, arg) != 0) btpd_err("Failed to add event (%s).\n", strerror(errno)); } void btpd_ev_del(struct fdev *ev) { if (fdev_del(ev) != 0) btpd_err("Failed to remove event (%s).\n", strerror(errno)); } void btpd_ev_enable(struct fdev *ev, uint16_t flags) { if (fdev_enable(ev, flags) != 0) btpd_err("Failed to enable event (%s).\n", strerror(errno)); } void btpd_ev_disable(struct fdev *ev, uint16_t flags) { if (fdev_disable(ev, flags) != 0) btpd_err("Failed to disable event (%s).\n", strerror(errno)); } void btpd_timer_add(struct timeout *to, struct timespec *ts) { if (evtimer_add(to, ts) != 0) btpd_err("Failed to add timeout (%s).\n", strerror(errno)); } void btpd_timer_del(struct timeout *to) { evtimer_del(to); } static const char * logtype_str(uint32_t type) { switch (type) { case BTPD_L_BTPD: return "btpd"; case BTPD_L_ERROR: return "error"; case BTPD_L_CONN: return "conn"; case BTPD_L_TR: return "tracker"; case BTPD_L_MSG: return "msg"; case BTPD_L_POL: return "policy"; case BTPD_L_BAD: return "bad"; } return ""; } static void log_common(uint32_t type, const char *fmt, va_list ap) { if (type & btpd_logmask) { char tbuf[20]; time_t tp = time(NULL); strftime(tbuf, 20, "%b %e %T", localtime(&tp)); printf("%s %s: ", tbuf, logtype_str(type)); vprintf(fmt, ap); } } extern int btpd_daemon_phase; extern void first_btpd_exit(char); void btpd_err(const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (btpd_daemon_phase > 0) { vprintf(fmt, ap); if (btpd_daemon_phase == 1) first_btpd_exit(1); exit(1); } else { log_common(BTPD_L_ERROR, fmt, ap); abort(); } } void btpd_log(uint32_t type, const char *fmt, ...) { va_list ap; va_start(ap, fmt); log_common(type, fmt, ap); va_end(ap); } btpd-0.16/depcomp0000755000175000001440000004426711426157640010706 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 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 outputing 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 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. ## 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" ;; 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" ;; #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" cat < "$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: btpd-0.16/CHANGES0000644000175000001440000001473011425124540010304 00000000000000btpd 0.16: ---------- Misc: - Added "start all" (start -a) command. - Allow adding multiple torrents at once. - Custom list formatting options. - Man pages for btpd, btcli, and btinfo. Bug fixes: - Handle .torrent files larger than 2MB. - http parsing and addrinfo freeing fixes. btpd 0.15: ---------- Bug fixes: - The event loop could busy loop for up to a millisecond sometimes. - On some platforms btpd couldn't initiate connections to other peers. - The timer code was broken on MacOS X. btpd 0.14: ---------- Misc: - IPv6 support. - Bans peers with bad data. - Better tracker compatability and more reliable tracker communication. - Show tracker counts in btcli stat. - Compiles on Solaris 10. - Btpd will now signal startup failures via the process exit value and print the failure reason to stdout. - Better shutdown and torrent stop behaviour. - Needs pthreads again. - Removed libevent in favour of own event loop code. Bug fixes: - An integer array was misaligned, which could cause crashes on systems with alignment requirements. E.g., on XScale arm. - An error in the torrent parsing code could cause crashes. - The '--topdir' option to btcli add didn't work properly for single file torrents. - The system name lookup scheme is now used. In btpd 0.13 only dns lookups were performed. btpd 0.13: ---------- Misc: - cURL is no longer required. btpd now uses its own http client. - btpd doesn't use threads anymore, so pthreads are not required. - Needed parts of libevent are now included in btpd. - I/O errors for torrents no longer make btpd shut down. Instead the problematic torrent is stopped. - Added the option '--ip' to specify the ip address btpd will report to trackers. - Resume file format changed. Already added torrents will be retested once. - The torrent info (ratio etc.) are now saved regularly. - Reduced the amount of outgoing data kept in memory. btpd 0.12: ---------- Misc: - btpd now starts with the same set of active torrents as it had when it was last shut down. The new '--empty-start' option disables this feature. - btpd now supports the key tracker extension. - btpd now supports the multi tracker extension. - btcli list and stat print headers for the presented data. Both commands displays more data than before. - Torrent management has changed, with changes to the add and del commands and two new commands, start and stop, as a result. Operation on torrents can now be done by number as well as torrent file. - A small delay has been added for contacting the same announce URL. - btpd sends keepalive messages. - The number of have messages sent has been reduced by not sending them to peers that already have the piece. - The structure of the torrents directory in the btpd directory has changed. It is best to remove it before running btpd 0.12. Bug fixes: - Zero sized files in a torrent were not always created. btpd 0.11: ---------- Bug fixes: - A file descriptor was closed too early, which could cause btpd to exit with an error message on systems using epoll. btpd 0.10: ---------- Misc: - The protection mode of the ipc socket can now be specified via the new "--ipcprot" option for btpd. Bug fixes: - The pid file is now written correctly. - btpd's "-d" option now works for relative paths too. - Add a time out for handshake completion. Prevously btpd could slowly fill with unused incoming connections. btpd 0.9: --------- Misc: - Small changes to 'btcli stat' output. Bug fixes: - Use correct value for '--prealloc' default. - Stopped torrents now show correct rates (0kB/s). - The test of content that has been modified between runs was broken. btpd 0.8: --------- Misc: - btpd now requires pthreads. - btpd keeps its logs and other information it needs in its own directory. $HOME/.btpd is the default location. - Various changes in btpd options ant btcli use. See '--help'. - The user chooses where to place content for each torrent. - Better disk IO performance. - Configureable disk preallocation to reduce file fragmentation. - The unchoke algorithm is global instead of per torrent. The number of peers to upload to is configurable. - Tracker errors are displayed in 'btcli stat' and most importantly don't make torrents unload on startup. - The rates displayed by btcli are now computed in btpd and are averaged over the last 20 seconds. - btpd now compares size and mtime of content to see if the resume file is valid. Bug fixes: - Double uninterest messages could be sent to some peers in endgame mode. - A function was called prematurely which could trigger an assert in rare cases. btpd 0.7: --------- Bug fixes: - Some communication stupidities was fixed, resulting in better download performance. btpd 0.6: --------- Misc: - Set an upper limit on how much data a peer can request at once. This protects from running out of memory because of a greedy peer. - End game is more efficient and uses much less memory. btpd 0.5: --------- Bug fixes: - The bitfield could be sent too late. This could cause the receiving peer to close the connection. btpd 0.4: --------- Misc: - The 0.1 rate limiter is back. It runs at a configurable hz now. - Added "--bw-hz" option to btpd. - Multiple have messages can be sent in place of a bitfield. - If btpd can't write to a peer for 60s, it will be disconnected. Bug fixes: - A calculation error made btpd buggy with small torrents. This caused strange crashes and many reports on bad hashes in the log. - The bitfield was sent too early. A peer could miss pieces btpd got while the peer was in handshake. - Some situations in end game or with bad hashes could cause a crash. btpd 0.3: --------- Misc: - New download strategy. - Pipe ten requests instead of five. - "-d" option added to btpd. - "--with-warn" option added to configure. The default is now to compile with warnings off. Bug fixes: - It was possible for blocks to remain marked as busy when a peer choked or was lost, causing a piece download to wait until end game. - The peer wanted level could get too high during end game. btpd 0.2: --------- Misc: - A new way to do rate limiting. - Compact mode is now used when talking to the tracker. Bug fixes: - A buffer was too small by four bytes, causing a buffer overflow on the heap in certain conditions. - An iteration over a list was unsafe and could cause a crash. - Unloading a torrent didn't kill peers in handshake for that torrent, and a crash was possible when the handshake finished. - The counter for uploaded data was updated too early. - Fixed illegal operator for test(1) in configure. btpd-0.16/configure.ac0000644000175000001440000000776211425123660011610 00000000000000AC_PREREQ(2.61) AC_INIT(btpd, 0.16, btpd-users@googlegroups.com) AM_INIT_AUTOMAKE([1.10 foreign subdir-objects]) AC_CONFIG_FILES([Makefile]) AC_PROG_CC AM_PROG_CC_C_O AC_PROG_RANLIB AC_USE_SYSTEM_EXTENSIONS AC_DEFUN([PROG_SILENT_IFELSE], ac_output=`$1 2>&1` if test x"$ac_output" != x; then echo $1 nonsilent >&AS_MESSAGE_LOG_FD echo $ac_output >&AS_MESSAGE_LOG_FD [$3] else [$2] fi) AC_DEFUN([CC_ARGS_OK_IFELSE], AC_LANG_PUSH(C) AC_LANG_CONFTEST([int foo(void) { return 12; }]) AC_LANG_POP(C) PROG_SILENT_IFELSE([$CC $1 -c conftest.c], rm -f conftest.c conftest.$OBJEXT [$2], rm -f conftest.c conftest.$OBJEXT [$3])) AC_ARG_WITH(openssl, [ --with-openssl=dir use openssl installed in dir], [ AC_SUBST(openssl_LDFLAGS,["-L${withval}/lib -Wl,-R,${withval}/lib"]) AC_SUBST(openssl_CPPFLAGS,"-I${withval}/include") ]) AC_ARG_WITH(evloop-method, [ --with-evloop-method select evloop method (epoll,poll,kqueue)], evloop_methods=$withval, evloop_methods="epoll kqueue poll") old_LIBS=$LIBS LIBS="" AC_SEARCH_LIBS(inet_ntop, nsl,,AC_MSG_FAILURE(btpd needs inet_ntop)) AC_SEARCH_LIBS(bind, socket,,AC_MSG_FAILURE(btpd needs bind)) AC_SUBST(INETLIBS,$LIBS) LIBS=$old_LIBS AC_CHECK_FUNCS(asprintf) AC_MSG_CHECKING(for CLOCK_MONOTONIC) AC_COMPILE_IFELSE([ #include #include int main(void) { return clock_gettime(CLOCK_MONOTONIC, (void *)0); } ], clock_gettime=yes, clock_gettime=no) AC_MSG_RESULT($clock_gettime) if test $clock_gettime = yes; then old_LIBS=$LIBS LIBS="" AC_SEARCH_LIBS(clock_gettime,rt,clock_gettime=yes,clock_gettime=no) AC_SUBST(CLOCKLIB,$LIBS) LIBS=$old_LIBS AC_DEFINE(HAVE_CLOCK_MONOTONIC) fi if test $clock_gettime = no; then AC_CHECK_FUNCS(mach_absolute_time,, AC_MSG_FAILURE(no supported time mechanism found)) fi AC_MSG_CHECKING(whether compiler accepts -Wno-pointer-sign) CC_ARGS_OK_IFELSE(-Wno-pointer-sign, AC_SUBST(WARNNPS,"-Wno-pointer-sign") AC_MSG_RESULT(yes) , AC_MSG_RESULT(no)) old_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $openssl_LDFLAGS" AC_CHECK_LIB(crypto, SHA1_Final,:,AC_MSG_FAILURE(btpd needs openssl's libraries and headers)) LDFLAGS=$old_LDFLAGS for m in $evloop_methods; do case $m in epoll) AC_CHECK_FUNC(epoll_wait,[ AC_SUBST(EVLOOP_IMPL,"evloop/epoll.${OBJEXT}") AC_SUBST(EVLOOP_METHOD,EVLOOP_EPOLL) break]) ;; kqueue) AC_CHECK_FUNC(kqueue,[ AC_SUBST(EVLOOP_IMPL,"evloop/kqueue.${OBJEXT}") AC_SUBST(EVLOOP_METHOD,EVLOOP_KQUEUE) break]) ;; poll) AC_CHECK_FUNC(poll,[ AC_SUBST(EVLOOP_IMPL,"evloop/poll.${OBJEXT}") AC_SUBST(EVLOOP_METHOD,EVLOOP_POLL) break]) break ;; *) AC_MSG_ERROR($m is not a valid evloop method) exit 1 ;; esac done if test x"$EVLOOP_METHOD" = x; then AC_MSG_FAILURE(no suitable evloop method found) exit 1 else AC_MSG_NOTICE(selected evloop method $EVLOOP_METHOD) fi for i in 0 1 2 3 4 5 6 7; do case $i in 0) if test x"$TD_CFLAGS$TD_LIBS" = x; then continue; fi;; 1) TD_CFLAGS=-pthread;; 2) TD_CFLAGS=-pthreads;; 3) TD_CFLAGS=-kthread;; 4) TD_CFLAGS=-mt;; 5) TD_LIBS=-lpthread;; 6) ;; 7) AC_MSG_FAILURE(how do you build with pthreads on this system?);; esac AC_MSG_CHECKING(whether pthreads compiles with flags \"$TD_CFLAGS $TD_LIBS\") CC_ARGS_OK_IFELSE($TD_CFLAGS $CFLAGS $TD_LIBS $LIBS,, AC_MSG_RESULT(no) TD_CFLAGS=""; TD_LIBS="" continue) old_CFLAGS=$CFLAGS; old_LIBS=$LIBS CFLAGS="$TD_CFLAGS $CFLAGS"; LIBS="$TD_LIBS $LIBS" AC_LINK_IFELSE([ #include int main(void) { return pthread_create(0,0,0,0);} ], [ AC_MSG_RESULT(yes) CFLAGS=$old_CFLAGS; LIBS=$old_LIBS break ], [ AC_MSG_RESULT(no) TD_CFLAGS=""; TD_LIBS="" CFLAGS=$old_CFLAGS; LIBS=$old_LIBS ]) done AC_SUBST(TD_CFLAGS) AC_SUBST(TD_LIBS) AC_OUTPUT btpd-0.16/cli/0000755000175000001440000000000011426157674010152 500000000000000btpd-0.16/cli/btinfo.c0000644000175000001440000000404211417473677011523 00000000000000#include #include #include #include #include #include #include #include #include "metainfo.h" #include "subr.h" static void usage() { fprintf(stderr, "Usage: btinfo file ...\n\n"); exit(1); } static struct option longopts[] = { { "help", no_argument, NULL, 1 }, { NULL, 0, NULL, 0 } }; static void print_metainfo(const char *mi) { uint8_t hash[20]; char hex[SHAHEXSIZE]; char *name = mi_name(mi); unsigned nfiles = mi_nfiles(mi); struct mi_file *files = mi_files(mi); struct mi_announce *ann = mi_announce(mi); printf("Name: %s\n", name); printf("Info hash: %s\n", bin2hex(mi_info_hash(mi, hash), hex, 20)); printf("Tracker URLs: [ "); for (int i = 0; i < ann->ntiers; i++) { printf("[ "); for (int j = 0; j < ann->tiers[i].nurls; j++) printf("%s ", ann->tiers[i].urls[j]); printf("] "); } printf("]\n"); printf("Number of pieces: %lu\n", (unsigned long)mi_npieces(mi)); printf("Piece size: %lld\n", (long long)mi_piece_length(mi)); printf("Total size: %lld\n", (long long)mi_total_length(mi)); printf("Number of files: %u\n", nfiles); printf("Files:\n"); for (int i = 0; i < nfiles; i++) { printf("%s (%lld)\n", files[i].path, (long long)files[i].length); } printf("\n"); free(name); mi_free_files(nfiles, files); mi_free_announce(ann); } int main(int argc, char **argv) { int ch; srandom(time(NULL)); while ((ch = getopt_long(argc, argv, "", longopts, NULL)) != -1) usage(); argc -= optind; argv += optind; if (argc < 1) usage(); while (argc > 0) { char *mi = NULL; if ((mi = mi_load(*argv, NULL)) == NULL) { fprintf(stderr, "failed to load torrent file '%s' (%s).\n", *argv, strerror(errno)); exit(1); } print_metainfo(mi); free(mi); argc--; argv++; } return 0; } btpd-0.16/cli/kill.c0000644000175000001440000000060111417473677011172 00000000000000#include "btcli.h" void usage_kill(void) { printf( "Shutdown btpd.\n" "\n" "Usage: kill\n" "\n" ); exit(1); } void cmd_kill(int argc, char **argv) { enum ipc_err code; if (argc > 1) usage_kill(); btpd_connect(); if ((code = btpd_die(ipc)) != 0) diemsg("command failed (%s).\n", ipc_strerror(code)); } btpd-0.16/cli/add.c0000644000175000001440000000603411423447207010760 00000000000000#include "btcli.h" void usage_add(void) { printf( "Add torrents to btpd.\n" "\n" "Usage: add [-n name] [-T] [-N] -d dir file(s)\n" "\n" "Arguments:\n" "file\n" "\tThe torrent file to add.\n" "\n" "Options:\n" "-d dir\n" "\tUse the dir for content.\n" "\n" "-n name\n" "\tSet the name displayed for this torrent.\n" "\n" "--nostart, -N\n" "\tDon't activate the torrent after adding it.\n" "\n" "--topdir, -T\n" "\tAppend the torrent top directory (if any) to the content path.\n" "\n" ); exit(1); } static struct option add_opts [] = { { "help", no_argument, NULL, 'H' }, { "nostart", no_argument, NULL, 'N'}, { "topdir", no_argument, NULL, 'T'}, {NULL, 0, NULL, 0} }; void cmd_add(int argc, char **argv) { int ch, topdir = 0, start = 1, nfile, nloaded = 0; size_t dirlen = 0; char *dir = NULL, *name = NULL; while ((ch = getopt_long(argc, argv, "NTd:n:", add_opts, NULL)) != -1) { switch (ch) { case 'N': start = 0; break; case 'T': topdir = 1; break; case 'd': dir = optarg; if ((dirlen = strlen(dir)) == 0) diemsg("bad option value for -d.\n"); break; case 'n': name = optarg; break; default: usage_add(); } } argc -= optind; argv += optind; if (argc < 1 || dir == NULL) usage_add(); btpd_connect(); char *mi; size_t mi_size; enum ipc_err code; char dpath[PATH_MAX]; struct iobuf iob; for (nfile = 0; nfile < argc; nfile++) { if ((mi = mi_load(argv[nfile], &mi_size)) == NULL) { fprintf(stderr, "error loading '%s' (%s).\n", argv[nfile], strerror(errno)); continue; } iob = iobuf_init(PATH_MAX); iobuf_write(&iob, dir, dirlen); if (topdir && !mi_simple(mi)) { size_t tdlen; const char *td = benc_dget_mem(benc_dget_dct(mi, "info"), "name", &tdlen); iobuf_swrite(&iob, "/"); iobuf_write(&iob, td, tdlen); } iobuf_swrite(&iob, "\0"); if ((errno = make_abs_path(iob.buf, dpath)) != 0) { fprintf(stderr, "make_abs_path '%s' failed (%s).\n", dpath, strerror(errno)); iobuf_free(&iob); continue; } code = btpd_add(ipc, mi, mi_size, dpath, name); if ((code == IPC_OK) && start) { struct ipc_torrent tspec; tspec.by_hash = 1; mi_info_hash(mi, tspec.u.hash); code = btpd_start(ipc, &tspec); } if (code != IPC_OK) { fprintf(stderr, "command failed for '%s' (%s).\n", argv[nfile], ipc_strerror(code)); } else { nloaded++; } iobuf_free(&iob); } if (nloaded != nfile) { diemsg("error loaded %d of %d files.\n", nloaded, nfile); } } btpd-0.16/cli/stop.c0000644000175000001440000000236611417473677011236 00000000000000#include "btcli.h" void usage_stop(void) { printf( "Deactivate torrents.\n" "\n" "Usage: stop -a\n" " stop torrent ...\n" "\n" "Arguments:\n" "torrent ...\n" "\tThe torrents to deactivate.\n" "\n" "Options:\n" "-a\n" "\tDeactivate all active torrents.\n" "\n" ); exit(1); } static struct option stop_opts [] = { { "help", no_argument, NULL, 'H' }, {NULL, 0, NULL, 0} }; void cmd_stop(int argc, char **argv) { int ch, all = 0; struct ipc_torrent t; while ((ch = getopt_long(argc, argv, "a", stop_opts, NULL)) != -1) { switch (ch) { case 'a': all = 1; break; default: usage_stop(); } } argc -= optind; argv += optind; if ((argc == 0 && !all) || (all && argc != 0)) usage_stop(); btpd_connect(); if (all) { enum ipc_err code = btpd_stop_all(ipc); if (code != IPC_OK) diemsg("command failed (%s).\n", ipc_strerror(code)); } else { for (int i = 0; i < argc; i++) if (torrent_spec(argv[i], &t)) handle_ipc_res(btpd_stop(ipc, &t), "stop", argv[i]); } } btpd-0.16/cli/stat.c0000644000175000001440000001214711417473677011222 00000000000000#include "btcli.h" void usage_stat(void) { printf( "Display stats for active torrents.\n" "\n" "Usage: stat [-i] [-w seconds] [torrent ...]\n" "\n" "Arguments:\n" "torrent ...\n" "\tOnly display stats for the given torrents.\n" "\n" "Options:\n" "-i\n" "\tDisplay individual lines for each torrent.\n" "\n" "-n\n" "\tDisplay the name of each torrent. Implies '-i'.\n" "\n" "-w n\n" "\tDisplay stats every n seconds.\n" "\n"); exit(1); } struct btstat { unsigned num; enum ipc_tstate state; unsigned peers, tr_good; long long content_got, content_size, downloaded, uploaded, rate_up, rate_down, tot_up; uint32_t pieces_seen, torrent_pieces; }; struct cbarg { int individual, names; struct btstat tot; }; static enum ipc_tval stkeys[] = { IPC_TVAL_STATE, IPC_TVAL_NUM, IPC_TVAL_NAME, IPC_TVAL_PCOUNT, IPC_TVAL_TRGOOD, IPC_TVAL_PCCOUNT, IPC_TVAL_PCSEEN, IPC_TVAL_SESSUP, IPC_TVAL_SESSDWN, IPC_TVAL_TOTUP, IPC_TVAL_RATEUP, IPC_TVAL_RATEDWN, IPC_TVAL_CGOT, IPC_TVAL_CSIZE }; static size_t nstkeys = sizeof(stkeys) / sizeof(stkeys[0]); static void print_stat(struct btstat *st) { print_percent(st->content_got, st->content_size); print_size(st->downloaded); print_rate(st->rate_down); print_size(st->uploaded); print_rate(st->rate_up); print_ratio(st->tot_up, st->content_size); printf("%4u ", st->peers); print_percent(st->pieces_seen, st->torrent_pieces); printf("%3u", st->tr_good); printf("\n"); } static void stat_cb(int obji, enum ipc_err objerr, struct ipc_get_res *res, void *arg) { struct cbarg *cba = arg; struct btstat st, *tot = &cba->tot; if (objerr != IPC_OK || res[IPC_TVAL_STATE].v.num == IPC_TSTATE_INACTIVE) return; bzero(&st, sizeof(st)); st.state = res[IPC_TVAL_STATE].v.num; st.num = res[IPC_TVAL_NUM].v.num; tot->torrent_pieces += (st.torrent_pieces = res[IPC_TVAL_PCCOUNT].v.num); tot->pieces_seen += (st.pieces_seen = res[IPC_TVAL_PCSEEN].v.num); tot->content_got += (st.content_got = res[IPC_TVAL_CGOT].v.num); tot->content_size += (st.content_size = res[IPC_TVAL_CSIZE].v.num); tot->downloaded += (st.downloaded = res[IPC_TVAL_SESSDWN].v.num); tot->uploaded += (st.uploaded = res[IPC_TVAL_SESSUP].v.num); tot->rate_down += (st.rate_down = res[IPC_TVAL_RATEDWN].v.num); tot->rate_up += (st.rate_up = res[IPC_TVAL_RATEUP].v.num); tot->peers += (st.peers = res[IPC_TVAL_PCOUNT].v.num); tot->tot_up += (st.tot_up = res[IPC_TVAL_TOTUP].v.num); tot->tr_good += (st.tr_good = res[IPC_TVAL_TRGOOD].v.num); if (cba->individual) { if (cba->names) printf("%.*s\n", (int)res[IPC_TVAL_NAME].v.str.l, res[IPC_TVAL_NAME].v.str.p); printf("%4u %c. ", st.num, tstate_char(st.state)); print_stat(&st); } } static void do_stat(int individual, int names, int seconds, struct ipc_torrent *tps, int ntps) { enum ipc_err err; struct cbarg cba; int header = 1; if (names) individual = 1; cba.individual = individual; cba.names = names; again: header--; if (header == 0) { if (individual) { header = 1; printf(" NUM ST "); } else header = 20; printf(" HAVE DLOAD RTDWN ULOAD RTUP RATIO CONN" " AVAIL TR\n"); } bzero(&cba.tot, sizeof(cba.tot)); cba.tot.state = IPC_TSTATE_INACTIVE; if (tps == NULL) err = btpd_tget_wc(ipc, IPC_TWC_ACTIVE, stkeys, nstkeys, stat_cb, &cba); else err = btpd_tget(ipc, tps, ntps, stkeys, nstkeys, stat_cb, &cba); if (err != IPC_OK) diemsg("command failed (%s).\n", ipc_strerror(err)); if (names) printf("-------\n"); if (individual) printf(" "); print_stat(&cba.tot); if (seconds > 0) { sleep(seconds); goto again; } } static struct option stat_opts [] = { { "help", no_argument, NULL, 'H' }, {NULL, 0, NULL, 0} }; void cmd_stat(int argc, char **argv) { int ch; int wflag = 0, iflag = 0, nflag = 0, seconds = 0; struct ipc_torrent *tps = NULL; int ntps = 0; char *endptr; while ((ch = getopt_long(argc, argv, "inw:", stat_opts, NULL)) != -1) { switch (ch) { case 'i': iflag = 1; break; case 'n': nflag = 1; break; case 'w': wflag = 1; seconds = strtol(optarg, &endptr, 10); if (*endptr != '\0' || seconds < 1) usage_stat(); break; default: usage_stat(); } } argc -= optind; argv += optind; if (argc > 0) { tps = malloc(argc * sizeof(*tps)); for (int i = 0; i < argc; i++) { if (torrent_spec(argv[i], &tps[ntps])) ntps++; else exit(1); } } btpd_connect(); do_stat(iflag, nflag, seconds, tps, ntps); } btpd-0.16/cli/btcli.h0000644000175000001440000000237311417473677011351 00000000000000#ifndef BTCLI_H #define BTCLI_H #include #include #include #include #include #include #include #include #include #include #include "btpd_if.h" #include "metainfo.h" #include "subr.h" #include "benc.h" #include "iobuf.h" #include "queue.h" extern const char *btpd_dir; extern struct ipc *ipc; __attribute__((noreturn)) void diemsg(const char *fmt, ...); void btpd_connect(void); enum ipc_err handle_ipc_res(enum ipc_err err, const char *cmd, const char *target); char tstate_char(enum ipc_tstate ts); int torrent_spec(char *arg, struct ipc_torrent *tp); void print_rate(long long rate); void print_size(long long size); void print_ratio(long long part, long long whole); void print_percent(long long part, long long whole); void usage_add(void); void cmd_add(int argc, char **argv); void usage_del(void); void cmd_del(int argc, char **argv); void usage_list(void); void cmd_list(int argc, char **argv); void usage_stat(void); void cmd_stat(int argc, char **argv); void usage_kill(void); void cmd_kill(int argc, char **argv); void usage_start(void); void cmd_start(int argc, char **argv); void usage_stop(void); void cmd_stop(int argc, char **argv); #endif btpd-0.16/cli/del.c0000644000175000001440000000141611417473677011010 00000000000000#include "btcli.h" void usage_del(void) { printf( "Remove torrents from btpd.\n" "\n" "Usage: del torrent ...\n" "\n" "Arguments:\n" "torrent ...\n" "\tThe torrents to remove.\n" "\n"); exit(1); } static struct option del_opts [] = { { "help", no_argument, NULL, 'H' }, {NULL, 0, NULL, 0} }; void cmd_del(int argc, char **argv) { int ch; struct ipc_torrent t; while ((ch = getopt_long(argc, argv, "", del_opts, NULL)) != -1) usage_del(); argc -= optind; argv += optind; if (argc < 1) usage_del(); btpd_connect(); for (int i = 0; i < argc; i++) if (torrent_spec(argv[i], &t)) handle_ipc_res(btpd_del(ipc, &t), "del", argv[i]); } btpd-0.16/cli/btcli.c0000644000175000001440000001051411417473677011340 00000000000000#include #include "btcli.h" const char *btpd_dir; struct ipc *ipc; void diemsg(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); exit(1); } void btpd_connect(void) { if ((errno = ipc_open(btpd_dir, &ipc)) != 0) diemsg("cannot open connection to btpd in %s (%s).\n", btpd_dir, strerror(errno)); } enum ipc_err handle_ipc_res(enum ipc_err code, const char *cmd, const char *target) { switch (code) { case IPC_OK: break; case IPC_COMMERR: diemsg("error in communication with btpd.\n"); default: fprintf(stderr, "btcli %s '%s': %s.\n", cmd, target, ipc_strerror(code)); } return code; } void print_percent(long long part, long long whole) { printf("%5.1f%% ", floor(1000.0 * part / whole) / 10); } void print_rate(long long rate) { if (rate >= 999.995 * (1 << 10)) printf("%6.2fMB/s ", (double)rate / (1 << 20)); else printf("%6.2fkB/s ", (double)rate / (1 << 10)); } void print_size(long long size) { if (size >= 999.995 * (1 << 20)) printf("%6.2fG ", (double)size / (1 << 30)); else printf("%6.2fM ", (double)size / (1 << 20)); } void print_ratio(long long part, long long whole) { printf("%7.2f ", (double)part / whole); } char tstate_char(enum ipc_tstate ts) { switch (ts) { case IPC_TSTATE_INACTIVE: return 'I'; case IPC_TSTATE_START: return '+'; case IPC_TSTATE_STOP: return '-'; case IPC_TSTATE_LEECH: return 'L'; case IPC_TSTATE_SEED: return 'S'; } diemsg("unrecognized torrent state.\n"); } int torrent_spec(char *arg, struct ipc_torrent *tp) { char *p; tp->u.num = strtoul(arg, &p, 10); if (*p == '\0') { tp->by_hash = 0; return 1; } if ((p = mi_load(arg, NULL)) == NULL) { fprintf(stderr, "btcli: bad torrent '%s' (%s).\n", arg, strerror(errno)); return 0; } tp->by_hash = 1; mi_info_hash(p, tp->u.hash); free(p); return 1; } static struct { const char *name; void (*fun)(int, char **); void (*help)(void); } cmd_table[] = { { "add", cmd_add, usage_add }, { "del", cmd_del, usage_del }, { "kill", cmd_kill, usage_kill }, { "list", cmd_list, usage_list }, { "start", cmd_start, usage_start }, { "stop", cmd_stop, usage_stop }, { "stat", cmd_stat, usage_stat } }; int ncmds = sizeof(cmd_table) / sizeof(cmd_table[0]); static void usage(void) { printf( "btcli is the btpd command line interface.\n" "\n" "Usage: btcli [main options] command [command options]\n" "\n" "Main options:\n" "-d dir\n" "\tThe btpd directory.\n" "\n" "--help [command]\n" "\tShow this text or help for the specified command.\n" "\n" "Commands:\n" "add\t- Add torrents to btpd.\n" "del\t- Remove torrents from btpd.\n" "kill\t- Shut down btpd.\n" "list\t- List torrents.\n" "start\t- Activate torrents.\n" "stat\t- Display stats for active torrents.\n" "stop\t- Deactivate torrents.\n" "\n" "Note:\n" "Torrents can be specified either with its number or its file.\n" "\n" ); exit(1); } static struct option base_opts [] = { { "help", no_argument, NULL, 'H' }, {NULL, 0, NULL, 0} }; int main(int argc, char **argv) { int ch, help = 0; if (argc < 2) usage(); while ((ch = getopt_long(argc, argv, "+d:", base_opts, NULL)) != -1) { switch (ch) { case 'd': btpd_dir = optarg; break; case 'H': help = 1; break; default: usage(); } } argc -= optind; argv += optind; if (argc == 0) usage(); if (btpd_dir == NULL) if ((btpd_dir = find_btpd_dir()) == NULL) diemsg("cannot find the btpd directory.\n"); optind = 0; int found = 0; for (int i = 0; !found && i < ncmds; i++) { if (strcmp(argv[0], cmd_table[i].name) == 0) { found = 1; if (help) cmd_table[i].help(); else cmd_table[i].fun(argc, argv); } } if (!found) usage(); return 0; } btpd-0.16/cli/start.c0000644000175000001440000000233611423447207011366 00000000000000#include "btcli.h" void usage_start(void) { printf( "Activate torrents.\n" "\n" "Usage: start torrent ...\n" "\n" "Arguments:\n" "torrent ...\n" "\tThe torrents to activate.\n" "\n" "Options:\n" "-a\n" "\tActivate all inactive torrents.\n" "\n" ); exit(1); } static struct option start_opts [] = { { "help", no_argument, NULL, 'H' }, {NULL, 0, NULL, 0} }; void cmd_start(int argc, char **argv) { int ch, all = 0; struct ipc_torrent t; while ((ch = getopt_long(argc, argv, "a", start_opts, NULL)) != -1) { switch (ch) { case 'a': all = 1; break; default: usage_start(); } } argc -= optind; argv += optind; if ((argc == 0 && !all) || (all && argc != 0)) usage_start(); btpd_connect(); if (all) { enum ipc_err code = btpd_start_all(ipc); if (code != IPC_OK) diemsg("command failed (%s).\n", ipc_strerror(code)); } else { for (int i = 0; i < argc; i++) if (torrent_spec(argv[i], &t)) handle_ipc_res(btpd_start(ipc, &t), "start", argv[i]); } } btpd-0.16/cli/list.c0000644000175000001440000001701211424700760011176 00000000000000#include "btcli.h" void usage_list(void) { printf( "List torrents.\n" "\n" "Usage: list [-a] [-i] [-f ]\n" " list torrent ...\n" "\n" "Arguments:\n" "torrent ...\n" "\tThe torrents to list. Running 'btcli list' without any arguments\n" "\tor options is equivalent to running 'btcli list -ai'.\n" "\n" "Options:\n" "-a\n" "\tList active torrents.\n" "\n" "-i\n" "\tList inactive torrents.\n" "\n" ); exit(1); } struct item { unsigned num, peers; char *name, *dir; char hash[SHAHEXSIZE]; char st; long long cgot, csize, totup, downloaded, uploaded, rate_up, rate_down; uint32_t torrent_pieces, pieces_have, pieces_seen; BTPDQ_ENTRY(item) entry; }; struct items { int count; char **argv; int ntps; struct ipc_torrent *tps; BTPDQ_HEAD(item_tq, item) hd; }; void itm_insert(struct items *itms, struct item *itm) { struct item *p; BTPDQ_FOREACH(p, &itms->hd, entry) if (strcmp(itm->name, p->name) < 0) break; if (p != NULL) BTPDQ_INSERT_BEFORE(p, itm, entry); else BTPDQ_INSERT_TAIL(&itms->hd, itm, entry); } static void list_cb(int obji, enum ipc_err objerr, struct ipc_get_res *res, void *arg) { struct items *itms = arg; struct item *itm = calloc(1, sizeof(*itm)); if (objerr != IPC_OK) diemsg("list failed for '%s' (%s).\n", itms->argv[obji], ipc_strerror(objerr)); itms->count++; itm->num = (unsigned)res[IPC_TVAL_NUM].v.num; itm->peers = (unsigned)res[IPC_TVAL_PCOUNT].v.num; itm->st = tstate_char(res[IPC_TVAL_STATE].v.num); if (res[IPC_TVAL_NAME].type == IPC_TYPE_ERR) asprintf(&itm->name, "%s", ipc_strerror(res[IPC_TVAL_NAME].v.num)); else asprintf(&itm->name, "%.*s", (int)res[IPC_TVAL_NAME].v.str.l, res[IPC_TVAL_NAME].v.str.p); if (res[IPC_TVAL_DIR].type == IPC_TYPE_ERR) asprintf(&itm->dir, "%s", ipc_strerror(res[IPC_TVAL_DIR].v.num)); else asprintf(&itm->dir, "%.*s", (int)res[IPC_TVAL_DIR].v.str.l, res[IPC_TVAL_DIR].v.str.p); bin2hex(res[IPC_TVAL_IHASH].v.str.p, itm->hash, 20); itm->cgot = res[IPC_TVAL_CGOT].v.num; itm->csize = res[IPC_TVAL_CSIZE].v.num; itm->totup = res[IPC_TVAL_TOTUP].v.num; itm->downloaded = res[IPC_TVAL_SESSDWN].v.num; itm->uploaded = res[IPC_TVAL_SESSUP].v.num; itm->rate_up = res[IPC_TVAL_RATEUP].v.num; itm->rate_down = res[IPC_TVAL_RATEDWN].v.num; itm->torrent_pieces = (uint32_t)res[IPC_TVAL_PCCOUNT].v.num; itm->pieces_seen = (uint32_t)res[IPC_TVAL_PCSEEN].v.num; itm->pieces_have = (uint32_t)res[IPC_TVAL_PCGOT].v.num; itm_insert(itms, itm); } void print_items(struct items* itms, char *format) { struct item *p; char *it; BTPDQ_FOREACH(p, &itms->hd, entry) { if(format) { for (it = format; *it; ++it) { switch (*it) { case '%': ++it; switch (*it) { case '%': putchar('%'); break; case '#': printf("%u", p->num); break; case '^': printf("%lld", p->rate_up); break; case 'A': printf("%u", p->pieces_seen); break; case 'D': printf("%lld", p->downloaded); break; case 'H': printf("%u", p->pieces_have); break; case 'P': printf("%u", p->peers); break; case 'S': printf("%lld", p->csize); break; case 'U': printf("%lld", p->uploaded); break; case 'T': printf("%u", p->torrent_pieces); break; case 'd': printf("%s", p->dir); break; case 'g': printf("%lld", p->cgot); break; case 'h': printf("%s", p->hash); break; case 'n': printf("%s", p->name); break; case 'p': print_percent(p->cgot, p->csize); break; case 'r': print_ratio(p->totup, p->csize); break; case 's': print_size(p->csize); break; case 't': printf("%c", p->st); break; case 'u': printf("%lld", p->totup); break; case 'v': printf("%lld", p->rate_down); break; case '\0': continue; } break; case '\\': ++it; switch (*it) { case 'n': putchar('\n'); break; case 't': putchar('\t'); break; case '\0': continue; } break; default: putchar(*it); break; } } } else { printf("%-40.40s %4u %c. ", p->name, p->num, p->st); print_percent(p->cgot, p->csize); print_size(p->csize); print_ratio(p->totup, p->csize); printf("\n"); } } } static struct option list_opts [] = { { "format", required_argument, NULL, 'f' }, { "help", no_argument, NULL, 'H' }, {NULL, 0, NULL, 0} }; void cmd_list(int argc, char **argv) { int ch, inactive = 0, active = 0; char *format = NULL; enum ipc_err code; enum ipc_twc twc; enum ipc_tval keys[] = { IPC_TVAL_NUM, IPC_TVAL_STATE, IPC_TVAL_NAME, IPC_TVAL_TOTUP, IPC_TVAL_CSIZE, IPC_TVAL_CGOT, IPC_TVAL_PCOUNT, IPC_TVAL_PCCOUNT, IPC_TVAL_PCSEEN, IPC_TVAL_PCGOT, IPC_TVAL_SESSUP, IPC_TVAL_SESSDWN, IPC_TVAL_RATEUP, IPC_TVAL_RATEDWN, IPC_TVAL_IHASH, IPC_TVAL_DIR }; size_t nkeys = sizeof(keys) / sizeof(keys[0]); struct items itms; while ((ch = getopt_long(argc, argv, "aif:", list_opts, NULL)) != -1) { switch (ch) { case 'a': active = 1; break; case 'f': format = optarg; break; case 'i': inactive = 1; break; default: usage_list(); } } argc -= optind; argv += optind; if (argc > 0) { if (inactive || active) usage_list(); itms.tps = malloc(argc * sizeof(*itms.tps)); for (itms.ntps = 0; itms.ntps < argc; itms.ntps++) { if (!torrent_spec(argv[itms.ntps], &itms.tps[itms.ntps])) exit(1); } } else { itms.ntps = 0; itms.tps = NULL; } if (inactive == active) twc = IPC_TWC_ALL; else if (inactive) twc = IPC_TWC_INACTIVE; else twc = IPC_TWC_ACTIVE; btpd_connect(); itms.count = 0; itms.argv = argv; BTPDQ_INIT(&itms.hd); if (itms.tps == NULL) code = btpd_tget_wc(ipc, twc, keys, nkeys, list_cb, &itms); else code = btpd_tget(ipc, itms.tps, itms.ntps, keys, nkeys, list_cb, &itms); if (code != IPC_OK) diemsg("command failed (%s).\n", ipc_strerror(code)); if (format == NULL) printf("%-40.40s NUM ST HAVE SIZE RATIO\n", "NAME"); print_items(&itms, format); } btpd-0.16/misc/0000755000175000001440000000000011426157674010336 500000000000000btpd-0.16/misc/metainfo.c0000644000175000001440000002333111423447061012213 00000000000000#include #include #include #include #include #include #include #include "benc.h" #include "metainfo.h" #include "subr.h" /* * d * announce = url * announce-list = l l url ... e ... e * info = d * name = advisory file/dir save name * piece length = power of two length of each block * pieces = 20b of sha1-hash * num of pieces * length = length of file in bytes in single file download * files = l d * length = length of file in bytes * path = l path components * */ uint8_t * mi_hashes(const char *p) { return benc_dget_mema(benc_dget_dct(p, "info"), "pieces", NULL); } size_t mi_npieces(const char *p) { size_t plen; benc_dget_mem(benc_dget_dct(p, "info"), "pieces", &plen); return plen / 20; } int mi_simple(const char *p) { return benc_dget_lst(benc_dget_dct(p, "info"), "files") == NULL; } void mi_free_announce(struct mi_announce *ann) { if (ann->tiers != NULL) { for (int ti = 0; ti < ann->ntiers; ti++) if (ann->tiers[ti].urls != NULL) { for (int ui = 0; ui < ann->tiers[ti].nurls; ui++) if (ann->tiers[ti].urls[ui] != NULL) free(ann->tiers[ti].urls[ui]); free(ann->tiers[ti].urls); } free(ann->tiers); } free(ann); } static void mi_shuffle_announce(struct mi_announce *ann) { for (int i = 0; i < ann->ntiers; i++) { for (int j = 0; j < ann->tiers[i].nurls - 1; j++) { char *tmp = ann->tiers[i].urls[j]; int ri = rand_between(j, ann->tiers[i].nurls - 1); ann->tiers[i].urls[j] = ann->tiers[i].urls[ri]; ann->tiers[i].urls[ri] = tmp; } } } struct mi_announce * mi_announce(const char *p) { int ti, ui; const char *alst, *ulst, *url; struct mi_announce *res; if ((res = calloc(1, sizeof(*res))) == NULL) return NULL; if ((alst = benc_dget_lst(p, "announce-list")) != NULL) { res->ntiers = benc_nelems(alst); if ((res->tiers = calloc(res->ntiers, sizeof(*res->tiers))) == NULL) goto error; ti = 0; ulst = benc_first(alst); while (ulst != NULL) { res->tiers[ti].nurls = benc_nelems(ulst); res->tiers[ti].urls = calloc(res->tiers[ti].nurls, sizeof(*res->tiers[ti].urls)); if (res->tiers[ti].urls == NULL) goto error; ui = 0; url = benc_first(ulst); while (url != NULL) { if ((res->tiers[ti].urls[ui] = benc_str(url, NULL, NULL)) == NULL) goto error; ui++; url = benc_next(url); } ti++; ulst = benc_next(ulst); } } else { res->ntiers = 1; if ((res->tiers = calloc(1, sizeof(*res->tiers))) == NULL) goto error; res->tiers[0].nurls = 1; if ((res->tiers[0].urls = calloc(1, sizeof(*res->tiers[0].urls))) == NULL) goto error; if ((res->tiers[0].urls[0] = benc_dget_str(p, "announce", NULL)) == NULL) goto error; } mi_shuffle_announce(res); return res; error: if (res != NULL) mi_free_announce(res); return NULL; } off_t mi_piece_length(const char *p) { return benc_dget_int(benc_dget_dct(p, "info"), "piece length"); } off_t mi_total_length(const char *p) { const char *info = benc_dget_dct(p, "info"); const char *files = benc_dget_lst(info, "files"); if (files != NULL) { off_t length = 0; const char *fdct = benc_first(files); while (fdct != NULL) { length += benc_dget_int(fdct, "length"); fdct = benc_next(fdct); } return length; } else return benc_dget_int(info, "length"); } uint8_t * mi_info_hash(const char *p, uint8_t *hash) { const char *info = benc_dget_dct(p, "info"); if (hash == NULL) if ((hash = malloc(20)) == NULL) return NULL; return SHA1(info, benc_length(info), hash); } char * mi_name(const char *p) { return benc_dget_str(benc_dget_dct(p, "info"), "name", NULL); } size_t mi_nfiles(const char *p) { const char *files = benc_dget_lst(benc_dget_dct(p, "info"), "files"); if (files != NULL) return benc_nelems(files); else return 1; } static char * mi_filepath(const char *plst) { char *res = NULL; const char *str; size_t npaths = 0, plen = 0, len; const char *iter = benc_first(plst); while (iter != NULL) { benc_mem(iter, &len, &iter); npaths++; plen += len; } if ((res = malloc(plen + (npaths - 1) + 1)) == NULL) return NULL; iter = benc_first(plst); str = benc_mem(iter, &len, &iter); bcopy(str, res, len); plen = len; npaths--; while (npaths > 0) { res[plen] = '/'; plen++; str = benc_mem(iter, &len, &iter); bcopy(str, res + plen, len); plen += len; npaths--; } res[plen] = '\0'; return res; } void mi_free_files(unsigned nfiles, struct mi_file *files) { for (unsigned i = 0; i < nfiles; i++) if (files[i].path != NULL) free(files[i].path); free(files); } struct mi_file * mi_files(const char *p) { struct mi_file *fi; const char *info = benc_dget_dct(p, "info"); const char *files = benc_dget_lst(info, "files"); if (files != NULL) { int i = 0; unsigned nfiles = benc_nelems(files); const char *fdct = benc_first(files); if ((fi = calloc(nfiles, sizeof(*fi))) == NULL) return NULL; for (fdct = benc_first(files); fdct != NULL; fdct = benc_next(fdct)) { fi[i].length = benc_dget_int(fdct, "length"); fi[i].path = mi_filepath(benc_dget_lst(fdct, "path")); if (fi[i].path == NULL) { mi_free_files(nfiles, fi); return NULL; } i++; } } else { if ((fi = calloc(1, sizeof(*fi))) == NULL) return NULL; fi[0].length = benc_dget_int(info, "length"); fi[0].path = benc_dget_str(info, "name", NULL); if (fi[0].path == NULL) { free(fi); return NULL; } } return fi; } static int mi_test_path(const char *path, size_t len) { if (len == 0) return 0; else if (len == 1 && path[0] == '.') return 0; else if (len == 2 && path[0] == '.' && path[1] == '.') return 0; else if (memchr(path, '/', len) != NULL) return 0; return 1; } static int mi_test_files(const char *files) { int fcount = 0; const char *fdct = benc_first(files); while (fdct != NULL) { const char *plst; const char *path; int pcount = 0; if (!benc_isdct(fdct)) return 0; if (benc_dget_int(fdct, "length") < 0) return 0; if ((plst = benc_dget_lst(fdct, "path")) == NULL) return 0; path = benc_first(plst); while (path != NULL) { size_t plen; const char *pstr = benc_mem(path, &plen, &path); if (pstr == NULL || !mi_test_path(pstr, plen)) return 0; pcount++; } if (pcount == 0) return 0; fcount++; fdct = benc_next(fdct); } return fcount > 0 ? 1 : 0; } static int mi_test_announce_list(const char *alst) { int lstcount = 0; const char *t = benc_first(alst); while (t != NULL && benc_islst(t)) { int strcount = 0; const char *s = benc_first(t); while (s != NULL && benc_isstr(s)) { strcount++; s = benc_next(s); } if (strcount == 0) return 0; lstcount++; t = benc_next(t); } return lstcount > 0 ? 1 : 0; } int mi_test(const char *p, size_t size) { const char *info; const char *alst; const char *pieces; const char *files; const char *fdct; const char *name; size_t slen, npieces; off_t length = 0, piece_length; if (benc_validate(p, size) != 0 || !benc_isdct(p)) return 0; if ((alst = benc_dget_any(p, "announce-list")) != NULL) { if (!benc_islst(alst)) return 0; if (!mi_test_announce_list(alst)) return 0; } else if (benc_dget_mem(p, "announce", NULL) == NULL) return 0; if ((info = benc_dget_dct(p, "info")) == NULL) return 0; if ((name = benc_dget_mem(info, "name", &slen)) != NULL) if (!mi_test_path(name, slen)) return 0; if ((piece_length = benc_dget_int(info, "piece length")) <= 0) return 0; if ((pieces = benc_dget_mem(info, "pieces", &slen)) == NULL || slen % 20 != 0) return 0; npieces = slen / 20; if ((length = benc_dget_int(info, "length")) != 0) { if (length < 0 || benc_dget_any(info, "files") != NULL) return 0; } else { if ((files = benc_dget_lst(info, "files")) == NULL) return 0; if (!mi_test_files(files)) return 0; fdct = benc_first(files); while (fdct != NULL) { length += benc_dget_int(fdct, "length"); fdct = benc_next(fdct); } } if (length < (npieces - 1) * piece_length || length > npieces * piece_length) return 0; return 1; } char * mi_load(const char *path, size_t *size) { char *res; size_t mi_size = 0; if ((res = read_file(path, NULL, &mi_size)) == NULL) return NULL; if (!mi_test(res, mi_size)) { free(res); errno = EINVAL; return NULL; } if (size != NULL) *size = mi_size; return res; } btpd-0.16/misc/benc.c0000644000175000001440000001675511417473677011353 00000000000000#include #include #include #include #include #include #include #include #include "benc.h" #include "subr.h" #define benc_safeset(out, val) if ((out) != NULL) *(out) = (val) static const char *benc_validate_aux(const char *p, const char *end); int benc_validate(const char *p, size_t len) { const char *end = p + len - 1; if (len <= 0) return EINVAL; return benc_validate_aux(p, end) == end ? 0 : EINVAL; } static const char * benc_validate_aux(const char *p, const char *end) { size_t d = 0; switch (*p) { case 'd': d = 1; case 'l': for (p++; p <= end && *p != 'e'; p++) { if (d != 0) { if (d % 2 == 1 && !isdigit(*p)) return NULL; else d++; } if ((p = benc_validate_aux(p, end)) == NULL) return NULL; } if (p > end || (d != 0 && d % 2 != 1)) return NULL; break; case 'i': p++; if (p > end) return NULL; if (*p == '-') p++; if (p > end || !isdigit(*p)) return NULL; p++; while (p <= end && isdigit(*p)) p++; if (p > end || *p != 'e') return NULL; break; default: if (isdigit(*p)) { size_t len = 0; while (p <= end && isdigit(*p)) { len *= 10; len += *p - '0'; p++; } if (p <= end && *p == ':' && p + len <= end) p += len; else return NULL; } else return NULL; break; } return p; } int benc_strcmp(const char *str1, const char *str2) { size_t len1, len2; const char *cs1 = benc_mem(str1, &len1, NULL); const char *cs2 = benc_mem(str2, &len2, NULL); int test = strncmp(cs1, cs2, min(len1, len2)); if (test == 0) { if (len1 == len2) return 0; else if (len1 < len2) return -1; else return 1; } else return test; } size_t benc_strlen(const char *p) { char *endptr; return strtoul(p, &endptr, 10); } size_t benc_length(const char *p) { size_t blen; const char *next; switch (*p) { case 'd': case 'l': blen = 2; // [l|d]...e next = p + 1; while (*next != 'e') { size_t len = benc_length(next); blen += len; next += len; } return blen; case 'i': for (next = p + 1; *next != 'e'; next++) ; return next - p + 1; default: assert((next = benc_mem(p, &blen, NULL)) != NULL); return next - p + blen; } } size_t benc_nelems(const char *p) { size_t nelems = 0; for (p = benc_first(p); p != NULL; p = benc_next(p)) nelems++; return nelems; } const char * benc_first(const char *p) { assert(benc_islst(p)); return *(p + 1) == 'e' ? NULL : p + 1; } const char * benc_next(const char *p) { size_t blen = benc_length(p); return *(p + blen) == 'e' ? NULL : p + blen; } const char * benc_mem(const char *p, size_t *len, const char**next) { if (!benc_isstr(p)) return NULL; char *endptr; size_t blen = strtoul(p, &endptr, 10); assert(*endptr == ':'); benc_safeset(len, blen); benc_safeset(next, *(endptr + blen + 1) == 'e' ? NULL : endptr + blen + 1); return endptr + 1; } char * benc_str(const char *p, size_t *len, const char **next) { size_t blen; const char *bstr; char *ret; if ((bstr = benc_mem(p, &blen, next)) == NULL) return NULL; if ((ret = malloc(blen + 1)) == NULL) return NULL; bcopy(bstr, ret, blen); ret[blen] = '\0'; benc_safeset(len, blen); return ret; } char * benc_mema(const char *p, size_t *len, const char **next) { size_t blen; const char *bstr; char *ret; if ((bstr = benc_mem(p, &blen, next)) == NULL) return NULL; if ((ret = malloc(blen)) == NULL) return NULL; bcopy(bstr, ret, blen); benc_safeset(len, blen); return ret; } long long benc_int(const char *p, const char **next) { long long res; char *endptr; if (!benc_isint(p)) return 0; res = strtoll(p + 1, &endptr, 10); assert(*endptr == 'e'); benc_safeset(next, *(endptr + 1) == 'e' ? NULL : endptr + 1); return res; } const char * benc_dget_any(const char *p, const char *key) { int cmp; size_t len, blen; const char *bstr; if (!benc_isdct(p)) return NULL; len = strlen(key); p = benc_first(p); while (p != NULL) { if (!benc_isstr(p)) return NULL; bstr = benc_mem(p, &blen, &p); cmp = strncmp(bstr, key, blen); if (cmp == 0 && len == blen) return p; else if (cmp <= 0) p = benc_next(p); else return NULL; } return NULL; } const char * benc_dget_lst(const char *p, const char *key) { const char *ret = benc_dget_any(p, key); return ret != NULL && benc_islst(ret) ? ret : NULL; } const char * benc_dget_dct(const char *p, const char *key) { const char *ret = benc_dget_any(p, key); return ret != NULL && benc_isdct(ret) ? ret : NULL; } const char * benc_dget_mem(const char *p, const char *key, size_t *len) { const char *str = benc_dget_any(p, key); return str != NULL && benc_isstr(str) ? benc_mem(str, len, NULL) : NULL; } char * benc_dget_mema(const char *p, const char *key, size_t *len) { const char *str = benc_dget_any(p, key); return str != NULL && benc_isstr(str) ? benc_mema(str, len, NULL) : NULL; } char * benc_dget_str(const char *p, const char *key, size_t *len) { const char *str = benc_dget_any(p, key); return str != NULL && benc_isstr(str) ? benc_str(str, len, NULL) : NULL; } long long benc_dget_int(const char *p, const char *key) { const char *intp = benc_dget_any(p, key); return intp != NULL && benc_isint(intp) ? benc_int(intp, NULL) : 0; } int benc_islst(const char *p) { return *p == 'l' || *p == 'd'; } int benc_isdct(const char *p) { return *p == 'd'; } int benc_isint(const char *p) { return *p == 'i'; } int benc_isstr(const char *p) { return isdigit(*p); } int benc_istype(const char *p, enum be_type type) { switch (type) { case BE_ANY: return benc_isdct(p) || benc_isint(p) || benc_islst(p) || benc_isstr(p); case BE_DCT: return benc_isdct(p); case BE_INT: return benc_isint(p); case BE_LST: return benc_islst(p); case BE_STR: return benc_isstr(p); default: abort(); } } int benc_dct_chk(const char *p, int count, ...) { int i, ok = 1; va_list ap; if (!benc_isdct(p)) ok = 0; va_start(ap, count); for (i = 0; ok && i < count; i++) { enum be_type type = va_arg(ap, enum be_type); int level = va_arg(ap, int); const char *dct = p; const char *key = va_arg(ap, const char *); while (ok && level > 1) { if ((dct = benc_dget_dct(dct, key)) != NULL) { level--; key = va_arg(ap, const char *); } else ok = 0; } if (ok) { const char *val = benc_dget_any(dct, key); if (val == NULL || !benc_istype(val, type)) ok = 0; } } va_end(ap); return ok; } btpd-0.16/misc/stream.h0000644000175000001440000000141411417473677011726 00000000000000#ifndef BTPD_STREAM_H #define BTPD_STREAM_H typedef int (*fdcb_t)(const char *, int *, void *); typedef void (*hashcb_t)(uint32_t, uint8_t *, void *); struct bt_stream { unsigned nfiles; struct mi_file *files; off_t totlen; fdcb_t fd_cb; void *fd_arg; unsigned index; off_t t_off; off_t f_off; int fd; }; int bts_open(struct bt_stream **res, unsigned nfiles, struct mi_file *files, fdcb_t fd_cb, void *fd_arg); int bts_close(struct bt_stream *bts); int bts_get(struct bt_stream *bts, off_t off, uint8_t *buf, size_t len); int bts_put(struct bt_stream *bts, off_t off, const uint8_t *buf, size_t len); int bts_sha(struct bt_stream *bts, off_t start, off_t length, uint8_t *hash); const char *bts_filename(struct bt_stream *bts); #endif btpd-0.16/misc/btpd_if.h0000644000175000001440000000402411423447207012025 00000000000000#ifndef BTPD_IPC_H #define BTPD_IPC_H enum ipc_err { #define ERRDEF(name, msg) IPC_##name, #include "ipcdefs.h" #undef ERRDEF IPC_ERRCOUNT }; enum ipc_type { IPC_TYPE_ERR, IPC_TYPE_BIN, IPC_TYPE_NUM, IPC_TYPE_STR }; enum ipc_tval { #define TVDEF(val, type, name) IPC_TVAL_##val, #include "ipcdefs.h" #undef TVDEF IPC_TVALCOUNT }; enum ipc_dval { IPC_DVAL_MIN, IPC_DVAL_MAX }; enum ipc_twc { IPC_TWC_ALL, IPC_TWC_ACTIVE, IPC_TWC_INACTIVE }; enum ipc_tstate { IPC_TSTATE_INACTIVE, IPC_TSTATE_START, IPC_TSTATE_STOP, IPC_TSTATE_LEECH, IPC_TSTATE_SEED }; #ifndef DAEMON struct ipc; struct ipc_get_res { enum ipc_type type; union { struct { const char *p; size_t l; } str; long long num; } v; }; struct ipc_torrent { int by_hash; union { unsigned num; uint8_t hash[20]; } u; }; typedef void (*tget_cb_t)(int obji, enum ipc_err objerr, struct ipc_get_res *res, void *arg); //typedef void (*dget_cb_t)(struct ipc_get_res *res, size_t nres, void *arg); int ipc_open(const char *dir, struct ipc **out); void ipc_close(struct ipc *ipc); const char *ipc_strerror(enum ipc_err err); enum ipc_err btpd_add(struct ipc *ipc, const char *mi, size_t mi_size, const char *content, const char *name); enum ipc_err btpd_del(struct ipc *ipc, struct ipc_torrent *tp); enum ipc_err btpd_start(struct ipc *ipc, struct ipc_torrent *tp); enum ipc_err btpd_start_all(struct ipc *ipc); enum ipc_err btpd_stop(struct ipc *ipc, struct ipc_torrent *tp); enum ipc_err btpd_stop_all(struct ipc *ipc); enum ipc_err btpd_die(struct ipc *ipc); enum ipc_err btpd_get(struct ipc *ipc, enum ipc_dval *keys, size_t nkeys, tget_cb_t cb, void *arg); enum ipc_err btpd_tget(struct ipc *ipc, struct ipc_torrent *tps, size_t ntps, enum ipc_tval *keys, size_t nkeys, tget_cb_t cb, void *arg); enum ipc_err btpd_tget_wc(struct ipc *ipc, enum ipc_twc, enum ipc_tval *keys, size_t nkeys, tget_cb_t cb, void *arg); #endif #endif btpd-0.16/misc/iobuf.c0000644000175000001440000000411011417473677011526 00000000000000#include #include #include #include #include #include #include #include "iobuf.h" #include "subr.h" struct iobuf iobuf_init(size_t size) { struct iobuf iob; iob.size = size; iob.off = 0; iob.skip = 0; iob.error = (iob.buf = malloc(size)) == NULL ? 1 : 0; return iob; } void iobuf_free(struct iobuf *iob) { if (iob->buf != NULL) free(iob->buf - iob->skip); iob->buf = NULL; iob->error = 1; } void iobuf_consumed(struct iobuf *iob, size_t count) { if (iob->error) return; assert(count <= iob->off); iob->skip += count; iob->buf += count; iob->off -= count; } int iobuf_accommodate(struct iobuf *iob, size_t count) { if (iob->error) return 0; size_t esize = iob->size - (iob->skip + iob->off); if (esize >= count) return 1; else if (esize + iob->skip >= count) { bcopy(iob->buf, iob->buf - iob->skip, iob->off); iob->buf -= iob->skip; iob->skip = 0; return 1; } else { uint8_t *nbuf = realloc(iob->buf - iob->skip, iob->size + count); if (nbuf == NULL) { iob->error = 1; return 0; } iob->buf = nbuf + iob->skip; iob->size += count; return 1; } } int iobuf_print(struct iobuf *iob, const char *fmt, ...) { if (iob->error) return 0; int np; va_list ap; va_start(ap, fmt); np = vsnprintf(NULL, 0, fmt, ap); va_end(ap); if (!iobuf_accommodate(iob, np + 1)) return 0; va_start(ap, fmt); vsnprintf(iob->buf + iob->off, np + 1, fmt, ap); va_end(ap); iob->off += np; return 1; } int iobuf_write(struct iobuf *iob, const void *buf, size_t count) { if (iob->error) return 0; if (!iobuf_accommodate(iob, count)) return 0; bcopy(buf, iob->buf + iob->off, count); iob->off += count; return 1; } void * iobuf_find(struct iobuf *iob, const void *p, size_t plen) { return iob->error ? NULL : memfind(p, plen, iob->buf, iob->off); } btpd-0.16/misc/ipcdefs.h0000644000175000001440000000317611417473677012057 00000000000000#ifndef ERRDEF #define __IPCE #define ERRDEF(name, msg) #endif ERRDEF(OK, "no error") ERRDEF(COMMERR, "communication error") ERRDEF(EBADCDIR, "bad content directory") ERRDEF(EBADT, "bad torrent") ERRDEF(EBADTENT, "bad torrent entry") ERRDEF(EBADTRACKER, "bad tracker") ERRDEF(ECREATECDIR, "couldn't create content directory") ERRDEF(ENOKEY, "no such key") ERRDEF(ENOTENT, "no such torrent entry") ERRDEF(ESHUTDOWN, "btpd is shutting down") ERRDEF(ETACTIVE, "torrent is active") ERRDEF(ETENTEXIST, "torrent entry exists") ERRDEF(ETINACTIVE, "torrent is inactive") #ifdef __IPCE #undef __IPCE #undef ERRDEF #endif #ifndef TVDEF #define __IPCTV #define TVDEF(val, type, name) #endif TVDEF(CGOT, NUM, "content_got") TVDEF(CSIZE, NUM, "content_size") TVDEF(DIR, PATH, "dir") TVDEF(NAME, STR, "name") TVDEF(NUM, NUM, "num") TVDEF(IHASH, BIN, "info_hash") TVDEF(PCGOT, NUM, "pieces_got") TVDEF(PCOUNT, NUM, "peer_count") TVDEF(PCCOUNT, NUM, "piece_count") TVDEF(PCSEEN, NUM, "pieces_seen") TVDEF(RATEDWN, NUM, "rate_down") TVDEF(RATEUP, NUM, "rate_up") TVDEF(SESSDWN, NUM, "sess_down") TVDEF(SESSUP, NUM, "sess_up") TVDEF(STATE, TSTATE, "state") TVDEF(TOTDWN, NUM, "total_down") TVDEF(TOTUP, NUM, "total_up") TVDEF(TRERR, NUM, "tr_errors") TVDEF(TRGOOD, NUM, "tr_good") #ifdef __IPCTV #undef __IPCTV #undef TVDEF #endif btpd-0.16/misc/hashtable.h0000644000175000001440000000561611417473677012376 00000000000000#ifndef BTPD_HASHTABLE_H #define BTPD_HASHTABLE_H struct htbl_iter { struct _htbl *tbl; size_t bi; size_t cnt; struct _any **ptr; struct _any *obj; }; struct _htbl *_htbl_create(float ratio, int (*equal)(const void *, const void *), uint32_t (*hash)(const void *), size_t keyoff, size_t chainoff); void _htbl_free(struct _htbl *tbl); void _htbl_insert(struct _htbl *tbl, struct _any *o); struct _any *_htbl_remove(struct _htbl *tbl, const void *key); struct _any *_htbl_find(struct _htbl *tbl, const void *key); void _htbl_fillv(struct _htbl *tbl, struct _any **v); struct _any **_htbl_tov(struct _htbl *tbl); size_t _htbl_size(struct _htbl *tbl); struct _any *_htbl_iter_first(struct _htbl *tbl, struct htbl_iter *it); struct _any *_htbl_iter_next(struct htbl_iter *it); struct _any *_htbl_iter_del(struct htbl_iter *it); #define HTBL_ENTRY(name) struct _any *name #define HTBL_TYPE(name, type, ktype, kname, cname) \ __attribute__((always_inline)) static inline struct name * \ name##_create(float ratio, int (*equal)(const void *, const void *), \ uint32_t (*hash)(const void *)) \ { \ return (struct name *) \ _htbl_create(ratio, equal, hash, offsetof(struct type, kname), \ offsetof(struct type, cname)); \ } \ \ __attribute__((always_inline)) static inline struct type * \ name##_find(struct name *tbl, const ktype *key) \ { \ return (struct type *)_htbl_find((struct _htbl *)tbl, key); \ } \ \ __attribute__((always_inline)) static inline struct type * \ name##_remove(struct name *tbl, const ktype *key) \ { \ return (struct type *)_htbl_remove((struct _htbl *)tbl, key); \ } \ \ __attribute__((always_inline)) static inline void \ name##_free(struct name *tbl) \ { \ _htbl_free((struct _htbl *)tbl); \ } \ \ __attribute__((always_inline)) static inline void \ name##_insert(struct name *tbl, struct type *o) \ { \ _htbl_insert((struct _htbl *)tbl, (struct _any *)o); \ } \ __attribute__((always_inline)) static inline struct type ** \ name##_tov(struct name *tbl) \ { \ return (struct type **) _htbl_tov((struct _htbl *)tbl); \ } \ __attribute__((always_inline)) static inline void \ name##_fillv(struct name *tbl, struct type **v) \ { \ _htbl_fillv((struct _htbl *)tbl, (struct _any **)v); \ } \ \ __attribute__((always_inline)) static inline size_t \ name##_size(struct name *tbl) \ { \ return _htbl_size((struct _htbl *)tbl); \ } \ \ __attribute__((always_inline)) static inline struct type * \ name##_iter_first(struct name *tbl, struct htbl_iter *it) \ { \ return (struct type *)_htbl_iter_first((struct _htbl *)tbl, it); \ } \ \ __attribute__((always_inline)) static inline struct type * \ name##_iter_del(struct htbl_iter *it) \ { \ return (struct type *)_htbl_iter_del(it); \ } \ __attribute__((always_inline)) static inline struct type * \ name##_iter_next(struct htbl_iter *it) \ { \ return (struct type *)_htbl_iter_next(it); \ } #endif btpd-0.16/misc/http_client.c0000644000175000001440000002443311420645241012727 00000000000000#include #include #include #include #include #include #include #include #include #include "iobuf.h" #include "subr.h" #include "http_client.h" struct http_url * http_url_parse(const char *url) { size_t ulen = strlen(url); if (strncmp(url, "http://", 7) != 0) return NULL; const char *cur, *at, *uri = NULL, *uri_e = NULL; const char *host = NULL, *host_e = NULL; const char *port = NULL, *port_e = NULL; at = strchr(url + 7, '@'); uri = strchr(url + 7, '/'); cur = strchr(url + 7, '?'); if (cur != NULL && (uri == NULL || cur < uri)) uri = cur; if (uri == NULL) uri = url + ulen; if (at != NULL && at < uri) host = at + 1; else host = url + 7; cur = host; while (cur < uri && *cur != ':') cur++; host_e = cur; if (host_e == host) return NULL; if (*cur == ':') { cur++; port = cur; while (cur < uri && *cur >= '0' && *cur <= '9') cur++; if (cur == port || cur != uri) return NULL; port_e = cur; } while (*cur != '\0') cur++; uri_e = cur; struct http_url *res = malloc(sizeof(*res) + host_e - host + 1 + uri_e - uri + 2); if (res == NULL) return NULL; if (port != NULL) sscanf(port, "%hu", &res->port); else res->port = 80; res->host = (char *)(res + 1); res->uri = res->host + (host_e - host + 1); bcopy(host, res->host, host_e - host); res->host[host_e - host] = '\0'; if (*uri != '/') { res->uri[0] = '/'; bcopy(uri, res->uri + 1, uri_e - uri); res->uri[uri_e - uri + 1] = '\0'; } else { bcopy(uri, res->uri, uri_e - uri); res->uri[uri_e - uri] = '\0'; } return res; } void http_url_free(struct http_url *url) { free(url); } struct http_req { enum { PS_HEAD, PS_CHUNK_SIZE, PS_CHUNK_DATA, PS_CHUNK_CRLF, PS_ID_DATA } pstate; int parsing; int cancel; int chunked; long length; http_cb_t cb; void *arg; struct http_url *url; struct iobuf rbuf; struct iobuf wbuf; }; static void http_free(struct http_req *req) { if (req->url != NULL) http_url_free(req->url); iobuf_free(&req->rbuf); iobuf_free(&req->wbuf); free(req); } static void http_error(struct http_req *req) { struct http_response res; res.type = HTTP_T_ERR; res.v.error = 1; req->cb(req, &res, req->arg); http_free(req); } static char * strnl(char *str, int *nlsize) { char *nl = strchr(str, '\n'); if (nl != NULL && nl > str && *(nl - 1) == '\r') { *nlsize = 2; return nl - 1; } else { *nlsize = 1; return nl; } } static int headers_parse(struct http_req *req, char *buf, char *end) { int code, majv, minv, nlsize; char *cur, *nl; char name[128], value[872]; struct http_response res; req->chunked = 0; req->length = -1; if (sscanf(buf, "HTTP/%d.%d %d", &majv, &minv, &code) != 3) return 0; res.type = HTTP_T_CODE; res.v.code = code; req->cb(req, &res, req->arg); if (req->cancel) return 1; cur = strchr(buf, '\n') + 1; nl = strnl(cur, &nlsize); while (cur < end) { int i; char *colon = strchr(cur, ':'); if (colon == NULL || colon > nl) return 0; snprintf(name, sizeof(name), "%.*s", (int)(colon - cur), cur); cur = colon + 1; i = 0; val_loop: while (isblank(*cur)) cur++; while (cur < nl) { if (i < sizeof(value) - 1) { value[i] = *cur; i++; } cur++; } cur += nlsize; nl = strnl(cur, &nlsize); if (isblank(*cur)) { if (i < sizeof(value) - 1) { value[i] = ' '; i++; } cur++; goto val_loop; } value[i] = '\0'; for (i--; i >= 0 && isblank(value[i]); i--) value[i] = '\0'; res.type = HTTP_T_HEADER; res.v.header.n = name; res.v.header.v = value; req->cb(req, &res, req->arg); if (req->cancel) return 1; if ((!req->chunked && strcasecmp("Transfer-Encoding", name) == 0 && strcasecmp("chunked", value) == 0)) req->chunked = 1; if ((!req->chunked && req->length == -1 && strcasecmp("Content-Length", name) == 0)) { errno = 0; req->length = strtol(value, NULL, 10); if (errno) req->length = -1; } } if (req->chunked) req->pstate = PS_CHUNK_SIZE; else req->pstate = PS_ID_DATA; return 1; } static int http_parse(struct http_req *req, int len) { char *end, *numend; size_t dlen, consumed; struct http_response res; again: switch (req->pstate) { case PS_HEAD: if (len == 0) goto error; if ((end = iobuf_find(&req->rbuf, "\r\n\r\n", 4)) != NULL) dlen = 4; else if ((end = iobuf_find(&req->rbuf, "\n\n", 2)) != NULL) dlen = 2; else { if (req->rbuf.off < (1 << 15)) return 1; else goto error; } /* req->rbuf.buf may be reallocated inside iobuf_write() * so calculate the offset before that is called */ consumed = end - (char *)req->rbuf.buf + dlen; if (!iobuf_write(&req->rbuf, "", 1)) goto error; req->rbuf.off--; if (!headers_parse(req, req->rbuf.buf, end)) goto error; if (req->cancel) goto cancel; iobuf_consumed(&req->rbuf, consumed); goto again; case PS_CHUNK_SIZE: assert(req->chunked); if (len == 0) goto error; if ((end = iobuf_find(&req->rbuf, "\n", 1)) == NULL) { if (req->rbuf.off < 20) return 1; else goto error; } errno = 0; req->length = strtol(req->rbuf.buf, &numend, 16); if (req->length < 0 || numend == (char *)req->rbuf.buf || errno) goto error; if (req->length == 0) goto done; iobuf_consumed(&req->rbuf, end - (char *)req->rbuf.buf + 1); req->pstate = PS_CHUNK_DATA; goto again; case PS_CHUNK_DATA: if (len == 0) goto error; assert(req->length > 0); dlen = min(req->rbuf.off, req->length); if (dlen > 0) { res.type = HTTP_T_DATA; res.v.data.l = dlen; res.v.data.p = req->rbuf.buf; req->cb(req, &res, req->arg); if (req->cancel) goto cancel; iobuf_consumed(&req->rbuf, dlen); req->length -= dlen; if (req->length == 0) { req->pstate = PS_CHUNK_CRLF; goto again; } } return 1; case PS_CHUNK_CRLF: if (len == 0) goto error; assert(req->length == 0); if (req->rbuf.off < 2) return 1; if (req->rbuf.buf[0] == '\r' && req->rbuf.buf[1] == '\n') dlen = 2; else if (req->rbuf.buf[0] == '\n') dlen = 1; else goto error; iobuf_consumed(&req->rbuf, dlen); req->pstate = PS_CHUNK_SIZE; goto again; case PS_ID_DATA: if (len == 0 && req->length < 0) goto done; else if (len == 0) goto error; if (req->length < 0) dlen = req->rbuf.off; else dlen = min(req->rbuf.off, req->length); if (dlen > 0) { res.type = HTTP_T_DATA; res.v.data.p = req->rbuf.buf; res.v.data.l = dlen; req->cb(req, &res, req->arg); if (req->cancel) goto cancel; iobuf_consumed(&req->rbuf, dlen); if (req->length > 0) { req->length -= dlen; if (req->length == 0) goto done; } } return 1; default: abort(); } error: http_error(req); return 0; done: res.type = HTTP_T_DONE; req->cb(req, &res, req->arg); cancel: http_free(req); return 0; } struct http_url * http_url_get(struct http_req *req) { return req->url; } int http_want_read(struct http_req *req) { return 1; } int http_want_write(struct http_req *req) { return req->wbuf.off > 0; } int http_read(struct http_req *req, int sd) { if (!iobuf_accommodate(&req->rbuf, 4096)) { http_error(req); return 0; } ssize_t nr = read(sd, req->rbuf.buf + req->rbuf.off, 4096); if (nr < 0 && errno == EAGAIN) return 1; else if (nr < 0) { http_error(req); return 0; } else { req->rbuf.off += nr; req->parsing = 1; if (http_parse(req, nr)) { req->parsing = 0; return 1; } else return 0; } } int http_write(struct http_req *req, int sd) { assert(req->wbuf.off > 0); ssize_t nw = write(sd, req->wbuf.buf, req->wbuf.off); if (nw < 0 && errno == EAGAIN) return 1; else if (nw < 0) { http_error(req); return 0; } else { iobuf_consumed(&req->wbuf, nw); return 1; } } int http_get(struct http_req **out, const char *url, const char *hdrs, http_cb_t cb, void *arg) { struct http_req *req = calloc(1, sizeof(*req)); if (req == NULL) return 0; req->cb = cb; req->arg = arg; req->url = http_url_parse(url); if (req->url == NULL) goto error; req->rbuf = iobuf_init(4096); req->wbuf = iobuf_init(1024); if (!iobuf_print(&req->wbuf, "GET %s HTTP/1.1\r\n" "Host: %s:%hu\r\n" "Accept-Encoding:\r\n" "Connection: close\r\n" "%s" "\r\n", req->url->uri, req->url->host, req->url->port, hdrs)) goto error; if (out != NULL) *out = req; return 1; error: http_free(req); return 0; } void http_cancel(struct http_req *req) { if (req->parsing) req->cancel = 1; else http_free(req); } btpd-0.16/misc/queue.h0000644000175000001440000001126711417473677011566 00000000000000/* * @(#)queue.h 8.5 (Berkeley) 8/20/94 * $FreeBSD: src/sys/sys/queue.h,v 1.58.2.1 2005/01/31 23:26:57 imp Exp $ */ #ifndef BTPD_QUEUE_H #define BTPD_QUEUE_H /* * Tail queue declarations. */ #define BTPDQ_HEAD(name, type) \ struct name { \ struct type *tqh_first; /* first element */ \ struct type **tqh_last; /* addr of last next element */ \ } #define BTPDQ_HEAD_INITIALIZER(head) \ { NULL, &(head).tqh_first } #define BTPDQ_ENTRY(type) \ struct { \ struct type *tqe_next; /* next element */ \ struct type **tqe_prev; /* address of previous next element */ \ } #define BTPDQ_EMPTY(head) ((head)->tqh_first == NULL) #define BTPDQ_FIRST(head) ((head)->tqh_first) #define BTPDQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) #define BTPDQ_NEXT(elm, field) ((elm)->field.tqe_next) #define BTPDQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) #define BTPDQ_FOREACH(var, head, field) \ for ((var) = BTPDQ_FIRST((head)); \ (var); \ (var) = BTPDQ_NEXT((var), field)) #define BTPDQ_FOREACH_MUTABLE(var, head, field, nvar) \ for ((var) = BTPDQ_FIRST((head)); \ (var) && ((nvar) = BTPDQ_NEXT((var), field), (var)); \ (var) = (nvar)) #define BTPDQ_INIT(head) do { \ BTPDQ_FIRST((head)) = NULL; \ (head)->tqh_last = &BTPDQ_FIRST((head)); \ } while (0) #define BTPDQ_INSERT_AFTER(head, listelm, elm, field) do { \ if ((BTPDQ_NEXT((elm), field) = BTPDQ_NEXT((listelm), field)) != NULL)\ BTPDQ_NEXT((elm), field)->field.tqe_prev = \ &BTPDQ_NEXT((elm), field); \ else { \ (head)->tqh_last = &BTPDQ_NEXT((elm), field); \ } \ BTPDQ_NEXT((listelm), field) = (elm); \ (elm)->field.tqe_prev = &BTPDQ_NEXT((listelm), field); \ } while (0) #define BTPDQ_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ BTPDQ_NEXT((elm), field) = (listelm); \ *(listelm)->field.tqe_prev = (elm); \ (listelm)->field.tqe_prev = &BTPDQ_NEXT((elm), field); \ } while (0) #define BTPDQ_INSERT_HEAD(head, elm, field) do { \ if ((BTPDQ_NEXT((elm), field) = BTPDQ_FIRST((head))) != NULL) \ BTPDQ_FIRST((head))->field.tqe_prev = \ &BTPDQ_NEXT((elm), field); \ else \ (head)->tqh_last = &BTPDQ_NEXT((elm), field); \ BTPDQ_FIRST((head)) = (elm); \ (elm)->field.tqe_prev = &BTPDQ_FIRST((head)); \ } while (0) #define BTPDQ_INSERT_TAIL(head, elm, field) do { \ BTPDQ_NEXT((elm), field) = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ *(head)->tqh_last = (elm); \ (head)->tqh_last = &BTPDQ_NEXT((elm), field); \ } while (0) #define BTPDQ_REMOVE(head, elm, field) do { \ if ((BTPDQ_NEXT((elm), field)) != NULL) \ BTPDQ_NEXT((elm), field)->field.tqe_prev = \ (elm)->field.tqe_prev; \ else { \ (head)->tqh_last = (elm)->field.tqe_prev; \ } \ *(elm)->field.tqe_prev = BTPDQ_NEXT((elm), field); \ } while (0) #endif btpd-0.16/misc/subr.c0000644000175000001440000002201211417473677011376 00000000000000#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "subr.h" void * memfind(const void *sub, size_t sublen, const void *mem, size_t memlen) { size_t i, j; const uint8_t *s = sub, *m = mem; for (i = 0; i < memlen - sublen + 1; i++) { for (j = 0; j < sublen; j++) if (m[i+j] != s[j]) break; if (j == sublen) return (void *)(m + i); } return NULL; } void enc_be32(void *buf, uint32_t num) { uint8_t *p = buf; *p = (num >> 24) & 0xff; *(p + 1) = (num >> 16) & 0xff; *(p + 2) = (num >> 8) & 0xff; *(p + 3) = num & 0xff; } uint32_t dec_be32(const void *buf) { const uint8_t *p = buf; return (uint32_t)*p << 24 | (uint32_t)*(p + 1) << 16 | (uint16_t)*(p + 2) << 8 | *(p + 3); } void enc_be64(void *buf, uint64_t num) { uint8_t *p = buf; *p = (num >> 56) & 0xff; *(p + 1) = (num >> 48) & 0xff; *(p + 2) = (num >> 40) & 0xff; *(p + 3) = (num >> 32) & 0xff; *(p + 4) = (num >> 24) & 0xff; *(p + 5) = (num >> 16) & 0xff; *(p + 6) = (num >> 8) & 0xff; *(p + 7) = num & 0xff; } uint64_t dec_be64(const void *buf) { const uint8_t *p = buf; return (uint64_t)*p << 56 | (uint64_t)*(p + 1) << 48 | (uint64_t)*(p + 2) << 40 | (uint64_t)*(p + 3) << 32 | (uint64_t)*(p + 4) << 24 | (uint64_t)*(p + 5) << 16 | (uint64_t)*(p + 6) << 8 | (uint64_t)*(p + 7); } void set_bit(uint8_t *bits, unsigned long index) { bits[index / 8] |= (1 << (7 - index % 8)); } void clear_bit(uint8_t *bits, unsigned long index) { bits[index / 8] &= ~(1 << (7 - index % 8)); } int has_bit(const uint8_t *bits, unsigned long index) { return bits[index / 8] & (1 << (7 - index % 8)); } uint8_t hex2i(char c) { if (c >= '0' && c <= '9') return c - '0'; else if (c >= 'a' && c <= 'f') return 10 + c - 'a'; else abort(); } int ishex(char *str) { while (*str != '\0') { if (!((*str >= '0' && *str <= '9') || (*str >= 'a' && *str <= 'f'))) return 0; str++; } return 1; } uint8_t * hex2bin(const char *hex, uint8_t *bin, size_t bsize) { for (size_t i = 0; i < bsize; i++) bin[i] = hex2i(hex[i * 2]) << 4 | hex2i(hex[i * 2 + 1]); return bin; } char * bin2hex(const uint8_t *bin, char *hex, size_t bsize) { size_t i; const char *hexc = "0123456789abcdef"; for (i = 0; i < bsize; i++) { hex[i * 2] = hexc[(bin[i] >> 4) & 0xf]; hex[i * 2 + 1] = hexc[bin[i] &0xf]; } hex[i * 2] = '\0'; return hex; } int set_nonblocking(int fd) { int oflags; if ((oflags = fcntl(fd, F_GETFL, 0)) == -1) return errno; if (fcntl(fd, F_SETFL, oflags | O_NONBLOCK) == -1) return errno; return 0; } int set_blocking(int fd) { int oflags; if ((oflags = fcntl(fd, F_GETFL, 0)) == -1) return errno; if (fcntl(fd, F_SETFL, oflags & ~O_NONBLOCK) == -1) return errno; return 0; } int mkdirs(char *path, int mode) { int err = 0; char *spos = strchr(path + 1, '/'); // Skip leading '/' while (spos != NULL) { *spos = '\0'; err = mkdir(path, mode); *spos = '/'; if (err != 0 && errno != EEXIST) return errno; spos = strchr(spos + 1, '/'); } if (mkdir(path, mode) != 0) return errno; return 0; } int vaopen(int *res, int flags, const char *fmt, va_list ap) { int fd, didmkdirs; char path[PATH_MAX + 1]; if (vsnprintf(path, PATH_MAX, fmt, ap) >= PATH_MAX) return ENAMETOOLONG; didmkdirs = 0; again: fd = open(path, flags, 0666); if (fd < 0 && errno == ENOENT && (flags & O_CREAT) != 0 && !didmkdirs) { char *rs = rindex(path, '/'); if (rs != NULL) { *rs = '\0'; if (mkdirs(path, 0777) == 0) { *rs = '/'; didmkdirs = 1; goto again; } } return errno; } if (fd >= 0) { *res = fd; return 0; } else return errno; } int vopen(int *res, int flags, const char *fmt, ...) { int err; va_list ap; va_start(ap, fmt); err = vaopen(res, flags, fmt, ap); va_end(ap); return err; } int vfsync(const char *fmt, ...) { int err, fd; va_list ap; va_start(ap, fmt); err = vaopen(&fd, O_RDONLY, fmt, ap); va_end(ap); if (err != 0) return err; if (fsync(fd) < 0) err = errno; close(fd); return err; } int vfopen(FILE **ret, const char *mode, const char *fmt, ...) { int err = 0; char path[PATH_MAX + 1]; va_list ap; va_start(ap, fmt); if (vsnprintf(path, PATH_MAX, fmt, ap) >= PATH_MAX) err = ENAMETOOLONG; va_end(ap); if (err == 0) if ((*ret = fopen(path, mode)) == NULL) err = errno; return err; } long rand_between(long min, long max) { return min + (long)rint((double)random() * (max - min) / RAND_MAX); } int write_fully(int fd, const void *buf, size_t len) { ssize_t nw; size_t off = 0; while (off < len) { nw = write(fd, buf + off, len - off); if (nw == -1) return errno; off += nw; } return 0; } int read_fully(int fd, void *buf, size_t len) { ssize_t nread; size_t off = 0; while (off < len) { nread = read(fd, buf + off, len - off); if (nread == 0) return EIO; else if (nread == -1) return errno; off += nread; } return 0; } void * read_file(const char *path, void *buf, size_t *size) { int fd, esave; void *mem = NULL; struct stat sb; if ((fd = open(path, O_RDONLY)) == -1) return NULL; if (fstat(fd, &sb) == -1) goto error; if (*size != 0 && *size < sb.st_size) { errno = EFBIG; goto error; } *size = sb.st_size; if (buf == NULL && (mem = malloc(sb.st_size)) == NULL) goto error; if (buf == NULL) buf = mem; if ((errno = read_fully(fd, buf, *size)) != 0) goto error; close(fd); return buf; error: esave = errno; if (mem != NULL) free(mem); close(fd); errno = esave; return NULL; } char * find_btpd_dir(void) { char *res = getenv("BTPD_HOME"); if (res != NULL) return strdup(res); char *home = getenv("HOME"); if (home == NULL) { struct passwd *pwent = getpwuid(getuid()); endpwent(); if (pwent != NULL) home = pwent->pw_dir; } if (home != NULL) asprintf(&res, "%s/.btpd", home); return res; } int make_abs_path(const char *in, char *out) { int ii = 0, oi = 0, lastsep = 0; switch (in[0]) { case '\0': return EINVAL; case '/': if (strlen(in) >= PATH_MAX) return ENAMETOOLONG; out[0] = '/'; oi++; ii++; break; default: if (getcwd(out, PATH_MAX) == NULL) return errno; oi = strlen(out); if (oi + strlen(in) + 1 >= PATH_MAX) return ENAMETOOLONG; out[oi] = '/'; lastsep = oi; oi++; break; } after_slash: while (in[ii] == '/') ii++; switch(in[ii]) { case '\0': goto end; case '.': ii++; goto one_dot; default: goto normal; } one_dot: switch (in[ii]) { case '\0': goto end; case '/': ii++; goto after_slash; case '.': ii++; goto two_dot; default: out[oi] = '.'; oi++; goto normal; } two_dot: switch (in[ii]) { case '\0': if (lastsep == 0) oi = 1; else { oi = lastsep; while (out[oi - 1] != '/') oi--; lastsep = oi - 1; } goto end; case '/': if (lastsep == 0) oi = 1; else { oi = lastsep; while (out[oi - 1] != '/') oi--; lastsep = oi - 1; } ii++; goto after_slash; default: out[oi] = '.'; out[oi + 1] = '.'; oi += 2; goto normal; } normal: switch (in[ii]) { case '\0': goto end; case '/': out[oi] = '/'; lastsep = oi; oi++; ii++; goto after_slash; default: out[oi] = in[ii]; oi++; ii++; goto normal; } end: if (oi == lastsep + 1 && lastsep != 0) oi = lastsep; out[oi] = '\0'; return 0; } #ifndef HAVE_ASPRINTF int asprintf(char **strp, const char *fmt, ...) { int np; va_list ap; va_start(ap, fmt); np = vsnprintf(NULL, 0, fmt, ap); va_end(ap); if ((*strp = malloc(np + 1)) == NULL) return -1; va_start(ap, fmt); vsnprintf(*strp, np + 1, fmt, ap); va_end(ap); return np; } #endif btpd-0.16/misc/hashtable.c0000644000175000001440000001102511417473677012360 00000000000000#include #include #include "hashtable.h" struct _htbl { int (*eq)(const void *, const void *); uint32_t (*hash)(const void *); struct _any **buckets; size_t buckcnt; size_t size; size_t keyoff; size_t chainoff; float ratio; }; #define KEYP(tbl, o) ((void *)(o) + (tbl)->keyoff) #define CHAINP(tbl, o) *(struct _any **)((void *)(o) + (tbl)->chainoff) struct _htbl * _htbl_create(float ratio, int (*eq)(const void *, const void *), uint32_t (*hash)(const void *), size_t keyoff, size_t chainoff) { struct _htbl *tbl = calloc(1, sizeof(*tbl)); if (tbl == NULL) return NULL; tbl->size = 0; tbl->buckcnt = 1; tbl->ratio = ratio; tbl->keyoff = keyoff; tbl->chainoff = chainoff; tbl->hash = hash; tbl->eq = eq; tbl->buckets = calloc(tbl->buckcnt, sizeof(*tbl->buckets)); if (tbl->buckets == NULL) { free(tbl); return NULL; } return tbl; } void _htbl_free(struct _htbl *tbl) { free(tbl->buckets); free(tbl); } static struct _any * bucket_rev(struct _htbl *tbl, struct _any *p, struct _any *n) { while (n != NULL) { struct _any *s = CHAINP(tbl, n); CHAINP(tbl, n) = p; p = n; n = s; } return p; } static void bucket_insert(struct _htbl *tbl, struct _any *o) { size_t bi = tbl->hash(KEYP(tbl, o)) % tbl->buckcnt; CHAINP(tbl, o) = tbl->buckets[bi]; tbl->buckets[bi] = o; } static void _htbl_grow(struct _htbl *tbl) { size_t ncnt = 2 * tbl->buckcnt + 1; size_t ocnt = tbl->buckcnt; struct _any **obuckets = tbl->buckets; struct _any **nbuckets = calloc(ncnt, sizeof(*nbuckets)); if (nbuckets == NULL) return; tbl->buckcnt = ncnt; tbl->buckets = nbuckets; for (size_t i = 0; i < ocnt; i++) { struct _any *o = bucket_rev(tbl, NULL, obuckets[i]); while (o != NULL) { struct _any *s = CHAINP(tbl, o); bucket_insert(tbl, o); o = s; } } free(obuckets); } void _htbl_insert(struct _htbl *tbl, struct _any *o) { bucket_insert(tbl, o); tbl->size++; if (tbl->size > tbl->buckcnt * tbl->ratio) _htbl_grow(tbl); } struct _any * _htbl_find(struct _htbl *tbl, const void *key) { struct _any *ret; size_t bi = tbl->hash(key) % tbl->buckcnt; for (ret = tbl->buckets[bi]; ret != NULL; ret = CHAINP(tbl, ret)) if (tbl->eq(KEYP(tbl, ret), key)) return ret; return NULL; } struct _any * _htbl_remove(struct _htbl *tbl, const void *key) { size_t bi = tbl->hash(key) % tbl->buckcnt; struct _any **p = &tbl->buckets[bi], *o = tbl->buckets[bi]; while (o != NULL && !tbl->eq(KEYP(tbl, o), key)) { p = &CHAINP(tbl, o); o = *p; } if (o != NULL) { *p = CHAINP(tbl, o); tbl->size--; } return o; } void _htbl_fillv(struct _htbl *tbl, struct _any **v) { size_t vi = 0; size_t bi = 0; struct _any *o = tbl->buckets[bi]; while (vi < tbl->size) { while (o == NULL) { bi++; o = tbl->buckets[bi]; } v[vi] = o; vi++; o = CHAINP(tbl, o); } } struct _any ** _htbl_tov(struct _htbl *tbl) { struct _any **v = malloc(sizeof(*v)); if (v != NULL) _htbl_fillv(tbl, v); return v; } size_t _htbl_size(struct _htbl *tbl) { return tbl->size; } static void iter_next_bucket(struct htbl_iter *it) { while (it->tbl->buckets[it->bi] == NULL) it->bi++; it->obj = it->tbl->buckets[it->bi]; it->ptr = &it->tbl->buckets[it->bi]; } struct _any * _htbl_iter_first(struct _htbl *tbl, struct htbl_iter *it) { if (tbl->size == 0) return NULL; it->tbl = tbl; it->cnt = 1; it->bi = 0; iter_next_bucket(it); return it->obj; } struct _any * _htbl_iter_next(struct htbl_iter *it) { struct _any *tmp; if (it->cnt == it->tbl->size) return NULL; it->cnt++; if ((tmp = CHAINP(it->tbl, it->obj)) != NULL) { it->ptr = &CHAINP(it->tbl, it->obj); it->obj = tmp; } else { it->bi++; iter_next_bucket(it); } return it->obj; } #include struct _any * _htbl_iter_del(struct htbl_iter *it) { struct _any *tmp; it->tbl->size--; if (it->cnt > it->tbl->size) { *it->ptr = NULL; return NULL; } if ((tmp = CHAINP(it->tbl, it->obj)) != NULL) { *it->ptr = tmp; it->obj = tmp; } else { *it->ptr = NULL; it->bi++; iter_next_bucket(it); } return it->obj; } btpd-0.16/misc/benc.h0000644000175000001440000000237411417473677011350 00000000000000#ifndef BTPD_BENC_H #define BTPD_BENC_H enum be_type { BE_ANY, BE_DCT, BE_INT, BE_LST, BE_STR }; int benc_validate(const char *p, size_t len); int benc_dct_chk(const char *p, int count, ...); int benc_islst(const char *p); int benc_isdct(const char *p); int benc_isint(const char *p); int benc_isstr(const char *p); int benc_strcmp(const char *str1, const char *str2); size_t benc_strlen(const char *p); size_t benc_length(const char *p); size_t benc_nelems(const char *p); const char *benc_first(const char *p); const char *benc_next(const char *p); long long benc_int(const char *p, const char **next); const char *benc_mem(const char *p, size_t *len, const char **next); char *benc_mema(const char *p, size_t *len, const char **next); char *benc_str(const char *p, size_t *len, const char **next); const char *benc_dget_any(const char *p, const char *key); const char *benc_dget_lst(const char *p, const char *key); const char *benc_dget_dct(const char *p, const char *key); long long benc_dget_int(const char *p, const char *key); const char *benc_dget_mem(const char *p, const char *key, size_t *len); char *benc_dget_mema(const char *p, const char *key, size_t *len); char *benc_dget_str(const char *p, const char *key, size_t *len); #endif btpd-0.16/misc/subr.h0000644000175000001440000000307711417473677011415 00000000000000#ifndef BTPD_SUBR_H #define BTPD_SUBR_H #include #include #include #define max(x, y) ((x) >= (y) ? (x) : (y)) #define min(x, y) ((x) <= (y) ? (x) : (y)) #define SHAHEXSIZE 41 void *memfind(const void *sub, size_t sublen, const void *mem, size_t memlen); uint32_t dec_be32(const void *buf); uint64_t dec_be64(const void *buf); void enc_be32(void *buf, uint32_t num); void enc_be64(void *buf, uint64_t num); int set_nonblocking(int fd); int set_blocking(int fd); int mkdirs(char *path, int mode); __attribute__((format (printf, 3, 0))) int vaopen(int *resfd, int flags, const char *fmt, va_list ap); __attribute__((format (printf, 3, 4))) int vopen(int *resfd, int flags, const char *fmt, ...); __attribute__((format (printf, 3, 4))) int vfopen(FILE **ret, const char *mode, const char *fmt, ...); int vfsync(const char *fmt, ...); void set_bit(uint8_t *bits, unsigned long index); int has_bit(const uint8_t *bits, unsigned long index); void clear_bit(uint8_t *bits, unsigned long index); char *bin2hex(const uint8_t *bin, char *hex, size_t bsize); uint8_t *hex2bin(const char *hex, uint8_t *bin, size_t bsize); uint8_t hex2i(char c); int ishex(char *str); long rand_between(long min, long max); int read_fully(int fd, void *buf, size_t len); int write_fully(int fd, const void *buf, size_t len); void *read_file(const char *path, void *buf, size_t *size); char *find_btpd_dir(void); int make_abs_path(const char *in, char *out); #ifndef HAVE_ASPRINTF __attribute__((format (printf, 2, 3))) int asprintf(char **strp, const char *fmt, ...); #endif #endif btpd-0.16/misc/http_client.h0000644000175000001440000000200411417473677012744 00000000000000#ifndef BTPD_HTTP_CLIENT_H #define BTPD_HTTP_CLIENT_H struct http_url { char *host; char *uri; uint16_t port; }; struct http_url *http_url_parse(const char *url); void http_url_free(struct http_url *url); struct http_response { enum { HTTP_T_ERR, HTTP_T_CODE, HTTP_T_HEADER, HTTP_T_DATA, HTTP_T_DONE } type; union { int error; int code; struct { char *n; char *v; } header; struct { size_t l; char *p; } data; } v; }; struct http_req; typedef void (*http_cb_t)(struct http_req *, struct http_response *, void *); int http_get(struct http_req **out, const char *url, const char *hdrs, http_cb_t cb, void *arg); void http_cancel(struct http_req *req); struct http_url *http_url_get(struct http_req *req); int http_want_read(struct http_req *req); int http_want_write(struct http_req *req); int http_read(struct http_req *req, int sd); int http_write(struct http_req *req, int sd); #endif btpd-0.16/misc/metainfo.h0000644000175000001440000000145411417473677012241 00000000000000#ifndef BTPD_METAINFO_H #define BTPD_METAINFO_H struct mi_file { char *path; off_t length; }; struct mi_tier { int nurls; char **urls; }; struct mi_announce { int ntiers; struct mi_tier *tiers; }; char *mi_name(const char *p); uint8_t *mi_info_hash(const char *p, uint8_t *hash); uint8_t *mi_hashes(const char *p); int mi_simple(const char *p); size_t mi_npieces(const char *p); off_t mi_total_length(const char *p); off_t mi_piece_length(const char *p); struct mi_announce *mi_announce(const char *p); void mi_free_announce(struct mi_announce *ann); size_t mi_nfiles(const char *p); struct mi_file *mi_files(const char *p); void mi_free_files(unsigned nfiles, struct mi_file *files); int mi_test(const char *p, size_t size); char *mi_load(const char *path, size_t *size); #endif btpd-0.16/misc/stream.c0000644000175000001440000001027211417473677011723 00000000000000#include #include #include #include #include #include #include #include "metainfo.h" #include "subr.h" #include "stream.h" int bts_open(struct bt_stream **res, unsigned nfiles, struct mi_file *files, fdcb_t fd_cb, void *fd_arg) { struct bt_stream *bts = calloc(1, sizeof(*bts)); if (bts == NULL) return ENOMEM; bts->nfiles = nfiles; bts->files = files; bts->fd_cb = fd_cb; bts->fd_arg = fd_arg; bts->fd = -1; for (unsigned i = 0; i < bts->nfiles; i++) bts->totlen += bts->files[i].length; *res = bts; return 0; } int bts_close(struct bt_stream *bts) { int err = 0; if (bts->fd != -1 && close(bts->fd) == -1) err = errno; free(bts); return err; } int bts_seek(struct bt_stream *bts, off_t off) { if (bts->t_off == off) return 0; bts->t_off = off; unsigned i; for (i = 0; off >= bts->files[i].length; i++) off -= bts->files[i].length; if (i != bts->index) { if (bts->fd != -1) { if (close(bts->fd) == -1) return errno; bts->fd = -1; } } else if (bts->fd != -1) lseek(bts->fd, off, SEEK_SET); bts->index = i; bts->f_off = off; return 0; } int bts_get(struct bt_stream *bts, off_t off, uint8_t *buf, size_t len) { size_t boff, wantread; ssize_t didread; int err; assert(off + len <= bts->totlen); if ((err = bts_seek(bts, off)) != 0) return err; boff = 0; while (boff < len) { if (bts->fd == -1) { while (bts->files[bts->index].length == 0) bts->index++; err = bts->fd_cb(bts->files[bts->index].path, &bts->fd, bts->fd_arg); if (err != 0) return err; if (bts->f_off != 0) lseek(bts->fd, bts->f_off, SEEK_SET); } wantread = min(len - boff, bts->files[bts->index].length - bts->f_off); didread = read(bts->fd, buf + boff, wantread); if (didread == -1) return errno; boff += didread; bts->f_off += didread; bts->t_off += didread; if (bts->f_off == bts->files[bts->index].length) { close(bts->fd); bts->fd = -1; bts->f_off = 0; bts->index++; } if (didread != wantread) return ENOENT; } return 0; } int bts_put(struct bt_stream *bts, off_t off, const uint8_t *buf, size_t len) { size_t boff, wantwrite; ssize_t didwrite; int err; assert(off + len <= bts->totlen); if ((err = bts_seek(bts, off)) != 0) return err; boff = 0; while (boff < len) { if (bts->fd == -1) { while (bts->files[bts->index].length == 0) bts->index++; err = bts->fd_cb(bts->files[bts->index].path, &bts->fd, bts->fd_arg); if (err != 0) return err; if (bts->f_off != 0) lseek(bts->fd, bts->f_off, SEEK_SET); } wantwrite = min(len - boff, bts->files[bts->index].length - bts->f_off); didwrite = write(bts->fd, buf + boff, wantwrite); if (didwrite == -1) return errno; boff += didwrite; bts->f_off += didwrite; bts->t_off += didwrite; if (bts->f_off == bts->files[bts->index].length) { if (close(bts->fd) == -1) return errno; bts->fd = -1; bts->f_off = 0; bts->index++; } } return 0; } #define SHAFILEBUF (1 << 15) int bts_sha(struct bt_stream *bts, off_t start, off_t length, uint8_t *hash) { SHA_CTX ctx; char buf[SHAFILEBUF]; size_t wantread; int err = 0; SHA1_Init(&ctx); while (length > 0) { wantread = min(length, SHAFILEBUF); if ((err = bts_get(bts, start, buf, wantread)) != 0) break; length -= wantread; start += wantread; SHA1_Update(&ctx, buf, wantread); } SHA1_Final(hash, &ctx); return err; } const char * bts_filename(struct bt_stream *bts) { return bts->files[bts->index].path; } btpd-0.16/misc/iobuf.h0000644000175000001440000000116611417473677011543 00000000000000#ifndef BTPD_IOBUF_H #define BTPD_IOBUF_H struct iobuf { uint8_t *buf; size_t size; size_t off; size_t skip; int error; }; struct iobuf iobuf_init(size_t size); void iobuf_free(struct iobuf *iob); int iobuf_accommodate(struct iobuf *iob, size_t size); int iobuf_write(struct iobuf *iob, const void *data, size_t size); __attribute__((format (printf, 2, 3))) int iobuf_print(struct iobuf *iob, const char *fmt, ...); void *iobuf_find(struct iobuf *iob, const void *p, size_t plen); void iobuf_consumed(struct iobuf *iob, size_t count); #define iobuf_swrite(iob, s) iobuf_write(iob, s, sizeof(s) - 1) #endif btpd-0.16/misc/btpd_if.c0000644000175000001440000001667611423447207012040 00000000000000#include #include #include #include #include #include #include #include #include #include #include #include "benc.h" #include "btpd_if.h" #include "iobuf.h" #include "subr.h" struct ipc { int sd; }; static const char *errmsgs[] = { #define ERRDEF(name, msg) msg, #include "ipcdefs.h" #undef ERRDEF NULL }; static const char *tval_names[] = { #define TVDEF(val, type, name) name, #include "ipcdefs.h" #undef TVDEF NULL }; const char * ipc_strerror(enum ipc_err err) { if (err < 0 || err >= IPC_ERRCOUNT) return "unknown error"; return errmsgs[err]; } const char * tval_name(enum ipc_tval key) { if (key < 0 || key >= IPC_TVALCOUNT) return "unknown key"; return tval_names[key]; } int ipc_open(const char *dir, struct ipc **out) { int sd = -1, err = 0; size_t plen; struct ipc *res; struct sockaddr_un addr; plen = sizeof(addr.sun_path); if (snprintf(addr.sun_path, plen, "%s/sock", dir) >= plen) return ENAMETOOLONG; addr.sun_family = AF_UNIX; if ((sd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) return errno; if (connect(sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { err = errno; close(sd); return err; } if ((res = malloc(sizeof(*res))) == NULL) { close(sd); return ENOMEM; } res->sd = sd; *out = res; return 0; } void ipc_close(struct ipc *ipc) { close(ipc->sd); free(ipc); } static enum ipc_err ipc_response(struct ipc *ipc, char **out, uint32_t *len) { uint32_t size; char *buf; if (read_fully(ipc->sd, &size, sizeof(size)) != 0) return IPC_COMMERR; if (size == 0) return IPC_COMMERR; if ((buf = malloc(size)) == NULL) return IPC_COMMERR; if (read_fully(ipc->sd, buf, size) != 0) { free(buf); return IPC_COMMERR; } *out = buf; *len = size; return IPC_OK; } static enum ipc_err ipc_req_res(struct ipc *ipc, const char *req, uint32_t qlen, char **res, uint32_t *rlen) { if (write_fully(ipc->sd, &qlen, sizeof(qlen)) != 0) return IPC_COMMERR; if (write_fully(ipc->sd, req, qlen) != 0) return IPC_COMMERR; if (ipc_response(ipc, res, rlen) != 0) return IPC_COMMERR; if (benc_validate(*res, *rlen) != 0) return IPC_COMMERR; if (!benc_isdct(*res)) return IPC_COMMERR; return IPC_OK; } static enum ipc_err ipc_buf_req_res(struct ipc *ipc, struct iobuf *iob, char **res, uint32_t *rlen) { enum ipc_err err; if (iob->error) err = IPC_COMMERR; else err = ipc_req_res(ipc, iob->buf, iob->off, res, rlen); iobuf_free(iob); return err; } static enum ipc_err ipc_buf_req_code(struct ipc *ipc, struct iobuf *iob) { enum ipc_err err; char *res; uint32_t rlen; if ((err = ipc_buf_req_res(ipc, iob, &res, &rlen)) == 0) { err = benc_dget_int(res, "code"); free(res); } return err; } enum ipc_err btpd_die(struct ipc *ipc) { struct iobuf iob = iobuf_init(16); iobuf_swrite(&iob, "l3:diee"); return ipc_buf_req_code(ipc, &iob); } static enum ipc_err tget_common(char *ans, enum ipc_tval *keys, size_t nkeys, tget_cb_t cb, void *arg) { int err; const char *res; struct ipc_get_res cbres[IPC_TVALCOUNT]; if ((err = benc_dget_int(ans, "code")) != 0) return err; res = benc_dget_lst(ans, "result"); int obji = 0; for (res = benc_first(res); res != NULL; res = benc_next(res)) { if (benc_isint(res)) { cb(obji, benc_int(res, NULL), NULL, arg); obji++; continue; } const char *t = benc_first(res); const char *v = benc_next(t); for (int j = 0; j < nkeys; j++) { cbres[keys[j]].type = benc_int(t, NULL); switch (cbres[keys[j]].type) { case IPC_TYPE_ERR: case IPC_TYPE_NUM: cbres[keys[j]].v.num = benc_int(v, NULL); break; case IPC_TYPE_STR: case IPC_TYPE_BIN: cbres[keys[j]].v.str.p= benc_mem(v, &cbres[keys[j]].v.str.l, NULL); break; } t = benc_next(v); if (t != NULL) v = benc_next(t); } cb(obji, IPC_OK, cbres, arg); obji++; } free(ans); return IPC_OK; } enum ipc_err btpd_tget(struct ipc *ipc, struct ipc_torrent *tps, size_t ntps, enum ipc_tval *keys, size_t nkeys, tget_cb_t cb, void *arg) { char *res; uint32_t rlen; enum ipc_err err; struct iobuf iob; if (nkeys == 0 || ntps == 0) return IPC_COMMERR; iob = iobuf_init(1 << 14); iobuf_swrite(&iob, "l4:tgetd4:froml"); for (int i = 0; i < ntps; i++) { if (tps[i].by_hash) { iobuf_swrite(&iob, "20:"); iobuf_write(&iob, tps[i].u.hash, 20); } else iobuf_print(&iob, "i%ue", tps[i].u.num); } iobuf_swrite(&iob, "e4:keysl"); for (int k = 0; k < nkeys; k++) iobuf_print(&iob, "i%de", keys[k]); iobuf_swrite(&iob, "eee"); if ((err = ipc_buf_req_res(ipc, &iob, &res, &rlen)) == 0) err = tget_common(res, keys, nkeys, cb, arg); return err; } enum ipc_err btpd_tget_wc(struct ipc *ipc, enum ipc_twc twc, enum ipc_tval *keys, size_t nkeys, tget_cb_t cb, void *arg) { char *res; uint32_t rlen; struct iobuf iob; enum ipc_err err; if (nkeys == 0) return IPC_COMMERR; iob = iobuf_init(1 << 14); iobuf_print(&iob, "l4:tgetd4:fromi%de4:keysl", twc); for (int i = 0; i < nkeys; i++) iobuf_print(&iob, "i%de", keys[i]); iobuf_swrite(&iob, "eee"); if ((err = ipc_buf_req_res(ipc, &iob, &res, &rlen)) == 0) err = tget_common(res, keys, nkeys, cb, arg); return err; } enum ipc_err btpd_add(struct ipc *ipc, const char *mi, size_t mi_size, const char *content, const char *name) { struct iobuf iob = iobuf_init(1 << 10); iobuf_print(&iob, "l3:addd7:content%d:%s", (int)strlen(content), content); if (name != NULL) iobuf_print(&iob, "4:name%d:%s", (int)strlen(name), name); iobuf_print(&iob, "7:torrent%lu:", (unsigned long)mi_size); iobuf_write(&iob, mi, mi_size); iobuf_swrite(&iob, "ee"); return ipc_buf_req_code(ipc, &iob); } static enum ipc_err simple_treq(struct ipc *ipc, char *cmd, struct ipc_torrent *tp) { struct iobuf iob = iobuf_init(32); if (tp->by_hash) { iobuf_print(&iob, "l%d:%s20:", (int)strlen(cmd), cmd); iobuf_write(&iob, tp->u.hash, 20); iobuf_swrite(&iob, "e"); } else iobuf_print(&iob, "l%d:%si%uee", (int)strlen(cmd), cmd, tp->u.num); return ipc_buf_req_code(ipc, &iob); } enum ipc_err btpd_del(struct ipc *ipc, struct ipc_torrent *tp) { return simple_treq(ipc, "del", tp); } enum ipc_err btpd_start(struct ipc *ipc, struct ipc_torrent *tp) { return simple_treq(ipc, "start", tp); } enum ipc_err btpd_start_all(struct ipc *ipc) { struct iobuf iob = iobuf_init(16); iobuf_swrite(&iob, "l9:start-alle"); return ipc_buf_req_code(ipc, &iob); } enum ipc_err btpd_stop(struct ipc *ipc, struct ipc_torrent *tp) { return simple_treq(ipc, "stop", tp); } enum ipc_err btpd_stop_all(struct ipc *ipc) { struct iobuf iob = iobuf_init(16); iobuf_swrite(&iob, "l8:stop-alle"); return ipc_buf_req_code(ipc, &iob); } btpd-0.16/missing0000755000175000001440000002623311426157640010721 00000000000000#! /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: btpd-0.16/configure0000755000175000001440000053343111426157641011235 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.66 for btpd 0.16. # # 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. 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 \$(( 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. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$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 $0: btpd-users@googlegroups.com about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do 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'" 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='btpd' PACKAGE_TARNAME='btpd' PACKAGE_VERSION='0.16' PACKAGE_STRING='btpd 0.16' PACKAGE_BUGREPORT='btpd-users@googlegroups.com' 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 TD_LIBS TD_CFLAGS EVLOOP_METHOD EVLOOP_IMPL WARNNPS CLOCKLIB INETLIBS openssl_CPPFLAGS openssl_LDFLAGS EGREP GREP CPP RANLIB am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC 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 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 enable_dependency_tracking with_openssl with_evloop_method ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # 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=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 btpd 0.16 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/btpd] --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 _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of btpd 0.16:";; 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] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-openssl=dir use openssl installed in dir --with-evloop-method select evloop method (epoll,poll,kqueue) 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 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 btpd configure 0.16 generated by GNU Autoconf 2.66 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_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; } >/dev/null && { 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; 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.$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 btpd-users@googlegroups.com ## ## ------------------------------------------ ##" ) | 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 "test \"\${$3+set}\"" = set; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_mongrel # 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run # 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 "test \"\${$3+set}\"" = set; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link # 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 "test \"\${$3+set}\"" = set; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func 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 btpd $as_me 0.16, which was generated by GNU Autoconf 2.66. 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 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 test "${ac_cv_path_install+set}" = set; 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 test "${ac_cv_prog_STRIP+set}" = set; 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 test "${ac_cv_prog_ac_ct_STRIP+set}" = set; 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 test "${ac_cv_path_mkdir+set}" = set; 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 test "${ac_cv_prog_AWK+set}" = set; 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 "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; 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='btpd' VERSION='0.16' 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. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_files="$ac_config_files Makefile" 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 test "${ac_cv_prog_CC+set}" = set; 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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 test "${ac_cv_prog_CC+set}" = set; 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 test "${ac_cv_prog_CC+set}" = set; 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 test "${ac_cv_prog_CC+set}" = set; 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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 test "${ac_cv_objext+set}" = set; 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 test "${ac_cv_c_compiler_gnu+set}" = set; 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 test "${ac_cv_prog_cc_g+set}" = set; 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 test "${ac_cv_prog_cc_c89+set}" = set; 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 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='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi 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 test "${am_cv_CC_dependencies_compiler_type+set}" = set; 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'. 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 ;; 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 if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval "test \"\${ac_cv_prog_cc_${ac_cc}_c_o+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { 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; } && test -f conftest2.$ac_objext && { { 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 eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&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_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { 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; } && test -f conftest2.$ac_objext && { { 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 # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; 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_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi 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 test "${ac_cv_prog_RANLIB+set}" = set; 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 test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; 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 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 test "${ac_cv_prog_CPP+set}" = set; 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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 grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; 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 test "${ac_cv_path_EGREP+set}" = set; 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 ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; 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 ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" if test "x$ac_cv_header_minix_config_h" = x""yes; then : MINIX=yes else MINIX= fi if test "$MINIX" = yes; then $as_echo "#define _POSIX_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h $as_echo "#define _MINIX 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_define___extensions__=yes else ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } test $ac_cv_safe_to_define___extensions__ = yes && $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h $as_echo "#define _ALL_SOURCE 1" >>confdefs.h $as_echo "#define _GNU_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h # Check whether --with-openssl was given. if test "${with_openssl+set}" = set; then : withval=$with_openssl; openssl_LDFLAGS="-L${withval}/lib -Wl,-R,${withval}/lib" openssl_CPPFLAGS="-I${withval}/include" fi # Check whether --with-evloop-method was given. if test "${with_evloop_method+set}" = set; then : withval=$with_evloop_method; evloop_methods=$withval else evloop_methods="epoll kqueue poll" fi old_LIBS=$LIBS LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_ntop" >&5 $as_echo_n "checking for library containing inet_ntop... " >&6; } if test "${ac_cv_search_inet_ntop+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 inet_ntop (); int main () { return inet_ntop (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_inet_ntop=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_inet_ntop+set}" = set; then : break fi done if test "${ac_cv_search_inet_ntop+set}" = set; then : else ac_cv_search_inet_ntop=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_ntop" >&5 $as_echo "$ac_cv_search_inet_ntop" >&6; } ac_res=$ac_cv_search_inet_ntop if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" 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 $? "btpd needs inet_ntop See \`config.log' for more details" "$LINENO" 5; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing bind" >&5 $as_echo_n "checking for library containing bind... " >&6; } if test "${ac_cv_search_bind+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 bind (); int main () { return bind (); ; return 0; } _ACEOF for ac_lib in '' socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_bind=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_bind+set}" = set; then : break fi done if test "${ac_cv_search_bind+set}" = set; then : else ac_cv_search_bind=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_bind" >&5 $as_echo "$ac_cv_search_bind" >&6; } ac_res=$ac_cv_search_bind if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" 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 $? "btpd needs bind See \`config.log' for more details" "$LINENO" 5; } fi INETLIBS=$LIBS LIBS=$old_LIBS for ac_func in asprintf do : ac_fn_c_check_func "$LINENO" "asprintf" "ac_cv_func_asprintf" if test "x$ac_cv_func_asprintf" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ASPRINTF 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CLOCK_MONOTONIC" >&5 $as_echo_n "checking for CLOCK_MONOTONIC... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { return clock_gettime(CLOCK_MONOTONIC, (void *)0); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : clock_gettime=yes else clock_gettime=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $clock_gettime" >&5 $as_echo "$clock_gettime" >&6; } if test $clock_gettime = yes; then old_LIBS=$LIBS LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 $as_echo_n "checking for library containing clock_gettime... " >&6; } if test "${ac_cv_search_clock_gettime+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF for ac_lib in '' rt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_clock_gettime+set}" = set; then : break fi done if test "${ac_cv_search_clock_gettime+set}" = set; then : else ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 $as_echo "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" clock_gettime=yes else clock_gettime=no fi CLOCKLIB=$LIBS LIBS=$old_LIBS $as_echo "#define HAVE_CLOCK_MONOTONIC 1" >>confdefs.h fi if test $clock_gettime = no; then for ac_func in mach_absolute_time do : ac_fn_c_check_func "$LINENO" "mach_absolute_time" "ac_cv_func_mach_absolute_time" if test "x$ac_cv_func_mach_absolute_time" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MACH_ABSOLUTE_TIME 1 _ACEOF 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 $? "no supported time mechanism found See \`config.log' for more details" "$LINENO" 5; } fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler accepts -Wno-pointer-sign" >&5 $as_echo_n "checking whether compiler accepts -Wno-pointer-sign... " >&6; } 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 foo(void) { return 12; } _ACEOF 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 ac_output=`$CC -Wno-pointer-sign -c conftest.c 2>&1` if test x"$ac_output" != x; then echo $CC -Wno-pointer-sign -c conftest.c nonsilent >&5 echo $ac_output >&5 rm -f conftest.c conftest.$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else rm -f conftest.c conftest.$OBJEXT WARNNPS="-Wno-pointer-sign" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi old_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $openssl_LDFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SHA1_Final in -lcrypto" >&5 $as_echo_n "checking for SHA1_Final in -lcrypto... " >&6; } if test "${ac_cv_lib_crypto_SHA1_Final+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $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 SHA1_Final (); int main () { return SHA1_Final (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypto_SHA1_Final=yes else ac_cv_lib_crypto_SHA1_Final=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_crypto_SHA1_Final" >&5 $as_echo "$ac_cv_lib_crypto_SHA1_Final" >&6; } if test "x$ac_cv_lib_crypto_SHA1_Final" = x""yes; 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 $? "btpd needs openssl's libraries and headers See \`config.log' for more details" "$LINENO" 5; } fi LDFLAGS=$old_LDFLAGS for m in $evloop_methods; do case $m in epoll) ac_fn_c_check_func "$LINENO" "epoll_wait" "ac_cv_func_epoll_wait" if test "x$ac_cv_func_epoll_wait" = x""yes; then : EVLOOP_IMPL="evloop/epoll.${OBJEXT}" EVLOOP_METHOD=EVLOOP_EPOLL break fi ;; kqueue) ac_fn_c_check_func "$LINENO" "kqueue" "ac_cv_func_kqueue" if test "x$ac_cv_func_kqueue" = x""yes; then : EVLOOP_IMPL="evloop/kqueue.${OBJEXT}" EVLOOP_METHOD=EVLOOP_KQUEUE break fi ;; poll) ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll" if test "x$ac_cv_func_poll" = x""yes; then : EVLOOP_IMPL="evloop/poll.${OBJEXT}" EVLOOP_METHOD=EVLOOP_POLL break fi break ;; *) as_fn_error $? "$m is not a valid evloop method" "$LINENO" 5 exit 1 ;; esac done if test x"$EVLOOP_METHOD" = x; 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 $? "no suitable evloop method found See \`config.log' for more details" "$LINENO" 5; } exit 1 else { $as_echo "$as_me:${as_lineno-$LINENO}: selected evloop method $EVLOOP_METHOD" >&5 $as_echo "$as_me: selected evloop method $EVLOOP_METHOD" >&6;} fi for i in 0 1 2 3 4 5 6 7; do case $i in 0) if test x"$TD_CFLAGS$TD_LIBS" = x; then continue; fi;; 1) TD_CFLAGS=-pthread;; 2) TD_CFLAGS=-pthreads;; 3) TD_CFLAGS=-kthread;; 4) TD_CFLAGS=-mt;; 5) TD_LIBS=-lpthread;; 6) ;; 7) { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "how do you build with pthreads on this system? See \`config.log' for more details" "$LINENO" 5; };; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads compiles with flags \"$TD_CFLAGS $TD_LIBS\"" >&5 $as_echo_n "checking whether pthreads compiles with flags \"$TD_CFLAGS $TD_LIBS\"... " >&6; } 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 foo(void) { return 12; } _ACEOF 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 ac_output=`$CC $TD_CFLAGS $CFLAGS $TD_LIBS $LIBS -c conftest.c 2>&1` if test x"$ac_output" != x; then echo $CC $TD_CFLAGS $CFLAGS $TD_LIBS $LIBS -c conftest.c nonsilent >&5 echo $ac_output >&5 rm -f conftest.c conftest.$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } TD_CFLAGS=""; TD_LIBS="" continue else rm -f conftest.c conftest.$OBJEXT fi old_CFLAGS=$CFLAGS; old_LIBS=$LIBS CFLAGS="$TD_CFLAGS $CFLAGS"; LIBS="$TD_LIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { return pthread_create(0,0,0,0);} _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS=$old_CFLAGS; LIBS=$old_LIBS break else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } TD_CFLAGS=""; TD_LIBS="" CFLAGS=$old_CFLAGS; LIBS=$old_LIBS fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done 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 test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file 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}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.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 : ${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. 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 btpd $as_me 0.16, which was generated by GNU Autoconf 2.66. 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 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" 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 Configuration files: $config_files 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="\\ btpd config.status 0.16 configured by $0, generated by GNU Autoconf 2.66, 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=$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"` ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --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" _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 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; *) 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_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= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$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 -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # 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 {' >"$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 >>"\$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 >>"\$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 < "$tmp/subs1.awk" > "$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" eval set X " :F $CONFIG_FILES :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="$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 >"$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 "$tmp/subs.awk" >$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' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$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 "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :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 } ;; 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