-diff -purN btpd-0.13/btpd/content.c btpd-0.13-hack/btpd/content.c
---- btpd-0.13/btpd/content.c 2007-05-18 19:32:01.000000000 +0400
-+++ btpd-0.13-hack/btpd/content.c 2007-09-04 14:59:06.000000000 +0400
-@@ -7,7 +7,7 @@
- #include <string.h>
- #include <unistd.h>
+diff -urN btpd-0.15/btpd/content.c btpd-0.15-new/btpd/content.c
+--- btpd-0.15/btpd/content.c 2009-02-03 10:15:01.000000000 -0500
++++ btpd-0.15-new/btpd/content.c 2009-06-19 15:02:48.000000000 -0400
+@@ -1,6 +1,6 @@
+ #include "btpd.h"
-#include <openssl/sha.h>
+#include "sha1.h"
+ #include <stream.h>
- #include "btpd.h"
- #include "stream.h"
-diff -purN btpd-0.13/btpd/download_subr.c btpd-0.13-hack/btpd/download_subr.c
---- btpd-0.13/btpd/download_subr.c 2007-05-18 19:32:01.000000000 +0400
-+++ btpd-0.13-hack/btpd/download_subr.c 2007-09-04 15:13:35.000000000 +0400
-@@ -24,8 +24,6 @@
- #include <string.h>
- #include <unistd.h>
+ struct content {
+diff -urN btpd-0.15/btpd/download_subr.c btpd-0.15-new/btpd/download_subr.c
+--- btpd-0.15/btpd/download_subr.c 2009-02-07 16:45:36.000000000 -0500
++++ btpd-0.15-new/btpd/download_subr.c 2009-06-19 15:03:06.000000000 -0400
+@@ -21,7 +21,6 @@
--#include <openssl/sha.h>
--
#include "btpd.h"
- #include "stream.h"
-
-diff -purN btpd-0.13/btpd/Makefile.am btpd-0.13-hack/btpd/Makefile.am
---- btpd-0.13/btpd/Makefile.am 2007-05-18 19:32:01.000000000 +0400
-+++ btpd-0.13-hack/btpd/Makefile.am 2007-09-04 15:15:17.000000000 +0400
-@@ -16,5 +16,5 @@ btpd_SOURCES=\
- util.c
-
- btpd_LDADD=../misc/libmisc.a ../libevent/libevent.a
--btpd_CPPFLAGS=-I$(top_srcdir)/misc -I$(top_srcdir)/libevent @openssl_CPPFLAGS@
--btpd_LDFLAGS=@openssl_LDFLAGS@ -lcrypto -lm
-+btpd_CPPFLAGS=-I$(top_srcdir)/misc -I$(top_srcdir)/libevent
-+btpd_LDFLAGS=-lm
-diff -purN btpd-0.13/btpd/torrent.c btpd-0.13-hack/btpd/torrent.c
---- btpd-0.13/btpd/torrent.c 2007-05-19 12:41:32.000000000 +0400
-+++ btpd-0.13-hack/btpd/torrent.c 2007-09-04 15:14:06.000000000 +0400
-@@ -10,8 +10,6 @@
- #include <string.h>
- #include <unistd.h>
-#include <openssl/sha.h>
--
- #include "btpd.h"
- #include "tracker_req.h"
- #include "stream.h"
-diff -purN btpd-0.13/cli/Makefile.am btpd-0.13-hack/cli/Makefile.am
---- btpd-0.13/cli/Makefile.am 2007-05-18 19:32:00.000000000 +0400
-+++ btpd-0.13-hack/cli/Makefile.am 2007-09-04 15:14:46.000000000 +0400
-@@ -1,11 +1,11 @@
- bin_PROGRAMS=btinfo btcli
+ #include <stream.h>
- btinfo_SOURCES=btinfo.c
--btinfo_LDADD=../misc/libmisc.a -lcrypto -lm
--btinfo_CPPFLAGS=-I$(top_srcdir)/misc @openssl_CPPFLAGS@
--btinfo_LDFLAGS=@openssl_LDFLAGS@
-+btinfo_LDADD=../misc/libmisc.a -lm
-+btinfo_CPPFLAGS=-I$(top_srcdir)/misc
-+btinfo_LDFLAGS=
-
- btcli_SOURCES=btcli.c btcli.h add.c del.c list.c kill.c start.c stop.c stat.c
--btcli_LDADD=../misc/libmisc.a -lcrypto -lm
--btcli_CPPFLAGS=-I$(top_srcdir)/misc @openssl_CPPFLAGS@
--btcli_LDFLAGS=@openssl_LDFLAGS@
-+btcli_LDADD=../misc/libmisc.a -lm
-+btcli_CPPFLAGS=-I$(top_srcdir)/misc
-+btcli_LDFLAGS=
-diff -urN btpd-0.13.orig/configure btpd-0.13/configure
---- btpd-0.13.orig/configure 2007-05-19 13:55:14.000000000 -0700
-+++ btpd-0.13/configure 2008-06-14 23:04:33.000000000 -0700
-@@ -2939,80 +2939,6 @@
- fi;
+ static void
+diff -urN btpd-0.15/btpd/torrent.c btpd-0.15-new/btpd/torrent.c
+--- btpd-0.15/btpd/torrent.c 2009-01-26 16:15:10.000000000 -0500
++++ btpd-0.15-new/btpd/torrent.c 2009-06-19 15:03:24.000000000 -0400
+@@ -1,7 +1,5 @@
+ #include "btpd.h"
- old_LDFLAGS="$LDFLAGS"
--LDFLAGS="$LDFLAGS $openssl_LDFLAGS"
--
--echo "$as_me:$LINENO: checking for SHA1_Final in -lcrypto" >&5
--echo $ECHO_N "checking for SHA1_Final in -lcrypto... $ECHO_C" >&6
--if test "${ac_cv_lib_crypto_SHA1_Final+set}" = set; then
-- echo $ECHO_N "(cached) $ECHO_C" >&6
--else
-- ac_check_lib_save_LIBS=$LIBS
--LIBS="-lcrypto $LIBS"
--cat >conftest.$ac_ext <<_ACEOF
--/* confdefs.h. */
--_ACEOF
--cat confdefs.h >>conftest.$ac_ext
--cat >>conftest.$ac_ext <<_ACEOF
--/* end confdefs.h. */
--
--/* Override any gcc2 internal prototype to avoid an error. */
--#ifdef __cplusplus
--extern "C"
--#endif
--/* We use char because int might match the return type of a gcc2
-- builtin and then its argument prototype would still apply. */
--char SHA1_Final ();
--int
--main ()
--{
--SHA1_Final ();
-- ;
-- return 0;
--}
--_ACEOF
--rm -f conftest.$ac_objext conftest$ac_exeext
--if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-- (eval $ac_link) 2>conftest.er1
-- ac_status=$?
-- grep -v '^ *+' conftest.er1 >conftest.err
-- rm -f conftest.er1
-- cat conftest.err >&5
-- echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); } &&
-- { ac_try='test -z "$ac_c_werror_flag"
-- || test ! -s conftest.err'
-- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-- (eval $ac_try) 2>&5
-- ac_status=$?
-- echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }; } &&
-- { ac_try='test -s conftest$ac_exeext'
-- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-- (eval $ac_try) 2>&5
-- ac_status=$?
-- echo "$as_me:$LINENO: \$? = $ac_status" >&5
-- (exit $ac_status); }; }; then
-- ac_cv_lib_crypto_SHA1_Final=yes
--else
-- echo "$as_me: failed program was:" >&5
--sed 's/^/| /' conftest.$ac_ext >&5
--
--ac_cv_lib_crypto_SHA1_Final=no
--fi
--rm -f conftest.err conftest.$ac_objext \
-- conftest$ac_exeext conftest.$ac_ext
--LIBS=$ac_check_lib_save_LIBS
--fi
--echo "$as_me:$LINENO: result: $ac_cv_lib_crypto_SHA1_Final" >&5
--echo "${ECHO_T}$ac_cv_lib_crypto_SHA1_Final" >&6
--if test $ac_cv_lib_crypto_SHA1_Final = yes; then
-- :
--else
-- echo Must have openssl; exit 1
--fi
--
--LDFLAGS=$old_LDFLAGS
+-#include <openssl/sha.h>
-
+ #define SAVE_INTERVAL 300
-
- subdirs="$subdirs libevent"
-diff -purN btpd-0.13/configure.ac btpd-0.13-hack/configure.ac
---- btpd-0.13/configure.ac 2007-05-18 19:31:59.000000000 +0400
-+++ btpd-0.13-hack/configure.ac 2007-09-04 15:09:17.000000000 +0400
-@@ -10,14 +10,6 @@ AC_PROG_RANLIB
- CFLAGS="$CFLAGS -std=c99"
- CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64"
+ static unsigned m_nghosts;
+diff -urN btpd-0.15/configure.ac btpd-0.15-new/configure.ac
+--- btpd-0.15/configure.ac 2009-02-09 16:04:53.000000000 -0500
++++ btpd-0.15-new/configure.ac 2009-06-19 15:04:12.000000000 -0400
+@@ -29,13 +29,6 @@
+ 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,-rpath=${withval}/lib"])
-- AC_SUBST(openssl_CPPFLAGS,"-I${withval}/include")
--],
--[])
+- AC_SUBST(openssl_LDFLAGS,["-L${withval}/lib -Wl,-R,${withval}/lib"])
+- AC_SUBST(openssl_CPPFLAGS,"-I${withval}/include")
+-])
-
- AC_ARG_WITH(warn,
- [ --with-warn=level select warning preset (no,all,allerr)],
- [
-@@ -38,11 +30,6 @@ AC_ARG_WITH(warn,
- ],
- [])
+ AC_ARG_WITH(evloop-method,
+ [ --with-evloop-method select evloop method (epoll,poll,kqueue)],
+ evloop_methods=$withval,
+@@ -76,11 +69,6 @@
+ ,
+ AC_MSG_RESULT(no))
-old_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS $openssl_LDFLAGS"
--AC_CHECK_LIB(crypto, SHA1_Final, :, echo Must have openssl; exit 1)
+-AC_CHECK_LIB(crypto, SHA1_Final,:,AC_MSG_FAILURE(btpd needs openssl's libraries and headers))
-LDFLAGS=$old_LDFLAGS
-
- AC_CONFIG_SUBDIRS([libevent])
+ for m in $evloop_methods; do
+ case $m in
+ epoll)
+diff -urN btpd-0.15/Makefile.in btpd-0.15-new/Makefile.in
+--- btpd-0.15/Makefile.in 2009-02-09 16:08:59.000000000 -0500
++++ btpd-0.15-new/Makefile.in 2009-06-19 15:21:05.000000000 -0400
+@@ -58,7 +58,8 @@
+ 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/stream.$(OBJEXT) misc/subr.$(OBJEXT) \
++ misc/sha1.$(OBJEXT)
+ misc_libmisc_a_OBJECTS = $(am_misc_libmisc_a_OBJECTS)
+ am__installdirs = "$(DESTDIR)$(bindir)"
+ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+@@ -213,8 +214,8 @@
+ 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@
++AM_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D@EVLOOP_METHOD@ -I$(top_srcdir)/misc -I$(top_srcdir)/evloop
++AM_LDFLAGS =
+ noinst_LIBRARIES = misc/libmisc.a evloop/libevloop.a
+ EXTRA_DIST = COPYRIGHT CHANGES
- AC_OUTPUT
-diff -purN btpd-0.13/libevent/evdns.c btpd-0.13-hack/libevent/evdns.c
---- btpd-0.13/libevent/evdns.c 2007-05-18 19:32:01.000000000 +0400
-+++ btpd-0.13-hack/libevent/evdns.c 2007-09-04 15:12:38.000000000 +0400
-@@ -47,33 +47,21 @@
+@@ -256,7 +257,8 @@
+ misc/iobuf.c misc/iobuf.h\
+ misc/queue.h\
+ misc/stream.c misc/stream.h\
+- misc/subr.c misc/subr.h
++ misc/subr.c misc/subr.h\
++ misc/sha1.c misc/sha1.h
- #ifndef DNS_USE_CPU_CLOCK_FOR_ID
- #ifndef DNS_USE_GETTIMEOFDAY_FOR_ID
--#ifndef DNS_USE_OPENSSL_FOR_ID
- #error Must configure at least one id generation method.
- #error Please see the documentation.
- #endif
- #endif
--#endif
- // #define _POSIX_C_SOURCE 200507
- #define _GNU_SOURCE
+ # evloop
+@@ -349,6 +351,8 @@
+ misc/$(DEPDIR)/$(am__dirstamp)
+ misc/subr.$(OBJEXT): misc/$(am__dirstamp) \
+ misc/$(DEPDIR)/$(am__dirstamp)
++misc/sha1.$(OBJEXT): misc/$(am__dirstamp) \
++ misc/$(DIPDIR)/$(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)
+@@ -492,6 +496,7 @@
+ -rm -f misc/metainfo.$(OBJEXT)
+ -rm -f misc/stream.$(OBJEXT)
+ -rm -f misc/subr.$(OBJEXT)
++ -rm -f misc/sha1.$(OBJEXT)
- #ifdef DNS_USE_CPU_CLOCK_FOR_ID
--#ifdef DNS_USE_OPENSSL_FOR_ID
--#error Multiple id options selected
--#endif
- #ifdef DNS_USE_GETTIMEOFDAY_FOR_ID
- #error Multiple id options selected
- #endif
- #include <time.h>
- #endif
+ distclean-compile:
+ -rm -f *.tab.c
+@@ -538,6 +543,7 @@
+ @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@
++@AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/sha1.Po@am__quote@
--#ifdef DNS_USE_OPENSSL_FOR_ID
--#ifdef DNS_USE_GETTIMEOFDAY_FOR_ID
--#error Multiple id options selected
--#endif
--#include <openssl/rand.h>
--#endif
--
- #define _FORTIFY_SOURCE 3
-
- #include <string.h>
-@@ -1026,18 +1014,6 @@ transaction_id_pick(void) {
- trans_id = tv.tv_usec & 0xffff;
- #endif
-
--#ifdef DNS_USE_OPENSSL_FOR_ID
-- u16 trans_id;
-- if (RAND_pseudo_bytes((u8 *) &trans_id, 2) == -1) {
-- /* // in the case that the RAND call fails we back
-- // down to using gettimeofday.
-- struct timeval tv;
-- gettimeofday(&tv, NULL);
-- trans_id = tv.tv_usec & 0xffff; */
-- abort();
-- }
--#endif
--
- if (trans_id == 0xffff) continue;
- // now check to see if that id is already inflight
- req = started_at = req_head;
-diff -purN btpd-0.13/misc/Makefile.am btpd-0.13-hack/misc/Makefile.am
---- btpd-0.13/misc/Makefile.am 2007-05-18 19:32:01.000000000 +0400
-+++ btpd-0.13-hack/misc/Makefile.am 2007-09-04 14:57:39.000000000 +0400
-@@ -8,5 +8,6 @@ libmisc_a_SOURCES=\
- iobuf.c iobuf.h\
- queue.h\
- stream.c stream.h\
-- subr.c subr.h
--libmisc_a_CPPFLAGS=-I$(top_srcdir)/libevent @openssl_CPPFLAGS@
-+ subr.c subr.h\
-+ sha1.c sha1.h
-+libmisc_a_CPPFLAGS=-I$(top_srcdir)/libevent
-diff -purN btpd-0.13/misc/metainfo.c btpd-0.13-hack/misc/metainfo.c
---- btpd-0.13/misc/metainfo.c 2007-05-18 19:32:01.000000000 +0400
-+++ btpd-0.13-hack/misc/metainfo.c 2007-09-04 14:58:20.000000000 +0400
-@@ -5,8 +5,7 @@
- #include <stdlib.h>
+ .c.o:
+ @am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+diff -urN btpd-0.15/misc/metainfo.c btpd-0.15-new/misc/metainfo.c
+--- btpd-0.15/misc/metainfo.c 2009-01-12 17:43:18.000000000 -0500
++++ btpd-0.15-new/misc/metainfo.c 2009-06-19 15:02:20.000000000 -0400
+@@ -6,8 +6,7 @@
#include <string.h>
+ #include <strings.h>
-#include <openssl/sha.h>
-
#include "benc.h"
#include "metainfo.h"
#include "subr.h"
-@@ -158,7 +157,7 @@ mi_info_hash(const char *p, uint8_t *has
+@@ -159,7 +158,7 @@
if (hash == NULL)
if ((hash = malloc(20)) == NULL)
return NULL;
}
char *
-diff -purN btpd-0.13/misc/sha1.c btpd-0.13-hack/misc/sha1.c
---- btpd-0.13/misc/sha1.c 1970-01-01 03:00:00.000000000 +0300
-+++ btpd-0.13-hack/misc/sha1.c 2007-09-04 14:45:36.000000000 +0400
+diff -urN btpd-0.15/misc/sha1.c btpd-0.15-new/misc/sha1.c
+--- btpd-0.15/misc/sha1.c 1969-12-31 19:00:00.000000000 -0500
++++ btpd-0.15-new/misc/sha1.c 2009-06-19 15:02:20.000000000 -0400
@@ -0,0 +1,423 @@
+/* sha1.c - Functions to compute SHA1 message digest of files or
+ memory blocks according to the NIST specification FIPS-180-1.
+ e = ctx->E += e;
+ }
+}
-diff -purN btpd-0.13/misc/sha1.h btpd-0.13-hack/misc/sha1.h
---- btpd-0.13/misc/sha1.h 1970-01-01 03:00:00.000000000 +0300
-+++ btpd-0.13-hack/misc/sha1.h 2007-09-04 14:49:48.000000000 +0400
+diff -urN btpd-0.15/misc/sha1.h btpd-0.15-new/misc/sha1.h
+--- btpd-0.15/misc/sha1.h 1969-12-31 19:00:00.000000000 -0500
++++ btpd-0.15-new/misc/sha1.h 2009-06-19 15:02:20.000000000 -0400
@@ -0,0 +1,90 @@
+/* Declarations of functions and data types used for SHA1 sum
+ library functions.
+extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
+
+#endif
-diff -purN btpd-0.13/misc/stream.c btpd-0.13-hack/misc/stream.c
---- btpd-0.13/misc/stream.c 2007-05-18 19:32:01.000000000 +0400
-+++ btpd-0.13-hack/misc/stream.c 2007-09-04 14:53:35.000000000 +0400
+diff -urN btpd-0.15/misc/stream.c btpd-0.15-new/misc/stream.c
+--- btpd-0.15/misc/stream.c 2008-12-22 17:25:36.000000000 -0500
++++ btpd-0.15-new/misc/stream.c 2009-06-19 15:02:20.000000000 -0400
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <unistd.h>
#include "metainfo.h"
#include "subr.h"
-@@ -161,21 +161,21 @@ bts_put(struct bt_stream *bts, off_t off
+@@ -161,21 +161,21 @@
int
bts_sha(struct bt_stream *bts, off_t start, off_t length, uint8_t *hash)
{
return err;
}
+diff -urN btpd-0.15/.pc/.version btpd-0.15-new/.pc/.version
+--- btpd-0.15/.pc/.version 1969-12-31 19:00:00.000000000 -0500
++++ btpd-0.15-new/.pc/.version 2009-06-19 15:00:46.000000000 -0400
+@@ -0,0 +1 @@
++2
+diff -urN btpd-0.15/Makefile.am btpd-0.15.new/Makefile.am
+--- btpd-0.15/Makefile.am 2009-02-03 12:09:25.000000000 +0100
++++ btpd-0.15.new/Makefile.am 2009-07-02 17:39:47.000000000 +0200
+@@ -1,6 +1,6 @@
+ 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@
++AM_CPPFLAGS=-D_FILE_OFFSET_BITS=64 -D@EVLOOP_METHOD@ -I$(top_srcdir)/misc -I$(top_srcdir)/evloop
++AM_LDFLAGS=
+
+ bin_PROGRAMS=btpd/btpd cli/btcli cli/btinfo
+ noinst_LIBRARIES=misc/libmisc.a evloop/libevloop.a
+@@ -44,7 +44,8 @@
+ misc/iobuf.c misc/iobuf.h\
+ misc/queue.h\
+ misc/stream.c misc/stream.h\
+- misc/subr.c misc/subr.h
++ misc/subr.c misc/subr.h\
++ misc/sha1.c misc/sha1.h
+
+ # evloop
+ EXTRA_evloop_libevloop_a_SOURCES=evloop/epoll.c evloop/kqueue.c evloop/poll.c