fix a bunch of issues to properly support dynamic linking of libtorrent with visibility=hidden. Still requires a small patch to boost
This commit is contained in:
parent
8213814102
commit
a2521bd23c
|
@ -6,6 +6,7 @@ set(sources
|
||||||
alert
|
alert
|
||||||
allocator
|
allocator
|
||||||
asio
|
asio
|
||||||
|
asio_ssl
|
||||||
assert
|
assert
|
||||||
bandwidth_limit
|
bandwidth_limit
|
||||||
bandwidth_manager
|
bandwidth_manager
|
||||||
|
@ -240,7 +241,7 @@ endforeach (s)
|
||||||
|
|
||||||
configure_file(libtorrent-rasterbar-cmake.pc.in libtorrent-rasterbar.pc)
|
configure_file(libtorrent-rasterbar-cmake.pc.in libtorrent-rasterbar.pc)
|
||||||
|
|
||||||
string (COMPARE EQUAL ${CMAKE_SIZEOF_VOID_P} "8" IS64BITS)
|
string (COMPARE EQUAL "${CMAKE_SIZEOF_VOID_P}" "8" IS64BITS)
|
||||||
|
|
||||||
if (IS64BITS AND RESPECTLIB64)
|
if (IS64BITS AND RESPECTLIB64)
|
||||||
set (LIBDIR "lib64")
|
set (LIBDIR "lib64")
|
||||||
|
|
30
Jamfile
30
Jamfile
|
@ -31,17 +31,6 @@ rule linking ( properties * )
|
||||||
{
|
{
|
||||||
local result ;
|
local result ;
|
||||||
|
|
||||||
if <link>shared in $(properties)
|
|
||||||
{
|
|
||||||
# make sure asio symbols are properly exported
|
|
||||||
# and imported
|
|
||||||
result += <define>BOOST_ASIO_DYN_LINK ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result += <define>BOOST_ASIO_SEPARATE_COMPILATION ;
|
|
||||||
}
|
|
||||||
|
|
||||||
# openssl libraries, if enabled
|
# openssl libraries, if enabled
|
||||||
if <encryption>openssl in $(properties)
|
if <encryption>openssl in $(properties)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +198,15 @@ rule building ( properties * )
|
||||||
{
|
{
|
||||||
local result ;
|
local result ;
|
||||||
|
|
||||||
|
if <link>shared in $(properties) && <export-extra>on in $(properties)
|
||||||
|
{
|
||||||
|
# export some internal libtorrent functions
|
||||||
|
# in order to me able to unit test them.
|
||||||
|
# this is off by default to keep the export
|
||||||
|
# symbol table reasonably small
|
||||||
|
result += <define>TORRENT_EXPORT_EXTRA ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( <variant>debug in $(properties)
|
if ( <variant>debug in $(properties)
|
||||||
|| <asserts>on in $(properties) )
|
|| <asserts>on in $(properties) )
|
||||||
{
|
{
|
||||||
|
@ -249,7 +247,7 @@ rule building ( properties * )
|
||||||
# hide non-external symbols
|
# hide non-external symbols
|
||||||
# use ms-compat because boost.asio (as of 1.47.0
|
# use ms-compat because boost.asio (as of 1.47.0
|
||||||
# appears to have some types not fulle exported)
|
# appears to have some types not fulle exported)
|
||||||
result += <cflags>-fvisibility-ms-compat ;
|
result += <cflags>-fvisibility=hidden ;
|
||||||
result += <cxxflags>-fvisibility-inlines-hidden ;
|
result += <cxxflags>-fvisibility-inlines-hidden ;
|
||||||
result += <linkflags>-W1,-Bsymbolic ;
|
result += <linkflags>-W1,-Bsymbolic ;
|
||||||
}
|
}
|
||||||
|
@ -378,6 +376,10 @@ feature fpic : off on : composite propagated link-incompatible ;
|
||||||
feature.compose <fpic>on : <cflags>-fPIC ;
|
feature.compose <fpic>on : <cflags>-fPIC ;
|
||||||
feature.compose <fpic>off : <toolset>darwin:<cflags>-mdynamic-no-pic ;
|
feature.compose <fpic>off : <toolset>darwin:<cflags>-mdynamic-no-pic ;
|
||||||
|
|
||||||
|
# controls whether or not to export some internal
|
||||||
|
# libtorrent functions. Used for unit testing
|
||||||
|
feature export-extra : off on : composite propagated ;
|
||||||
|
|
||||||
# required for openssl on windows
|
# required for openssl on windows
|
||||||
lib ssleay32 : : <name>ssleay32 ;
|
lib ssleay32 : : <name>ssleay32 ;
|
||||||
lib libeay32 : : <name>libeay32 ;
|
lib libeay32 : : <name>libeay32 ;
|
||||||
|
@ -560,6 +562,10 @@ local usage-requirements =
|
||||||
<boost>system:<linkflags>$(LDFLAGS)
|
<boost>system:<linkflags>$(LDFLAGS)
|
||||||
# this works around a bug in asio in boost-1.39
|
# this works around a bug in asio in boost-1.39
|
||||||
<define>BOOST_ASIO_HASH_MAP_BUCKETS=1021
|
<define>BOOST_ASIO_HASH_MAP_BUCKETS=1021
|
||||||
|
# make sure asio symbols are properly exported
|
||||||
|
# and imported
|
||||||
|
<link>shared:<define>BOOST_ASIO_DYN_LINK
|
||||||
|
<link>static:<define>BOOST_ASIO_SEPARATE_COMPILATION
|
||||||
<tag>@tag
|
<tag>@tag
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ AC_CHECK_FUNCS([clock_gettime], [],
|
||||||
|
|
||||||
|
|
||||||
dnl Pass some build options to setup.py and .pc file
|
dnl Pass some build options to setup.py and .pc file
|
||||||
COMPILETIME_OPTIONS="-DBOOST_ASIO_DYN_LINK "
|
COMPILETIME_OPTIONS=""
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -581,6 +581,8 @@ AM_CONDITIONAL([ENABLE_TESTS], [test "x$ARG_ENABLE_TESTS" = "xyes"])
|
||||||
AM_CONDITIONAL([ENABLE_PYTHON_BINDING], [test "x$ARG_ENABLE_PYTHON_BINDING" = "xyes"])
|
AM_CONDITIONAL([ENABLE_PYTHON_BINDING], [test "x$ARG_ENABLE_PYTHON_BINDING" = "xyes"])
|
||||||
|
|
||||||
AM_CONDITIONAL([WITH_SHIPPED_GEOIP], [test "x$ARG_WITH_LIBGEOIP" = "xno" ])
|
AM_CONDITIONAL([WITH_SHIPPED_GEOIP], [test "x$ARG_WITH_LIBGEOIP" = "xno" ])
|
||||||
|
#error
|
||||||
|
AM_CONDITIONAL([WITH_OPENSSL], [test "x$ARG_ENABLE_ENCRYPTION" = "xyes" -o "x$ARG_ENABLE_ENCRYPTION" = "xon" ])
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -598,6 +600,9 @@ COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DBOOST_EXCEPTION_DISABLE "
|
||||||
AC_DEFINE([BOOST_ASIO_ENABLE_CANCELIO],[1],[Define to enable cancel support in asio on windows XP and older.])
|
AC_DEFINE([BOOST_ASIO_ENABLE_CANCELIO],[1],[Define to enable cancel support in asio on windows XP and older.])
|
||||||
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DBOOST_ASIO_ENABLE_CANCELIO "
|
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DBOOST_ASIO_ENABLE_CANCELIO "
|
||||||
|
|
||||||
|
AC_DEFINE([BOOST_ASIO_DYN_LINK],[1],[make asio export its symbols])
|
||||||
|
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DBOOST_ASIO_DYN_LINK"
|
||||||
|
|
||||||
dnl Use possibly specific python install params
|
dnl Use possibly specific python install params
|
||||||
AC_ARG_VAR([PYTHON_INSTALL_PARAMS], [Set specific install parameters for python bindings.])
|
AC_ARG_VAR([PYTHON_INSTALL_PARAMS], [Set specific install parameters for python bindings.])
|
||||||
AS_IF([test "x$PYTHON_INSTALL_PARAMS" = "x"],
|
AS_IF([test "x$PYTHON_INSTALL_PARAMS" = "x"],
|
||||||
|
|
|
@ -1250,8 +1250,8 @@ int main(int argc, char* argv[])
|
||||||
// match it against the <hash>@<tracker> format
|
// match it against the <hash>@<tracker> format
|
||||||
if (strlen(argv[i]) > 45
|
if (strlen(argv[i]) > 45
|
||||||
&& is_hex(argv[i], 40)
|
&& is_hex(argv[i], 40)
|
||||||
&& (string_begins_no_case(argv[i] + 40, "@http://")
|
&& (strncmp(argv[i] + 40, "@http://", 8) == 0
|
||||||
|| string_begins_no_case(argv[i] + 40, "@udp://")))
|
|| strncmp(argv[i] + 40, "@udp://", 7) == 0))
|
||||||
{
|
{
|
||||||
sha1_hash info_hash;
|
sha1_hash info_hash;
|
||||||
from_hex(argv[i], 40, (char*)&info_hash[0]);
|
from_hex(argv[i], 40, (char*)&info_hash[0]);
|
||||||
|
@ -1488,18 +1488,13 @@ int main(int argc, char* argv[])
|
||||||
std::vector<char> buf;
|
std::vector<char> buf;
|
||||||
if (std::strstr(i->c_str(), "magnet:") == i->c_str())
|
if (std::strstr(i->c_str(), "magnet:") == i->c_str())
|
||||||
{
|
{
|
||||||
std::string btih = url_has_argument(*i, "xt");
|
add_torrent_params tmp;
|
||||||
if (btih.empty()) continue;
|
parse_magnet_uri(*i, tmp, ec);
|
||||||
|
|
||||||
if (btih.compare(0, 9, "urn:btih:") != 0)
|
if (ec) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
sha1_hash info_hash;
|
|
||||||
if (btih.size() == 40 + 9) from_hex(&btih[9], 40, (char*)&info_hash[0]);
|
|
||||||
else info_hash.assign(base32decode(btih.substr(9)));
|
|
||||||
|
|
||||||
std::string filename = combine_path(save_path, combine_path(".resume"
|
std::string filename = combine_path(save_path, combine_path(".resume"
|
||||||
, to_hex(info_hash.to_string()) + ".resume"));
|
, to_hex(tmp.info_hash.to_string()) + ".resume"));
|
||||||
|
|
||||||
if (load_file(filename.c_str(), buf, ec) == 0)
|
if (load_file(filename.c_str(), buf, ec) == 0)
|
||||||
p.resume_data = &buf;
|
p.resume_data = &buf;
|
||||||
|
@ -1864,8 +1859,11 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
feed_status st = i->get_feed_status();
|
feed_status st = i->get_feed_status();
|
||||||
if (st.url.size() > 70) st.url.resize(70);
|
if (st.url.size() > 70) st.url.resize(70);
|
||||||
|
|
||||||
|
char update_timer[20];
|
||||||
|
snprintf(update_timer, sizeof(update_timer), "%d", st.next_update);
|
||||||
snprintf(str, sizeof(str), "%-70s %s (%2d) %s\n", st.url.c_str()
|
snprintf(str, sizeof(str), "%-70s %s (%2d) %s\n", st.url.c_str()
|
||||||
, st.updating ? "updating" : to_string(st.next_update).elems
|
, st.updating ? "updating" : update_timer
|
||||||
, int(st.items.size())
|
, int(st.items.size())
|
||||||
, st.error ? st.error.message().c_str() : "");
|
, st.error ? st.error.message().c_str() : "");
|
||||||
out += str;
|
out += str;
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace libtorrent {
|
||||||
ptime m_timestamp;
|
ptime m_timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TORRENT_EXPORT alert_manager
|
class TORRENT_EXTRA_EXPORT alert_manager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
alert_manager(io_service& ios, int queue_limit
|
alert_manager(io_service& ios, int queue_limit
|
||||||
|
|
|
@ -39,9 +39,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
TORRENT_EXPORT int page_size();
|
TORRENT_EXTRA_EXPORT int page_size();
|
||||||
|
|
||||||
struct TORRENT_EXPORT page_aligned_allocator
|
struct TORRENT_EXTRA_EXPORT page_aligned_allocator
|
||||||
{
|
{
|
||||||
typedef std::size_t size_type;
|
typedef std::size_t size_type;
|
||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
@ -50,7 +50,7 @@ namespace libtorrent
|
||||||
static void free(char* const block);
|
static void free(char* const block);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT aligned_holder
|
struct TORRENT_EXTRA_EXPORT aligned_holder
|
||||||
{
|
{
|
||||||
aligned_holder(): m_buf(0) {}
|
aligned_holder(): m_buf(0) {}
|
||||||
aligned_holder(int size): m_buf(page_aligned_allocator::malloc(size)) {}
|
aligned_holder(int size): m_buf(page_aligned_allocator::malloc(size)) {}
|
||||||
|
|
|
@ -181,7 +181,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// this is the link between the main thread and the
|
// this is the link between the main thread and the
|
||||||
// thread started to run the main downloader loop
|
// thread started to run the main downloader loop
|
||||||
struct TORRENT_EXPORT session_impl: boost::noncopyable, initialize_timer
|
struct TORRENT_EXTRA_EXPORT session_impl: boost::noncopyable, initialize_timer
|
||||||
, boost::enable_shared_from_this<session_impl>
|
, boost::enable_shared_from_this<session_impl>
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
|
|
|
@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
// member of peer_connection
|
// member of peer_connection
|
||||||
struct TORRENT_EXPORT bandwidth_channel
|
struct TORRENT_EXTRA_EXPORT bandwidth_channel
|
||||||
{
|
{
|
||||||
static const int inf = boost::integer_traits<int>::const_max;
|
static const int inf = boost::integer_traits<int>::const_max;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ using boost::intrusive_ptr;
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
struct TORRENT_EXPORT bandwidth_manager
|
struct TORRENT_EXTRA_EXPORT bandwidth_manager
|
||||||
{
|
{
|
||||||
bandwidth_manager(int channel
|
bandwidth_manager(int channel
|
||||||
#ifdef TORRENT_VERBOSE_BANDWIDTH_LIMIT
|
#ifdef TORRENT_VERBOSE_BANDWIDTH_LIMIT
|
||||||
|
|
|
@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
struct TORRENT_EXPORT bw_request
|
struct TORRENT_EXTRA_EXPORT bw_request
|
||||||
{
|
{
|
||||||
bw_request(boost::intrusive_ptr<bandwidth_socket> const& pe
|
bw_request(boost::intrusive_ptr<bandwidth_socket> const& pe
|
||||||
, int blk, int prio);
|
, int blk, int prio);
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace libtorrent
|
||||||
return int(val.length());
|
return int(val.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_EXPORT char const* integer_to_str(char* buf, int size, entry::integer_type val);
|
TORRENT_EXTRA_EXPORT char const* integer_to_str(char* buf, int size, entry::integer_type val);
|
||||||
|
|
||||||
template <class OutIt>
|
template <class OutIt>
|
||||||
int write_integer(OutIt& out, entry::integer_type val)
|
int write_integer(OutIt& out, entry::integer_type val)
|
||||||
|
|
|
@ -41,9 +41,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_EXPORT void set_bits(boost::uint8_t const* b, boost::uint8_t* bits, int len);
|
TORRENT_EXTRA_EXPORT void set_bits(boost::uint8_t const* b, boost::uint8_t* bits, int len);
|
||||||
TORRENT_EXPORT bool has_bits(boost::uint8_t const* b, boost::uint8_t const* bits, int len);
|
TORRENT_EXTRA_EXPORT bool has_bits(boost::uint8_t const* b, boost::uint8_t const* bits, int len);
|
||||||
TORRENT_EXPORT int count_zero_bits(boost::uint8_t const* bits, int len);
|
TORRENT_EXTRA_EXPORT int count_zero_bits(boost::uint8_t const* bits, int len);
|
||||||
|
|
||||||
template <int N>
|
template <int N>
|
||||||
struct bloom_filter
|
struct bloom_filter
|
||||||
|
|
|
@ -50,12 +50,12 @@ namespace libtorrent
|
||||||
TORRENT_EXPORT bool is_multicast(address const& addr);
|
TORRENT_EXPORT bool is_multicast(address const& addr);
|
||||||
TORRENT_EXPORT bool is_any(address const& addr);
|
TORRENT_EXPORT bool is_any(address const& addr);
|
||||||
TORRENT_EXPORT bool is_teredo(address const& addr);
|
TORRENT_EXPORT bool is_teredo(address const& addr);
|
||||||
TORRENT_EXPORT int cidr_distance(address const& a1, address const& a2);
|
TORRENT_EXTRA_EXPORT int cidr_distance(address const& a1, address const& a2);
|
||||||
|
|
||||||
// determines if the operating system supports IPv6
|
// determines if the operating system supports IPv6
|
||||||
TORRENT_EXPORT bool supports_ipv6();
|
TORRENT_EXPORT bool supports_ipv6();
|
||||||
|
|
||||||
TORRENT_EXPORT int common_bits(unsigned char const* b1
|
TORRENT_EXTRA_EXPORT int common_bits(unsigned char const* b1
|
||||||
, unsigned char const* b2, int n);
|
, unsigned char const* b2, int n);
|
||||||
|
|
||||||
TORRENT_EXPORT address guess_local_address(io_service&);
|
TORRENT_EXPORT address guess_local_address(io_service&);
|
||||||
|
@ -63,7 +63,7 @@ namespace libtorrent
|
||||||
typedef boost::function<void(udp::endpoint const& from
|
typedef boost::function<void(udp::endpoint const& from
|
||||||
, char* buffer, int size)> receive_handler_t;
|
, char* buffer, int size)> receive_handler_t;
|
||||||
|
|
||||||
class TORRENT_EXPORT broadcast_socket
|
class TORRENT_EXTRA_EXPORT broadcast_socket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
broadcast_socket(io_service& ios, udp::endpoint const& multicast_endpoint
|
broadcast_socket(io_service& ios, udp::endpoint const& multicast_endpoint
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace libtorrent
|
||||||
struct session_impl;
|
struct session_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TORRENT_EXPORT bt_peer_connection
|
class TORRENT_EXTRA_EXPORT bt_peer_connection
|
||||||
: public peer_connection
|
: public peer_connection
|
||||||
{
|
{
|
||||||
friend class invariant_access;
|
friend class invariant_access;
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace libtorrent
|
||||||
#if BOOST_VERSION >= 103500
|
#if BOOST_VERSION >= 103500
|
||||||
namespace asio = boost::asio;
|
namespace asio = boost::asio;
|
||||||
#endif
|
#endif
|
||||||
struct TORRENT_EXPORT chained_buffer
|
struct TORRENT_EXTRA_EXPORT chained_buffer
|
||||||
{
|
{
|
||||||
chained_buffer(): m_bytes(0), m_capacity(0)
|
chained_buffer(): m_bytes(0), m_capacity(0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,6 +66,20 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
# define TORRENT_EXPORT BOOST_SYMBOL_IMPORT
|
# define TORRENT_EXPORT BOOST_SYMBOL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// when this is specified, export a bunch of extra
|
||||||
|
// symbols, mostly for the unit tests to reach
|
||||||
|
#if TORRENT_EXPORT_EXTRA
|
||||||
|
# if defined TORRENT_BUILDING_SHARED
|
||||||
|
# define TORRENT_EXTRA_EXPORT BOOST_SYMBOL_EXPORT
|
||||||
|
# elif defined TORRENT_LINKING_SHARED
|
||||||
|
# define TORRENT_EXTRA_EXPORT BOOST_SYMBOL_IMPORT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_EXTRA_EXPORT
|
||||||
|
# define TORRENT_EXTRA_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
// ======= GCC =========
|
// ======= GCC =========
|
||||||
|
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
|
@ -200,13 +214,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_USE_ICONV
|
#ifndef TORRENT_USE_ICONV
|
||||||
#define TORRENT_USE_ICONV 0
|
#define TORRENT_USE_ICONV 0
|
||||||
#endif
|
#endif
|
||||||
#if __GNUCC__ == 2
|
|
||||||
# if defined(TORRENT_BUILDING_SHARED)
|
|
||||||
# define TORRENT_EXPORT __declspec(dllexport)
|
|
||||||
# elif defined(TORRENT_LINKING_SHARED)
|
|
||||||
# define TORRENT_EXPORT __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ==== GNU/Hurd ===
|
// ==== GNU/Hurd ===
|
||||||
#elif defined __GNU__
|
#elif defined __GNU__
|
||||||
|
|
|
@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
class TORRENT_EXPORT connection_queue : public boost::noncopyable
|
class TORRENT_EXTRA_EXPORT connection_queue : public boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
connection_queue(io_service& ios);
|
connection_queue(io_service& ios);
|
||||||
|
|
|
@ -190,54 +190,9 @@ namespace libtorrent
|
||||||
int TORRENT_EXPORT get_file_attributes(std::string const& p);
|
int TORRENT_EXPORT get_file_attributes(std::string const& p);
|
||||||
std::string TORRENT_EXPORT get_symlink_path(std::string const& p);
|
std::string TORRENT_EXPORT get_symlink_path(std::string const& p);
|
||||||
|
|
||||||
template <class Pred>
|
TORRENT_EXPORT void add_files_impl(file_storage& fs, std::string const& p
|
||||||
void add_files_impl(file_storage& fs, std::string const& p
|
, std::string const& l, boost::function<bool(std::string)> pred
|
||||||
, std::string const& l, Pred pred, boost::uint32_t flags)
|
, boost::uint32_t flags);
|
||||||
{
|
|
||||||
std::string f = combine_path(p, l);
|
|
||||||
if (!pred(f)) return;
|
|
||||||
error_code ec;
|
|
||||||
file_status s;
|
|
||||||
stat_file(f, &s, ec, (flags & create_torrent::symlinks) ? dont_follow_links : 0);
|
|
||||||
if (ec) return;
|
|
||||||
|
|
||||||
// recurse into directories
|
|
||||||
bool recurse = (s.mode & file_status::directory) != 0;
|
|
||||||
|
|
||||||
// if the file is not a link or we're following links, and it's a directory
|
|
||||||
// only then should we recurse
|
|
||||||
#ifndef TORRENT_WINDOWS
|
|
||||||
if ((s.mode & file_status::link) && (flags & create_torrent::symlinks))
|
|
||||||
recurse = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (recurse)
|
|
||||||
{
|
|
||||||
for (directory i(f, ec); !i.done(); i.next(ec))
|
|
||||||
{
|
|
||||||
std::string leaf = i.file();
|
|
||||||
if (ignore_subdir(leaf)) continue;
|
|
||||||
add_files_impl(fs, p, combine_path(l, leaf), pred, flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// #error use the fields from s
|
|
||||||
int file_flags = get_file_attributes(f);
|
|
||||||
|
|
||||||
// mask all bits to check if the file is a symlink
|
|
||||||
if ((file_flags & file_storage::attribute_symlink)
|
|
||||||
&& (flags & create_torrent::symlinks))
|
|
||||||
{
|
|
||||||
std::string sym_path = get_symlink_path(f);
|
|
||||||
fs.add_file(l, 0, file_flags, s.mtime, sym_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fs.add_file(l, s.file_size, file_flags, s.mtime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Pred>
|
template <class Pred>
|
||||||
|
@ -252,75 +207,8 @@ namespace libtorrent
|
||||||
, detail::default_pred, flags);
|
, detail::default_pred, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct piece_holder
|
TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::string const& p
|
||||||
{
|
, boost::function<void(int)> f, error_code& ec);
|
||||||
piece_holder(int bytes): m_piece(page_aligned_allocator::malloc(bytes)) {}
|
|
||||||
~piece_holder() { page_aligned_allocator::free(m_piece); }
|
|
||||||
char* bytes() { return m_piece; }
|
|
||||||
private:
|
|
||||||
char* m_piece;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Fun>
|
|
||||||
void set_piece_hashes(create_torrent& t, std::string const& p, Fun f
|
|
||||||
, error_code& ec)
|
|
||||||
{
|
|
||||||
file_pool fp;
|
|
||||||
boost::scoped_ptr<storage_interface> st(
|
|
||||||
default_storage_constructor(const_cast<file_storage&>(t.files()), 0, p, fp
|
|
||||||
, std::vector<boost::uint8_t>()));
|
|
||||||
|
|
||||||
// if we're calculating file hashes as well, use this hasher
|
|
||||||
hasher filehash;
|
|
||||||
int file_idx = 0;
|
|
||||||
size_type left_in_file = t.files().at(0).size;
|
|
||||||
|
|
||||||
// calculate the hash for all pieces
|
|
||||||
int num = t.num_pieces();
|
|
||||||
piece_holder buf(t.piece_length());
|
|
||||||
for (int i = 0; i < num; ++i)
|
|
||||||
{
|
|
||||||
// read hits the disk and will block. Progress should
|
|
||||||
// be updated in between reads
|
|
||||||
st->read(buf.bytes(), i, 0, t.piece_size(i));
|
|
||||||
if (st->error())
|
|
||||||
{
|
|
||||||
ec = st->error();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t.should_add_file_hashes())
|
|
||||||
{
|
|
||||||
int left_in_piece = t.piece_size(i);
|
|
||||||
int this_piece_size = left_in_piece;
|
|
||||||
// the number of bytes from this file we just read
|
|
||||||
while (left_in_piece > 0)
|
|
||||||
{
|
|
||||||
int to_hash_for_file = int((std::min)(size_type(left_in_piece), left_in_file));
|
|
||||||
if (to_hash_for_file > 0)
|
|
||||||
{
|
|
||||||
int offset = this_piece_size - left_in_piece;
|
|
||||||
filehash.update(buf.bytes() + offset, to_hash_for_file);
|
|
||||||
}
|
|
||||||
left_in_file -= to_hash_for_file;
|
|
||||||
left_in_piece -= to_hash_for_file;
|
|
||||||
if (left_in_file == 0)
|
|
||||||
{
|
|
||||||
if (!t.files().at(file_idx).pad_file)
|
|
||||||
t.set_file_hash(file_idx, filehash.final());
|
|
||||||
filehash.reset();
|
|
||||||
file_idx++;
|
|
||||||
if (file_idx >= t.files().num_files()) break;
|
|
||||||
left_in_file = t.files().at(file_idx).size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hasher h(buf.bytes(), t.piece_size(i));
|
|
||||||
t.set_hash(i, h.final());
|
|
||||||
f(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
template <class Fun>
|
template <class Fun>
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace libtorrent
|
||||||
namespace aux { struct session_impl; }
|
namespace aux { struct session_impl; }
|
||||||
struct disk_buffer_pool;
|
struct disk_buffer_pool;
|
||||||
|
|
||||||
struct TORRENT_EXPORT disk_buffer_holder
|
struct TORRENT_EXTRA_EXPORT disk_buffer_holder
|
||||||
{
|
{
|
||||||
disk_buffer_holder(aux::session_impl& ses, char* buf);
|
disk_buffer_holder(aux::session_impl& ses, char* buf);
|
||||||
disk_buffer_holder(disk_buffer_pool& disk_pool, char* buf);
|
disk_buffer_holder(disk_buffer_pool& disk_pool, char* buf);
|
||||||
|
|
|
@ -48,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
struct TORRENT_EXPORT disk_buffer_pool : boost::noncopyable
|
struct TORRENT_EXTRA_EXPORT disk_buffer_pool : boost::noncopyable
|
||||||
{
|
{
|
||||||
disk_buffer_pool(int block_size);
|
disk_buffer_pool(int block_size);
|
||||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||||
|
|
|
@ -225,7 +225,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// this is a singleton consisting of the thread and a queue
|
// this is a singleton consisting of the thread and a queue
|
||||||
// of disk io jobs
|
// of disk io jobs
|
||||||
struct TORRENT_EXPORT disk_io_thread : disk_buffer_pool
|
struct TORRENT_EXTRA_EXPORT disk_io_thread : disk_buffer_pool
|
||||||
{
|
{
|
||||||
disk_io_thread(io_service& ios
|
disk_io_thread(io_service& ios
|
||||||
, boost::function<void()> const& queue_callback
|
, boost::function<void()> const& queue_callback
|
||||||
|
|
|
@ -42,57 +42,57 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_EXPORT boost::array<char, 3 + std::numeric_limits<size_type>::digits10> to_string(size_type n);
|
TORRENT_EXTRA_EXPORT boost::array<char, 3 + std::numeric_limits<size_type>::digits10> to_string(size_type n);
|
||||||
TORRENT_EXPORT bool is_alpha(char c);
|
TORRENT_EXTRA_EXPORT bool is_alpha(char c);
|
||||||
TORRENT_EXPORT bool is_digit(char c);
|
TORRENT_EXTRA_EXPORT bool is_digit(char c);
|
||||||
TORRENT_EXPORT bool is_print(char c);
|
TORRENT_EXTRA_EXPORT bool is_print(char c);
|
||||||
TORRENT_EXPORT bool is_space(char c);
|
TORRENT_EXTRA_EXPORT bool is_space(char c);
|
||||||
TORRENT_EXPORT char to_lower(char c);
|
TORRENT_EXTRA_EXPORT char to_lower(char c);
|
||||||
|
|
||||||
TORRENT_EXPORT int split_string(char const** tags, int buf_size, char* in);
|
TORRENT_EXTRA_EXPORT int split_string(char const** tags, int buf_size, char* in);
|
||||||
TORRENT_EXPORT bool string_begins_no_case(char const* s1, char const* s2);
|
TORRENT_EXTRA_EXPORT bool string_begins_no_case(char const* s1, char const* s2);
|
||||||
TORRENT_EXPORT bool string_equal_no_case(char const* s1, char const* s2);
|
TORRENT_EXTRA_EXPORT bool string_equal_no_case(char const* s1, char const* s2);
|
||||||
|
|
||||||
TORRENT_EXPORT void url_random(char* begin, char* end);
|
TORRENT_EXTRA_EXPORT void url_random(char* begin, char* end);
|
||||||
|
|
||||||
TORRENT_EXPORT std::string unescape_string(std::string const& s, error_code& ec);
|
TORRENT_EXTRA_EXPORT std::string unescape_string(std::string const& s, error_code& ec);
|
||||||
// replaces all disallowed URL characters by their %-encoding
|
// replaces all disallowed URL characters by their %-encoding
|
||||||
TORRENT_EXPORT std::string escape_string(const char* str, int len);
|
TORRENT_EXTRA_EXPORT std::string escape_string(const char* str, int len);
|
||||||
// same as escape_string but does not encode '/'
|
// same as escape_string but does not encode '/'
|
||||||
TORRENT_EXPORT std::string escape_path(const char* str, int len);
|
TORRENT_EXTRA_EXPORT std::string escape_path(const char* str, int len);
|
||||||
// if the url does not appear to be encoded, and it contains illegal url characters
|
// if the url does not appear to be encoded, and it contains illegal url characters
|
||||||
// it will be encoded
|
// it will be encoded
|
||||||
TORRENT_EXPORT std::string maybe_url_encode(std::string const& url);
|
TORRENT_EXTRA_EXPORT std::string maybe_url_encode(std::string const& url);
|
||||||
|
|
||||||
TORRENT_EXPORT bool need_encoding(char const* str, int len);
|
TORRENT_EXTRA_EXPORT bool need_encoding(char const* str, int len);
|
||||||
|
|
||||||
// encodes a string using the base64 scheme
|
// encodes a string using the base64 scheme
|
||||||
TORRENT_EXPORT std::string base64encode(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::string base64encode(std::string const& s);
|
||||||
TORRENT_EXPORT std::string base64decode(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::string base64decode(std::string const& s);
|
||||||
// encodes a string using the base32 scheme
|
// encodes a string using the base32 scheme
|
||||||
TORRENT_EXPORT std::string base32encode(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::string base32encode(std::string const& s);
|
||||||
TORRENT_EXPORT std::string base32decode(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::string base32decode(std::string const& s);
|
||||||
|
|
||||||
TORRENT_EXPORT std::string url_has_argument(
|
TORRENT_EXTRA_EXPORT std::string url_has_argument(
|
||||||
std::string const& url, std::string argument, std::string::size_type* out_pos = 0);
|
std::string const& url, std::string argument, std::string::size_type* out_pos = 0);
|
||||||
|
|
||||||
// replaces \ with /
|
// replaces \ with /
|
||||||
TORRENT_EXPORT void convert_path_to_posix(std::string& path);
|
TORRENT_EXTRA_EXPORT void convert_path_to_posix(std::string& path);
|
||||||
|
|
||||||
TORRENT_EXPORT std::string read_until(char const*& str, char delim, char const* end);
|
TORRENT_EXTRA_EXPORT std::string read_until(char const*& str, char delim, char const* end);
|
||||||
TORRENT_EXPORT std::string to_hex(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::string to_hex(std::string const& s);
|
||||||
TORRENT_EXPORT bool is_hex(char const *in, int len);
|
TORRENT_EXTRA_EXPORT bool is_hex(char const *in, int len);
|
||||||
TORRENT_EXPORT void to_hex(char const *in, int len, char* out);
|
TORRENT_EXTRA_EXPORT void to_hex(char const *in, int len, char* out);
|
||||||
TORRENT_EXPORT bool from_hex(char const *in, int len, char* out);
|
TORRENT_EXTRA_EXPORT bool from_hex(char const *in, int len, char* out);
|
||||||
|
|
||||||
#if defined TORRENT_WINDOWS && TORRENT_USE_WSTRING
|
#if defined TORRENT_WINDOWS && TORRENT_USE_WSTRING
|
||||||
TORRENT_EXPORT std::wstring convert_to_wstring(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::wstring convert_to_wstring(std::string const& s);
|
||||||
TORRENT_EXPORT std::string convert_from_wstring(std::wstring const& s);
|
TORRENT_EXTRA_EXPORT std::string convert_from_wstring(std::wstring const& s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_ICONV || TORRENT_USE_LOCALE
|
#if TORRENT_USE_ICONV || TORRENT_USE_LOCALE
|
||||||
TORRENT_EXPORT std::string convert_to_native(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::string convert_to_native(std::string const& s);
|
||||||
TORRENT_EXPORT std::string convert_from_native(std::string const& s);
|
TORRENT_EXTRA_EXPORT std::string convert_from_native(std::string const& s);
|
||||||
#else
|
#else
|
||||||
inline std::string const& convert_to_native(std::string const& s) { return s; }
|
inline std::string const& convert_to_native(std::string const& s) { return s; }
|
||||||
inline std::string const& convert_from_native(std::string const& s) { return s; }
|
inline std::string const& convert_from_native(std::string const& s) { return s; }
|
||||||
|
|
|
@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
TORRENT_EXPORT bool inflate_gzip(
|
TORRENT_EXTRA_EXPORT bool inflate_gzip(
|
||||||
char const* in, int size
|
char const* in, int size
|
||||||
, std::vector<char>& buffer
|
, std::vector<char>& buffer
|
||||||
, int maximum_size
|
, int maximum_size
|
||||||
|
|
|
@ -48,16 +48,16 @@ extern "C"
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// from sha1.cpp
|
// from sha1.cpp
|
||||||
struct TORRENT_EXPORT SHA_CTX
|
struct TORRENT_EXTRA_EXPORT SHA_CTX
|
||||||
{
|
{
|
||||||
boost::uint32_t state[5];
|
boost::uint32_t state[5];
|
||||||
boost::uint32_t count[2];
|
boost::uint32_t count[2];
|
||||||
boost::uint8_t buffer[64];
|
boost::uint8_t buffer[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
TORRENT_EXPORT void SHA1_Init(SHA_CTX* context);
|
TORRENT_EXTRA_EXPORT void SHA1_Init(SHA_CTX* context);
|
||||||
TORRENT_EXPORT void SHA1_Update(SHA_CTX* context, boost::uint8_t const* data, boost::uint32_t len);
|
TORRENT_EXTRA_EXPORT void SHA1_Update(SHA_CTX* context, boost::uint8_t const* data, boost::uint32_t len);
|
||||||
TORRENT_EXPORT void SHA1_Final(boost::uint8_t* digest, SHA_CTX* context);
|
TORRENT_EXTRA_EXPORT void SHA1_Final(boost::uint8_t* digest, SHA_CTX* context);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace libtorrent
|
||||||
// if from is specified, a new socket will be created
|
// if from is specified, a new socket will be created
|
||||||
// using the same underlying socket object as 'from'.
|
// using the same underlying socket object as 'from'.
|
||||||
// this can be used to "upgrade" a socket into an SSL socket
|
// this can be used to "upgrade" a socket into an SSL socket
|
||||||
TORRENT_EXPORT bool instantiate_connection(io_service& ios
|
TORRENT_EXTRA_EXPORT bool instantiate_connection(io_service& ios
|
||||||
, proxy_settings const& ps, socket_type& s
|
, proxy_settings const& ps, socket_type& s
|
||||||
, void* ssl_context = 0
|
, void* ssl_context = 0
|
||||||
, utp_socket_manager* sm = 0
|
, utp_socket_manager* sm = 0
|
||||||
|
|
|
@ -174,7 +174,7 @@ struct count_peers
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TORRENT_EXPORT node_impl : boost::noncopyable
|
class TORRENT_EXTRA_EXPORT node_impl : boost::noncopyable
|
||||||
{
|
{
|
||||||
typedef std::map<node_id, torrent_entry> table_t;
|
typedef std::map<node_id, torrent_entry> table_t;
|
||||||
typedef std::map<node_id, dht_immutable_item> dht_immutable_table_t;
|
typedef std::map<node_id, dht_immutable_item> dht_immutable_table_t;
|
||||||
|
|
|
@ -47,19 +47,19 @@ typedef libtorrent::big_number node_id;
|
||||||
|
|
||||||
// returns the distance between the two nodes
|
// returns the distance between the two nodes
|
||||||
// using the kademlia XOR-metric
|
// using the kademlia XOR-metric
|
||||||
node_id TORRENT_EXPORT distance(node_id const& n1, node_id const& n2);
|
node_id TORRENT_EXTRA_EXPORT distance(node_id const& n1, node_id const& n2);
|
||||||
|
|
||||||
// returns true if: distance(n1, ref) < distance(n2, ref)
|
// returns true if: distance(n1, ref) < distance(n2, ref)
|
||||||
bool TORRENT_EXPORT compare_ref(node_id const& n1, node_id const& n2, node_id const& ref);
|
bool TORRENT_EXTRA_EXPORT compare_ref(node_id const& n1, node_id const& n2, node_id const& ref);
|
||||||
|
|
||||||
// returns n in: 2^n <= distance(n1, n2) < 2^(n+1)
|
// returns n in: 2^n <= distance(n1, n2) < 2^(n+1)
|
||||||
// usefult for finding out which bucket a node belongs to
|
// usefult for finding out which bucket a node belongs to
|
||||||
int TORRENT_EXPORT distance_exp(node_id const& n1, node_id const& n2);
|
int TORRENT_EXTRA_EXPORT distance_exp(node_id const& n1, node_id const& n2);
|
||||||
|
|
||||||
node_id TORRENT_EXPORT generate_id(address const& external_ip);
|
node_id TORRENT_EXTRA_EXPORT generate_id(address const& external_ip);
|
||||||
node_id TORRENT_EXPORT generate_random_id();
|
node_id TORRENT_EXTRA_EXPORT generate_random_id();
|
||||||
|
|
||||||
bool TORRENT_EXPORT verify_id(node_id const& nid, address const& source_ip);
|
bool TORRENT_EXTRA_EXPORT verify_id(node_id const& nid, address const& source_ip);
|
||||||
|
|
||||||
} } // namespace libtorrent::dht
|
} } // namespace libtorrent::dht
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace libtorrent
|
||||||
// whenever the element at the cursor is removed, the
|
// whenever the element at the cursor is removed, the
|
||||||
// cursor is bumped to the next occupied element
|
// cursor is bumped to the next occupied element
|
||||||
|
|
||||||
class TORRENT_EXPORT packet_buffer
|
class TORRENT_EXTRA_EXPORT packet_buffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::uint32_t index_type;
|
typedef boost::uint32_t index_type;
|
||||||
|
|
|
@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
TORRENT_EXPORT boost::tuple<std::string, std::string
|
TORRENT_EXTRA_EXPORT boost::tuple<std::string, std::string
|
||||||
, std::string, int, std::string>
|
, std::string, int, std::string>
|
||||||
parse_url_components(std::string url, error_code& ec);
|
parse_url_components(std::string url, error_code& ec);
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ struct rc4 {
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
void TORRENT_EXPORT rc4_init(const unsigned char* in, unsigned long len, rc4 *state);
|
void TORRENT_EXTRA_EXPORT rc4_init(const unsigned char* in, unsigned long len, rc4 *state);
|
||||||
unsigned long TORRENT_EXPORT rc4_encrypt(unsigned char *out, unsigned long outlen, rc4 *state);
|
unsigned long TORRENT_EXTRA_EXPORT rc4_encrypt(unsigned char *out, unsigned long outlen, rc4 *state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libtorrent/peer_id.hpp" // For sha1_hash
|
#include "libtorrent/peer_id.hpp" // For sha1_hash
|
||||||
|
@ -59,7 +59,7 @@ unsigned long TORRENT_EXPORT rc4_encrypt(unsigned char *out, unsigned long outle
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
class TORRENT_EXPORT dh_key_exchange
|
class TORRENT_EXTRA_EXPORT dh_key_exchange
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dh_key_exchange();
|
dh_key_exchange();
|
||||||
|
|
|
@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
struct TORRENT_EXPORT peer_entry
|
struct TORRENT_EXTRA_EXPORT peer_entry
|
||||||
{
|
{
|
||||||
std::string ip;
|
std::string ip;
|
||||||
int port;
|
int port;
|
||||||
|
|
|
@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
struct TORRENT_EXPORT peer_request
|
struct TORRENT_EXTRA_EXPORT peer_request
|
||||||
{
|
{
|
||||||
int piece;
|
int piece;
|
||||||
int start;
|
int start;
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace libtorrent
|
||||||
class peer_connection;
|
class peer_connection;
|
||||||
struct bitfield;
|
struct bitfield;
|
||||||
|
|
||||||
struct TORRENT_EXPORT piece_block
|
struct TORRENT_EXTRA_EXPORT piece_block
|
||||||
{
|
{
|
||||||
const static piece_block invalid;
|
const static piece_block invalid;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace libtorrent
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TORRENT_EXPORT piece_picker
|
class TORRENT_EXTRA_EXPORT piece_picker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void request_a_block(torrent& t, peer_connection& c);
|
void request_a_block(torrent& t, peer_connection& c);
|
||||||
|
|
||||||
class TORRENT_EXPORT policy
|
class TORRENT_EXTRA_EXPORT policy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ namespace libtorrent
|
||||||
// supports_holepunch
|
// supports_holepunch
|
||||||
// 43 1 1 <padding>
|
// 43 1 1 <padding>
|
||||||
// 44
|
// 44
|
||||||
struct TORRENT_EXPORT peer
|
struct TORRENT_EXTRA_EXPORT peer
|
||||||
{
|
{
|
||||||
peer(boost::uint16_t port, bool connectable, int src);
|
peer(boost::uint16_t port, bool connectable, int src);
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT ipv4_peer : peer
|
struct TORRENT_EXTRA_EXPORT ipv4_peer : peer
|
||||||
{
|
{
|
||||||
ipv4_peer(tcp::endpoint const& ip, bool connectable, int src);
|
ipv4_peer(tcp::endpoint const& ip, bool connectable, int src);
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ namespace libtorrent
|
||||||
};
|
};
|
||||||
|
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
struct TORRENT_EXPORT i2p_peer : peer
|
struct TORRENT_EXTRA_EXPORT i2p_peer : peer
|
||||||
{
|
{
|
||||||
i2p_peer(char const* destination, bool connectable, int src);
|
i2p_peer(char const* destination, bool connectable, int src);
|
||||||
~i2p_peer();
|
~i2p_peer();
|
||||||
|
@ -334,7 +334,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
struct TORRENT_EXPORT ipv6_peer : peer
|
struct TORRENT_EXTRA_EXPORT ipv6_peer : peer
|
||||||
{
|
{
|
||||||
ipv6_peer(tcp::endpoint const& ip, bool connectable, int src);
|
ipv6_peer(tcp::endpoint const& ip, bool connectable, int src);
|
||||||
|
|
||||||
|
|
|
@ -41,19 +41,19 @@ namespace libtorrent
|
||||||
// both of these use SHA-1 as the message digest to be signed/verified
|
// both of these use SHA-1 as the message digest to be signed/verified
|
||||||
|
|
||||||
// returns the size of the resulting signature
|
// returns the size of the resulting signature
|
||||||
TORRENT_EXPORT int sign_rsa(sha1_hash const& digest
|
TORRENT_EXTRA_EXPORT int sign_rsa(sha1_hash const& digest
|
||||||
, char const* private_key, int private_len
|
, char const* private_key, int private_len
|
||||||
, char* signature, int sig_len);
|
, char* signature, int sig_len);
|
||||||
|
|
||||||
// returns true if the signature is valid
|
// returns true if the signature is valid
|
||||||
TORRENT_EXPORT bool verify_rsa(sha1_hash const& digest
|
TORRENT_EXTRA_EXPORT bool verify_rsa(sha1_hash const& digest
|
||||||
, char const* public_key, int public_len
|
, char const* public_key, int public_len
|
||||||
, char const* signature, int sig_len);
|
, char const* signature, int sig_len);
|
||||||
|
|
||||||
// returns false if it fails, for instance if the key
|
// returns false if it fails, for instance if the key
|
||||||
// buffers are too small. public_len and private_len
|
// buffers are too small. public_len and private_len
|
||||||
// are in-out values, set to the actual sizes
|
// are in-out values, set to the actual sizes
|
||||||
TORRENT_EXPORT bool generate_rsa_keys(char* public_key, int* public_len
|
TORRENT_EXTRA_EXPORT bool generate_rsa_keys(char* public_key, int* public_len
|
||||||
, char* private_key, int* private_len, int key_size);
|
, char* private_key, int* private_len, int key_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace libtorrent
|
||||||
TORRENT_EXPORT std::string print_endpoint(tcp::endpoint const& ep);
|
TORRENT_EXPORT std::string print_endpoint(tcp::endpoint const& ep);
|
||||||
TORRENT_EXPORT std::string print_endpoint(udp::endpoint const& ep);
|
TORRENT_EXPORT std::string print_endpoint(udp::endpoint const& ep);
|
||||||
TORRENT_EXPORT std::string address_to_bytes(address const& a);
|
TORRENT_EXPORT std::string address_to_bytes(address const& a);
|
||||||
TORRENT_EXPORT void hash_address(address const& ip, sha1_hash& h);
|
TORRENT_EXTRA_EXPORT void hash_address(address const& ip, sha1_hash& h);
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace libtorrent
|
||||||
{ enum { value = 9 }; };
|
{ enum { value = 9 }; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct TORRENT_EXPORT socket_type
|
struct TORRENT_EXTRA_EXPORT socket_type
|
||||||
{
|
{
|
||||||
typedef stream_socket::endpoint_type endpoint_type;
|
typedef stream_socket::endpoint_type endpoint_type;
|
||||||
typedef stream_socket::protocol_type protocol_type;
|
typedef stream_socket::protocol_type protocol_type;
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace libtorrent {
|
||||||
typedef asio::error::error_category socks_error_category;
|
typedef asio::error::error_category socks_error_category;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
struct TORRENT_EXPORT socks_error_category : boost::system::error_category
|
struct TORRENT_EXTRA_EXPORT socks_error_category : boost::system::error_category
|
||||||
{
|
{
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
virtual std::string message(int ev) const;
|
virtual std::string message(int ev) const;
|
||||||
|
|
|
@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
class TORRENT_EXPORT stat_channel
|
class TORRENT_EXTRA_EXPORT stat_channel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ namespace libtorrent
|
||||||
size_type m_total_counter;
|
size_type m_total_counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TORRENT_EXPORT stat
|
class TORRENT_EXTRA_EXPORT stat
|
||||||
{
|
{
|
||||||
friend class invariant_access;
|
friend class invariant_access;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -72,26 +72,26 @@ namespace libtorrent
|
||||||
struct disk_buffer_pool;
|
struct disk_buffer_pool;
|
||||||
struct session_settings;
|
struct session_settings;
|
||||||
|
|
||||||
TORRENT_EXPORT std::vector<std::pair<size_type, std::time_t> > get_filesizes(
|
TORRENT_EXTRA_EXPORT std::vector<std::pair<size_type, std::time_t> > get_filesizes(
|
||||||
file_storage const& t
|
file_storage const& t
|
||||||
, std::string const& p);
|
, std::string const& p);
|
||||||
|
|
||||||
TORRENT_EXPORT bool match_filesizes(
|
TORRENT_EXTRA_EXPORT bool match_filesizes(
|
||||||
file_storage const& t
|
file_storage const& t
|
||||||
, std::string const& p
|
, std::string const& p
|
||||||
, std::vector<std::pair<size_type, std::time_t> > const& sizes
|
, std::vector<std::pair<size_type, std::time_t> > const& sizes
|
||||||
, bool compact_mode
|
, bool compact_mode
|
||||||
, std::string* error = 0);
|
, std::string* error = 0);
|
||||||
|
/*
|
||||||
struct TORRENT_EXPORT file_allocation_failed: std::exception
|
struct TORRENT_EXTRA_EXPORT file_allocation_failed: std::exception
|
||||||
{
|
{
|
||||||
file_allocation_failed(const char* error_msg): m_msg(error_msg) {}
|
file_allocation_failed(const char* error_msg): m_msg(error_msg) {}
|
||||||
virtual const char* what() const throw() { return m_msg.c_str(); }
|
virtual const char* what() const throw() { return m_msg.c_str(); }
|
||||||
virtual ~file_allocation_failed() throw() {}
|
virtual ~file_allocation_failed() throw() {}
|
||||||
std::string m_msg;
|
std::string m_msg;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
struct TORRENT_EXPORT partial_hash
|
struct TORRENT_EXTRA_EXPORT partial_hash
|
||||||
{
|
{
|
||||||
partial_hash(): offset(0) {}
|
partial_hash(): offset(0) {}
|
||||||
// the number of bytes in the piece that has been hashed
|
// the number of bytes in the piece that has been hashed
|
||||||
|
@ -285,7 +285,7 @@ namespace libtorrent
|
||||||
|
|
||||||
struct disk_io_thread;
|
struct disk_io_thread;
|
||||||
|
|
||||||
class TORRENT_EXPORT piece_manager
|
class TORRENT_EXTRA_EXPORT piece_manager
|
||||||
: public intrusive_ptr_base<piece_manager>
|
: public intrusive_ptr_base<piece_manager>
|
||||||
, boost::noncopyable
|
, boost::noncopyable
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace libtorrent
|
||||||
|
|
||||||
TORRENT_EXPORT void sleep(int milliseconds);
|
TORRENT_EXPORT void sleep(int milliseconds);
|
||||||
|
|
||||||
struct TORRENT_EXPORT condition
|
struct TORRENT_EXTRA_EXPORT condition
|
||||||
{
|
{
|
||||||
condition();
|
condition();
|
||||||
~condition();
|
~condition();
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
// timestamp history keeps a history of the lowest timestamps we've
|
// timestamp history keeps a history of the lowest timestamps we've
|
||||||
// seen in the last 20 minutes
|
// seen in the last 20 minutes
|
||||||
struct TORRENT_EXPORT timestamp_history
|
struct TORRENT_EXTRA_EXPORT timestamp_history
|
||||||
{
|
{
|
||||||
enum { history_size = 20 };
|
enum { history_size = 20 };
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace libtorrent
|
||||||
// a torrent is a class that holds information
|
// a torrent is a class that holds information
|
||||||
// for a specific download. It updates itself against
|
// for a specific download. It updates itself against
|
||||||
// the tracker
|
// the tracker
|
||||||
class TORRENT_EXPORT torrent: public request_callback
|
class TORRENT_EXTRA_EXPORT torrent: public request_callback
|
||||||
, public boost::enable_shared_from_this<torrent>
|
, public boost::enable_shared_from_this<torrent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -76,9 +76,9 @@ namespace libtorrent
|
||||||
namespace aux { struct session_impl; }
|
namespace aux { struct session_impl; }
|
||||||
|
|
||||||
// returns -1 if gzip header is invalid or the header size in bytes
|
// returns -1 if gzip header is invalid or the header size in bytes
|
||||||
TORRENT_EXPORT int gzip_header(const char* buf, int size);
|
TORRENT_EXTRA_EXPORT int gzip_header(const char* buf, int size);
|
||||||
|
|
||||||
struct TORRENT_EXPORT tracker_request
|
struct TORRENT_EXTRA_EXPORT tracker_request
|
||||||
{
|
{
|
||||||
tracker_request()
|
tracker_request()
|
||||||
: kind(announce_request)
|
: kind(announce_request)
|
||||||
|
@ -136,7 +136,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT request_callback
|
struct TORRENT_EXTRA_EXPORT request_callback
|
||||||
{
|
{
|
||||||
friend class tracker_manager;
|
friend class tracker_manager;
|
||||||
request_callback(): m_manager(0) {}
|
request_callback(): m_manager(0) {}
|
||||||
|
@ -174,7 +174,7 @@ namespace libtorrent
|
||||||
tracker_manager* m_manager;
|
tracker_manager* m_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT timeout_handler
|
struct TORRENT_EXTRA_EXPORT timeout_handler
|
||||||
: intrusive_ptr_base<timeout_handler>
|
: intrusive_ptr_base<timeout_handler>
|
||||||
, boost::noncopyable
|
, boost::noncopyable
|
||||||
{
|
{
|
||||||
|
@ -216,7 +216,7 @@ namespace libtorrent
|
||||||
bool m_abort;
|
bool m_abort;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT tracker_connection
|
struct TORRENT_EXTRA_EXPORT tracker_connection
|
||||||
: timeout_handler
|
: timeout_handler
|
||||||
{
|
{
|
||||||
tracker_connection(tracker_manager& man
|
tracker_connection(tracker_manager& man
|
||||||
|
@ -263,7 +263,7 @@ namespace libtorrent
|
||||||
const tracker_request m_req;
|
const tracker_request m_req;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TORRENT_EXPORT tracker_manager: boost::noncopyable
|
class TORRENT_EXTRA_EXPORT tracker_manager: boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
namespace aux { struct session_impl; }
|
namespace aux { struct session_impl; }
|
||||||
|
|
||||||
class TORRENT_EXPORT udp_tracker_connection: public tracker_connection
|
class TORRENT_EXTRA_EXPORT udp_tracker_connection: public tracker_connection
|
||||||
{
|
{
|
||||||
friend class tracker_manager;
|
friend class tracker_manager;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -166,7 +166,7 @@ int socket_impl_size();
|
||||||
// will keep the utp_stream object around for.
|
// will keep the utp_stream object around for.
|
||||||
// for more details, see utp_socket_impl, which is analogous
|
// for more details, see utp_socket_impl, which is analogous
|
||||||
// to the kernel state for a socket. It's defined in utp_stream.cpp
|
// to the kernel state for a socket. It's defined in utp_stream.cpp
|
||||||
class TORRENT_EXPORT utp_stream
|
class TORRENT_EXTRA_EXPORT utp_stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace libtorrent
|
||||||
struct session_impl;
|
struct session_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TORRENT_EXPORT web_connection_base
|
class TORRENT_EXTRA_EXPORT web_connection_base
|
||||||
: public peer_connection
|
: public peer_connection
|
||||||
{
|
{
|
||||||
friend class invariant_access;
|
friend class invariant_access;
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace libtorrent
|
||||||
struct session_impl;
|
struct session_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TORRENT_EXPORT web_peer_connection
|
class TORRENT_EXTRA_EXPORT web_peer_connection
|
||||||
: public web_connection_base
|
: public web_connection_base
|
||||||
{
|
{
|
||||||
friend class invariant_access;
|
friend class invariant_access;
|
||||||
|
|
|
@ -16,6 +16,10 @@ if WITH_SHIPPED_GEOIP
|
||||||
GEOIP_SOURCES = GeoIP.c
|
GEOIP_SOURCES = GeoIP.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if WITH_OPENSSL
|
||||||
|
ASIO_OPENSSL_SOURCES = asio_ssl.cpp
|
||||||
|
endif
|
||||||
|
|
||||||
libtorrent_rasterbar_la_SOURCES = \
|
libtorrent_rasterbar_la_SOURCES = \
|
||||||
web_connection_base.cpp \
|
web_connection_base.cpp \
|
||||||
alert.cpp \
|
alert.cpp \
|
||||||
|
@ -96,7 +100,8 @@ libtorrent_rasterbar_la_SOURCES = \
|
||||||
web_peer_connection.cpp \
|
web_peer_connection.cpp \
|
||||||
\
|
\
|
||||||
$(KADEMLIA_SOURCES) \
|
$(KADEMLIA_SOURCES) \
|
||||||
$(GEOIP_SOURCES)
|
$(GEOIP_SOURCES) \
|
||||||
|
$(ASIO_OPENSSL_SOURCES)
|
||||||
|
|
||||||
#libtorrent_rasterbar_la_LDFLAGS = $(LDFLAGS) -version-info $(INTERFACE_VERSION_INFO)
|
#libtorrent_rasterbar_la_LDFLAGS = $(LDFLAGS) -version-info $(INTERFACE_VERSION_INFO)
|
||||||
libtorrent_rasterbar_la_LDFLAGS = -version-info $(INTERFACE_VERSION_INFO)
|
libtorrent_rasterbar_la_LDFLAGS = -version-info $(INTERFACE_VERSION_INFO)
|
||||||
|
|
|
@ -102,6 +102,122 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_files_impl(file_storage& fs, std::string const& p
|
||||||
|
, std::string const& l, boost::function<bool(std::string)> pred, boost::uint32_t flags)
|
||||||
|
{
|
||||||
|
std::string f = combine_path(p, l);
|
||||||
|
if (!pred(f)) return;
|
||||||
|
error_code ec;
|
||||||
|
file_status s;
|
||||||
|
stat_file(f, &s, ec, (flags & create_torrent::symlinks) ? dont_follow_links : 0);
|
||||||
|
if (ec) return;
|
||||||
|
|
||||||
|
// recurse into directories
|
||||||
|
bool recurse = (s.mode & file_status::directory) != 0;
|
||||||
|
|
||||||
|
// if the file is not a link or we're following links, and it's a directory
|
||||||
|
// only then should we recurse
|
||||||
|
#ifndef TORRENT_WINDOWS
|
||||||
|
if ((s.mode & file_status::link) && (flags & create_torrent::symlinks))
|
||||||
|
recurse = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (recurse)
|
||||||
|
{
|
||||||
|
for (directory i(f, ec); !i.done(); i.next(ec))
|
||||||
|
{
|
||||||
|
std::string leaf = i.file();
|
||||||
|
if (ignore_subdir(leaf)) continue;
|
||||||
|
add_files_impl(fs, p, combine_path(l, leaf), pred, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// #error use the fields from s
|
||||||
|
int file_flags = get_file_attributes(f);
|
||||||
|
|
||||||
|
// mask all bits to check if the file is a symlink
|
||||||
|
if ((file_flags & file_storage::attribute_symlink)
|
||||||
|
&& (flags & create_torrent::symlinks))
|
||||||
|
{
|
||||||
|
std::string sym_path = get_symlink_path(f);
|
||||||
|
fs.add_file(l, 0, file_flags, s.mtime, sym_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fs.add_file(l, s.file_size, file_flags, s.mtime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct piece_holder
|
||||||
|
{
|
||||||
|
piece_holder(int bytes): m_piece(page_aligned_allocator::malloc(bytes)) {}
|
||||||
|
~piece_holder() { page_aligned_allocator::free(m_piece); }
|
||||||
|
char* bytes() { return m_piece; }
|
||||||
|
private:
|
||||||
|
char* m_piece;
|
||||||
|
};
|
||||||
|
|
||||||
|
void set_piece_hashes(create_torrent& t, std::string const& p, boost::function<void(int)> f
|
||||||
|
, error_code& ec)
|
||||||
|
{
|
||||||
|
file_pool fp;
|
||||||
|
boost::scoped_ptr<storage_interface> st(
|
||||||
|
default_storage_constructor(const_cast<file_storage&>(t.files()), 0, p, fp
|
||||||
|
, std::vector<boost::uint8_t>()));
|
||||||
|
|
||||||
|
// if we're calculating file hashes as well, use this hasher
|
||||||
|
hasher filehash;
|
||||||
|
int file_idx = 0;
|
||||||
|
size_type left_in_file = t.files().at(0).size;
|
||||||
|
|
||||||
|
// calculate the hash for all pieces
|
||||||
|
int num = t.num_pieces();
|
||||||
|
piece_holder buf(t.piece_length());
|
||||||
|
for (int i = 0; i < num; ++i)
|
||||||
|
{
|
||||||
|
// read hits the disk and will block. Progress should
|
||||||
|
// be updated in between reads
|
||||||
|
st->read(buf.bytes(), i, 0, t.piece_size(i));
|
||||||
|
if (st->error())
|
||||||
|
{
|
||||||
|
ec = st->error();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t.should_add_file_hashes())
|
||||||
|
{
|
||||||
|
int left_in_piece = t.piece_size(i);
|
||||||
|
int this_piece_size = left_in_piece;
|
||||||
|
// the number of bytes from this file we just read
|
||||||
|
while (left_in_piece > 0)
|
||||||
|
{
|
||||||
|
int to_hash_for_file = int((std::min)(size_type(left_in_piece), left_in_file));
|
||||||
|
if (to_hash_for_file > 0)
|
||||||
|
{
|
||||||
|
int offset = this_piece_size - left_in_piece;
|
||||||
|
filehash.update(buf.bytes() + offset, to_hash_for_file);
|
||||||
|
}
|
||||||
|
left_in_file -= to_hash_for_file;
|
||||||
|
left_in_piece -= to_hash_for_file;
|
||||||
|
if (left_in_file == 0)
|
||||||
|
{
|
||||||
|
if (!t.files().at(file_idx).pad_file)
|
||||||
|
t.set_file_hash(file_idx, filehash.final());
|
||||||
|
filehash.reset();
|
||||||
|
file_idx++;
|
||||||
|
if (file_idx >= t.files().num_files()) break;
|
||||||
|
left_in_file = t.files().at(file_idx).size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hasher h(buf.bytes(), t.piece_size(i));
|
||||||
|
t.set_hash(i, h.final());
|
||||||
|
f(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_torrent::create_torrent(file_storage& fs, int piece_size, int pad_file_limit, int flags)
|
create_torrent::create_torrent(file_storage& fs, int piece_size, int pad_file_limit, int flags)
|
||||||
|
|
|
@ -9,7 +9,7 @@ explicit test_natpmp ;
|
||||||
|
|
||||||
project
|
project
|
||||||
: requirements
|
: requirements
|
||||||
<library>/torrent//torrent/<link>shared/<boost-link>shared
|
<library>/torrent//torrent/<link>shared/<boost-link>shared/<export-extra>on
|
||||||
<source>main.cpp
|
<source>main.cpp
|
||||||
<source>setup_transfer.cpp
|
<source>setup_transfer.cpp
|
||||||
: default-build
|
: default-build
|
||||||
|
|
|
@ -124,7 +124,9 @@ void test_feed(std::string const& filename, rss_expect const& expect)
|
||||||
f->save_state(state);
|
f->save_state(state);
|
||||||
|
|
||||||
fprintf(stderr, "feed_state:\n");
|
fprintf(stderr, "feed_state:\n");
|
||||||
|
#ifdef TORRENT_DEBUG
|
||||||
state.print(std::cerr);
|
state.print(std::cerr);
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: verify some key state is saved in 'state'
|
// TODO: verify some key state is saved in 'state'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue